mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-21 17:46:26 +08:00
Simplify pondering time management (#1899)
stopOnPonderhit is used to stop search quickly on a ponderhit. It is set by mainThread as part of its time management. However, master employs it as a signal between mainThread and the UCI thread. This is not necessary, it is sufficient for the UCI thread to signal that pondering finished, and mainThread should do its usual time-keeping job, and in this case stop immediately. This patch implements this, removing stopOnPonderHit as an atomic variable from the ThreadPool, and moving it as a normal variable to mainThread, reducing its scope. In MainThread::check_time() the search is stopped immediately if ponder switches to false, and the variable stopOnPonderHit is set. Furthermore, ponder has been moved to mainThread, as the variable is only used to exchange signals between the UCI thread and mainThread. The version has been tested locally (as fishtest doesn't support ponder): Score of ponderSimp vs master: 2616 - 2528 - 8630 [0.503] 13774 Elo difference: 2.22 +/- 3.54 which indicates no regression. No functional change.
This commit is contained in:
committed by
Marco Costalba
parent
59b2486bc3
commit
58d3ee6175
14
src/uci.cpp
14
src/uci.cpp
@@ -207,18 +207,16 @@ void UCI::loop(int argc, char* argv[]) {
|
||||
token.clear(); // Avoid a stale if getline() returns empty or blank line
|
||||
is >> skipws >> token;
|
||||
|
||||
if ( token == "quit"
|
||||
|| token == "stop")
|
||||
Threads.stop = true;
|
||||
|
||||
// The GUI sends 'ponderhit' to tell us the user has played the expected move.
|
||||
// So 'ponderhit' will be sent if we were told to ponder on the same move the
|
||||
// user has played. We should continue searching but switch from pondering to
|
||||
// normal search. In case Threads.stopOnPonderhit is set we are waiting for
|
||||
// 'ponderhit' to stop the search, for instance if max search depth is reached.
|
||||
if ( token == "quit"
|
||||
|| token == "stop"
|
||||
|| (token == "ponderhit" && Threads.stopOnPonderhit))
|
||||
Threads.stop = true;
|
||||
|
||||
// normal search.
|
||||
else if (token == "ponderhit")
|
||||
Threads.ponder = false; // Switch to normal search
|
||||
Threads.main()->ponder = false; // Switch to normal search
|
||||
|
||||
else if (token == "uci")
|
||||
sync_cout << "id name " << engine_info(true)
|
||||
|
||||
Reference in New Issue
Block a user