Skip to content

Commit

Permalink
Improve thread load balancing
Browse files Browse the repository at this point in the history
  • Loading branch information
kimwalisch committed Oct 22, 2024
1 parent bf8e09f commit 87be58a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Changes in version 12.5, 22/10/2024
===================================

* Improve thread load balancing for large number of CPU cores.

Changes in version 12.4, 22/06/2024
===================================

Expand Down
4 changes: 2 additions & 2 deletions src/ParallelSieve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/// @file ParallelSieve.cpp
/// @brief Multi-threaded prime sieve using std::async.
///
/// Copyright (C) 2023 Kim Walisch, <[email protected]>
/// Copyright (C) 2024 Kim Walisch, <[email protected]>
///
/// This file is distributed under the BSD License. See the COPYING
/// file in the top level directory.
Expand Down Expand Up @@ -83,7 +83,7 @@ uint64_t ParallelSieve::getThreadDistance(int threads) const
ASSERT(getDistance() > 0);

uint64_t dist = getDistance();
uint64_t balanced = isqrt(stop_) * 1000;
uint64_t balanced = isqrt(stop_) * 200;
uint64_t unbalanced = dist / threads;
uint64_t fastest = std::min(balanced, unbalanced);
uint64_t iters = dist / fastest;
Expand Down

0 comments on commit 87be58a

Please sign in to comment.