mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 17:16:33 +08:00
Split also if no slaves are found
Because we test for available slaves before entering split(), we almost always allocate a slave, only in the rare case of a race (less then 2% of cases) this is not true, but to special case this occurrence is not worth the added complexity. bench: 7451319
This commit is contained in:
@@ -296,12 +296,9 @@ void Thread::split(Position& pos, const Stack* ss, Value alpha, Value beta, Valu
|
||||
activeSplitPoint = &sp;
|
||||
activePosition = NULL;
|
||||
|
||||
int slavesCnt = 1; // This thread is always included
|
||||
Thread* slave;
|
||||
|
||||
while (!Fake && (slave = Threads.available_slave(this)) != NULL)
|
||||
if (!Fake)
|
||||
for (Thread* slave; (slave = Threads.available_slave(this)) != NULL; )
|
||||
{
|
||||
++slavesCnt;
|
||||
sp.slavesMask |= 1ULL << slave->idx;
|
||||
slave->activeSplitPoint = &sp;
|
||||
slave->searching = true; // Slave leaves idle_loop()
|
||||
@@ -312,8 +309,6 @@ void Thread::split(Position& pos, const Stack* ss, Value alpha, Value beta, Valu
|
||||
// it will instantly launch a search, because its 'searching' flag is set.
|
||||
// The thread will return from the idle loop when all slaves have finished
|
||||
// their work at this split point.
|
||||
if (slavesCnt > 1 || Fake)
|
||||
{
|
||||
sp.mutex.unlock();
|
||||
Threads.mutex.unlock();
|
||||
|
||||
@@ -330,7 +325,6 @@ void Thread::split(Position& pos, const Stack* ss, Value alpha, Value beta, Valu
|
||||
// done under lock protection to avoid a race with Thread::available_to().
|
||||
Threads.mutex.lock();
|
||||
sp.mutex.lock();
|
||||
}
|
||||
|
||||
searching = true;
|
||||
--splitPointsSize;
|
||||
|
||||
Reference in New Issue
Block a user