From 802fca6fdd562c4c52397521eb0ac05cb2be9046 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sun, 2 Jul 2017 03:10:50 -0700 Subject: [PATCH] Don't uselessy share rootDepth 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 | 4 ++-- src/thread.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index e6c3cd70..09e3c4fa 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -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) diff --git a/src/thread.h b/src/thread.h index c254047c..dc0c51c2 100644 --- a/src/thread.h +++ b/src/thread.h @@ -65,7 +65,7 @@ public: Position rootPos; Search::RootMoves rootMoves; - std::atomic rootDepth; + Depth rootDepth; Depth completedDepth; CounterMoveStat counterMoves; ButterflyHistory history; -- 2.39.2