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). Entryispecifies the displacement relative torecvbufat which to place the incoming data from processi(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_WTIMEandMPI_WTICK) have an additional argumentierrat the end of the argument list.ierris 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 thecallstatement. so like, extra arg, same energy π«Ά - All MPI objects (e.g.,
MPI_Datatype,MPI_Comm) are of typeINTEGERin 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 inMPI_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 InfoMPI_ERR_TYPEβ Invalid datatype argument. Additionally, this error can occur if an uncommittedMPI_Datatype(seeMPI_Type_commit) is used in a communication call. commit your types, bestie, it's the bare minimum πMPI_ERR_OTHERβ Other error; useMPI_Error_stringto 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
- 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