]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Copy only the search stack tail in split()
[stockfish] / src / search.cpp
index 5d2e5175b052bdc35fc5019bdf45dfa39bbd9860..f205774124063dca9e3fed76471d2e0083d89115 100644 (file)
@@ -442,6 +442,10 @@ bool think(const Position& pos, bool infinite, bool ponder, int side_to_move,
   {
       ActiveThreads = newActiveThreads;
       init_eval(ActiveThreads);
+      // HACK: init_eval() destroys the static castleRightsMask[] array in the
+      // Position class. The below line repairs the damage.
+      Position p(pos.to_fen());
+      assert(pos.is_ok());
   }
 
   // Wake up sleeping threads
@@ -2982,15 +2986,15 @@ namespace {
     for (i = 0; i < ActiveThreads; i++)
         splitPoint->slaves[i] = 0;
 
-    // Copy the current search stack to the master thread
-    memcpy(splitPoint->sstack[master], sstck, (ply+1) * sizeof(SearchStack));
+    // Copy the tail of current search stack to the master thread
+    memcpy(splitPoint->sstack[master] + ply - 1, sstck + ply - 1, 3 * sizeof(SearchStack));
     Threads[master].splitPoint = splitPoint;
 
     // Make copies of the current position and search stack for each thread
     for (i = 0; i < ActiveThreads && splitPoint->cpus < MaxThreadsPerSplitPoint; i++)
         if (thread_is_available(i, master))
         {
-            memcpy(splitPoint->sstack[i], sstck, (ply+1) * sizeof(SearchStack));
+            memcpy(splitPoint->sstack[i] + ply - 1, sstck + ply - 1, 3 * sizeof(SearchStack));
             Threads[i].splitPoint = splitPoint;
             splitPoint->slaves[i] = 1;
             splitPoint->cpus++;