X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Ftt.cpp;h=19de55ae3cbf55d15eb6624909114f843076739c;hb=856a5f3aaaf8b9d53599963decacd4476b55c034;hp=bb49a824519a52b97828b1a6055d2e12cc8f198b;hpb=f6f1d2422303923927c0c088dee1d6df22dc4b98;p=stockfish diff --git a/src/tt.cpp b/src/tt.cpp index bb49a824..19de55ae 100644 --- a/src/tt.cpp +++ b/src/tt.cpp @@ -32,6 +32,8 @@ 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) @@ -94,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; +}