1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-05-01 17:19:36 +00:00

Fix search result aggregation

This reverts my earlier change that only the root node gets to output best move after fixing problem with MPI_Allreduce by our custom operator(BestMoveOp). This function is not commutable and we must ensure that its output is consistent among all nodes.
This commit is contained in:
noobpwnftw 2018-07-13 16:51:26 +08:00 committed by Stéphane Nicolet
parent 8a95d269eb
commit 2405b38165
2 changed files with 5 additions and 5 deletions

View file

@ -58,8 +58,8 @@ static void BestMove(void* in, void* inout, int* len, MPI_Datatype* datatype) {
MoveInfo* r = static_cast<MoveInfo*>(inout); MoveInfo* r = static_cast<MoveInfo*>(inout);
for (int i=0; i < *len; ++i) for (int i=0; i < *len; ++i)
{ {
if ( l[i].depth > r[i].depth if ( (l[i].depth > r[i].depth || (l[i].depth == r[i].depth && l[i].rank < r[i].rank))
&& (l[i].score >= r[i].score || l[i].score >= VALUE_MATE_IN_MAX_PLY)) && (l[i].score >= r[i].score))
r[i] = l[i]; r[i] = l[i];
} }
} }
@ -102,7 +102,7 @@ void init() {
MPI_Type_create_hindexed_block(3, 1, MIdisps.data(), MPI_INT, &MIDatatype); MPI_Type_create_hindexed_block(3, 1, MIdisps.data(), MPI_INT, &MIDatatype);
MPI_Type_commit(&MIDatatype); MPI_Type_commit(&MIDatatype);
MPI_Op_create(BestMove, true, &BestMoveOp); MPI_Op_create(BestMove, false, &BestMoveOp);
MPI_Comm_dup(MPI_COMM_WORLD, &InputComm); MPI_Comm_dup(MPI_COMM_WORLD, &InputComm);
MPI_Comm_dup(MPI_COMM_WORLD, &TTComm); MPI_Comm_dup(MPI_COMM_WORLD, &TTComm);

View file

@ -295,7 +295,7 @@ void MainThread::search() {
previousScore = static_cast<Value>(mi.score); previousScore = static_cast<Value>(mi.score);
if (Cluster::is_root()) { if (mi.rank == Cluster::rank()) {
// Send again PV info if we have a new best thread // Send again PV info if we have a new best thread
if (bestThread != this) if (bestThread != this)
sync_cout << UCI::pv(bestThread->rootPos, bestThread->completedDepth, -VALUE_INFINITE, VALUE_INFINITE) << sync_endl; sync_cout << UCI::pv(bestThread->rootPos, bestThread->completedDepth, -VALUE_INFINITE, VALUE_INFINITE) << sync_endl;
@ -373,7 +373,7 @@ void Thread::search() {
// Distribute search depths across the helper threads // Distribute search depths across the helper threads
if (idx + Cluster::rank() > 0) if (idx + Cluster::rank() > 0)
{ {
int i = (idx + Cluster::rank() - 1) % 20; int i = (idx + Cluster::rank() * (int)Options["Threads"] - 1) % 20;
if (((rootDepth / ONE_PLY + SkipPhase[i]) / SkipSize[i]) % 2) if (((rootDepth / ONE_PLY + SkipPhase[i]) / SkipSize[i]) % 2)
continue; // Retry with an incremented rootDepth continue; // Retry with an incremented rootDepth
} }