MPIX_Allreduce_enqueue(3)
π MPIX_Allreduce_enqueue β the MPI manual page, bestie edition π
okay so real quick: this page lives in section 3 of the MPI manual, and it's all about one lil' function that queues up an allreduce onto a GPU stream that's tied to the local stream. lowkey iconic. let's get into it β¨
πΈ NAME πΈ
MPIX_Allreduce_enqueue β enqueue an allreduce operation to a GPU stream that is associated with the local stream π«Ά
π SYNOPSIS π
int MPIX_Allreduce_enqueue(const void *sendbuf, void *recvbuf, int count,
MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
int MPIX_Allreduce_enqueue_c(const void *sendbuf, void *recvbuf,
MPI_Count count, MPI_Datatype datatype, MPI_Op op,
MPI_Comm comm)
notice there's a_ctwin up in here β that's the one wherecountis anMPI_Countinstead of a plainint. two versions, same energy. π
β¨ INPUT PARAMETERS β¨
sendbufβ the starting address of the send buffer (it's a choice, so you pick). no cap. π€countβ how many elements are chillin' in the send buffer (non-negative integer, so zero and up, bestie). π’datatypeβ the data type of the elements in the send buffer (handle). πopβ the operation (handle). this is the actual reduce-y business. π₯commβ the communicator (handle). the group chat of processes, fr fr. π«
π OUTPUT PARAMETERS π
recvbufβ the starting address of the receive buffer (choice). this is where the answer lands. π₯
π§΅ THREAD AND INTERRUPT SAFETY π§΅
good news first: this routine is thread-safe. that means multiple threads can use it at the same time and you do not need to bring your own thread locks. she's self-sufficient. π β¨
sad news second: it is not interrupt safe. typically that's because it uses memory allocation routines like malloc or other non-MPICH runtime routines, and those routines are themselves not interrupt-safe. so, like, don't interrupt. π
π NOTES FOR FORTRAN π
okay so Fortran besties, listen up:
- every MPI routine in Fortran (except for
MPI_WTIMEandMPI_WTICK) has one extra argument calledierrat the very end of the argument list. π ierris an integer, and it means the exact same thing as the return value of the routine in C.- in Fortran, MPI routines are subroutines, and you invoke them with the
callstatement. periodt. - all MPI objects (e.g.,
MPI_Datatype,MPI_Comm) are of typeINTEGERin Fortran. that's just the rules. π
π ERRORS π
so here's the deal: all MPI routines (except MPI_Wtime and MPI_Wtick) return an error value. in C, that's the value of the function itself; in Fortran, it's the last argument. before that value comes back to you, the current MPI error handler gets called.
by default, that error handler aborts the MPI job π β like, full on. dramatic. but you can change it:
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 (aka, please don't, she's old π΅). and the predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned instead.
β οΈ important caveat, do not skip this: MPI does not guarantee that an MPI program can continue past an error. however, MPI implementations will attempt to continue whenever possible. so like... fingers crossed, but no promises. π
here's every error code you might catch, and what it's giving:
MPI_SUCCESSβ no error; the MPI routine completed successfully. the good ending. βMPI_ERR_ARGβ invalid argument. some argument is invalid and isn't 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 using a null communicator in a call (not even allowed inMPI_Comm_rank, okay?? π).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. the miscellaneous queen. π
and that's the whole page, bestie! this was MPIX_Allreduce_enqueue from the MPI manual, section 3, dated 4/10/2026 β so go enqueue that allreduce on your GPU stream and slay π
β¨π¦π
you got this. periodt. π
π¦ 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