diff --git a/src/search.cpp b/src/search.cpp index 8b3b8fb4864..1aa3e92e694 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -557,7 +557,7 @@ namespace { // search to overwrite a previous full search TT value, so we use a different // position key in case of an excluded move. excludedMove = ss->excludedMove; - posKey = pos.key() ^ Key(excludedMove); + posKey = pos.key() ^ Key(excludedMove << 16); // isn't a very good hash tte = TT.probe(posKey, ttHit); ttValue = ttHit ? value_from_tt(tte->value(), ss->ply) : VALUE_NONE; ttMove = rootNode ? thisThread->rootMoves[thisThread->PVIdx].pv[0] diff --git a/src/tt.cpp b/src/tt.cpp index f283d0c6d71..a1ef4442283 100644 --- a/src/tt.cpp +++ b/src/tt.cpp @@ -33,7 +33,7 @@ TranspositionTable TT; // Our global transposition table void TranspositionTable::resize(size_t mbSize) { - size_t newClusterCount = size_t(1) << msb((mbSize * 1024 * 1024) / sizeof(Cluster)); + size_t newClusterCount = mbSize * 1024 * 1024 / sizeof(Cluster); if (newClusterCount == clusterCount) return; diff --git a/src/tt.h b/src/tt.h index 24045ed0f40..e1bef323af5 100644 --- a/src/tt.h +++ b/src/tt.h @@ -104,9 +104,9 @@ class TranspositionTable { void resize(size_t mbSize); void clear(); - // The lowest order bits of the key are used to get the index of the cluster + // The 32 lowest order bits of the key are used to get the index of the cluster TTEntry* first_entry(const Key key) const { - return &table[(size_t)key & (clusterCount - 1)].entry[0]; + return &table[(uint32_t(key) * uint64_t(clusterCount)) >> 32].entry[0]; } private: diff --git a/src/ucioption.cpp b/src/ucioption.cpp index b902677f93c..f85ede1813c 100644 --- a/src/ucioption.cpp +++ b/src/ucioption.cpp @@ -55,7 +55,8 @@ bool CaseInsensitiveLess::operator() (const string& s1, const string& s2) const void init(OptionsMap& o) { - const int MaxHashMB = Is64Bit ? 1024 * 1024 : 2048; + // at most 2^32 clusters. + const int MaxHashMB = Is64Bit ? 131072 : 2048; o["Debug Log File"] << Option("", on_logger); o["Contempt"] << Option(0, -100, 100);