From 7a32d26d5fcf61e15a19c3dc637be5e1bafc855d Mon Sep 17 00:00:00 2001 From: Joost VandeVondele Date: Tue, 25 Dec 2018 09:15:39 +0100 Subject: [PATCH] [cluster] keep track of TB hits cluster-wide. --- src/cluster.cpp | 18 ++++++++++++++++-- src/cluster.h | 2 ++ src/search.cpp | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/cluster.cpp b/src/cluster.cpp index 222b344d..293a5c96 100644 --- a/src/cluster.cpp +++ b/src/cluster.cpp @@ -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 diff --git a/src/cluster.h b/src/cluster.h index 7e7bf07b..4b80107d 100644 --- a/src/cluster.h +++ b/src/cluster.h @@ -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() { } diff --git a/src/search.cpp b/src/search.cpp index b06f57ae..569a9c4a 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -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) {