]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Revert "Recursive lock"
[stockfish] / src / search.cpp
index 5539b5294ac294fab381a60e5f89dd5d989a4640..ecc53580716e26ee1b3134baac8dd4e4b6f38ea3 100644 (file)
@@ -1851,25 +1851,10 @@ 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
       {
-          // Recursive locking, lock current split point and its ancestors to
-          // guarantee thread_should_stop() and sp_update_pv() are race free.
-          SplitPoint* spChain[MAX_THREADS * ACTIVE_SPLIT_POINTS_MAX];
-          int cnt = 0;
-          for (spChain[cnt] = sp; spChain[cnt]; )
-          {
-              lock_grab(&(spChain[cnt++]->lock));
-              spChain[cnt] = spChain[cnt - 1]->parent;
-          }
-
+          lock_grab(&(sp->lock));
           if (value > sp->bestValue && !TM.thread_should_stop(threadID))
           {
               sp->bestValue = value;
@@ -1879,10 +1864,7 @@ namespace {
                   sp_update_pv(sp->parentSstack, ss, sp->ply);
               }
           }
-
-          // Release locks in reverse order
-          while (cnt > 0)
-              lock_release(&(spChain[--cnt]->lock));
+          lock_release(&(sp->lock));
       }
     }
 
@@ -1978,25 +1960,10 @@ 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
       {
-          // Recursive locking, lock current split point and its ancestors to
-          // guarantee thread_should_stop() and sp_update_pv() are race free.
-          SplitPoint* spChain[MAX_THREADS * ACTIVE_SPLIT_POINTS_MAX];
-          int cnt = 0;
-          for (spChain[cnt] = sp; spChain[cnt]; )
-          {
-              lock_grab(&(spChain[cnt++]->lock));
-              spChain[cnt] = spChain[cnt - 1]->parent;
-          }
-
+          lock_grab(&(sp->lock));
           if (value > sp->bestValue && !TM.thread_should_stop(threadID))
           {
               sp->bestValue = value;
@@ -2013,10 +1980,7 @@ namespace {
                       ss[sp->ply].mateKiller = move;
               }
           }
-
-          // Release locks in reverse order
-          while (cnt > 0)
-              lock_release(&(spChain[--cnt]->lock));
+          lock_release(&(sp->lock));
       }
     }