MPI_Ireduce_scatter(3)

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

✨ MPI_Ireduce_scatter(3) β€” the MPI manual, bestie edition ✨

okay so bestie, welcome to MPI_Ireduce_scatter(3) πŸ’– this one lives in the MPI manual and it is so good once you get it. think of it as reduce + scatter but it hands you back a ticket instead of making you wait. nonblocking, iconic, main character energy πŸ‘‘


🌸 NAME 🌸

MPI_Ireduce_scatter β€” combines values and scatters the results, but make it nonblocking πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

int MPI_Ireduce_scatter(const void *sendbuf, void *recvbuf,
const int recvcounts[], MPI_Datatype datatype,
MPI_Op op, MPI_Comm comm, MPI_Request *request)

int MPI_Ireduce_scatter_c(const void *sendbuf, void *recvbuf,
const MPI_Count recvcounts[], MPI_Datatype datatype,
MPI_Op op, MPI_Comm comm, MPI_Request *request)

πŸŽ€ INPUT PARAMETERS πŸŽ€

  • sendbuf β€” where your send buffer starts, the address of it (choice) πŸ“€
  • recvcounts β€” a non-negative integer array telling you how many elements of the result get distributed to each process. girly pop, this array must be identical on all calling processes, so no freestyling πŸ™…β€β™€οΈ (non-negative integer)
  • datatype β€” the data type of the elements chilling in your input buffer (handle) 🧚
  • op β€” the operation you're doing, mmkay (handle) πŸ’«
  • comm β€” the communicator, your little group chat (handle) 🫢

πŸ’– OUTPUT PARAMETERS πŸ’–

  • recvbuf β€” where the receive buffer starts, the address of it (choice) πŸ“₯
  • request β€” the communication request (handle) 🎫

πŸ‘‘ THREAD AND INTERRUPT SAFETY πŸ‘‘

This routine is thread-safe, periodt ✨ which means you can literally call it from multiple threads with zero user-provided thread locks, no cap. However, it is not interrupt safe 😭 and the reason is usually that it uses memory allocation routines like malloc, or other non-MPICH runtime routines that themselves aren't interrupt-safe. so like, respect the boundary bestie πŸ’€


πŸ“ NOTES FOR FORTRAN πŸ“

Every MPI routine in Fortran (except for MPI_WTIME and MPI_WTICK) gets a little extra bonus argument called ierr tacked on at 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. also, in Fortran, MPI routines are subroutines, and you invoke them with the call statement, iykyk πŸ“ž

All MPI objects (e.g., MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. that's just how Fortran does it πŸ’œ


🌈 ERRORS 🌈

Every MPI routine (except MPI_Wtime and MPI_Wtick) returns an error value β€” C routines as the value of the function, and Fortran routines in that last argument 🫑 Before the value gets returned, the current MPI error handler is called. By default that error handler aborts the MPI job, so yeah, it's giving dramatic πŸ’€

The error handler can be swapped out 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 ⚠️ The predefined error handler MPI_ERRORS_RETURN may be used if you want error values to actually come back to you instead. Note that MPI does not guarantee an MPI program can continue past an error; however, MPI implementations will attempt to continue whenever possible 🀞

  • MPI_SUCCESS β€” no error, your MPI routine completed successfully, slay βœ…
  • 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 one is using a null communicator in a call (which isn't 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, so don't panic about that one πŸ‘Œ
  • 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 πŸ”

πŸ’Œ and that's the whole thing bestie, go forth and scatter those reduced values nonblockingly, you absolute legend 🌟

this page was served fresh on 4/10/2026 as part of the MPI docs, and it's still called MPI_Ireduce_scatter(3) πŸ’… mwah, bye! πŸŽ€πŸ¦‹βœ¨

πŸ“¦ where this page comes from