prefetching tt for speedup | bench 5829415 #109

Merged
rektdie merged 1 commits from tt-prefetch into main 2025-09-15 08:03:03 +02:00
2 changed files with 11 additions and 0 deletions

No files matched your search

+7
View File
@@ -329,6 +329,9 @@ static SearchResults Quiescence(Board& board, int alpha, int beta, int ply, Sear
}
ctx->positionHistory[copy.positionIndex] = copy.hashKey;
ctx->nodes++;
ctx->TT.PrefetchEntry(copy.hashKey);
int score = -Quiescence<mode>(copy, -beta, -alpha, ply + 1, ctx).score;
if (score >= beta) {
@@ -430,6 +433,8 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
const int reduction = 4 + improving + depth / 3;
ctx->TT.PrefetchEntry(copy.hashKey);
ctx->doingNullMove = true;
int score = -PVS<false, mode>(copy, depth - reduction, -beta, -beta + 1, ply + 1, ctx, !cutnode).score;
ctx->doingNullMove = false;
@@ -508,6 +513,8 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
ctx->positionHistory[copy.positionIndex] = copy.hashKey;
ctx->nodes++;
ctx->TT.PrefetchEntry(copy.hashKey);
int extension = 0;
if (ply
+4
View File
@@ -61,6 +61,10 @@ public:
table.resize(size);
}
void PrefetchEntry(U64 &hashKey) {
__builtin_prefetch(&table[hashKey % table.size()]);
}
TTEntry GetRawEntry(U64 &hashKey) {
TTEntry *current = &table[hashKey % table.size()];
return *current;