]> git.sesse.net Git - stockfish/commitdiff
Ressurrect hashfull patch
authorJean-Francois Romang <jromang@posteo.de>
Sun, 25 Jan 2015 07:57:51 +0000 (08:57 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Fri, 30 Jan 2015 17:07:20 +0000 (18:07 +0100)
This is an old patch from Jean-Francois Romang to send
UCI hashfull info to the GUI:
https://github.com/mcostalba/Stockfish/pull/60/files

It was wrongly judged as a slowdown, but it takes much
less than 1 ms to run, indeed on my core i5 2.6Ghz it
takes about 2 microsecs to run!

Regression test is good:

STC
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 7352 W: 1548 L: 1401 D: 4403

LTC
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 61432 W: 10307 L: 10251 D: 40874

I have set the name of the author to the original
one.

No functional change.

src/search.cpp
src/tt.cpp
src/tt.h

index 3c32c4bb762a45ee1ae35f14a02aa119ff654418..eea529845ab8474822a6e38c142e98c4f7d7216f 100644 (file)
@@ -1447,8 +1447,12 @@ moves_loop: // When in check and at SpNode search starts from here
               ss << (v >= beta ? " lowerbound" : v <= alpha ? " upperbound" : "");
 
         ss << " nodes "     << pos.nodes_searched()
-           << " nps "       << pos.nodes_searched() * 1000 / elapsed
-           << " tbhits "    << TB::Hits
+           << " nps "       << pos.nodes_searched() * 1000 / elapsed;
+
+        if (elapsed > 1000) // Earlier makes little sense
+           ss << " hashfull "  << TT.hashfull();
+
+        ss << " tbhits "    << TB::Hits
            << " time "      << elapsed
            << " pv";
 
index 66113ee8f2c4969bbe76e1cb2e3aa5e88e8c082f..19de55ae3cbf55d15eb6624909114f843076739c 100644 (file)
@@ -96,3 +96,20 @@ TTEntry* TranspositionTable::probe(const Key key, bool& found) const {
 
   return found = false, replace;
 }
+
+
+/// Returns an approximation of the hashtable occupation during a search. The
+/// hash is x permill full, as per UCI protocol.
+
+int TranspositionTable::hashfull() const
+{
+  int cnt = 0;
+  for (int i = 0; i < 1000 / ClusterSize; i++)
+  {
+      const TTEntry* tte = &table[i].entry[0];
+      for (int j = 0; j < ClusterSize; j++)
+          if ((tte[j].genBound8 & 0xFC) == generation8)
+              cnt++;
+  }
+  return cnt;
+}
index 4df015c07cbc34c5f847f4a91202b64b79a90b3f..7343c525fc6847da40c83c3168fdfa857446f73a 100644 (file)
--- a/src/tt.h
+++ b/src/tt.h
@@ -86,6 +86,7 @@ public:
   void new_search() { generation8 += 4; } // Lower 2 bits are used by Bound
   uint8_t generation() const { return generation8; }
   TTEntry* probe(const Key key, bool& found) const;
+  int hashfull() const;
   void resize(size_t mbSize);
   void clear();