Communication Modes
- Buffered SEND
- Synchronous SEND
- Ready SEND
The standard MPI_SEND function may or may not buffer the
outgoing message. Implementations decide whether the
outgoing message should be buffered to a system buffer or -- for performance
issues -- whether the sender waits until a matching RECV is posted and
the data are copied to the receiver buffer.
The MPI standards provide several modes for each SEND operation.
In a buffered send, the message containing the outgoing data is
guaranteed to be buffered. The buffer, however, is not provided by the
system but rather by the application and is part of the application's
memory space. Before using MPI_Bsend, you must allocate the
buffer by calling MPI_Buffer_attach.
MPI_Buffer_attach(send_buff,buff_size)
...
MPI_Bsend(send_buff,count,datatype,dest,tag,comm)
where buff_size is the size of the buffer to be allocated, in bytes,
for use with MPI_Bsend. After the message in the buffer has been sent,
the buffer may be reclaimed for reuse by calling the function
MPI_buffer_detach.
MPI_Buffer_detach(send_buff,buff_size)
The call to MPI_detach blocks until the message in the buffer has
been sent.
A synchronous send, MPI_Ssend, is not returned until a matching receive
has been posted and the receiver has actually started receiving the
message. This provides a kind of synchronization in the sense that
the return of MPI_Ssend implies that a receiver is actually receiving
the message although it has not necessarily completed receiving it.
However, if no
matching receive is posted, the sender will block.
MPI_Ssend(send_buff,count,datatype,dest,tag,comm)
The call to MPI_Rsend does not start on the sender side until a
matching receive has been posted (i.e., a receiver has called a matching
MPI_Recv). If no matching receive has been posted, the call to MPI_Rsend
is erroneous, and the outcome is undefined.
MPI_Rsend(send_buff,count,datatype,dest,tag,comm)
All the SEND modes described above are blocking. On the sender side, a call
to any of these SENDs block until it is safe for the sender to reuse
its send buffer. Non-blocking versions of these modes are also available
with the calling syntax:
MPI_Ibsend(send_buff,count,datatype,dest,tag,comm)
MPI_Issend(send_buff,count,datatype,dest,tag,comm)
MPI_Irsend(send_buff,count,datatype,dest,tag,comm)
As in the standard non-blocking send, MPI_Isend, these calls return
immediately. You must verify their completion before reusing
the send buffer.