MPI_Imrecv(3)

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

πŸ’Œ MPI_Imrecv β€” bestie's guide (from the MPI manual, section 3)

okay so listen. you know how MPI_Mprobe and MPI_Improbe hand you a whole entire message without actually taking the data yet? yeah. this is the other half of that situationship. 🫢

MPI_Imrecv is a nonblocking receive of a message matched by MPI_Mprobe or MPI_Improbe. that's it. that's the whole vibe. no cap.


✨ NAME ✨

MPI_Imrecv β€” nonblocking receive of message matched by MPI_Mprobe or MPI_Improbe.


🌸 SYNOPSIS 🌸

int MPI_Imrecv(void *buf, int count, MPI_Datatype datatype,
MPI_Message *message, MPI_Request *request)

int MPI_Imrecv_c(void *buf, MPI_Count count, MPI_Datatype datatype,
MPI_Message *message, MPI_Request *request)

two flavors, bestie β€” the regular one and the _c one that takes an MPI_Count instead of a plain int. pick your fighter. πŸ’…


πŸŽ€ INPUT PARAMETERS πŸŽ€

  • count β€” number of elements in the receive buffer. it's a non-negative integer, so like… zero is fine, negative is not the move. πŸ™ˆ
  • datatype β€” datatype of each receive buffer element (handle).

πŸ¦‹ INPUT/OUTPUT PARAMETERS πŸ¦‹

  • message β€” message (handle). it goes in, and it comes back out, because it's an in/out kinda girlie. ✨

🌈 OUTPUT PARAMETERS 🌈

  • buf β€” initial address of receive buffer (choice).
  • request β€” communication request (handle). this is your lil ticket, hold onto it. πŸ‘‘

πŸ’€ THREAD AND INTERRUPT SAFETY πŸ’€

This routine is thread-safe. that means you can let multiple threads hit it at the same time with zero user-provided thread locks, no chaos, no drama. slay.

however β€” and this is the important part β€” 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, don't interrupt it mid-glow-up. it's giving fragile.


🧚 NOTES FOR FORTRAN 🧚

so for all my Fortran besties:

  • every 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 the exact 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.
  • all MPI objects (e.g. MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. yes really. iconic of them honestly.

😭 ERRORS 😭

okay so the whole error situation, fr fr:

All MPI routines (except MPI_Wtime and MPI_Wtick) return an error value β€” C routines as the value of the function, and Fortran routines in that last argument. Before the value is returned, the current MPI error handler is called. By default, this error handler aborts the MPI job. yeah. it just kills the whole thing. no warning shot. πŸ’€

The error handler may be changed 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 its use is deprecated. don't. just don't.

The predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned (instead of the whole job getting nuked).

Note that MPI does not guarantee that an MPI program can continue past an error; however, MPI implementations will attempt to continue whenever possible. 🫢

here's the error roster:

  • MPI_SUCCESS β€” no error; MPI routine completed successfully. the dream. ✨
  • MPI_ERR_ARG β€” invalid argument. some argument is invalid and is 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_COUNT β€” invalid count argument. count arguments must be non-negative; a count of zero is often valid.
  • MPI_ERR_REQUEST β€” invalid MPI_Request. either null, or, in the case of an MPI_Start or MPI_Startall, not a persistent request.
  • 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.

that's the whole page, bestie. go forth and nonblocking-receive your little heart out. πŸ’–

this has been your girl, coming to you from the MPI manual β€” 4/10/2026, MPI_Imrecv(3) era. mwah. πŸ’…βœ¨

πŸ“¦ where this page comes from