]> git.sesse.net Git - stockfish/commitdiff
Don't uselessy share rootDepth
authorMarco Costalba <mcostalba@gmail.com>
Sun, 2 Jul 2017 10:10:50 +0000 (03:10 -0700)
committerJoona Kiiski <joona@zoox.com>
Mon, 3 Jul 2017 05:06:47 +0000 (22:06 -0700)
It is not needed becuase the only case is a real special
one (bench on depth with many threads) and can be easily
rewritten to avoid sharing rootDepth.

Verified with ThreadSanitizer.

No functional change.

Closes #1159

src/search.cpp
src/thread.h

index e6c3cd701485947c1c174b98f037661dca03409e..09e3c4fa979efd0620d021e14daacbb51ea8034c 100644 (file)
@@ -360,9 +360,9 @@ void Thread::search() {
   multiPV = std::min(multiPV, rootMoves.size());
 
   // Iterative deepening loop until requested to stop or the target depth is reached
-  while (   (rootDepth = rootDepth + ONE_PLY) < DEPTH_MAX
+  while (   (rootDepth += ONE_PLY) < DEPTH_MAX
          && !Signals.stop
-         && (!Limits.depth || Threads.main()->rootDepth / ONE_PLY <= Limits.depth))
+         && !(Limits.depth && mainThread && rootDepth / ONE_PLY > Limits.depth))
   {
       // Distribute search depths across the threads
       if (idx)
index c254047c23f4ce90a04415bcc97090f3c57aae0b..dc0c51c28d5c2401e415ccde5ce361b43061a3b9 100644 (file)
@@ -65,7 +65,7 @@ public:
 
   Position rootPos;
   Search::RootMoves rootMoves;
-  std::atomic<Depth> rootDepth;
+  Depth rootDepth;
   Depth completedDepth;
   CounterMoveStat counterMoves;
   ButterflyHistory history;