From cc6c745b543e0cd94dea82deeed25572227f98ab Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sat, 31 Mar 2012 10:01:31 +0100 Subject: [PATCH] Reset search time as early as possible In particualr before to wake up main thread that could take some random time. Until we don't reset search time we are not able to correctly track the elapsed search time and this can be dangerous under extreme time pressure. No functional change. Signed-off-by: Marco Costalba --- src/search.cpp | 4 +--- src/search.h | 2 ++ src/thread.cpp | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index 8d0c0c6b..9ebf5c5c 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -28,7 +28,6 @@ #include "book.h" #include "evaluate.h" #include "history.h" -#include "misc.h" #include "movegen.h" #include "movepick.h" #include "search.h" @@ -43,6 +42,7 @@ namespace Search { LimitsType Limits; std::vector RootMoves; Position RootPosition; + Time SearchTime; } using std::string; @@ -118,7 +118,6 @@ namespace { size_t MultiPV, UCIMultiPV, PVIdx; TimeManager TimeMgr; - Time SearchTime; int BestMoveChanges; int SkillLevel; bool SkillLevelEnabled, Chess960; @@ -253,7 +252,6 @@ void Search::think() { Position& pos = RootPosition; Chess960 = pos.is_chess960(); Eval::RootColor = pos.side_to_move(); - SearchTime.restart(); TimeMgr.init(Limits, pos.startpos_ply_counter(), pos.side_to_move()); TT.new_search(); H.clear(); diff --git a/src/search.h b/src/search.h index c957c34b..b6f28a73 100644 --- a/src/search.h +++ b/src/search.h @@ -23,6 +23,7 @@ #include #include +#include "misc.h" #include "types.h" class Position; @@ -94,6 +95,7 @@ extern volatile SignalsType Signals; extern LimitsType Limits; extern std::vector RootMoves; extern Position RootPosition; +extern Time SearchTime; extern void init(); extern int64_t perft(Position& pos, Depth depth); diff --git a/src/thread.cpp b/src/thread.cpp index 6fefd58a..2dcbf910 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -432,6 +432,8 @@ void ThreadsManager::start_searching(const Position& pos, const LimitsType& limi const std::set& searchMoves) { wait_for_search_finished(); + SearchTime.restart(); // As early as possible + Signals.stopOnPonderhit = Signals.firstRootMove = false; Signals.stop = Signals.failedLowAtRoot = false; -- 2.39.2