MPI_Gatherv(3)
π MPI_Gatherv π
ok so this is the manual page for MPI_Gatherv, from section 3 of the MPI manual. bestie, this one is the glow-up version of gather: it gathers into specified locations from all processes in a group β¨
π SYNOPSIS π
int MPI_Gatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, const int recvcounts[], const int displs[],
MPI_Datatype recvtype, int root, MPI_Comm comm)
int MPI_Gatherv_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)
like. two whole flavors. the regular one and the _c one with the big boi counts. both iconic, no cap π
π INPUT PARAMETERS π
sendbufβ the starting address of the send buffer (choice)sendcountβ how many elements are chillin' in the send buffer (non-negative integer)sendtypeβ the data type of the send buffer elements (handle)recvcountsβ a non-negative integer array (length = group size) holding the number of elements received from each process (non-negative integer). yes it's array-of-length-group-size, it's giving very thorough πdisplsβ integer array (length = group size). entry i says the displacement relative torecvbufwhere the incoming data from process i gets placed (integer)recvtypeβ the data type of the recv buffer elements (handle)rootβ the rank of the receiving process (integer). main character of this whole operation frcommβ communicator (handle)
π¦ OUTPUT PARAMETERS π¦
recvbufβ address of receive buffer (choice)
π₯ THREAD AND INTERRUPT SAFETY π₯
ok so good news first: this routine is thread-safe β¨ which means multiple threads can use it at the same time and you do not need to bring your own thread locks. she handles that herself.
but. however. she 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, threads yes, interrupts no. vibe check passed, interrupt check failed π
π NOTES FOR FORTRAN π
all MPI routines in Fortran (except for MPI_WTIME and MPI_WTICK) have an extra argument ierr tacked onto the end of the argument list. ierr is an integer and it means 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 πΈ
also, all MPI objects (e.g., MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. that's just how it is, periodt.
π ERRORS π
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 that value comes back, the current MPI error handler gets called. and by default, that error handler aborts the MPI job. yeah. the default is dramatic π
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 β so like, it exists, but don't. seriously.
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 π«Ά
MPI_SUCCESSβ no error; MPI routine completed successfully. the dream πMPI_ERR_BUFFERβ invalid buffer pointer. usually a null buffer where one is not valid.MPI_ERR_COMMβ invalid communicator. a common error is using a null communicator in a call (not even allowed inMPI_Comm_rank).MPI_ERR_COUNTβ invalid count argument. count arguments must be non-negative; a count of zero is often valid.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.
k bye bestie, go gather those buffers, you got this π
β¨ this was the MPI manual page for MPI_Gatherv, dated 4/10/2026, page MPI_Gatherv(3) in the corner like a lil signature. slay π
π¦ 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