MPIX_Allreduce_enqueue(3)

πŸ“¦
version 5.0.1 Β· 4 versions
, in nixos 26.05, ubuntu stonking

πŸ’– 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 _c twin up in here β€” that's the one where count is an MPI_Count instead of a plain int. 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_WTIME and MPI_WTICK) has one extra argument called ierr at the very end of the argument list. πŸ‘€
  • ierr is 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 call statement. periodt.
  • all MPI objects (e.g., MPI_Datatype, MPI_Comm) are of type INTEGER in 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 communicators
  • MPI_File_set_errhandler β€” for files
  • MPI_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 in MPI_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 type MPI_Op) must either be one of the predefined operations (e.g., MPI_SUM) or created with MPI_Op_create. βš™οΈ
  • MPI_ERR_TYPE β€” invalid datatype argument. additionally, this error can occur if an uncommitted MPI_Datatype (see MPI_Type_commit) is used in a communication call. 🏷️
  • MPI_ERR_OTHER β€” other error; use MPI_Error_string to 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