]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Initialize a new split point out of lock
[stockfish] / src / search.cpp
index cc910f7d81da39c5f1d1b42ebbd36567cd6abd79..d06ca8f3bfd98ed3f4755ad0e0571836ba502b15 100644 (file)
@@ -560,7 +560,8 @@ namespace {
             // Start with a small aspiration window and, in case of fail high/low,
             // research with bigger window until not failing high/low anymore.
             do {
-                // Search starting from ss+1 to allow calling update_gains()
+                // Search starting from ss+1 to allow referencing (ss-1). This is
+                // needed by update_gains() and ss copy when splitting at Root.
                 value = search<Root>(pos, ss+1, alpha, beta, depth * ONE_PLY);
 
                 // It is critical that sorting is done with a stable algorithm
@@ -1170,17 +1171,12 @@ split_point_start: // At split points actual search starts from here
           alpha = sp->alpha;
       }
 
-
-      if (RootNode)
+      // Finished searching the move. If StopRequest is true, the search
+      // was aborted because the user interrupted the search or because we
+      // ran out of time. In this case, the return value of the search cannot
+      // be trusted, and we don't update the best move and/or PV.
+      if (RootNode && !StopRequest)
       {
-          // Finished searching the move. If StopRequest is true, the search
-          // was aborted because the user interrupted the search or because we
-          // ran out of time. In this case, the return value of the search cannot
-          // be trusted, and we break out of the loop without updating the best
-          // move and/or PV.
-          if (StopRequest)
-              break;
-
           // Remember searched nodes counts for this move
           RootMove* rm = Rml.find(move);
           rm->nodes += pos.nodes_searched() - nodes;
@@ -2215,6 +2211,8 @@ void ThreadsManager::idle_loop(int threadID, SplitPoint* sp) {
               search<SplitPointPV>(pos, ss+1, tsp->alpha, tsp->beta, tsp->depth);
           else if (tsp->nodeType == NonPV)
               search<SplitPointNonPV>(pos, ss+1, tsp->alpha, tsp->beta, tsp->depth);
+          else
+              assert(false);
 
           assert(threads[threadID].state == Thread::SEARCHING);
 
@@ -2243,8 +2241,6 @@ void ThreadsManager::idle_loop(int threadID, SplitPoint* sp) {
           // In helpful master concept a master can help only a sub-tree, and
           // because here is all finished is not possible master is booked.
           assert(threads[threadID].state == Thread::AVAILABLE);
-
-          threads[threadID].state = Thread::SEARCHING;
           return;
       }
   }