From 19b416b043537a27b56cd10e707c95e724f91d07 Mon Sep 17 00:00:00 2001 From: Thomas Heller Date: Wed, 23 Sep 2015 00:51:16 -0500 Subject: [PATCH 1/2] Fixing thread binding when running more than one locality per node and no affinity description --- src/hpx_init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hpx_init.cpp b/src/hpx_init.cpp index 0e1ce815bdde..5ff0494b980a 100644 --- a/src/hpx_init.cpp +++ b/src/hpx_init.cpp @@ -585,7 +585,7 @@ namespace hpx std::size_t get_pu_offset(util::command_line_handling const& cfg) { - std::size_t pu_offset = 0; + std::size_t pu_offset = -1; #if defined(HPX_HAVE_HWLOC) if (cfg.pu_offset_ != 0) { pu_offset = cfg.pu_offset_; From 0f71979936593c960fcb50ac522c2c5e6cc75489 Mon Sep 17 00:00:00 2001 From: Thomas Heller Date: Wed, 23 Sep 2015 01:25:27 -0500 Subject: [PATCH 2/2] Fixing #1757: pinning not correct using --hpx:bind --- src/runtime/threads/policies/parse_affinity_options.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/runtime/threads/policies/parse_affinity_options.cpp b/src/runtime/threads/policies/parse_affinity_options.cpp index 36820288bc1d..6597dd4da02e 100644 --- a/src/runtime/threads/policies/parse_affinity_options.cpp +++ b/src/runtime/threads/policies/parse_affinity_options.cpp @@ -573,7 +573,7 @@ namespace hpx { namespace threads { namespace detail std::vector& num_pus, error_code& ec) { std::size_t num_threads = affinities.size(); - std::size_t num_cores = max_cores % (t.get_number_of_cores()+1); + std::size_t num_cores = (std::min)(max_cores, t.get_number_of_cores()); num_pus.resize(num_threads); for (std::size_t num_thread = 0; num_thread != num_threads; /**/) @@ -608,7 +608,7 @@ namespace hpx { namespace threads { namespace detail std::vector& num_pus, error_code& ec) { std::size_t num_threads = affinities.size(); - std::size_t num_cores = max_cores % (t.get_number_of_cores()+1); + std::size_t num_cores = (std::min)(max_cores, t.get_number_of_cores()); std::vector num_pus_cores(num_cores, 0); num_pus.resize(num_threads); @@ -642,7 +642,7 @@ namespace hpx { namespace threads { namespace detail std::vector& num_pus, error_code& ec) { std::size_t num_threads = affinities.size(); - std::size_t num_cores = max_cores % (t.get_number_of_cores()+1); + std::size_t num_cores = (std::min)(max_cores, t.get_number_of_cores()); std::vector num_pus_cores(num_cores, 0); num_pus.resize(num_threads);