Compute SplitPoint::spLevel on the fly
authorMarco Costalba <mcostalba@gmail.com>
Tue, 17 Feb 2015 09:10:58 +0000 (10:10 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Wed, 18 Feb 2015 20:50:35 +0000 (21:50 +0100)
And retire a redundant field. This is important also
from a concept point of view becuase we want to keep
SMP structures as simple as possible with the only
strictly necessary data.

Verified with

dbg_hit_on(sp->spLevel != level)

that the values are 100% the same out of more 50K samples.

No functional change.

src/search.cpp
src/thread.cpp
src/thread.h

index 29820a1f45ac884a6c77edeb5abaa46b0677dd4d..dcb89d75caf89733567141297faaf3594271210c 100644 (file)
@@ -1604,7 +1604,12 @@ void Thread::idle_loop() {
                       && sp->slavesCount < MAX_SLAVES_PER_SPLITPOINT
                       && available_to(Threads[i]))
                   {
-                      int score = sp->spLevel * 256 * 256 + sp->slavesCount * 256 - sp->depth * 1;
+                      // Compute the recursive split points chain size
+                      int level = -1;
+                      for (SplitPoint* spp = Threads[i]->activeSplitPoint; spp; spp = spp->parentSplitPoint)
+                          level++;
+
+                      int score = level * 256 * 256 + sp->slavesCount * 256 - sp->depth * 1;
 
                       if (score < bestScore)
                       {
@@ -1618,7 +1623,7 @@ void Thread::idle_loop() {
               if (bestSp)
               {
                   sp = bestSp;
+
                   // Recheck the conditions under lock protection
                   Threads.mutex.lock();
                   sp->mutex.lock();
index 02cb45629dff48b8048890911139efe0eae5d46a..5c013c6a0b72e06830d2a7389706f45d73b9a43a 100644 (file)
@@ -154,7 +154,6 @@ void Thread::split(Position& pos, Stack* ss, Value alpha, Value beta, Value* bes
 
   sp.masterThread = this;
   sp.parentSplitPoint = activeSplitPoint;
-  sp.spLevel = activeSplitPoint ? activeSplitPoint->spLevel + 1 : 0;
   sp.slavesMask = 0, sp.slavesMask.set(idx);
   sp.slavesCount = 1;
   sp.depth = depth;
@@ -184,7 +183,7 @@ void Thread::split(Position& pos, Stack* ss, Value alpha, Value beta, Value* bes
 
   Thread* slave;
 
-  while (    sp.slavesCount < MAX_SLAVES_PER_SPLITPOINT 
+  while (    sp.slavesCount < MAX_SLAVES_PER_SPLITPOINT
          && (slave = Threads.available_slave(this)) != NULL)
   {
       sp.slavesMask.set(slave->idx);
index 949f87ad28ae086fe75e0577b98e859029cfc4ed..0265ee670b2ea9e84765a8b6208f8b1f8ccb2e9c 100644 (file)
@@ -73,7 +73,6 @@ struct SplitPoint {
   const Position* pos;
   Search::Stack* ss;
   Thread* masterThread;
-  int spLevel;
   Depth depth;
   Value beta;
   int nodeType;