In this code, all processes post a barrier, sleep a while for good measure, then first Test
and then Wait
for the barrier. The Test
says no and the wait succeeds. A test should be like a non-blocking wait, so it should succeed. What am I missing?
printf("[%d] posting barrier, then sleeping\n",procid);
MPI_Request final_barrier;
MPI_Ibarrier(comm,&final_barrier);
sleep(2);
int all_done_flag=0;
MPI_Test(&final_barrier,&all_done_flag,MPI_STATUS_IGNORE);
printf("[%d] all done: %d\n",procid,all_done_flag);
MPI_Wait(&final_barrier,MPI_STATUS_IGNORE);
printf("[%d] concluded\n",procid);
MPI_Test
's in a row instead of one, the second one succeeds. Some googling led me to Why does MPI_Iprobe return false when message has definitely been sent (4 years old now), could the answer there be it? $\endgroup$Test
is a local operation: does only local testing without any interaction with other processes, whileWait
is a non-local operation. Another aspect of the problem is "progress": MPI needs to be activated every once in a while for everything to progress as it should. $\endgroup$