X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=738955f990f3e43de6d15d96a01d4b17df1910af;hp=88ef5237de054378e2514ad0f631269892ddf557;hb=27c74c5245f5f5ba1453438dc66a0c951fbbb411;hpb=2da290d72b4174fd36186261faba1eb8722e0ac8 diff --git a/src/search.cpp b/src/search.cpp index 88ef5237..738955f9 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -1851,12 +1851,6 @@ namespace { assert(value > -VALUE_INFINITE && value < VALUE_INFINITE); - if (TM.thread_should_stop(threadID)) - { - lock_grab(&(sp->lock)); - break; - } - // New best move? if (value > sp->bestValue) // Less then 2% of cases { @@ -1866,8 +1860,8 @@ namespace { sp->bestValue = value; if (sp->bestValue >= sp->beta) { - sp_update_pv(sp->parentSstack, ss, sp->ply); sp->stopRequest = true; + sp_update_pv(sp->parentSstack, ss, sp->ply); } } lock_release(&(sp->lock)); @@ -1966,12 +1960,6 @@ namespace { assert(value > -VALUE_INFINITE && value < VALUE_INFINITE); - if (TM.thread_should_stop(threadID)) - { - lock_grab(&(sp->lock)); - break; - } - // New best move? if (value > sp->bestValue) // Less then 2% of cases { @@ -2626,6 +2614,8 @@ namespace { // If this thread has been assigned work, launch a search if (threads[threadID].state == THREAD_WORKISWAITING) { + assert(!AllThreadsShouldExit); + threads[threadID].state = THREAD_SEARCHING; if (threads[threadID].splitPoint->pvNode) @@ -2635,13 +2625,7 @@ namespace { assert(threads[threadID].state == THREAD_SEARCHING); - // If this is a slave thread reset to available, instead - // if it is a master thread and all slaves have finished - // then leave as is to avoid booking by another master, - // we will leave idle loop shortly anyhow. - if ( !AllThreadsShouldExit - && (!waitSp || waitSp->cpus > 0)) - threads[threadID].state = THREAD_AVAILABLE; + threads[threadID].state = THREAD_AVAILABLE; } // If this thread is the master of a split point and all threads have @@ -2676,7 +2660,7 @@ namespace { lock_init(&IOLock, NULL); // Initialize SplitPointStack locks - for (int i = 0; i < MAX_THREADS; i++) + for (i = 0; i < MAX_THREADS; i++) for (int j = 0; j < ACTIVE_SPLIT_POINTS_MAX; j++) { SplitPointStack[i][j].parent = NULL; @@ -2858,8 +2842,7 @@ namespace { } // Pick the next available split point object from the split point stack - splitPoint = SplitPointStack[master] + threads[master].activeSplitPoints; - threads[master].activeSplitPoints++; + splitPoint = &SplitPointStack[master][threads[master].activeSplitPoints]; // Initialize the split point object splitPoint->parent = threads[master].splitPoint; @@ -2881,6 +2864,7 @@ namespace { splitPoint->slaves[i] = 0; threads[master].splitPoint = splitPoint; + threads[master].activeSplitPoints++; // If we are here it means we are not available assert(threads[master].state != THREAD_AVAILABLE);