X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=6ec744c859596415703fa8bef8e520f7eba47879;hp=93243ed7488ad512872fc22b6a874c23de49f9a2;hb=00950fec009a4f4046b8fa23eedf1b1a1c4068e6;hpb=083ed1ce94e7b2b5002c01cc947e56bec884737f diff --git a/src/search.cpp b/src/search.cpp index 93243ed7..6ec744c8 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -1692,13 +1692,12 @@ namespace { if (value > sp->bestValue && !ThreadsMgr.thread_should_stop(threadID)) { sp->bestValue = value; - - if (sp->bestValue > sp->alpha) + if (value > sp->alpha) { if (!PvNode || value >= sp->beta) sp->stopRequest = true; - if (PvNode && value < sp->beta) // This guarantees that always: sp->alpha < sp->beta + if (PvNode && value < sp->beta) // We want always sp->alpha < sp->beta sp->alpha = value; sp->parentSstack->bestMove = ss->bestMove = move; @@ -2463,13 +2462,11 @@ namespace { void ThreadsManager::exit_threads() { - ActiveThreads = MAX_THREADS; // HACK - AllThreadsShouldSleep = true; // HACK + ActiveThreads = MAX_THREADS; // Wake up all the threads + AllThreadsShouldExit = true; // Let the woken up threads to exit idle_loop() + AllThreadsShouldSleep = true; // Avoid an assert in wake_sleeping_threads() wake_sleeping_threads(); - // This makes the threads to exit idle_loop() - AllThreadsShouldExit = true; - // Wait for thread termination for (int i = 1; i < MAX_THREADS; i++) while (threads[i].state != THREAD_TERMINATED) {} @@ -2492,9 +2489,9 @@ namespace { assert(threadID >= 0 && threadID < ActiveThreads); - SplitPoint* sp; + SplitPoint* sp = threads[threadID].splitPoint; - for (sp = threads[threadID].splitPoint; sp && !sp->stopRequest; sp = sp->parent) {} + for ( ; sp && !sp->stopRequest; sp = sp->parent) {} return sp != NULL; } @@ -2519,12 +2516,9 @@ namespace { // Make a local copy to be sure doesn't change under our feet int localActiveSplitPoints = threads[slave].activeSplitPoints; - if (localActiveSplitPoints == 0) - // No active split points means that the thread is available as - // a slave for any other thread. - return true; - - if (ActiveThreads == 2) + // No active split points means that the thread is available as + // a slave for any other thread. + if (localActiveSplitPoints == 0 || ActiveThreads == 2) return true; // Apply the "helpful master" concept if possible. Use localActiveSplitPoints