diff --git a/src/main.cpp b/src/main.cpp index b5067b9b..c5bf3255 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -44,7 +44,6 @@ int main(int argc, char* argv[]) { Search::init(); Pawns::init(); Tablebases::init(Options["SyzygyPath"]); // After Bitboards are set - TT.resize(Options["Hash"]); Threads.set(Options["Threads"]); Search::clear(); // After threads are up diff --git a/src/thread.cpp b/src/thread.cpp index cab2d382..43a38e80 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -26,6 +26,7 @@ #include "thread.h" #include "uci.h" #include "syzygy/tbprobe.h" +#include "tt.h" ThreadPool Threads; // Global object @@ -136,6 +137,9 @@ void ThreadPool::set(size_t requested) { push_back(new Thread(size())); clear(); } + + // Reallocate the hash with the new threadpool size + TT.resize(Options["Hash"]); } /// ThreadPool::clear() sets threadPool data to initial values. diff --git a/src/tt.cpp b/src/tt.cpp index 5fa1290b..9f0bc4ba 100644 --- a/src/tt.cpp +++ b/src/tt.cpp @@ -36,12 +36,7 @@ TranspositionTable TT; // Our global transposition table void TranspositionTable::resize(size_t mbSize) { - size_t newClusterCount = mbSize * 1024 * 1024 / sizeof(Cluster); - - if (newClusterCount == clusterCount) - return; - - clusterCount = newClusterCount; + clusterCount = mbSize * 1024 * 1024 / sizeof(Cluster); free(mem); mem = malloc(clusterCount * sizeof(Cluster) + CacheLineSize - 1);