mirror of
https://github.com/sockspls/badfish
synced 2025-07-11 11:39:15 +00:00
Avoid casting to char* in prefetch()
Funny enough, gcc __builtin_prefetch() expects already a void*, instead Windows's _mm_prefetch() requires a char*. The patch allows to remove ugly casts from caller sites. No functional change.
This commit is contained in:
parent
152a4dc5cd
commit
99c9cae586
4 changed files with 9 additions and 9 deletions
|
@ -176,11 +176,11 @@ void start_logger(bool b) { Logger::start(b); }
|
||||||
/// which can be quite slow.
|
/// which can be quite slow.
|
||||||
#ifdef NO_PREFETCH
|
#ifdef NO_PREFETCH
|
||||||
|
|
||||||
void prefetch(char*) {}
|
void prefetch(void*) {}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
void prefetch(char* addr) {
|
void prefetch(void* addr) {
|
||||||
|
|
||||||
# if defined(__INTEL_COMPILER)
|
# if defined(__INTEL_COMPILER)
|
||||||
// This hack prevents prefetches from being optimized away by
|
// This hack prevents prefetches from being optimized away by
|
||||||
|
@ -189,7 +189,7 @@ void prefetch(char* addr) {
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(__INTEL_COMPILER) || defined(_MSC_VER)
|
# if defined(__INTEL_COMPILER) || defined(_MSC_VER)
|
||||||
_mm_prefetch(addr, _MM_HINT_T0);
|
_mm_prefetch((char*)addr, _MM_HINT_T0);
|
||||||
# else
|
# else
|
||||||
__builtin_prefetch(addr);
|
__builtin_prefetch(addr);
|
||||||
# endif
|
# endif
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
const std::string engine_info(bool to_uci = false);
|
const std::string engine_info(bool to_uci = false);
|
||||||
void prefetch(char* addr);
|
void prefetch(void* addr);
|
||||||
void start_logger(bool b);
|
void start_logger(bool b);
|
||||||
|
|
||||||
void dbg_hit_on(bool b);
|
void dbg_hit_on(bool b);
|
||||||
|
|
|
@ -774,7 +774,7 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
|
||||||
// Update material hash key and prefetch access to materialTable
|
// Update material hash key and prefetch access to materialTable
|
||||||
k ^= Zobrist::psq[them][captured][capsq];
|
k ^= Zobrist::psq[them][captured][capsq];
|
||||||
st->materialKey ^= Zobrist::psq[them][captured][pieceCount[them][captured]];
|
st->materialKey ^= Zobrist::psq[them][captured][pieceCount[them][captured]];
|
||||||
prefetch((char*)thisThread->materialTable[st->materialKey]);
|
prefetch(thisThread->materialTable[st->materialKey]);
|
||||||
|
|
||||||
// Update incremental scores
|
// Update incremental scores
|
||||||
st->psq -= psq[them][captured][capsq];
|
st->psq -= psq[them][captured][capsq];
|
||||||
|
@ -841,7 +841,7 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
|
||||||
|
|
||||||
// Update pawn hash key and prefetch access to pawnsTable
|
// 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]);
|
prefetch(thisThread->pawnsTable[st->pawnKey]);
|
||||||
|
|
||||||
// Reset rule 50 draw counter
|
// Reset rule 50 draw counter
|
||||||
st->rule50 = 0;
|
st->rule50 = 0;
|
||||||
|
@ -988,7 +988,7 @@ void Position::do_null_move(StateInfo& newSt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
st->key ^= Zobrist::side;
|
st->key ^= Zobrist::side;
|
||||||
prefetch((char*)TT.first_entry(st->key));
|
prefetch(TT.first_entry(st->key));
|
||||||
|
|
||||||
++st->rule50;
|
++st->rule50;
|
||||||
st->pliesFromNull = 0;
|
st->pliesFromNull = 0;
|
||||||
|
|
|
@ -872,7 +872,7 @@ moves_loop: // When in check and at SpNode search starts from here
|
||||||
}
|
}
|
||||||
|
|
||||||
// Speculative prefetch as early as possible
|
// Speculative prefetch as early as possible
|
||||||
prefetch((char*)TT.first_entry(pos.key_after(move)));
|
prefetch(TT.first_entry(pos.key_after(move)));
|
||||||
|
|
||||||
// Check for legality just before making the move
|
// Check for legality just before making the move
|
||||||
if (!RootNode && !SpNode && !pos.legal(move, ci.pinned))
|
if (!RootNode && !SpNode && !pos.legal(move, ci.pinned))
|
||||||
|
@ -1238,7 +1238,7 @@ moves_loop: // When in check and at SpNode search starts from here
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Speculative prefetch as early as possible
|
// Speculative prefetch as early as possible
|
||||||
prefetch((char*)TT.first_entry(pos.key_after(move)));
|
prefetch(TT.first_entry(pos.key_after(move)));
|
||||||
|
|
||||||
// Check for legality just before making the move
|
// Check for legality just before making the move
|
||||||
if (!pos.legal(move, ci.pinned))
|
if (!pos.legal(move, ci.pinned))
|
||||||
|
|
Loading…
Add table
Reference in a new issue