MPI_Iallreduce(3)
π MPI_Iallreduce β the group chat "k everyone agree?" move π
okay so bestie, welcome to the MPI manual, section 3 (that's library calls, for the uninitiated π«Ά). This one's called MPI_Iallreduce, and it is literally the nonblocking glow-up of everybody's fave collective.
β¨ NAME β¨
MPI_Iallreduce β combines values from all processes and distributes the result back to all processes, but in a nonblocking way π
Like, it does the whole "everyone shouts their number, everyone gets the total" thing, except it does not make you wait around for it. You hand in your homework, you get a receipt (request), and you go live your life. Main character energy fr fr. π
π SYNOPSIS π
int MPI_Iallreduce(const void *sendbuf, void *recvbuf, int count,
MPI_Datatype datatype, MPI_Op op, MPI_Comm comm,
MPI_Request *request)
int MPI_Iallreduce_c(const void *sendbuf, void *recvbuf, MPI_Count count,
MPI_Datatype datatype, MPI_Op op, MPI_Comm comm,
MPI_Request *request)
not one but TWO flavors, because why have one signature when you can have a _c variant with the big-girl MPI_Count count π
πΈ INPUT PARAMETERS πΈ
sendbufβ starting address of send buffer (choice). this is the thing you're putting in the potluck, bestie πcountβ number of elements in send buffer (non-negative integer). non-negative!! we do not do negative counts in this house πdatatypeβ data type of elements of send buffer (handle)opβ operation (handle) β the little spell you cast on the pile of everyone's values β¨commβ communicator (handle) β aka the group chat itself π―
π¦ OUTPUT PARAMETERS π¦
recvbufβ starting address of receive buffer (choice). where the combined result lands so everybody sees it π«Άrequestβ communication request (handle). your lil receipt, so you can check on it later π§Ύ
π THREAD AND INTERRUPT SAFETY π
This routine is thread-safe. Translation: multiple threads can use it at the same time, and you do not need to bring your own user-provided thread locks. no cap. π₯
But heads up: it is not interrupt safe. π Usually that's because it uses memory allocation routines like malloc, or other non-MPICH runtime routines, and those are themselves not interrupt-safe. so like, respecc the boundary.
β NOTES FOR FORTRAN β
All MPI routines in Fortran (except for MPI_WTIME and MPI_WTICK) get an extra argument ierr tacked onto the end of the argument list. ierr is an integer and it means exactly 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. classic Fortran behaviour π
All MPI objects (e.g. MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran.
π 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. By default, this error handler aborts the MPI job β like, the whole thing, gone, bye π
The error handler can 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 (we don't do that anymore, queen π). The predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned instead. Note that MPI does not guarantee that an MPI program can continue past an error; however, MPI implementations will attempt to continue whenever possible. so, y'know, vibes permitting.
Here's the full roster of possible error codes:
MPI_SUCCESSβ No error; MPI routine completed successfully. ate and left no crumbs β¨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).MPI_ERR_COUNTβ Invalid count argument. Count arguments must be non-negative; a count of zero is often valid.MPI_ERR_OPβ Invalid operation. MPI operations (objects of typeMPI_Op) must either be one of the predefined operations (e.g.,MPI_SUM) or created withMPI_Op_create.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.
and that's the whole page, bestie π go forth and reduce, nonblocking-ly π
this lil love letter came to you from the MPI manual, dated4/10/2026, filed underMPI_Iallreduce(3)π«Ά 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