io-chess
UCI chess engine
Loading...
Searching...
No Matches
TranspositionTable Class Reference

The main Transposition Table. More...

#include <TT.h>

Collaboration diagram for TranspositionTable:

Public Member Functions

 TranspositionTable ()=default
 ~TranspositionTable ()
void resize (size_t mb)
 Resizes the Transposition Table to the specified capacity in Megabytes.
void clear ()
 Clears the contents of the Transposition Table.
void newSearch ()
 Increments the internal age generation to age out older entries.
void setDisabled (bool disabled)
void setNumThreads (int n)
int hashfull () const
 Calculates the utilization of the Transposition Table (per-mille).
void prefetch (uint64_t key) const
 Issues a memory prefetch instruction for the cluster corresponding to the key.
bool probe (uint64_t key, int depth, int &score, Move &bestMove, int &entryDepth, Bound &entryBound) const
 Fully probes the TT for a search entry matching the key.
Move probeMove (uint64_t key) const
 Lightly probes the TT just to extract the best move (for move ordering).
std::optional< int > probeScore (uint64_t key) const
 Lightly probes the TT to extract only the score (for pruning heuristics).
bool probeEval (uint64_t key, int16_t &score) const
 Probes the dedicated static evaluation slot.
void storeEval (uint64_t key, int16_t score)
 Stores a static evaluation in the dedicated slot.
void store (uint64_t key, int depth, int score, Bound bound, Move bestMove, int staticEval=0)
 Stores search results into the best slot in the cluster.
void dumpToFile (const std::string &filename) const
bool saveFullToFile (const std::string &filename) const
bool loadFullFromFile (const std::string &filename)

Private Member Functions

size_t index (uint64_t key) const
int ageDiff (uint8_t entryAge) const

Private Attributes

Clustertable_ = nullptr
 Pointer to the heap-allocated clusters.
size_t clusterCount_ = 0
 Number of available clusters.
size_t indexMask_ = 0
 Bitmask for fast modulo addressing.
uint8_t currentAge_ = 0
 Current generation age (used to age out old entries).
bool disableTT_ = false
 Flag to disable the TT entirely.
int numThreads_ = 1
 Number of threads sharing the table.
bool usingHugePages_ = false
 True if the memory was allocated via HugePages.

Detailed Description

The main Transposition Table.

Manages allocation, probing, and replacement of clusters using a lockless architecture suitable for SMP search.

Constructor & Destructor Documentation

◆ TranspositionTable()

TranspositionTable::TranspositionTable ( )
default

◆ ~TranspositionTable()

TranspositionTable::~TranspositionTable ( )

Member Function Documentation

◆ ageDiff()

int TranspositionTable::ageDiff ( uint8_t entryAge) const
inlineprivate
Here is the caller graph for this function:

◆ clear()

void TranspositionTable::clear ( )

Clears the contents of the Transposition Table.

Here is the caller graph for this function:

◆ dumpToFile()

void TranspositionTable::dumpToFile ( const std::string & filename) const

◆ hashfull()

int TranspositionTable::hashfull ( ) const

Calculates the utilization of the Transposition Table (per-mille).

◆ index()

size_t TranspositionTable::index ( uint64_t key) const
inlineprivate
Here is the caller graph for this function:

◆ loadFullFromFile()

bool TranspositionTable::loadFullFromFile ( const std::string & filename)

◆ newSearch()

void TranspositionTable::newSearch ( )
inline

Increments the internal age generation to age out older entries.

◆ prefetch()

void TranspositionTable::prefetch ( uint64_t key) const

Issues a memory prefetch instruction for the cluster corresponding to the key.

Here is the call graph for this function:

◆ probe()

bool TranspositionTable::probe ( uint64_t key,
int depth,
int & score,
Move & bestMove,
int & entryDepth,
Bound & entryBound ) const

Fully probes the TT for a search entry matching the key.

Returns
True if a valid entry was found and the output parameters populated.
Here is the call graph for this function:

◆ probeEval()

bool TranspositionTable::probeEval ( uint64_t key,
int16_t & score ) const

Probes the dedicated static evaluation slot.

Here is the call graph for this function:

◆ probeMove()

Move TranspositionTable::probeMove ( uint64_t key) const

Lightly probes the TT just to extract the best move (for move ordering).

Here is the call graph for this function:

◆ probeScore()

std::optional< int > TranspositionTable::probeScore ( uint64_t key) const

Lightly probes the TT to extract only the score (for pruning heuristics).

Here is the call graph for this function:

◆ resize()

void TranspositionTable::resize ( size_t mb)

Resizes the Transposition Table to the specified capacity in Megabytes.

Here is the call graph for this function:

◆ saveFullToFile()

bool TranspositionTable::saveFullToFile ( const std::string & filename) const

◆ setDisabled()

void TranspositionTable::setDisabled ( bool disabled)
inline

◆ setNumThreads()

void TranspositionTable::setNumThreads ( int n)
inline

◆ store()

void TranspositionTable::store ( uint64_t key,
int depth,
int score,
Bound bound,
Move bestMove,
int staticEval = 0 )

Stores search results into the best slot in the cluster.

Implements a replacement scheme based on depth and age.

Here is the call graph for this function:

◆ storeEval()

void TranspositionTable::storeEval ( uint64_t key,
int16_t score )

Stores a static evaluation in the dedicated slot.

Here is the call graph for this function:

Member Data Documentation

◆ clusterCount_

size_t TranspositionTable::clusterCount_ = 0
private

Number of available clusters.

◆ currentAge_

uint8_t TranspositionTable::currentAge_ = 0
private

Current generation age (used to age out old entries).

◆ disableTT_

bool TranspositionTable::disableTT_ = false
private

Flag to disable the TT entirely.

◆ indexMask_

size_t TranspositionTable::indexMask_ = 0
private

Bitmask for fast modulo addressing.

◆ numThreads_

int TranspositionTable::numThreads_ = 1
private

Number of threads sharing the table.

◆ table_

Cluster* TranspositionTable::table_ = nullptr
private

Pointer to the heap-allocated clusters.

◆ usingHugePages_

bool TranspositionTable::usingHugePages_ = false
private

True if the memory was allocated via HugePages.


The documentation for this class was generated from the following files: