X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Ftt.cpp;h=c94dae53eb0289d4df142e2765ba7b71ff512099;hb=4095ff0ee51bdc76c247bd11d5f3a7008974e2ad;hp=66113ee8f2c4969bbe76e1cb2e3aa5e88e8c082f;hpb=05cb58f4fc585bb7776acfda2eb761a27959d6e5;p=stockfish diff --git a/src/tt.cpp b/src/tt.cpp index 66113ee8..c94dae53 100644 --- a/src/tt.cpp +++ b/src/tt.cpp @@ -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) @@ -89,10 +87,27 @@ TTEntry* TranspositionTable::probe(const Key key, bool& found) const { // Find an entry to be replaced according to the replacement strategy TTEntry* replace = tte; for (int i = 1; i < ClusterSize; ++i) - if ( (( tte[i].genBound8 & 0xFC) == generation8 || tte[i].bound() == BOUND_EXACT) + if ( (( tte[i].genBound8 & 0xFC) == generation8) - ((replace->genBound8 & 0xFC) == generation8) - (tte[i].depth8 < replace->depth8) < 0) replace = &tte[i]; 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; +}