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 in MPI_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 Info
  • 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 the attribute MPI_TAG_UB.
  • 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.
pro tip from the manpage itself: MPI_Parrived, MPI_Request_free are your next reads πŸ‘‡

πŸ‘‘ SEE ALSO πŸ‘‘

  • MPI_Parrived
  • MPI_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