MPI_Ireduce(3)
πΈ MPI_Ireduce πΈ
ok so bestie, welcome to the MPI manual, page for MPI_Ireduce(3). this one's a banger, let's get into it π
β¨ NAME β¨
MPI_Ireduce β reduces values on all processes to a single value in a nonblocking way π«Ά
like⦠everybody yells their number into the void, the void does math, and one process gets the answer. and it does NOT make you wait for it. iconic behavior honestly.
π SYNOPSIS π
int MPI_Ireduce(const void *sendbuf, void *recvbuf, int count,
MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm,
MPI_Request *request)
int MPI_Ireduce_c(const void *sendbuf, void *recvbuf, MPI_Count count,
MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm,
MPI_Request *request)
yes there's a _c version and yes the only glow-up is MPI_Count for count instead of int. slay β¨
π INPUT PARAMETERS π
sendbufβ address of send buffer (choice). this is the lil pile of stuff you're contributing to the group project πcountβ number of elements in send buffer (non-negative integer). no negative counts bestie, that's giving chaos πdatatypeβ data type of elements of send buffer (handle)opβ reduce operation (handle). this is the mood β sum, max, whatever the vibe isrootβ rank of root process (integer). the main character who receives the final answer πcommβ communicator (handle). the group chat, basically π¬
π OUTPUT PARAMETERS π
recvbufβ address of receive buffer (choice). only the root's really matters here, everyone else can lowkey just leave it berequestβ communication request (handle). your receipt π§Ύ hold onto it, you'll need it later
π THREAD AND INTERRUPT SAFETY π
ok so good news: this routine is thread-safe β¨ which means multiple threads can use it at the same time and you do not have to bring your own thread locks. the routine handled that itself, she's independent, she's thriving.
BUT. she is not interrupt safe. and why? typically because of memory allocation routines like malloc or other non-MPICH runtime routines that are themselves not interrupt-safe. so yeah. not interrupt safe. noted. don't come for me π
π¦ 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 they're invoked with thecallstatement. periodt π - all MPI objects (e.g.,
MPI_Datatype,MPI_Comm) are of typeINTEGERin Fortran. yes, all of them. no cap fr fr.
π ERRORS π
ok bestie, deep breath, this part is long but it 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 that value comes back, the current MPI error handler gets called. by default, this error handler aborts the MPI job. like, 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 β so like, don't, fr.
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. optimistic queens πΈ
so here's the roster:
MPI_SUCCESSβ No error; MPI routine completed successfully. we love a clean run β¨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. commit your types bestie, uncommitted is giving red flag π©MPI_ERR_OTHERβ Other error; useMPI_Error_stringto get more information about this error code.
ok that's the whole page!! nothing skipped, nothing skipped, i promise, we did the whole thing π
and that's a wrap π this was MPI_Ireduce(3) from the MPI manual, dated 4/10/2026. ty for reading bestie, go reduce some values, you're gonna eat π«Άβ¨π
π¦ 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