MPI_Bsend_init(3)
π MPI_Bsend_init β bestie edition
okay so this is the MPI_Bsend_init(3) page, straight out of the MPI manual, section 3 π it's a C function that builds a handle for a buffered send, and no cap, it's lowkey iconic once you get what it's for.
β¨ NAME β¨
MPI_Bsend_init β Builds a handle for a buffered send π
β¨ SYNOPSIS β¨
int MPI_Bsend_init(const void *buf, int count, MPI_Datatype datatype, int dest,
int tag, MPI_Comm comm, MPI_Request *request)
int MPI_Bsend_init_c(const void *buf, MPI_Count count, MPI_Datatype datatype,
int dest, int tag, MPI_Comm comm, MPI_Request *request)
see how there's two of them? the _c one is literally the same vibe but with a MPI_Count count instead of an int count π«Ά
β¨ INPUT PARAMETERS β¨
bufβ the initial address of your send buffer (a choice). this is where your goodies live β¨countβ how many elements you're sending (non-negative integer, bestie, no negatives π)datatypeβ the type of each element (handle)destβ rank of the destination (integer) β like, who's receiving thistagβ the message tag (integer) π·οΈcommβ the communicator (handle)
β¨ OUTPUT PARAMETERS β¨
requestβ communication request (handle). this is the whole point of the function, the little handle you'll hold onto π
β¨ THREAD AND INTERRUPT SAFETY β¨
good news first: this routine is thread-safe π₯ meaning you can safely use it from multiple threads and you do not need your own user-provided thread locks. slay.
BUT. and this is a big but π β the routine is not interrupt safe. typically this is because of memory allocation routines like malloc or other non-MPICH runtime routines that are themselves not interrupt-safe. so like, keep that in mind, okay?
β¨ NOTES FOR FORTRAN β¨
so every single MPI routine in Fortran β except MPI_WTIME and MPI_WTICK β has an extra argument ierr tacked onto the end of the argument list. ierr is an integer and it means exactly the same thing as the return value of the routine in C.
also, in Fortran, MPI routines are subroutines, and you invoke them with the call statement.
and all MPI objects (like, say, MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. that's just how it is π
β¨ ERRORS β¨
every MPI routine (except MPI_Wtime and MPI_Wtick, those two are the rebels π) returns an error value β C routines as the value of the function, Fortran routines in that last argument. before the value comes back to you, the current MPI error handler gets called.
by default, that error handler aborts the MPI job. like, full stop, everyone out π
you can swap the error handler with MPI_Comm_set_errhandler (for communicators), MPI_File_set_errhandler (for files), and MPI_Win_set_errhandler (for RMA windows). the MPI-1 routine MPI_Errhandler_set may be used but its use is deprecated (so maybe don't, bestie).
you can also use the predefined error handler MPI_ERRORS_RETURN to make error values actually get returned instead.
note: MPI does not guarantee that an MPI program can continue past an error. however, MPI implementations will attempt to continue whenever possible. so it's giving "we'll try" not "we promise" π
here's the full error roster:
MPI_SUCCESSβ no error; the MPI routine completed successfully πMPI_ERR_ARGβ invalid argument. some argument is invalid and it's not identified by a specific error class (e.g.MPI_ERR_RANK).MPI_ERR_BUFFERβ invalid buffer pointer. usually a null buffer where one is not valid.MPI_ERR_COMMβ invalid communicator. a common error is using a null communicator in a call (not even allowed inMPI_Comm_rank).MPI_ERR_COUNTβ invalid count argument. count arguments must be non-negative; a count of zero is often valid.MPI_ERR_RANKβ invalid source or destination rank. ranks must be between zero and the size of the communicator minus one; ranks in a receive (MPI_Recv,MPI_Irecv,MPI_Sendrecv, etc.) may also beMPI_ANY_SOURCE.MPI_ERR_TAGβ invalid tag argument. tags must be non-negative; tags in a receive (MPI_Recv,MPI_Irecv,MPI_Sendrecv, etc.) may also beMPI_ANY_TAG. the largest tag value is available through the attributeMPI_TAG_UB.MPI_ERR_TYPEβ invalid datatype argument. additionally, this error can occur if an uncommittedMPI_Datatype(seeMPI_Type_commit) is used in a communication call.MPI_ERR_OTHERβ other error; useMPI_Error_stringto get more information about this error code.
β¨ SEE ALSO β¨
MPI_Buffer_attachπΈ
that's the whole page, bestie, you ate it π this was MPI_Bsend_init(3), from the MPI manual, dated 4/10/2026. periodt π«Άβ¨
π¦ where this page comes from
- nixos 26.05: mpich 5.0.1
- ubuntu stonking: mpich-doc 5.0.1-9 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms