]> git.sesse.net Git - stockfish/commitdiff
Send correct searched nodes statistic
authorMarco Costalba <mcostalba@gmail.com>
Fri, 31 Dec 2010 17:18:23 +0000 (18:18 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Fri, 31 Dec 2010 18:47:17 +0000 (19:47 +0100)
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/search.cpp

index b39bd53d8b8e35ce76fae02d53d6a34f158e2e58..bd24b0f8837914d4fdcb632869b85e915eb5983a 100644 (file)
@@ -267,6 +267,7 @@ namespace {
 
   // Node counters, used only by thread[0] but try to keep in different cache
   // lines (64 bytes each) from the heavy multi-thread read accessed variables.
+  bool SendSearchedNodes;
   int NodesSincePoll;
   int NodesBetweenPolls = 30000;
 
@@ -401,7 +402,7 @@ bool think(Position& pos, bool infinite, bool ponder, int time[], int increment[
            int movesToGo, int maxDepth, int maxNodes, int maxTime, Move searchMoves[]) {
 
   // Initialize global search variables
-  StopOnPonderhit = AbortSearch = Quit = AspirationFailLow = false;
+  StopOnPonderhit = AbortSearch = Quit = AspirationFailLow = SendSearchedNodes = false;
   NodesSincePoll = 0;
   SearchStartTime = get_system_time();
   ExactMaxTime = maxTime;
@@ -721,6 +722,16 @@ namespace {
             // Save the current node count before the move is searched
             nodes = pos.nodes_searched();
 
+            // If it's time to send nodes info, do it here where we have the
+            // correct accumulated node counts searched by each thread.
+            if (SendSearchedNodes)
+            {
+                SendSearchedNodes = false;
+                cout << "info nodes " << nodes
+                     << " nps " << nps(pos)
+                     << " time " << current_search_time() << endl;
+            }
+
             // Pick the next root move, and print the move and the move number to
             // the standard output.
             move = ss->currentMove = rml[i].pv[0];
@@ -2007,8 +2018,8 @@ split_point_start: // At split points actual search starts from here
         if (dbg_show_hit_rate)
             dbg_print_hit_rate();
 
-        cout << "info nodes " << pos.nodes_searched() << " nps " << nps(pos)
-             << " time " << t << endl;
+        // Send info on searched nodes as soon as we return to root
+        SendSearchedNodes = true;
     }
 
     // Should we stop the search?