]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Fix an icc warning
[stockfish] / src / search.cpp
index 611b258329b680b5c7a07bacf466e3c6be7a55bf..738955f990f3e43de6d15d96a01d4b17df1910af 100644 (file)
@@ -1854,16 +1854,7 @@ namespace {
       // 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;
@@ -1873,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));
       }
     }
 
@@ -1975,16 +1963,7 @@ namespace {
       // 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;
@@ -2001,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));
       }
     }
 
@@ -2684,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;
@@ -2866,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;
@@ -2889,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);