MPI_Allgatherv(3)
π MPI_Allgatherv β the gossip ring but make it data π
okay so bestie, welcome to the MPI_Allgatherv(3) page from the MPI manual. this is the one where literally everybody in the group chat gets everything. no secrets, no crumbs, all tea shared with the whole squad β¨
β¨ NAME β¨
MPI_Allgatherv β gathers data from all tasks and delivers the combined data to all tasks π«Ά
like... everyone sends, everyone receives. it's giving "no private messages, only the group chat" energy. periodt.
π SYNOPSIS π
int MPI_Allgatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, const int recvcounts[], const int displs[],
MPI_Datatype recvtype, MPI_Comm comm)
int MPI_Allgatherv_c(const void *sendbuf, MPI_Count sendcount,
MPI_Datatype sendtype, void *recvbuf,
const MPI_Count recvcounts[], const MPI_Aint displs[],
MPI_Datatype recvtype, MPI_Comm comm)
yes bestie there's a _c version too, for when your counts are big big. she's the same girl, just with MPI_Count and MPI_Aint instead π
πΈ INPUT PARAMETERS πΈ
sendbufβ starting address of send buffer (choice). where your lil contribution lives πsendcountβ number of elements in send buffer (non-negative integer). how many things you're handing out, and no, it can't be negative, that's not a vibe πsendtypeβ data type of send buffer elements (handle). what kind of little guys you're sending πrecvcountsβ non-negative integer array (of length group size) containing the number of elements that are received from each process (non-negative integer). so like, one number per bestie telling you how much they're bringing to the function π§displsβ integer array (of length group size). Entry i specifies the displacement (relative torecvbuf) at which to place the incoming data from process i (integer). basically the seat assignment. entry i = where process i's data gets to sit β¨recvtypeβ data type of receive buffer elements (handle). the type of the lil guys coming IN πcommβ communicator (handle). the group chat itself, the whole squad π«Ά
π OUTPUT PARAMETERS π
recvbufβ address of receive buffer (choice). where all the collected tea gets poured π
π NOTES π
okay so this part is messy and we need to talk about it.
the MPI standard (1.0 and 1.1) says that:
The jth block of data sent from each process is received by every process and placed in the jth block of the buffer recvbuf .
...and like, that's misleading, fr fr. the better description is:
The block of data sent from the jth process is received by every process and placed in the jth block of the buffer recvbuf .
see the difference? it's the jth process, not the jth block. huge. iconic correction. the way that one word changes everything π
this text was suggested by Rajeev Thakur, and has been adopted as a clarification to the MPI standard by the MPI-Forum. shoutout Rajeev, you ate π
π§΅ THREAD AND INTERRUPT SAFETY π§΅
this routine is thread-safe β¨ which means you can safely use it from multiple threads, no user-provided thread locks required, she handles herself π
BUT. and this is a big but bestie β the routine is not interrupt safe π typically this is due to the use of memory allocation routines such as malloc or other non-MPICH runtime routines that are themselves not interrupt-safe. so like, don't interrupt her mid-glow-up, she's not built for that π
π 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 Fortran besties get one extra lil guy at the end π«Ά - All MPI objects (e.g.,
MPI_Datatype,MPI_Comm) are of typeINTEGERin Fortran. no fancy handle types over there, just plain ol'INTEGERβ¨
π 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 the value is returned, the current MPI error handler is called. By default, this error handler aborts the MPI job π so yeah. dramatic. 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, she's old news, don't text her back.
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. she'll try her best, but no promises π
here's the error code roster:
MPI_SUCCESSβ No error; MPI routine completed successfully. ate and left no crumbs βMPI_ERR_BUFFERβ Invalid buffer pointer. Usually a null buffer where one is not valid. you showed up empty-handed bestie πMPI_ERR_COMMβ Invalid communicator. A common error is to use a null communicator in a call (not even allowed inMPI_Comm_rank). the group chat doesn't exist πMPI_ERR_COUNTβ Invalid count argument. Count arguments must be non-negative; a count of zero is often valid. zero is fine, negative is NOT πMPI_ERR_TYPEβ Invalid datatype argument. Additionally, this error can occur if an uncommittedMPI_Datatype(seeMPI_Type_commit) is used in a communication call. she's not ready yet, let her commit first πMPI_ERR_OTHERβ Other error; useMPI_Error_stringto get more information about this error code. the mystery box, go askMPI_Error_stringπΈ
reminder bestie: hitting an error by default aborts the whole job. if you want the errors returned instead of the whole thing going down, set MPI_ERRORS_RETURN. protect your peace π«Ά
and that's the page!! this was MPI_Allgatherv(3) from the MPI manual, dated 4/10/2026, last updated before I stole her and gave her a personality π
β¨
stay gathered, stay v'd, and remember: everybody gets everybody's tea. that's the whole point. ππ¦πΈ
π¦ 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