X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=fc3ecae4d87e5c56230aec04a8bb6aacbee50cc0;hp=c5c5b94470fed9365831fea28427db4d4070d0e5;hb=db322e6a63459bc3dfdf7fd537d42234b854fb76;hpb=d165d5af914c3c925fb7ba53fbd63dfb2de92f5d diff --git a/src/search.cpp b/src/search.cpp index c5c5b944..fc3ecae4 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -44,7 +44,6 @@ namespace Search { Color RootColor; Time::point SearchTime; StateStackPtr SetupStates; - MovesVectPtr SetupMoves; } using std::string; @@ -294,7 +293,6 @@ namespace { Stack ss[MAX_PLY_PLUS_2]; int depth, prevBestMoveChanges; Value bestValue, alpha, beta, delta; - bool bestMoveNeverChanged = true; memset(ss, 0, 4 * sizeof(Stack)); depth = BestMoveChanges = 0; @@ -417,10 +415,6 @@ namespace { << std::endl; } - // Filter out startup noise when monitoring best move stability - if (depth > 2 && BestMoveChanges) - bestMoveNeverChanged = false; - // Do we have found a "mate in x"? if ( Limits.mate && bestValue >= VALUE_MATE_IN_MAX_PLY @@ -442,18 +436,12 @@ namespace { if (Time::now() - SearchTime > (TimeMgr.available_time() * 62) / 100) stop = true; - bool recapture = pos.is_capture(RootMoves[0].pv[0]) - && pos.captured_piece_type() - && SetupMoves->size() - && to_sq(SetupMoves->back()) == to_sq(RootMoves[0].pv[0]); - // Stop search early if one move seems to be much better than others if ( depth >= 12 && !stop && PVSize == 1 - && ( (bestMoveNeverChanged && recapture) - || RootMoves.size() == 1 - || Time::now() - SearchTime > (TimeMgr.available_time() * 40) / 100)) + && ( RootMoves.size() == 1 + || Time::now() - SearchTime > (TimeMgr.available_time() * 20) / 100)) { Value rBeta = bestValue - 2 * PawnValueMg; (ss+1)->excludedMove = RootMoves[0].pv[0]; @@ -1626,13 +1614,8 @@ void Thread::idle_loop() { assert(!this_sp || (this_sp->masterThread == this && searching)); - // If this thread is the master of a split point and all slaves have finished - // their work at this split point, return from the idle loop. - while (!this_sp || this_sp->slavesMask) + while (true) { - if (this_sp) - this_sp->mutex.unlock(); - // If we are not searching, wait for a condition to be signaled instead of // wasting CPU time polling for work. while ((!searching && Threads.sleepWhileIdle) || exit) @@ -1725,8 +1708,16 @@ void Thread::idle_loop() { sp->mutex.unlock(); } - if(this_sp) + // If this thread is the master of a split point and all slaves have finished + // their work at this split point, return from the idle loop. + if (this_sp && !this_sp->slavesMask) + { this_sp->mutex.lock(); + bool finished = !this_sp->slavesMask; // Retest under lock protection + this_sp->mutex.unlock(); + if (finished) + return; + } } }