I hope this is not too off-topic here -- I've asked it on SO but I'm hoping I'll get better answers here!
I'm a little bit confused about when I should call MPI_Wait (or other variants such as: MPI_Waitall, MPII_Waitsome, etc). Consider the following situations: (Note: pseudo code)
Case (1)
MPI_Isend (send_buffer, send_req);
// Do local work
MPI_Probe (recv_msg);
MPI_Irecv (recv_buffer, recv_req);
// wait for msgs to finish
MPI_Wait (recv_req); // <--- Is this needed?
MPI_Wait (send_req); // <--- How about this?
So my confusion stems from MPI_Probe
in this case. Since this is a blocking call, wouldn't that essentially mean it blocks the caller until message is received? If this is the case, then I think MPI_Waits are unnecessary here.
How about the following case?
Case (2)
MPI_Isend (send_buffer, send_req);
// Do local work
MPI_Probe (recv_msg);
MPI_Recv (recv_buffer);
// wait for msgs to finish
MPI_Wait (send_req); // <--- Is this necessary?
Similar to the first case but MPI_Irecv
is replaced with its blocking version. In this case, the message is definitely received by the time MPI_Wait
is called which means MPI_Isend
must have been finished ...
Also as a separate question, what do we mean when we say MPI_Probe
is blocking? Does it block until all of the message is received by the process or does it only block until "meta-data" (such as msg size, sender rank, etc) is received? In other words is MPI_Probe
+ MPI_Irecv
any better than MPI_Probe
+ MPI_Recv
?