MPI_Send_init(3)

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

πŸ’– MPI_Send_init(3) πŸ’–

okay bestie, gather round, because this is a page from the MPI manual (yes, that MPI, the message-passing one, section 3, the library-call zone) and it is iconic. no cap. let's get into it. πŸ¦‹


✨ NAME ✨

MPI_Send_init β€” makes you a persistent request for a standard send. like, you're setting up the whole send ahead of time and holding onto the lil ticket so you can fire it off again and again later. main character energy fr. πŸ’…


✨ SYNOPSIS ✨

int MPI_Send_init(const void *buf, int count, MPI_Datatype datatype, int dest,
       int tag, MPI_Comm comm, MPI_Request *request)

and the big-girl version with MPI_Count:

int MPI_Send_init_c(const void *buf, MPI_Count count, MPI_Datatype datatype,
       int dest, int tag, MPI_Comm comm, MPI_Request *request)

✨ INPUT PARAMETERS ✨

  • buf β€” the initial address of the send buffer (it's a choice, so pick your fave). πŸ“¬
  • count β€” how many elements you're sending (a non-negative integer, no negative vibes allowed, that's literally not a thing).
  • datatype β€” the type of each element (a handle).
  • dest β€” rank of destination (an integer). that's where the message is goingggg.
  • tag β€” message tag (an integer). cute lil label so the receiver knows what's up.
  • comm β€” communicator (a handle).

✨ OUTPUT PARAMETERS ✨

  • request β€” the communication request (a handle). hold onto this bestie, it's your ticket. 🎟️

✨ THREAD AND INTERRUPT SAFETY ✨

good news: this routine is thread-safe. meaning multiple threads can call it and you do not need to bring your own user-provided thread locks. slay. 🧚

but bestie, it is not interrupt safe. and the reason is typically that it uses memory allocation routines like malloc or other non-MPICH runtime routines that are themselves not interrupt-safe. so like… mind the gap. πŸ’€

✨ NOTES FOR FORTRAN ✨

every MPI routine in Fortran (except for MPI_WTIME and MPI_WTICK, the lil exceptions, we love them) gets an extra argument called 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 important: in Fortran, MPI routines are subroutines, and you invoke them with the call statement. periodt.

and every MPI object (like MPI_Datatype, MPI_Comm) is of type INTEGER in Fortran. yes literally all of them. okay?? πŸŽ€


✨ ERRORS ✨

so here's the deal: all MPI routines (except MPI_Wtime and MPI_Wtick, our two little rebels) return an error value. C routines hand it back as the value of the function, and Fortran routines put it in that last argument. before the value comes back to you, the current MPI error handler gets called. and by default? that error handler aborts the MPI job. 😭 so yeah, dramatic.

you can switch the handler with:

  • MPI_Comm_set_errhandler (for communicators)
  • MPI_File_set_errhandler (for files)
  • MPI_Win_set_errhandler (for RMA windows)

the MPI-1 routine MPI_Errhandler_set may be used, but heads up, its use is deprecated. πŸ™ˆ

there's also a predefined error handler called MPI_ERRORS_RETURN you can use to make error values get returned to you instead. handy.

ngl, MPI does not guarantee that an MPI program can continue past an error. that said, MPI implementations will attempt to continue whenever possible. so… shrug, they try their best. 🫢

here's the error code lineup:

  • MPI_SUCCESS β€” no error, the routine completed successfully. we ate. πŸ‘‘
  • MPI_ERR_ARG β€” invalid argument. some argument is invalid and isn't 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. not the move.
  • MPI_ERR_COMM β€” invalid communicator. a super common one is using a null communicator in a call (which is 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. zero is fine, negative is not.
  • 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. commit your types bestie!!
  • MPI_ERR_OTHER β€” other error; use MPI_Error_string to get more information about this error code. the catch-all. 🌈

✨ SEE ALSO ✨

  • MPI_Start
  • MPI_Startall
  • MPI_Request_free

go read those next, they're the sequel. πŸ”₯


and that's the page!! this was the MPI manual, and the footer says this one's dated 4/10/2026. mwah, thanks for reading, bestie, go set up some persistent sends and absolutely slay πŸ’–βœ¨πŸŒΈ

πŸ“¦ where this page comes from