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

[cluster] keep track of TB hits cluster-wide.

This commit is contained in:
Joost VandeVondele 2018-12-25 09:15:39 +01:00 committed by Stéphane Nicolet
parent fb5c1f5bf5
commit 7a32d26d5f
3 changed files with 19 additions and 3 deletions

View file

@ -41,11 +41,12 @@ static int world_size = 0;
static MPI_Request reqSignals = MPI_REQUEST_NULL;
static uint64_t signalsCallCounter = 0;
enum Signals : int { SIG_NODES = 0, SIG_STOP = 1, SIG_NB = 2};
enum Signals : int { SIG_NODES = 0, SIG_STOP = 1, SIG_TB = 2, SIG_NB = 3};
static uint64_t signalsSend[SIG_NB] = {};
static uint64_t signalsRecv[SIG_NB] = {};
static uint64_t nodesSearchedOthers = 0;
static uint64_t tbHitsOthers = 0;
static uint64_t stopSignalsPosted = 0;
static MPI_Comm InputComm = MPI_COMM_NULL;
@ -155,6 +156,7 @@ bool getline(std::istream& input, std::string& str) {
void signals_send() {
signalsSend[SIG_NODES] = Threads.nodes_searched();
signalsSend[SIG_TB] = Threads.tb_hits();
signalsSend[SIG_STOP] = Threads.stop;
MPI_Iallreduce(signalsSend, signalsRecv, SIG_NB, MPI_UINT64_T,
MPI_SUM, signalsComm, &reqSignals);
@ -164,6 +166,7 @@ void signals_send() {
void signals_process() {
nodesSearchedOthers = signalsRecv[SIG_NODES] - signalsSend[SIG_NODES];
tbHitsOthers = signalsRecv[SIG_TB] - signalsSend[SIG_TB];
stopSignalsPosted = signalsRecv[SIG_STOP];
if (signalsRecv[SIG_STOP] > 0)
Threads.stop = true;
@ -190,9 +193,10 @@ void signals_sync() {
void signals_init() {
stopSignalsPosted = nodesSearchedOthers = 0;
stopSignalsPosted = tbHitsOthers = nodesSearchedOthers = 0;
signalsSend[SIG_NODES] = signalsRecv[SIG_NODES] = 0;
signalsSend[SIG_TB] = signalsRecv[SIG_TB] = 0;
signalsSend[SIG_STOP] = signalsRecv[SIG_STOP] = 0;
}
@ -318,6 +322,11 @@ uint64_t nodes_searched() {
return nodesSearchedOthers + Threads.nodes_searched();
}
uint64_t tb_hits() {
return tbHitsOthers + Threads.tb_hits();
}
}
#else
@ -332,6 +341,11 @@ uint64_t nodes_searched() {
return Threads.nodes_searched();
}
uint64_t tb_hits() {
return Threads.tb_hits();
}
}
#endif // USE_MPI

View file

@ -75,6 +75,7 @@ inline bool is_root() { return rank() == 0; }
void save(Thread* thread, TTEntry* tte, Key k, Value v, Bound b, Depth d, Move m, Value ev);
void pick_moves(MoveInfo& mi);
uint64_t nodes_searched();
uint64_t tb_hits();
void signals_init();
void signals_poll();
void signals_sync();
@ -90,6 +91,7 @@ constexpr bool is_root() { return true; }
inline void save(Thread*, TTEntry* tte, Key k, Value v, Bound b, Depth d, Move m, Value ev) { tte->save(k, v, b, d, m, ev); }
inline void pick_moves(MoveInfo&) { }
uint64_t nodes_searched();
uint64_t tb_hits();
inline void signals_init() { }
inline void signals_poll() { }
inline void signals_sync() { }

View file

@ -1635,7 +1635,7 @@ string UCI::pv(const Position& pos, Depth depth, Value alpha, Value beta) {
size_t pvIdx = pos.this_thread()->pvIdx;
size_t multiPV = std::min((size_t)Options["MultiPV"], rootMoves.size());
uint64_t nodesSearched = Cluster::nodes_searched();
uint64_t tbHits = Threads.tb_hits() + (TB::RootInTB ? rootMoves.size() : 0);
uint64_t tbHits = Cluster::tb_hits() + (TB::RootInTB ? rootMoves.size() : 0);
for (size_t i = 0; i < multiPV; ++i)
{