diff --git a/src/cluster.cpp b/src/cluster.cpp index e0d3afc9..681cb4ed 100644 --- a/src/cluster.cpp +++ b/src/cluster.cpp @@ -266,6 +266,12 @@ void pick_moves(MoveInfo& mi) { MPI_Bcast(&mi, 1, MIDatatype, 0, MoveComm); } +void sum(uint64_t& val) { + + const uint64_t send = val; + MPI_Reduce(&send, &val, 1, MPI_UINT64_T, MPI_SUM, 0, MoveComm); +} + } #endif // USE_MPI diff --git a/src/cluster.h b/src/cluster.h index 3bbe9b9c..538a5479 100644 --- a/src/cluster.h +++ b/src/cluster.h @@ -74,6 +74,7 @@ int rank(); 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); +void sum(uint64_t& val); void sync_start(); void sync_stop(); @@ -94,6 +95,7 @@ inline void save(Thread* thread, TTEntry* tte, Key k, Value v, Bound b, Depth d, tte->save(k, v, b, d, m, ev); } inline void pick_moves(MoveInfo&) { } +void sum(uint64_t& val) { } inline void sync_start() { } inline void sync_stop() { } diff --git a/src/uci.cpp b/src/uci.cpp index a62edce7..9542ef39 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -141,8 +141,6 @@ namespace { // a list of UCI commands is setup according to bench parameters, then // it is run one by one printing a summary at the end. - // TODO make (output?) cluster compatible - void bench(Position& pos, istream& args, StateListPtr& states) { string token; @@ -160,7 +158,8 @@ namespace { if (token == "go") { - cerr << "\nPosition: " << cnt++ << '/' << num << endl; + if (Cluster::is_root()) + cerr << "\nPosition: " << cnt++ << '/' << num << endl; go(pos, is, states); Threads.main()->wait_for_search_finished(); nodes += Threads.nodes_searched(); @@ -174,10 +173,12 @@ namespace { dbg_print(); // Just before exiting - cerr << "\n===========================" - << "\nTotal time (ms) : " << elapsed - << "\nNodes searched : " << nodes - << "\nNodes/second : " << 1000 * nodes / elapsed << endl; + Cluster::sum(nodes); + if (Cluster::is_root()) + cerr << "\n===========================" + << "\nTotal time (ms) : " << elapsed + << "\nNodes searched : " << nodes + << "\nNodes/second : " << 1000 * nodes / elapsed << endl; } } // namespace