Skip to content

Commit

Permalink
Merge pull request #4106 from STEllAR-GROUP/fix_4105
Browse files Browse the repository at this point in the history
use std::round for guaranteed rounding without errors
  • Loading branch information
biddisco authored Sep 26, 2019
2 parents 8f9678c + b0fb36b commit 22472e8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/runtime/threads/policies/parse_affinity_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ BOOST_FUSION_ADAPT_STRUCT(
(hpx::threads::detail::spec_type::type, type_)
)


namespace hpx { namespace threads { namespace detail
{
static char const* const type_names[] =
Expand Down Expand Up @@ -1038,9 +1039,8 @@ namespace hpx { namespace threads { namespace detail
std::size_t pus_t2 = 0;
for (std::size_t n = 0; n < num_numas; ++n)
{
std::size_t temp = static_cast<std::size_t>(std::floor(0.5 +
static_cast<double>(num_threads) * num_pus_numa[n] /
pus_t));
std::size_t temp = static_cast<std::size_t>(std::round(
static_cast<double>(num_threads * num_pus_numa[n]) / pus_t));

// due to rounding up, we might have too many threads
if ((pus_t2 + temp) > num_threads)
Expand Down Expand Up @@ -1130,6 +1130,7 @@ namespace hpx { namespace threads { namespace detail
}
core_offset += num_cores_numa[n];
}

}

///////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 22472e8

Please sign in to comment.