Skip to content

Commit 4d97203

Browse files
committed
Purge communicator before free on mpich4+.
Mpich from 4.0 on seems to bug when there is a message dangling on freeing the communicator.
1 parent 6017b71 commit 4d97203

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/runtime-libraries/mpi/mpi_caf.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,6 +1104,23 @@ finalize_internal(int status_code)
11041104
ierr = MPI_Finalize(); chk_err(ierr);
11051105
}
11061106
#else
1107+
#ifdef MPICH
1108+
{
1109+
int probe_flag;
1110+
MPI_Status status;
1111+
do {
1112+
ierr = MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, CAF_COMM_WORLD, &probe_flag,
1113+
&status); /* error is not of interest. */
1114+
if (probe_flag) {
1115+
int cnt;
1116+
MPI_Get_count(&status, MPI_BYTE, &cnt);
1117+
void * buf = alloca(cnt);
1118+
ierr = MPI_Recv(buf, cnt, MPI_BYTE, status.MPI_SOURCE, status.MPI_TAG,
1119+
CAF_COMM_WORLD, &status); chk_err(ierr);
1120+
}
1121+
} while (probe_flag);
1122+
}
1123+
#endif
11071124
ierr = MPI_Comm_free(&CAF_COMM_WORLD); chk_err(ierr);
11081125

11091126
CAF_Win_unlock_all(*stat_tok);

0 commit comments

Comments
 (0)