MPI P2P Communication Modes
Intro to MPI modes for P2P communication
In the previous post, we saw the standard communication mode that is used under the hoods with MPI_Send
. Here, we describe a few more communication modes supported by the MPI standard.
MPI has three additional modes for P2P communication [1]:
- Buffered
- Synchronous
- Ready
In the buffered mode, the sending operation is always locally blocking and just like with standard communication mode, it will return as soon as the message is copied to a buffer. The difference here is that the buffer is user-provided [1].
The synchronous mode is a globally blocking operation [1]. In this mode, the sending operation will return only when the retrival of the message has been initiated by the receiving process. However, the message receiving may not be complete [1].
Remark
The buffered and synchronous modes constitute two symmetrical endpoints. In the buffered mode we trade the waiting with memory whilst in the synchronous mode we don't mind o wait for the message to reach the destination.
In the ready mode, the send operation will succeed only if a matching receive operation has been initiated already [1]. Otherwise, the function returns with an error code. The purpose of this mode is to reduce the overhead of handshaking operations [1].
So how can we distinguish between these different commnunication modes? This is done by prefixing the initial letter of each mode before the Send
[1]. Thus, we have
MPI_Bsend
MPI_Ssend
MPI_Rsend
The resr of the functions signatures is the same as that of MPI_Send
[1]
int [ MPI_Bsend | MPI_Ssend | MPI_Rsend ] (void∗ buf , int count ,
MPI_Datatype datatype ,
int dest , int tag , MPI_Comm comm ) ;
Remark
Bear in mind that blocking sends can be matched with non blocking receives, and vice versa [1]. However, the tuple (communicator, rank, message tag) should match in order to do so.
In this post, we introduced three more communication modes supported by MPI for P2P message exchange. The fact that we have in our disposal different means for P2P communucation means that we can adjust the application to better suit the hardware it is running on. The interafces of the supplied functions are the same with that of MPI_Send
. This greatly facilitates development. We can, for example, create an array of function pointers so that we group these functions in one place and call the specified function based on some given configuration parameter.
- Gerassimos Barlas,
Multicore and GPU Programming An Integrated Approach
, Morgan Kaufmann