Blame www/www3/MPI_Buffer_detach.html

Packit Service c5cf8c
Packit Service c5cf8c
<HTML>
Packit Service c5cf8c
<HEAD>
Packit Service c5cf8c
<META NAME="GENERATOR" CONTENT="DOCTEXT">
Packit Service c5cf8c
<TITLE>MPI_Buffer_detach</TITLE>
Packit Service c5cf8c
</HEAD>
Packit Service c5cf8c
<BODY BGCOLOR="FFFFFF">
Packit Service c5cf8c

MPI_Buffer_detach

Packit Service c5cf8c
Removes an existing buffer (for use in MPI_Bsend etc) 
Packit Service c5cf8c

Synopsis

Packit Service c5cf8c
Packit Service c5cf8c
int MPI_Buffer_detach(void *buffer_addr, int *size)
Packit Service c5cf8c
Packit Service c5cf8c

Output Parameters

Packit Service c5cf8c
Packit Service c5cf8c
buffer_addr
initial buffer address (choice)
Packit Service c5cf8c
Packit Service c5cf8c
size
buffer size, in bytes (integer)
Packit Service c5cf8c
Packit Service c5cf8c

Packit Service c5cf8c

Notes

Packit Service c5cf8c
The reason that <tt>MPI_Buffer_detach</tt> 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
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
    ... library code ...
Packit Service c5cf8c
    ...
Packit Service c5cf8c
    MPI_Buffer_detach(&dummy, &idummy);
Packit Service c5cf8c
    MPI_Buffer_attach(ptr, size);
Packit Service c5cf8c
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 <tt>MPI_BUFFER_DETACH</tt> contains the text
Packit Service c5cf8c

Packit Service c5cf8c
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
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 <tt>MPI_BUFFER_DETACH
Packit Service c5cf8c
</tt>as well.
Packit Service c5cf8c

Packit Service c5cf8c

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 <tt>MPI_Info</tt> 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., <tt>MPI_Bsend</tt>) 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 <tt>MPI_Buffer_attach</tt>.
Packit Service c5cf8c

Packit Service c5cf8c

Notes for Fortran

Packit Service c5cf8c
All MPI routines in Fortran (except for <tt>MPI_WTIME</tt> and <tt>MPI_WTICK</tt>) have
Packit Service c5cf8c
an additional argument <tt>ierr</tt> at the end of the argument list.  <tt>ierr
Packit Service c5cf8c
</tt>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
<tt>call</tt> statement.
Packit Service c5cf8c

Packit Service c5cf8c
All MPI objects (e.g., <tt>MPI_Datatype</tt>, <tt>MPI_Comm</tt>) are of type <tt>INTEGER
Packit Service c5cf8c
</tt>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

Notes for C

Packit Service c5cf8c
Even though the <tt>bufferptr</tt> argument is declared as <tt>void *</tt>, 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

See Also

Packit Service c5cf8c
 MPI_Buffer_attach
Packit Service c5cf8c

Packit Service c5cf8c
</BODY></HTML>