]> git.sesse.net Git - stockfish/blobdiff - src/tt.cpp
Sync with master
[stockfish] / src / tt.cpp
index 66113ee8f2c4969bbe76e1cb2e3aa5e88e8c082f..d0e2d729c8c766e883092277bfc5fd97b2bb58e2 100644 (file)
@@ -32,8 +32,6 @@ TranspositionTable TT; // Our global transposition table
 
 void TranspositionTable::resize(size_t mbSize) {
 
-  assert(sizeof(Cluster) == CacheLineSize / 2);
-
   size_t newClusterCount = size_t(1) << msb((mbSize * 1024 * 1024) / sizeof(Cluster));
 
   if (newClusterCount == clusterCount)
@@ -96,3 +94,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;
+}