MPI_Allgather(3)
β¨ MPI_Allgather(3) β¨
okay bestie, welcome to the MPI girlies manual page for MPI_Allgather. sit down, grab a boba, we're doing collective communication π
πΈ NAME πΈ
MPI_Allgather β gather all the data from every task, then hand the combined lil pile back to every task. no cap, everybody gets everything. it's giving "no secrets in this friend group" π«Ά
β¨ SYNOPSIS β¨
int MPI_Allgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, int recvcount, MPI_Datatype recvtype,
MPI_Comm comm)
int MPI_Allgather_c(const void *sendbuf, MPI_Count sendcount,
MPI_Datatype sendtype, void *recvbuf, MPI_Count recvcount,
MPI_Datatype recvtype, MPI_Comm comm)
π INPUT PARAMETERS π
sendbufβ the starting address of your send buffer (choice). this is what you're offering to the group chat.sendcountβ how many elements are chillin' in the send buffer. must be a non-negative integer, so no negative vibes pls πsendtypeβ the data type of the send buffer elements (handle).recvcountβ how many elements you receive from any process (non-negative integer, bestie, keep it positive or zero).recvtypeβ the data type of the receive buffer elements (handle).commβ the communicator (handle). it's the group chat itself, iykyk.
π OUTPUT PARAMETERS π
recvbufβ address of the receive buffer (choice). this is where the whole squad's data lands π
π NOTES π
so the MPI standard (versions 1.0 and 1.1) says this:
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⦠it's misleading, bestie. a better way to say it 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? the first one makes it sound like every process sends the "jth block" β no ma'am. it's the block from the jth process. this clarification was suggested by Rajeev Thakur and the MPI Forum adopted it as an official clarification. we love a glow-up β¨
π§΅ THREAD AND INTERRUPT SAFETY π§΅
this routine is thread-safe. that means multiple threads can use it at the same time, no user-provided thread locks needed. slay π
however β and this is the important part β the routine is NOT interrupt safe. typically that's because it uses memory allocation routines like malloc, or other non-MPICH runtime routines that are themselves not interrupt-safe. so yeah, don't interrupt it, she's busy π
π¦ NOTES FOR FORTRAN π¦
every MPI routine in Fortran (except for MPI_WTIME and MPI_WTICK) has an extra argument called ierr glued 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 call them with the call statement. periodt.
also! all MPI objects (like MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. π
π ERRORS π
every MPI routine (except MPI_Wtime and MPI_Wtick) returns an error value β C routines return it as the function's value, and Fortran routines put it in that last argument. before the value comes back, the current MPI error handler gets called. by default, that error handler aborts the MPI job. like, end of story, everyone out the group chat. π
the error handler can be changed with:
MPI_Comm_set_errhandlerβ for communicatorsMPI_File_set_errhandlerβ for filesMPI_Win_set_errhandlerβ for RMA windows
the MPI-1 routine MPI_Errhandler_set may be used but its use is deprecated (we don't do that anymore bestie).
the predefined error handler MPI_ERRORS_RETURN may be used to make error values get returned instead. note that MPI does not guarantee an MPI program can keep going after an error; however, MPI implementations will attempt to continue whenever possible. optimistic queens π
here's the error list:
MPI_SUCCESSβ no error; the MPI routine completed successfully. we love a happy ending π₯°MPI_ERR_BUFFERβ invalid buffer pointer. usually a null buffer where null is not valid. she's not there, bestie.MPI_ERR_COMMβ invalid communicator. a common oopsie is using a null communicator in a call (which isn't even allowed inMPI_Comm_rank).MPI_ERR_COUNTβ invalid count argument. count arguments must be non-negative; a count of zero is often valid, so don't panic.MPI_ERR_TYPEβ invalid datatype argument. also, this error can pop up if an uncommittedMPI_Datatype(seeMPI_Type_commit) is used in a communication call. commit your types first, girl πMPI_ERR_OTHERβ other error; useMPI_Error_stringto get more info about this error code.
and that's the whole page, bestie! you ate that. go forth and allgather your lil heart out ππ
this was brought to you by the MPI manual, dated 4/10/2026 β MPI_Allgather(3), and yes, the number in the parens means it's a library call. iconic behavior fr fr πβ¨
π¦ 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