MPI_Gatherv_init(3)

πŸ’– MPI_Gatherv_init β€” it's giving persistent request ✨

okay bestie, welcome to the MPI manual page for MPI_Gatherv_init(3), and let me just say β€” this one is lowkey a bop. πŸŽ€


🌸 NAME 🌸

MPI_Gatherv_init β€” bestie, this is literally create a persistent request for gatherv. That's it, that's the vibe. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

int MPI_Gatherv_init(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, const int recvcounts[], const int displs[],
MPI_Datatype recvtype, int root, MPI_Comm comm,
MPI_Info info, MPI_Request *request)

int MPI_Gatherv_init_c(const void *sendbuf, MPI_Count sendcount,
MPI_Datatype sendtype, void *recvbuf,
const MPI_Count recvcounts[], const MPI_Aint displs[],
MPI_Datatype recvtype, int root, MPI_Comm comm,
MPI_Info info, MPI_Request *request)

yes there are two of them, the classic one and the _c one with the big boi MPI_Count / MPI_Aint types. both iconic, no cap. ✨


πŸŽ€ INPUT PARAMETERS πŸŽ€

the stuff you gotta hand over, periodt:

  • sendbuf β€” starting address of send buffer (choice). where your lil data lives, bestie 🫢
  • sendcount β€” number of elements in send buffer (non-negative integer). no negatives, that's the rule 😀
  • sendtype β€” data type of send buffer elements (handle)
  • recvcounts β€” non-negative integer array (of length group size) containing the number of elements that are received from each process (non-negative integer). one count per bestie in the group πŸ’–
  • displs β€” integer array (of length group size). Entry i specifies the displacement relative to recvbuf at which to place the incoming data from process i (integer). literally the map of where everybody's stuff goes πŸ—ΊοΈ
  • recvtype β€” data type of recv buffer elements (handle)
  • root β€” rank of receiving process (integer). the main character, obviously πŸ‘‘
  • comm β€” communicator (handle)
  • info β€” info argument (handle)

πŸ’œ OUTPUT PARAMETERS πŸ’œ

what this function hands back to you:

  • recvbuf β€” address of receive buffer (choice)
  • request β€” communication request (handle). your persistent request, your legacy, your little guy ✨

πŸ”₯ THREAD AND INTERRUPT SAFETY πŸ”₯

okay so the tea: this routine is thread-safe. 🧚 Which means you can vibe with it from multiple threads and you do not need any user-provided thread locks. no lock drama, we love that for us.

However β€” and this is the "not me getting humbled" part β€” the routine is not interrupt safe. 😭 Typically this is 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. boundary check yourself accordingly πŸ’…


🌈 NOTES FOR FORTRAN 🌈

  • All MPI routines in Fortran (except for MPI_WTIME and MPI_WTICK) have an additional argument ierr at the end of the argument list. ierr is an integer and has the same meaning as the return value of the routine in C. In Fortran, MPI routines are subroutines, and are invoked with the call statement. so like, extra arg, same energy 🫢
  • All MPI objects (e.g., MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. slay, consistent typing ✨

πŸ’€ ERRORS πŸ’€

okay listen, this part matters. 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 the last argument. Before the value is returned, the current MPI error handler is called. By default, this error handler aborts the MPI job. 😱 (yes fr, it just ends everything, no cap.)

The error handler may be changed 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, it's giving legacy, do not. πŸ™ˆ The predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned. 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 whole error roster, no skips:

  • MPI_SUCCESS β€” No error; MPI routine completed successfully. we love a clean win πŸ’–
  • 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). 😭 not even allowed bestie, they said no.
  • 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_TYPE β€” Invalid datatype argument. Additionally, this error can occur if an uncommitted MPI_Datatype (see MPI_Type_commit) is used in a communication call. commit your types, bestie, it's the bare minimum πŸ’…
  • MPI_ERR_OTHER β€” Other error; use MPI_Error_string to get more information about this error code.

πŸ’Œ reminder: thread-safe but not interrupt safe. and the default error handler will absolutely abort your whole job. protect your peace and your error handlers. 🫢

that's the whole page, bestie β€” this one came from the MPI manual, dated 4/10/2026. go forth and gather (persistently). you ate. periodt. πŸ‘‘πŸ’–βœ¨

πŸ“¦ where this page comes from