X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fthread.cpp;h=4ae268eb77b9ae885554bf4e60c78ef1e2ebf032;hp=10f432bd71bdf81b30af7eafdf7ff2606d046cc9;hb=0439a79566d03065317b2025b9b479b9ae9f2d65;hpb=3d0d0237c52474fa7b5e4d9f52d985a69d87df2c diff --git a/src/thread.cpp b/src/thread.cpp index 10f432bd..4ae268eb 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -137,7 +137,6 @@ void Thread::main_loop() { void Thread::wake_up() { lock_grab(sleepLock); - do_sleep = false; cond_signal(sleepCond); lock_release(sleepLock); } @@ -257,6 +256,7 @@ void ThreadsManager::wake_up() const { for (int i = 0; i < size(); i++) { threads[i]->maxPly = 0; + threads[i]->do_sleep = false; if (!useSleepingThreads) threads[i]->wake_up(); @@ -309,7 +309,7 @@ Value ThreadsManager::split(Position& pos, Stack* ss, Value alpha, Value beta, assert(beta <= VALUE_INFINITE); assert(depth > DEPTH_ZERO); - int master = pos.thread(); + int master = pos.this_thread(); Thread& masterThread = *threads[master]; if (masterThread.splitPointsCnt >= MAX_SPLITPOINTS_PER_THREAD) @@ -419,6 +419,7 @@ void ThreadsManager::wait_for_search_finished() { Thread* main = threads[0]; lock_grab(main->sleepLock); + cond_signal(main->sleepCond); // In case is waiting for stop or ponderhit while (!main->do_sleep) cond_wait(sleepCond, main->sleepLock); lock_release(main->sleepLock); } @@ -428,9 +429,11 @@ void ThreadsManager::wait_for_search_finished() { // main_loop() so to start a new search, then returns immediately. void ThreadsManager::start_searching(const Position& pos, const LimitsType& limits, - const std::set& searchMoves) { + const std::vector& searchMoves) { wait_for_search_finished(); + SearchTime.restart(); // As early as possible + Signals.stopOnPonderhit = Signals.firstRootMove = false; Signals.stop = Signals.failedLowAtRoot = false; @@ -439,8 +442,9 @@ void ThreadsManager::start_searching(const Position& pos, const LimitsType& limi RootMoves.clear(); for (MoveList ml(pos); !ml.end(); ++ml) - if (searchMoves.empty() || searchMoves.count(ml.move())) + if (searchMoves.empty() || count(searchMoves.begin(), searchMoves.end(), ml.move())) RootMoves.push_back(RootMove(ml.move())); + threads[0]->do_sleep = false; threads[0]->wake_up(); }