Skip to content

Commit 72a6216

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 72a6216

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/runtime-libraries/mpi/mpi_caf.c

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

11091124
CAF_Win_unlock_all(*stat_tok);

0 commit comments

Comments
 (0)