MPI_Precv_init(3)
π MPI_Precv_init β okay bestie, let's build a partitioned receive request π
so this page lives in the MPI manual, section 3, and it's literally the glow-up of receive requests: MPI_Precv_init β¨
πΈ NAME πΈ
MPI_Precv_init β creates a partitioned communication receive request π«Ά
like, it's giving "I'm setting up a receive, but in partitions, and I'm doing it ahead of time." main character energy fr fr.
β¨ SYNOPSIS β¨
int MPI_Precv_init(void *buf, int partitions, MPI_Count count,
MPI_Datatype datatype, int dest, int tag, MPI_Comm comm,
MPI_Info info, MPI_Request *request)
π INPUT PARAMETERS π
bufβ the initial address of the recv buffer (choice). yes, choice, it says so, as in "it's a choice type in the MPI language bindings" πpartitionsβ number of partitions (non-negative integer). split it up, diva πcountβ number of elements send per partition (non-negative integer). yep it really says "send" there, we're quoting the manpage verbatim, don't come for me πdatatypeβ type of each element (handle)destβ rank of destination (integer)tagβ message tag (integer)commβ communicator (handle)infoβ info argument (handle)
π¦ OUTPUT PARAMETERS π¦
requestβ communication request (handle) π«Ά she's born, she's yours now
π§ THREAD AND INTERRUPT SAFETY π§
okay so the good news first: this routine is thread-safe π that means multiple threads can use it at the same time, no user-provided thread locks needed, no gatekeeping, we love that for us.
butβ¦ it is not interrupt safe π and 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 her mid-glow-up, she's busy.
π NOTES FOR FORTRAN π
every MPI routine in Fortran (except for MPI_WTIME and MPI_WTICK) has an extra argument ierr chillin' at the end of the argument list. ierr is an integer and 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. periodt.
also, all MPI objects (like MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. noted, bestie π
π ERRORS π
so, all MPI routines (except MPI_Wtime and MPI_Wtick) return an error value: C routines as the value of the function, Fortran routines in the last argument. before that value comes back, the current MPI error handler gets called. by default, that error handler aborts the MPI job π brutal but iconic.
you can swap the error handler 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 β like, it works, but it's giving 1994, don't.
the predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned. and heads up: MPI does not guarantee that an MPI program can continue past an error; however, MPI implementations will attempt to continue whenever possible. so like. maybe? no promises π
MPI_SUCCESSβ No error; MPI routine completed successfully. slay π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_COMMβ Invalid communicator. A common error is to use a null communicator in a call (not even allowed inMPI_Comm_rank). literally not even allowed, bestie πMPI_ERR_COUNTβ Invalid count argument. Count arguments must be non-negative; a count of zero is often valid.MPI_ERR_INFOβ Invalid InfoMPI_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 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.MPI_ERR_OTHERβ Other error; useMPI_Error_stringto get more information about this error code.
pro tip from the manpage itself: MPI_Parrived, MPI_Request_free are your next reads π
π SEE ALSO π
MPI_ParrivedMPI_Request_free
and that's the whole page bestie, no cap, every single line preserved π
this page is from the MPI manual, MPI_Precv_init(3), and it was dated 4/10/2026 β so go forth, partition responsibly, and remember: the vibes are immaculate but the facts are untouched π¦β¨
π¦ 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