Blame www/www3/MPI_Buffer_attach.html

Packit 0848f5
Packit 0848f5
<HTML>
Packit 0848f5
<HEAD>
Packit 0848f5
<META NAME="GENERATOR" CONTENT="DOCTEXT">
Packit 0848f5
<TITLE>MPI_Buffer_attach</TITLE>
Packit 0848f5
</HEAD>
Packit 0848f5
<BODY BGCOLOR="FFFFFF">
Packit 0848f5

MPI_Buffer_attach

Packit 0848f5
Attaches a user-provided buffer for sending  
Packit 0848f5

Synopsis

Packit 0848f5
Packit 0848f5
int MPI_Buffer_attach(void *buffer, int size)
Packit 0848f5
Packit 0848f5

Input Parameters

Packit 0848f5
Packit 0848f5
buffer
initial buffer address (choice)
Packit 0848f5
Packit 0848f5
size
buffer size, in bytes (integer)
Packit 0848f5
Packit 0848f5

Packit 0848f5

Notes

Packit 0848f5
The size given should be the sum of the sizes of all outstanding Bsends that
Packit 0848f5
you intend to have, plus <tt>MPI_BSEND_OVERHEAD</tt> for each Bsend that you do.
Packit 0848f5
For the purposes of calculating size, you should use <tt>MPI_Pack_size</tt>.
Packit 0848f5
In other words, in the code
Packit 0848f5
Packit 0848f5
     MPI_Buffer_attach( buffer, size );
Packit 0848f5
     MPI_Bsend( ..., count=20, datatype=type1,  ... );
Packit 0848f5
     ...
Packit 0848f5
     MPI_Bsend( ..., count=40, datatype=type2, ... );
Packit 0848f5
Packit 0848f5
Packit 0848f5
the value of <tt>size</tt> in the <tt>MPI_Buffer_attach</tt> call should be greater than
Packit 0848f5
the value computed by
Packit 0848f5
Packit 0848f5
     MPI_Pack_size( 20, type1, comm, &s1 );
Packit 0848f5
     MPI_Pack_size( 40, type2, comm, &s2 );
Packit 0848f5
     size = s1 + s2 + 2 * MPI_BSEND_OVERHEAD;
Packit 0848f5
Packit 0848f5
Packit 0848f5
The <tt>MPI_BSEND_OVERHEAD</tt> gives the maximum amount of space that may be used in
Packit 0848f5
the buffer for use by the BSEND routines in using the buffer.  This value
Packit 0848f5
is in <tt>mpi.h</tt> (for C) and <tt>mpif.h</tt> (for Fortran).
Packit 0848f5

Packit 0848f5

Thread and Interrupt Safety

Packit 0848f5

Packit 0848f5
The user is responsible for ensuring that multiple threads do not try to
Packit 0848f5
update the same MPI object from different threads.  This routine should
Packit 0848f5
not be used from within a signal handler.
Packit 0848f5

Packit 0848f5
The MPI standard defined a thread-safe interface but this does not
Packit 0848f5
mean that all routines may be called without any thread locks.  For
Packit 0848f5
example, two threads must not attempt to change the contents of the
Packit 0848f5
same <tt>MPI_Info</tt> object concurrently.  The user is responsible in this
Packit 0848f5
case for using some mechanism, such as thread locks, to ensure that
Packit 0848f5
only one thread at a time makes use of this routine.
Packit 0848f5
Because the buffer for buffered sends (e.g., <tt>MPI_Bsend</tt>) is shared by all
Packit 0848f5
threads in a process, the user is responsible for ensuring that only
Packit 0848f5
one thread at a time calls this routine or <tt>MPI_Buffer_detach</tt>.
Packit 0848f5

Packit 0848f5

Notes for Fortran

Packit 0848f5
All MPI routines in Fortran (except for <tt>MPI_WTIME</tt> and <tt>MPI_WTICK</tt>) have
Packit 0848f5
an additional argument <tt>ierr</tt> at the end of the argument list.  <tt>ierr
Packit 0848f5
</tt>is an integer and has the same meaning as the return value of the routine
Packit 0848f5
in C.  In Fortran, MPI routines are subroutines, and are invoked with the
Packit 0848f5
<tt>call</tt> statement.
Packit 0848f5

Packit 0848f5
All MPI objects (e.g., <tt>MPI_Datatype</tt>, <tt>MPI_Comm</tt>) are of type <tt>INTEGER
Packit 0848f5
</tt>in Fortran.
Packit 0848f5

Packit 0848f5

Errors

Packit 0848f5

Packit 0848f5
All MPI routines (except <tt>MPI_Wtime</tt> and <tt>MPI_Wtick</tt>) return an error value;
Packit 0848f5
C routines as the value of the function and Fortran routines in the last
Packit 0848f5
argument.  Before the value is returned, the current MPI error handler is
Packit 0848f5
called.  By default, this error handler aborts the MPI job.  The error handler
Packit 0848f5
may be changed with <tt>MPI_Comm_set_errhandler</tt> (for communicators),
Packit 0848f5
<tt>MPI_File_set_errhandler</tt> (for files), and <tt>MPI_Win_set_errhandler</tt> (for
Packit 0848f5
RMA windows).  The MPI-1 routine <tt>MPI_Errhandler_set</tt> may be used but
Packit 0848f5
its use is deprecated.  The predefined error handler
Packit 0848f5
<tt>MPI_ERRORS_RETURN</tt> may be used to cause error values to be returned.
Packit 0848f5
Note that MPI does not guarentee that an MPI program can continue past
Packit 0848f5
an error; however, MPI implementations will attempt to continue whenever
Packit 0848f5
possible.
Packit 0848f5

Packit 0848f5
MPI_SUCCESS
No error; MPI routine completed successfully.
Packit 0848f5
Packit 0848f5
MPI_ERR_BUFFER
Invalid buffer pointer. Usually a null buffer where
Packit 0848f5
one is not valid.
Packit 0848f5
Packit 0848f5
MPI_ERR_INTERN
An internal error has been detected. This is fatal.
Packit 0848f5
Please send a bug report to <tt>mpi-bugs@mcs.anl.gov</tt>.
Packit 0848f5
Packit 0848f5

Packit 0848f5
<H0>See Also</H0>
Packit 0848f5
 MPI_Buffer_detach, MPI_Bsend
Packit 0848f5

Packit 0848f5
</BODY></HTML>