X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Ftt.cpp;h=653d081f8f0eb01859408043467a4e0486241f2f;hp=716d13e0695b9c108ba142879c365f573e027a73;hb=e2683c47b398b24cec67c06fc4ee74cbf90995ae;hpb=340e9ea5096fb1c8e4a0914827f1af1d30075039 diff --git a/src/tt.cpp b/src/tt.cpp index 716d13e0..653d081f 100644 --- a/src/tt.cpp +++ b/src/tt.cpp @@ -24,6 +24,7 @@ #include "bitboard.h" #include "misc.h" +#include "thread.h" #include "tt.h" #include "uci.h" @@ -58,6 +59,8 @@ void TTEntry::save(Key k, Value v, Bound b, Depth d, Move m, Value ev) { void TranspositionTable::resize(size_t mbSize) { + Threads.main()->wait_for_search_finished(); + clusterCount = mbSize * 1024 * 1024 / sizeof(Cluster); free(mem); @@ -82,7 +85,7 @@ void TranspositionTable::clear() { std::vector threads; - for (size_t idx = 0; idx < Options["Threads"]; idx++) + for (size_t idx = 0; idx < Options["Threads"]; ++idx) { threads.emplace_back([this, idx]() { @@ -145,12 +148,9 @@ TTEntry* TranspositionTable::probe(const Key key, bool& found) const { 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; + for (int i = 0; i < 1000 / ClusterSize; ++i) + for (int j = 0; j < ClusterSize; ++j) + cnt += (table[i].entry[j].genBound8 & 0xFC) == generation8; + + return cnt * 1000 / (ClusterSize * (1000 / ClusterSize)); }