MPI_Imrecv(3)
π 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_WTIMEandMPI_WTICK) has an extra argumentierrtacked onto the end of the argument list. ierris 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
callstatement. - all MPI objects (e.g.
MPI_Datatype,MPI_Comm) are of typeINTEGERin 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β invalidMPI_Request. either null, or, in the case of anMPI_StartorMPI_Startall, not a persistent request.MPI_ERR_TYPEβ invalid datatype argument. additionally, this error can occur if an uncommittedMPI_Datatype(seeMPI_Type_commit) is used in a communication call.MPI_ERR_OTHERβ other error; useMPI_Error_stringto 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
- 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