mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 01:03:09 +00: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:
parent
a1a7bc84da
commit
a091ae4cc8
1 changed files with 21 additions and 27 deletions
|
@ -296,12 +296,9 @@ void Thread::split(Position& pos, const Stack* ss, Value alpha, Value beta, Valu
|
||||||
activeSplitPoint = &sp;
|
activeSplitPoint = &sp;
|
||||||
activePosition = NULL;
|
activePosition = NULL;
|
||||||
|
|
||||||
int slavesCnt = 1; // This thread is always included
|
if (!Fake)
|
||||||
Thread* slave;
|
for (Thread* slave; (slave = Threads.available_slave(this)) != NULL; )
|
||||||
|
|
||||||
while (!Fake && (slave = Threads.available_slave(this)) != NULL)
|
|
||||||
{
|
{
|
||||||
++slavesCnt;
|
|
||||||
sp.slavesMask |= 1ULL << slave->idx;
|
sp.slavesMask |= 1ULL << slave->idx;
|
||||||
slave->activeSplitPoint = &sp;
|
slave->activeSplitPoint = &sp;
|
||||||
slave->searching = true; // Slave leaves idle_loop()
|
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.
|
// 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
|
// The thread will return from the idle loop when all slaves have finished
|
||||||
// their work at this split point.
|
// their work at this split point.
|
||||||
if (slavesCnt > 1 || Fake)
|
|
||||||
{
|
|
||||||
sp.mutex.unlock();
|
sp.mutex.unlock();
|
||||||
Threads.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().
|
// done under lock protection to avoid a race with Thread::available_to().
|
||||||
Threads.mutex.lock();
|
Threads.mutex.lock();
|
||||||
sp.mutex.lock();
|
sp.mutex.lock();
|
||||||
}
|
|
||||||
|
|
||||||
searching = true;
|
searching = true;
|
||||||
--splitPointsSize;
|
--splitPointsSize;
|
||||||
|
|
Loading…
Add table
Reference in a new issue