1MPI_Bsend(3)                        LAM/MPI                       MPI_Bsend(3)
2
3
4

NAME

6       MPI_Bsend -  Basic send with user-specified buffering
7

SYNOPSIS

9       #include <mpi.h>
10       int MPI_Bsend(void *buf, int count, MPI_Datatype dtype,
11                     int dest, int tag, MPI_Comm comm)
12

INPUT PARAMETERS

14       buf    - initial address of send buffer (choice)
15       count  - number of elements in send buffer (nonnegative integer)
16       dtype  - datatype of each send buffer element (handle)
17       dest   - rank of destination (integer)
18       tag    - message tag (integer)
19       comm   - communicator (handle)
20
21

NOTES

23       This  send is provided as a convenience function; it allows the user to
24       send messages without worring about where they  are  buffered  (because
25       the user must have provided buffer space with MPI_Buffer_attach ).
26
27       In deciding how much buffer space to allocate, remember that the buffer
28       space is not available for reuse by subsequent MPI_Bsend s  unless  you
29       are certain that the message has been received (not just that it should
30       have been received).  For example, this code does not  allocate  enough
31       buffer space
32
33       MPI_Buffer_attach(b, n*sizeof(double) + MPI_BSEND_OVERHEAD);
34       for (i = 0; i < m; i++) {
35       MPI_Bsend(buf, n, MPI_DOUBLE, ...);
36       }
37
38       because only enough buffer space is provided for a single send, and the
39       loop may start a second MPI_Bsend before the first is done  making  use
40       of the buffer.
41
42       In C, you can force the messages to be delivered by
43       MPI_Buffer_detach(&b, &n);
44       MPI_Buffer_attach(b, n);
45
46       (The  MPI_Buffer_detach  will  not complete until all buffered messages
47       are delivered.)
48
49       It is generally a bad idea to use the MPI_Bsend function, as it guaran‐
50       tees  that the entire message will suffer the overhead of an additional
51       memory copy.  For large messages, or when shared memory message  trans‐
52       ports are being used, this overhead can be quite expensive.
53
54

NOTES FOR FORTRAN

56       All  MPI routines in Fortran (except for MPI_WTIME and MPI_WTICK ) have
57       an additional argument ierr at the end of the argument list.   ierr  is
58       an  integer and has the same meaning as the return value of the routine
59       in C.  In Fortran, MPI routines are subroutines, and are  invoked  with
60       the call statement.
61
62       All MPI objects (e.g., MPI_Datatype , MPI_Comm ) are of type INTEGER in
63       Fortran.
64
65

ERRORS

67       If an error occurs in an MPI function, the current MPI error handler is
68       called  to  handle  it.   By default, this error handler aborts the MPI
69       job.  The error handler may be changed with  MPI_Errhandler_set  ;  the
70       predefined  error  handler MPI_ERRORS_RETURN may be used to cause error
71       values to be returned (in C and Fortran; this  error  handler  is  less
72       useful  in  with  the  C++  MPI bindings.  The predefined error handler
73       MPI::ERRORS_THROW_EXCEPTIONS should be used in C++ if the  error  value
74       needs  to  be recovered).  Note that MPI does not guarantee that an MPI
75       program can continue past an error.
76
77       All MPI routines (except MPI_Wtime and  MPI_Wtick  )  return  an  error
78       value;  C routines as the value of the function and Fortran routines in
79       the last argument.  The C++ bindings for MPI do not return  error  val‐
80       ues;  instead,  error values are communicated by throwing exceptions of
81       type MPI::Exception (but not by default).  Exceptions are  only  thrown
82       if the error value is not MPI::SUCCESS .
83
84
85       Note  that  if  the MPI::ERRORS_RETURN handler is set in C++, while MPI
86       functions will return upon an error, there will be no  way  to  recover
87       what the actual error value was.
88       MPI_SUCCESS
89              - No error; MPI routine completed successfully.
90       MPI_ERR_COMM
91              -  Invalid communicator.  A common error is to use a null commu‐
92              nicator in a call (not even allowed in MPI_Comm_rank ).
93       MPI_ERR_COUNT
94              - Invalid count argument.  Count arguments must be non-negative;
95              a count of zero is often valid.
96       MPI_ERR_TYPE
97              - Invalid datatype argument.  May be an uncommitted MPI_Datatype
98              (see MPI_Type_commit ).
99       MPI_ERR_RANK
100              - Invalid source or destination rank.   Ranks  must  be  between
101              zero  and  the  size  of  the communicator minus one; ranks in a
102              receive ( MPI_Recv , MPI_Irecv , MPI_Sendrecv , etc.)  may  also
103              be MPI_ANY_SOURCE .
104
105       MPI_ERR_TAG
106              -  Invalid  tag  argument.  Tags must be non-negative; tags in a
107              receive ( MPI_Recv , MPI_Irecv , MPI_Sendrecv , etc.)  may  also
108              be MPI_ANY_TAG .  The largest tag value is available through the
109              the attribute MPI_TAG_UB .
110
111
112

SEE ALSO

114       MPI_Buffer_attach, MPI_Buffer_detach, MPI_Ibsend, MPI_Bsend_init
115
116

MORE INFORMATION

118       For more information, please see the official MPI Forum web site, which
119       contains  the  text of both the MPI-1 and MPI-2 standards.  These docu‐
120       ments contain detailed information about each  MPI  function  (most  of
121       which is not duplicated in these man pages).
122
123       http://www.mpi-forum.org/
124
125
126

ACKNOWLEDGEMENTS

128       The  LAM Team would like the thank the MPICH Team for the handy program
129       to generate man pages  ("doctext"  from  ftp://ftp.mcs.anl.gov/pub/sow‐
130       ing/sowing.tar.gz  ), the initial formatting, and some initial text for
131       most of the MPI-1 man pages.
132

LOCATION

134       bsend.c
135
136
137
138LAM/MPI 7.1.2                      2/23/2006                      MPI_Bsend(3)
Impressum