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

Don't prefetch if not needed

Prefetch access to hash tables only in case we
have changed pawn or material hash keys.

No functional change.
This commit is contained in:
Marco Costalba 2013-01-27 10:15:59 +01:00
parent bd87ab9ff5
commit 52cab06fff

View file

@ -802,9 +802,10 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
pieceList[them][capture][index[lastSquare]] = lastSquare; pieceList[them][capture][index[lastSquare]] = lastSquare;
pieceList[them][capture][pieceCount[them][capture]] = SQ_NONE; pieceList[them][capture][pieceCount[them][capture]] = SQ_NONE;
// Update hash keys // Update material hash key and prefetch access to materialTable
k ^= Zobrist::psq[them][capture][capsq]; k ^= Zobrist::psq[them][capture][capsq];
st->materialKey ^= Zobrist::psq[them][capture][pieceCount[them][capture]]; st->materialKey ^= Zobrist::psq[them][capture][pieceCount[them][capture]];
prefetch((char*)thisThread->materialTable[st->materialKey]);
// Update incremental scores // Update incremental scores
st->psqScore -= pieceSquareTable[make_piece(them, capture)][capsq]; st->psqScore -= pieceSquareTable[make_piece(them, capture)][capsq];
@ -831,7 +832,7 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
st->castleRights &= ~cr; st->castleRights &= ~cr;
} }
// Prefetch TT access as soon as we know key is updated // Prefetch TT access as soon as we know the new hash key
prefetch((char*)TT.first_entry(k)); prefetch((char*)TT.first_entry(k));
// Move the piece // Move the piece
@ -894,17 +895,14 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
st->npMaterial[us] += PieceValue[MG][promotion]; st->npMaterial[us] += PieceValue[MG][promotion];
} }
// Update pawn hash key // Update pawn hash key and prefetch access to pawnsTable
st->pawnKey ^= Zobrist::psq[us][PAWN][from] ^ Zobrist::psq[us][PAWN][to]; st->pawnKey ^= Zobrist::psq[us][PAWN][from] ^ Zobrist::psq[us][PAWN][to];
prefetch((char*)thisThread->pawnsTable[st->pawnKey]);
// Reset rule 50 draw counter // Reset rule 50 draw counter
st->rule50 = 0; st->rule50 = 0;
} }
// Prefetch pawn and material hash tables
prefetch((char*)thisThread->pawnsTable[st->pawnKey]);
prefetch((char*)thisThread->materialTable[st->materialKey]);
// Update incremental scores // Update incremental scores
st->psqScore += psq_delta(piece, from, to); st->psqScore += psq_delta(piece, from, to);