diff --git a/src/evaluate.cpp b/src/evaluate.cpp index e9feba06..86b37e3b 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -269,16 +269,13 @@ namespace { } -//// -//// Functions -//// +/// prefetchTables() is called in do_move() to prefetch pawn and material +/// hash tables data that will be needed shortly after in evaluation. +void prefetchTables(Key pKey, Key mKey, int threadID) { -/// Prefetches in pawn hash tables - -void prefetchPawn(Key key, int threadID) { - - PawnTable[threadID]->prefetch(key); + PawnTable[threadID]->prefetch(pKey); + MaterialTable[threadID]->prefetch(mKey); } diff --git a/src/misc.h b/src/misc.h index 0c4bd644..6c451934 100644 --- a/src/misc.h +++ b/src/misc.h @@ -29,7 +29,7 @@ extern int get_system_time(); extern int cpu_count(); extern int input_available(); extern void prefetch(char* addr); -extern void prefetchPawn(Key, int); +extern void prefetchTables(Key pKey, Key mKey, int threadID); // Debug functions extern bool dbg_show_mean; diff --git a/src/position.cpp b/src/position.cpp index f4a098d9..abe7fde3 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -885,7 +885,6 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI // Update pawn hash key and prefetch in L1/L2 cache st->pawnKey ^= zobrist[us][PAWN][from] ^ zobrist[us][PAWN][to]; - prefetchPawn(st->pawnKey, threadID); // Set en passant square, only if moved pawn can be captured if ((to ^ from) == 16) @@ -938,6 +937,9 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI } } + // Prefetch pawn and material hash tables + prefetchTables(st->pawnKey, st->materialKey, threadID); + // Update incremental scores st->value += pst_delta(piece, from, to);