]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Revert "Prefetch earlier in qsearch()"
[stockfish] / src / search.cpp
index d59edbaeefcbf4be8ba40ea965156a21e0bf387a..9f4ba00d1b9cd3ea5155ca63dc77564cf8dde335 100644 (file)
@@ -361,7 +361,7 @@ void Thread::search() {
   multiPV = std::min(multiPV, rootMoves.size());
 
   // Iterative deepening loop until requested to stop or the target depth is reached
-  while (   (rootDepth += ONE_PLY) < DEPTH_MAX
+  while (   (rootDepth = rootDepth + ONE_PLY) < DEPTH_MAX
          && !Signals.stop
          && (!Limits.depth || Threads.main()->rootDepth / ONE_PLY <= Limits.depth))
   {
@@ -400,6 +400,9 @@ void Thread::search() {
           {
               bestValue = ::search<PV>(rootPos, ss, alpha, beta, rootDepth, false, false);
 
+              this->tbHits = rootPos.tb_hits();
+              this->nodes = rootPos.nodes_searched();
+
               // Bring the best move to the front. It is critical that sorting
               // is done with a stable algorithm because all the values but the
               // first and eventually the new best one are set to -VALUE_INFINITE
@@ -568,6 +571,9 @@ namespace {
     {
         thisThread->resetCalls = false;
 
+        thisThread->tbHits = pos.tb_hits();
+        thisThread->nodes = pos.nodes_searched();
+
         // At low node count increase the checking rate to about 0.1% of nodes
         // otherwise use a default value.
         thisThread->callsCnt = Limits.nodes ? std::min(4096, int(Limits.nodes / 1024))
@@ -668,7 +674,7 @@ namespace {
 
             if (err != TB::ProbeState::FAIL)
             {
-                thisThread->tbHits++;
+                pos.increment_tbHits();
 
                 int drawScore = TB::UseRule50 ? 1 : 0;
 
@@ -1256,9 +1262,6 @@ moves_loop: // When in check search starts from here
     {
       assert(is_ok(move));
 
-      // Speculative prefetch as early as possible
-      prefetch(TT.first_entry(pos.key_after(move)));
-
       givesCheck =  type_of(move) == NORMAL && !pos.discovered_check_candidates()
                   ? pos.check_squares(type_of(pos.piece_on(from_sq(move)))) & to_sq(move)
                   : pos.gives_check(move);
@@ -1300,6 +1303,9 @@ moves_loop: // When in check search starts from here
           &&  !pos.see_ge(move))
           continue;
 
+      // Speculative prefetch as early as possible
+      prefetch(TT.first_entry(pos.key_after(move)));
+
       // Check for legality just before making the move
       if (!pos.legal(move))
       {
@@ -1473,7 +1479,7 @@ moves_loop: // When in check search starts from here
 
   void check_time() {
 
-    static TimePoint lastInfoTime = now();
+    static std::atomic<TimePoint> lastInfoTime = { now() };
 
     int elapsed = Time.elapsed();
     TimePoint tick = Limits.startTime + elapsed;