]> git.sesse.net Git - stockfish/blobdiff - src/tt.cpp
Start a TT resize only after search finished.
[stockfish] / src / tt.cpp
index 53e78595045548bed917e75132dfc084c60ed88a..50e8a3bfac4bad1bcf72ee61d79664d2db36fbe8 100644 (file)
@@ -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);
@@ -84,7 +87,7 @@ void TranspositionTable::clear() {
 
   for (size_t idx = 0; idx < Options["Threads"]; idx++)
   {
-      threads.push_back(std::thread([this, idx]() {
+      threads.emplace_back([this, idx]() {
 
           // Thread binding gives faster search on systems with a first-touch policy
           if (Options["Threads"] > 8)
@@ -97,7 +100,7 @@ void TranspositionTable::clear() {
                                 stride : clusterCount - start;
 
           std::memset(&table[start], 0, len * sizeof(Cluster));
-      }));
+      });
   }
 
   for (std::thread& th: threads)