A user may specify a buffer to be used for buffering messages sent in buffered mode. Buffering is done by the sender.
MPI_BUFFER_ATTACH( buffer, size)
[ IN buffer] initial buffer address (choice)
[ IN size] buffer size, in bytes (integer)
int MPI_Buffer_attach( void* buffer, int size)
MPI_BUFFER_ATTACH( BUFFER, SIZE, IERROR)
<type> BUFFER(*)
INTEGER SIZE, IERROR
Provides to MPI a buffer in the user's memory to be used for buffering outgoing messages. The buffer is used only by messages sent in buffered mode. Only one buffer can be attached to a process at a time.
MPI_BUFFER_DETACH( buffer, size)
[ OUT buffer] initial buffer address (choice)
[ OUT size] buffer size, in bytes (integer)
int MPI_Buffer_detach( void** buffer, int* size)
MPI_BUFFER_DETACH( BUFFER, SIZE, IERROR)
<type> BUFFER(*)
INTEGER SIZE, IERROR
Detach the buffer currently associated with MPI. This operation will block until all messages currently in the buffer have been transmitted. Upon return of this function, the user may reuse or deallocate the space taken by the buffer.
The statements made in this section describe the behavior of MPI for buffered-mode sends. When no buffer is currently associated, MPI behaves as if a zero-sized buffer is associated with the process.
MPI must provide as much buffering for outgoing messages as if outgoing message data were buffered by the sending process, in the specified buffer space, using a circular, contiguous-space allocation policy. We outline below a model implementation that defines this policy. MPI may provide more buffering, and may use a better buffer allocation algorithm than described below. On the other hand, MPI may signal an error whenever the simple buffering allocator described below would run out of space. In particular, if no buffer is explicitly associated with the process, then any buffered send may cause an error.
MPI does not provide mechanisms for querying or controlling buffering done by standard mode sends. It is expected that vendors will provide such information for their implementations.
[] Rationale.
There is a wide spectrum of possible implementations of buffered communication:
buffering can be done at sender, at receiver, or both; buffers can be dedicated
to one sender-receiver pair, or be shared by
all communications; buffering can be done in real or
in virtual memory; it can use dedicated memory, or memory shared by other
processes; buffer space may be allocated statically or be changed dynamically;
etc. It does not seem feasible to provide a portable mechanism for querying
or controlling buffering that would be compatible with all these choices, yet
provide meaningful information.
( End of rationale.)