MPI_Bsend_init(3)

πŸ“¦
version 5.0.1 Β· 5 versions
, in nixos 26.05, ubuntu stonking

πŸ’… 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 this
  • tag β€” 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 in MPI_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 be MPI_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 be MPI_ANY_TAG. the largest tag value is available through the attribute MPI_TAG_UB.
  • MPI_ERR_TYPE β€” invalid datatype argument. additionally, this error can occur if an uncommitted MPI_Datatype (see MPI_Type_commit) is used in a communication call.
  • MPI_ERR_OTHER β€” other error; use MPI_Error_string to 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