Blame man/man3/MPI_Buffer_detach.3

Packit Service c5cf8c
.TH MPI_Buffer_detach 3 "11/12/2019" " " "MPI"
Packit Service c5cf8c
.SH NAME
Packit Service c5cf8c
MPI_Buffer_detach \-  Removes an existing buffer (for use in MPI_Bsend etc) 
Packit Service c5cf8c
.SH SYNOPSIS
Packit Service c5cf8c
.nf
Packit Service c5cf8c
int MPI_Buffer_detach(void *buffer_addr, int *size)
Packit Service c5cf8c
.fi
Packit Service c5cf8c
.SH OUTPUT PARAMETERS
Packit Service c5cf8c
.PD 0
Packit Service c5cf8c
.TP
Packit Service c5cf8c
.B buffer_addr 
Packit Service c5cf8c
- initial buffer address (choice)
Packit Service c5cf8c
.PD 1
Packit Service c5cf8c
.PD 0
Packit Service c5cf8c
.TP
Packit Service c5cf8c
.B size 
Packit Service c5cf8c
- buffer size, in bytes (integer)
Packit Service c5cf8c
.PD 1
Packit Service c5cf8c
Packit Service c5cf8c
.SH NOTES
Packit Service c5cf8c
The reason that 
Packit Service c5cf8c
.I MPI_Buffer_detach
Packit Service c5cf8c
returns the address and size of the
Packit Service c5cf8c
buffer being detached is to allow nested libraries to replace and restore
Packit Service c5cf8c
the buffer.  For example, consider
Packit Service c5cf8c
Packit Service c5cf8c
.nf
Packit Service c5cf8c
int size, mysize, idummy;
Packit Service c5cf8c
void *ptr, *myptr, *dummy;
Packit Service c5cf8c
MPI_Buffer_detach(&ptr, &size);
Packit Service c5cf8c
MPI_Buffer_attach(myptr, mysize);
Packit Service c5cf8c
\&.
Packit Service c5cf8c
\&.
Packit Service c5cf8c
\&.
Packit Service c5cf8c
\&.
Packit Service c5cf8c
\&.
Packit Service c5cf8c
\&.
Packit Service c5cf8c
library code ...
Packit Service c5cf8c
\&.
Packit Service c5cf8c
\&.
Packit Service c5cf8c
\&.
Packit Service c5cf8c
MPI_Buffer_detach(&dummy, &idummy);
Packit Service c5cf8c
MPI_Buffer_attach(ptr, size);
Packit Service c5cf8c
.fi
Packit Service c5cf8c
Packit Service c5cf8c
Packit Service c5cf8c
This is much like the action of the Unix signal routine and has the same
Packit Service c5cf8c
strengths (it is simple) and weaknesses (it only works for nested usages).
Packit Service c5cf8c
Packit Service c5cf8c
Note that for this approach to work, MPI_Buffer_detach must return MPI_SUCCESS
Packit Service c5cf8c
even when there is no buffer to detach.  In that case, it returns a size of
Packit Service c5cf8c
zero.  The MPI 1.1 standard for 
Packit Service c5cf8c
.I MPI_BUFFER_DETACH
Packit Service c5cf8c
contains the text
Packit Service c5cf8c
Packit Service c5cf8c
.nf
Packit Service c5cf8c
The statements made in this section describe the behavior of MPI for
Packit Service c5cf8c
buffered-mode sends. When no buffer is currently associated, MPI behaves
Packit Service c5cf8c
as if a zero-sized buffer is associated with the process.
Packit Service c5cf8c
.fi
Packit Service c5cf8c
Packit Service c5cf8c
Packit Service c5cf8c
This could be read as applying only to the various Bsend routines.  This
Packit Service c5cf8c
implementation takes the position that this applies to 
Packit Service c5cf8c
.I MPI_BUFFER_DETACH
Packit Service c5cf8c
as well.
Packit Service c5cf8c
Packit Service c5cf8c
.SH THREAD AND INTERRUPT SAFETY
Packit Service c5cf8c
Packit Service c5cf8c
The user is responsible for ensuring that multiple threads do not try to
Packit Service c5cf8c
update the same MPI object from different threads.  This routine should
Packit Service c5cf8c
not be used from within a signal handler.
Packit Service c5cf8c
Packit Service c5cf8c
The MPI standard defined a thread-safe interface but this does not
Packit Service c5cf8c
mean that all routines may be called without any thread locks.  For
Packit Service c5cf8c
example, two threads must not attempt to change the contents of the
Packit Service c5cf8c
same 
Packit Service c5cf8c
.I MPI_Info
Packit Service c5cf8c
object concurrently.  The user is responsible in this
Packit Service c5cf8c
case for using some mechanism, such as thread locks, to ensure that
Packit Service c5cf8c
only one thread at a time makes use of this routine.
Packit Service c5cf8c
Because the buffer for buffered sends (e.g., 
Packit Service c5cf8c
.I MPI_Bsend
Packit Service c5cf8c
) is shared by all
Packit Service c5cf8c
threads in a process, the user is responsible for ensuring that only
Packit Service c5cf8c
one thread at a time calls this routine or 
Packit Service c5cf8c
.I MPI_Buffer_attach
Packit Service c5cf8c
\&.
Packit Service c5cf8c
Packit Service c5cf8c
Packit Service c5cf8c
.SH NOTES FOR FORTRAN
Packit Service c5cf8c
All MPI routines in Fortran (except for 
Packit Service c5cf8c
.I MPI_WTIME
Packit Service c5cf8c
and 
Packit Service c5cf8c
.I MPI_WTICK
Packit Service c5cf8c
) have
Packit Service c5cf8c
an additional argument 
Packit Service c5cf8c
.I ierr
Packit Service c5cf8c
at the end of the argument list.  
Packit Service c5cf8c
.I ierr
Packit Service c5cf8c
is an integer and has the same meaning as the return value of the routine
Packit Service c5cf8c
in C.  In Fortran, MPI routines are subroutines, and are invoked with the
Packit Service c5cf8c
.I call
Packit Service c5cf8c
statement.
Packit Service c5cf8c
Packit Service c5cf8c
All MPI objects (e.g., 
Packit Service c5cf8c
.I MPI_Datatype
Packit Service c5cf8c
, 
Packit Service c5cf8c
.I MPI_Comm
Packit Service c5cf8c
) are of type 
Packit Service c5cf8c
.I INTEGER
Packit Service c5cf8c
in Fortran.
Packit Service c5cf8c
Packit Service c5cf8c
The Fortran binding for this routine is different.  Because Fortran
Packit Service c5cf8c
does not have pointers, it is impossible to provide a way to use the
Packit Service c5cf8c
output of this routine to exchange buffers.  In this case, only the
Packit Service c5cf8c
size field is set.
Packit Service c5cf8c
Packit Service c5cf8c
.SH NOTES FOR C
Packit Service c5cf8c
Even though the 
Packit Service c5cf8c
.I bufferptr
Packit Service c5cf8c
argument is declared as 
Packit Service c5cf8c
.I void *
Packit Service c5cf8c
, it is
Packit Service c5cf8c
really the address of a void pointer.  See the rationale in the
Packit Service c5cf8c
standard for more details.
Packit Service c5cf8c
Packit Service c5cf8c
.SH SEE ALSO
Packit Service c5cf8c
MPI_Buffer_attach
Packit Service c5cf8c
.br