Suppose I have two processor:
The first one P0
- Call MPI_Send to send message A to p1;
- Call MPI_Recv to receive B from p1;
The second one P1
- Call MPI_Send to send message B to p0;
- Call MPI_Recv to receive A from p0;
What will happen if the sizes of both message A and B exceed the system buffer?
One should never ever assume that such a thing as buffering of the standard send exists. The MPI standard explicitly warns against it in Section 3.5 Semantics of Point-to-Point Communication:
MPI specifically addresses the use case in your question and provides the two send-receive calls
MPI_Sendrecv
andMPI_Sendrecv_replace
. The former uses separate send and receive buffers that must not overlap, while the latter uses a single buffer. Both guarantee that no deadlock will occur if the send and receive parts are matched with a corresponding receive/send operation.