mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 17:19:36 +00:00
Fix some races in SMP code
When a search fails high then sp->alpha is increased and slave threads are requested to stop. So we have to check for a stop request before to start a search otherwise we could end up with sp->alpha >= sp->beta leading to an assert in debug run in search_pv(). This patch fixes the assert and get rid of some of possible races. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
eb6ddd54f1
commit
3975a2b94f
1 changed files with 15 additions and 6 deletions
|
@ -2009,7 +2009,14 @@ namespace {
|
|||
if (sp->ply == 1 && RootMoveNumber == 1)
|
||||
Threads[threadID].failHighPly1 = true;
|
||||
|
||||
value = -search_pv(pos, ss, -sp->beta, -sp->alpha, newDepth, sp->ply+1, threadID);
|
||||
// If another thread has failed high then sp->alpha has been increased
|
||||
// to be higher or equal then beta, if so, avoid to start a PV search.
|
||||
localAlpha = sp->alpha;
|
||||
if (localAlpha < sp->beta)
|
||||
value = -search_pv(pos, ss, -sp->beta, -localAlpha, newDepth, sp->ply+1, threadID);
|
||||
else
|
||||
assert(thread_should_stop(threadID));
|
||||
|
||||
Threads[threadID].failHighPly1 = false;
|
||||
}
|
||||
}
|
||||
|
@ -2027,11 +2034,7 @@ namespace {
|
|||
sp->bestValue = value;
|
||||
if (value > sp->alpha)
|
||||
{
|
||||
sp->alpha = value;
|
||||
sp_update_pv(sp->parentSstack, ss, sp->ply);
|
||||
if (value == value_mate_in(sp->ply + 1))
|
||||
ss[sp->ply].mateKiller = move;
|
||||
|
||||
// Ask threads to stop before to modify sp->alpha
|
||||
if (value >= sp->beta)
|
||||
{
|
||||
for (int i = 0; i < ActiveThreads; i++)
|
||||
|
@ -2040,6 +2043,12 @@ namespace {
|
|||
|
||||
sp->finished = true;
|
||||
}
|
||||
|
||||
sp->alpha = value;
|
||||
|
||||
sp_update_pv(sp->parentSstack, ss, sp->ply);
|
||||
if (value == value_mate_in(sp->ply + 1))
|
||||
ss[sp->ply].mateKiller = move;
|
||||
}
|
||||
// If we are at ply 1, and we are searching the first root move at
|
||||
// ply 0, set the 'Problem' variable if the score has dropped a lot
|
||||
|
|
Loading…
Add table
Reference in a new issue