MPI_Send_init(3)
π 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 inMPI_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 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. commit your types bestie!!MPI_ERR_OTHERβ other error; useMPI_Error_stringto get more information about this error code. the catch-all. π
β¨ SEE ALSO β¨
MPI_StartMPI_StartallMPI_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
- 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