]> git.sesse.net Git - stockfish/commitdiff
Pre-initialize ss->ply
authorJ. Oster <osterj165@googlemail.com>
Mon, 31 May 2021 15:46:40 +0000 (17:46 +0200)
committerStéphane Nicolet <cassio@free.fr>
Tue, 1 Jun 2021 19:25:28 +0000 (21:25 +0200)
We pre-initialize ss->ply over the whole stack. There is no need
to re-assign the same value(s) over and over again while searching.
Probably a tiny speedup on longer searches.

Tested for no regression:

STC
LLR: 2.93 (-2.94,2.94) <-2.50,0.50>
Total: 25784 W: 2205 L: 2101 D: 21478
Ptnml(0-2): 62, 1660, 9368, 1716, 86
https://tests.stockfishchess.org/tests/view/60b516c6457376eb8bca9dfa

LTC
LLR: 2.94 (-2.94,2.94) <-2.50,0.50>
Total: 26200 W: 944 L: 878 D: 24378
Ptnml(0-2): 12, 732, 11545, 800, 11
https://tests.stockfishchess.org/tests/view/60b53652457376eb8bca9e0e

closes https://github.com/official-stockfish/Stockfish/pull/3516

No functional change.

src/search.cpp

index 2b4e4f1e8434652e8ff54f0c30ec612d96795fcd..dac326e2a27e89229296da945e2f7d6414f28d81 100644 (file)
@@ -253,7 +253,7 @@ void Thread::search() {
   // To allow access to (ss-7) up to (ss+2), the stack must be oversized.
   // The former is needed to allow update_continuation_histories(ss-1, ...),
   // which accesses its argument at ss-6, also near the root.
-  // The latter is needed for statScores and killer initialization.
+  // The latter is needed for statScore and killer initialization.
   Stack stack[MAX_PLY+10], *ss = stack+7;
   Move  pv[MAX_PLY+1];
   Value bestValue, alpha, beta, delta;
@@ -268,6 +268,9 @@ void Thread::search() {
   for (int i = 7; i > 0; i--)
       (ss-i)->continuationHistory = &this->continuationHistory[0][0][NO_PIECE][0]; // Use as a sentinel
 
+  for (int i = 0; i <= MAX_PLY + 2; ++i)
+      (ss+i)->ply = i;
+
   ss->pv = pv;
 
   bestValue = delta = alpha = -VALUE_INFINITE;
@@ -607,7 +610,6 @@ namespace {
 
     assert(0 <= ss->ply && ss->ply < MAX_PLY);
 
-    (ss+1)->ply = ss->ply + 1;
     (ss+1)->ttPv = false;
     (ss+1)->excludedMove = bestMove = MOVE_NONE;
     (ss+2)->killers[0] = (ss+2)->killers[1] = MOVE_NONE;
@@ -1379,7 +1381,6 @@ moves_loop: // When in check, search starts from here
     }
 
     Thread* thisThread = pos.this_thread();
-    (ss+1)->ply = ss->ply + 1;
     bestMove = MOVE_NONE;
     ss->inCheck = pos.checkers();
     moveCount = 0;