MPI_Reduce_init(3)

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

πŸ’– MPI_Reduce_init(3) β€” the MPI manual, but make it cute πŸ’–

okay bestie, welcome to MPI_Reduce_init from the MPI manual page family 🫢 this one is giving "set it up once, vibe forever" energy and honestly? iconic.


✨ NAME ✨

MPI_Reduce_init β€” Create a persistent request for reduce πŸ’…


🌸 SYNOPSIS 🌸

int MPI_Reduce_init(const void *sendbuf, void *recvbuf, int count,
MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm,
MPI_Info info, MPI_Request *request)

int MPI_Reduce_init_c(const void *sendbuf, void *recvbuf, MPI_Count count,
MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm,
MPI_Info info, MPI_Request *request)

so there's the classic C one and then MPI_Reduce_init_c which is the same thing but the count is an MPI_Count instead of an int, because sometimes you have BIG numbers of elements and the plain int said "not me, I can't" 😭


πŸŽ€ INPUT PARAMETERS πŸŽ€

the stuff you gotta hand over, bestie:

  • sendbuf β€” address of send buffer (choice) πŸ“€
  • count β€” number of elements in send buffer (non-negative integer) πŸ”’
  • datatype β€” data type of elements of send buffer (handle) 🏷️
  • op β€” reduce operation (handle) βž•
  • root β€” rank of root process (integer) πŸ‘‘
  • comm β€” communicator (handle) πŸ“‘
  • info β€” info argument (handle) πŸ“

πŸ’œ OUTPUT PARAMETERS πŸ’œ

the stuff it hands back to you:

  • recvbuf β€” address of receive buffer (choice) πŸ“₯
  • request β€” communication request (handle) 🎟️

🧡 THREAD AND INTERRUPT SAFETY 🧡

good news first: this routine is thread-safe ✨ which means multiple threads can use it at the same time and you do not need to bring your own user-provided thread locks. no babysitting required, she's self-sufficient πŸ’…

bad news: the routine is not interrupt safe 😭 and typically that's because of memory allocation routines like malloc, or other non-MPICH runtime routines, which are themselves not interrupt-safe. so like. it's not her fault fr fr, it's the company she keeps πŸ™ˆ


πŸ¦‹ NOTES FOR FORTRAN πŸ¦‹

Fortran besties, listen up πŸ“’ β€” all MPI routines in Fortran have an extra argument called ierr tacked onto the end of the argument list, except for MPI_WTIME and MPI_WTICK. ierr is an integer and it means exactly the same thing as the return value of the routine in C. and in Fortran, MPI routines are subroutines, invoked with the call statement, periodt.

also: all MPI objects (like MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. that's just the rules πŸŽ€


πŸ’€ ERRORS πŸ’€

okay so, all MPI routines (except MPI_Wtime and MPI_Wtick) return an error value β€” C routines as the value of the function, Fortran routines in that last argument. and before the value comes back to you, the current MPI error handler gets called. by default that error handler aborts the MPI job πŸ’€ so yeah, dramatic.

you can switch the error handler with MPI_Comm_set_errhandler (for communicators), MPI_File_set_errhandler (for files), and MPI_Win_set_errhandler (for RMA windows). there's also the MPI-1 routine MPI_Errhandler_set, which may be used but its use is deprecated 🚫 (old, tired, let her rest). and the predefined error handler MPI_ERRORS_RETURN can be used to make error values get returned instead.

real talk though: MPI does not guarantee that an MPI program can continue past an error. however, MPI implementations will attempt to continue whenever possible 🫢

now the error codes, one by one:

  • MPI_SUCCESS β€” No error; MPI routine completed successfully. πŸŽ‰ slay.
  • 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 in MPI_Comm_rank). πŸ“΅
  • MPI_ERR_COUNT β€” Invalid count argument. Count arguments must be non-negative; a count of zero is often valid. πŸ”’
  • MPI_ERR_INFO β€” Invalid Info. πŸ“
  • 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. πŸŒ€

that's the whole page bestie, you ate this πŸ’…βœ¨

signed off from the MPI manual, page dated 4/10/2026, filed under MPI_Reduce_init(3) β€” mwah, go forth and reduce responsively πŸ’–πŸŒˆπŸ¦‹

πŸ“¦ where this page comes from