1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-29 16:23:09 +00:00

Properly initialize the TT in a multithreaded way again

This commit is contained in:
Disservin 2024-06-04 07:53:25 +02:00
parent ba06671aa9
commit 7f09d06b83
2 changed files with 7 additions and 4 deletions

View file

@ -75,9 +75,11 @@ uint8_t TTEntry::relative_age(const uint8_t generation8) const {
// measured in megabytes. Transposition table consists // measured in megabytes. Transposition table consists
// of clusters and each cluster consists of ClusterSize number of TTEntry. // of clusters and each cluster consists of ClusterSize number of TTEntry.
void TranspositionTable::resize(size_t mbSize, ThreadPool& threads) { void TranspositionTable::resize(size_t mbSize, ThreadPool& threads) {
aligned_large_pages_free(table);
clusterCount = mbSize * 1024 * 1024 / sizeof(Cluster); clusterCount = mbSize * 1024 * 1024 / sizeof(Cluster);
table = make_unique_large_page<Cluster[]>(clusterCount); table = static_cast<Cluster*>(aligned_large_pages_alloc(clusterCount * sizeof(Cluster)));
if (!table) if (!table)
{ {

View file

@ -96,6 +96,7 @@ class TranspositionTable {
static constexpr int GENERATION_MASK = (0xFF << GENERATION_BITS) & 0xFF; static constexpr int GENERATION_MASK = (0xFF << GENERATION_BITS) & 0xFF;
public: public:
~TranspositionTable() { aligned_large_pages_free(table); }
void new_search() { void new_search() {
// increment by delta to keep lower bits as is // increment by delta to keep lower bits as is
generation8 += GENERATION_DELTA; generation8 += GENERATION_DELTA;
@ -115,9 +116,9 @@ class TranspositionTable {
private: private:
friend struct TTEntry; friend struct TTEntry;
size_t clusterCount; size_t clusterCount;
LargePagePtr<Cluster[]> table; Cluster* table = nullptr;
uint8_t generation8 = 0; // Size must be not bigger than TTEntry::genBound8 uint8_t generation8 = 0; // Size must be not bigger than TTEntry::genBound8
}; };
} // namespace Stockfish } // namespace Stockfish