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?
The code is wrong in any case.
It may work by the mercy of the MPI implementation / configuration / state. But generally, this is a deadlock. You shouldn't ponder about the buffering of standard blocking send calls for correctness. They are allowed to buffer exclusively for performance reasons, which can be surprising for beginners. Code that seemed to be working for small messages sizes suddenly deadlocked for larger message sizes, but actually the code was wrong all along, it just din't show.