MPI_Isendrecv(3)

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

πŸ’– NAME πŸ’–

MPI_Isendrecv β€” starts a nonblocking send and a receive, together, in one call. bestie it's giving "two errands, one trip" energy πŸ›οΈβœ¨


✨ SYNOPSIS ✨

int MPI_Isendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
       int dest, int sendtag, void *recvbuf, int recvcount,
       MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm,
       MPI_Request *request)

int MPI_Isendrecv_c(const void *sendbuf, MPI_Count sendcount,
       MPI_Datatype sendtype, int dest, int sendtag, void *recvbuf,
       MPI_Count recvcount, MPI_Datatype recvtype, int source,
       int recvtag, MPI_Comm comm, MPI_Request *request)

so yes there's a baby version and a big-girl version πŸ’… the _c one takes MPI_Count for the counts, everything else is the same vibe.

This page lives in the MPI manual, section 3 β€” iykyk 🫢


🌸 INPUT PARAMETERS 🌸

  • sendbuf β€” the initial address of the send buffer (a choice)
  • sendcount β€” how many elements are in the send buffer (non-negative integer, no negatives pls)
  • sendtype β€” the datatype of each element in the send buffer (a handle)
  • dest β€” rank of the destination (integer) β€” who's getting the goods πŸ“¬
  • sendtag β€” the send tag (integer)
  • recvcount β€” how many elements are in the receive buffer (non-negative integer)
  • recvtype β€” the datatype of each element in the receive buffer (a handle)
  • source β€” rank of the source, or MPI_ANY_SOURCE (integer) β€” not me accepting mail from literally anyone πŸ™ˆ
  • recvtag β€” the receive tag, or MPI_ANY_TAG (integer)
  • comm β€” the communicator (a handle)

πŸŽ€ OUTPUT PARAMETERS πŸŽ€

  • recvbuf β€” the initial address of the receive buffer (a choice)
  • request β€” the communication request (a handle) β€” hold onto this one, she's the main character for your later MPI_Wait/MPI_Test era πŸ‘‘

πŸ¦‹ THREAD AND INTERRUPT SAFETY πŸ¦‹

This routine is thread-safe. That means multiple threads can use it at the same time and you do not need to bring your own thread locks β€” she handles herself, no cap. πŸ’ͺ

However (and this is the plot twist 😭): the routine is not interrupt safe. Typically that's because of memory allocation routines like malloc, or other non-MPICH runtime routines, that are themselves not interrupt-safe. So like… thread-safe yes, interrupt-safe no. Different things, bestie, don't mix them up.


🧚 NOTES FOR FORTRAN 🧚

Every MPI routine in Fortran (except MPI_WTIME and MPI_WTICK) gets an extra argument called ierr tacked onto the very 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. In Fortran, MPI routines are subroutines, and you invoke them with the call statement. πŸ“ž

And all MPI objects (e.g., MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. that's just how Fortran rolls πŸ’œ


πŸ”₯ ERRORS πŸ”₯

All MPI routines (except MPI_Wtime and MPI_Wtick) return an error value β€” C routines hand it back as the value of the function, Fortran routines put it 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, whole thing, gone. πŸ’€

You can swap the error handler out 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 like, she's retired, respect the retirement. πŸ™ˆ

The predefined error handler MPI_ERRORS_RETURN may be used to make error values get returned instead. And heads up: MPI does not guarantee that an MPI program can continue past an error β€” though MPI implementations will attempt to continue whenever possible. Fingers crossed energy. 🀞

  • MPI_SUCCESS β€” no error, the routine completed successfully. slay. ✨
  • MPI_ERR_ARG β€” invalid argument. Something in there is invalid and it's not identified by a more specific error class (e.g., MPI_ERR_RANK).
  • MPI_ERR_BUFFER β€” invalid buffer pointer. Usually that's a null buffer where a null one is not valid. 🚫
  • MPI_ERR_COMM β€” invalid communicator. A super common one is passing a null communicator into a call β€” which isn't even allowed in MPI_Comm_rank.
  • MPI_ERR_COUNT β€” invalid count argument. Counts must be non-negative; a count of zero is often valid though, so don't panic about a 0.
  • 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. Also, this error can pop up if an uncommitted MPI_Datatype (see MPI_Type_commit) is used in a communication call. commit your types, girl 😀
  • MPI_ERR_OTHER β€” other error; use MPI_Error_string to get more info about this error code.

okay that's the whole page, you're so welcome 🫢 this was the MPI_Isendrecv(3) manual page from the MPI manual, dated 4/10/2026 β€” go forth and sendrecv nonblockingly, bestie, ily πŸ’–πŸŒΈβœ¨

πŸ“¦ where this page comes from