mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 17:16:33 +08:00
Upon changing the number of threads, make sure all threads are bound
The heuristic to avoid thread binding if less than 8 threads are requested resulted in the first 7 threads not being bound. The branch was verified to yield a roughly 13% speedup by @CoffeeOne on the appropriate hardware and OS, and an earlier version of this patch tested well on his machine: http://tests.stockfishchess.org/tests/view/5a3693480ebc590ccbb8be5a ELO: 9.24 +-4.6 (95%) LOS: 100.0% Total: 5000 W: 634 L: 501 D: 3865 To make sure all threads (including mainThread) are bound as soon as the total number exceeds 7, recreate all threads on a change of thread number. To do this, unify Threads::init, Threads::exit and Threads::set are unified in a single Threads::set function that goes through the needed steps. The code includes several suggestions from @joergoster. Fixes issue #1312 No functional change
This commit is contained in:
committed by
Marco Costalba
parent
2198cd0524
commit
1c50d8cbf5
@@ -293,14 +293,6 @@ int get_group(size_t idx) {
|
||||
|
||||
void bindThisThread(size_t idx) {
|
||||
|
||||
// If OS already scheduled us on a different group than 0 then don't overwrite
|
||||
// the choice, eventually we are one of many one-threaded processes running on
|
||||
// some Windows NUMA hardware, for instance in fishtest. To make it simple,
|
||||
// just check if running threads are below a threshold, in this case all this
|
||||
// NUMA machinery is not needed.
|
||||
if (Threads.size() < 8)
|
||||
return;
|
||||
|
||||
// Use only local variables to be thread-safe
|
||||
int group = get_group(idx);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user