MPI_Reduce_scatter_block_init(3)

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

πŸ’– MPI_Reduce_scatter_block_init(3) β€” the MPI girlies' guide πŸ’–

okay bestie, this one lives in the MPI manual (section 3, the library-call girlies 🫢), and it's literally the glow-up version of reduce_scatter_block β€” except instead of doing the thing, you're pre-registering to do the thing. it's giving "save my seat, I'll be right back" energy. ✨


✨ NAME ✨

MPI_Reduce_scatter_block_init β€” create a persistent request for reduce_scatter_block. no cap, that's the whole job. πŸ’…


🌸 SYNOPSIS 🌸

int MPI_Reduce_scatter_block_init(const void *sendbuf, void *recvbuf,
int recvcount, MPI_Datatype datatype,
MPI_Op op, MPI_Comm comm, MPI_Info info,
MPI_Request *request)

and for when your counts are Bigβ„’ (the C variant with the huge count type):

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

πŸŽ€ INPUT PARAMETERS πŸŽ€

the stuff you hand over to it, the "you" of the relationship:

  • sendbuf β€” starting address of the send buffer (choice). it's choice coded, so you get options, periodt.
  • recvcount β€” element count per block (non-negative integer). non-negative bestie, it's not asking for vibes, it's asking for a count.
  • datatype β€” data type of elements of send and receive buffers (handle).
  • op β€” operation (handle). this is the reduce part, the main character of the math. πŸ‘‘
  • comm β€” communicator (handle). your little group chat of processes.
  • info β€” info argument (handle).

πŸ’œ OUTPUT PARAMETERS πŸ’œ

what it gives you back, the little gift 🎁:

  • recvbuf β€” starting address of the receive buffer (choice).
  • request β€” communication request (handle). this is your persistent one, hold onto it!!

🧚 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. slay. πŸ’…

bad news second: it is not interrupt safe. the reason is typically that it uses memory allocation routines like malloc, or other non-MPICH runtime routines, and those routines are themselves not interrupt-safe. so like, interruption is not the move here. πŸ™ˆ


🌈 NOTES FOR FORTRAN 🌈

fr fr, Fortran has its own whole thing going on:

  • every MPI routine in Fortran (except MPI_WTIME and MPI_WTICK) gets an extra argument ierr at the 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.
  • all MPI objects (like MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran.

πŸ’€ ERRORS πŸ’€

so here's the tea on errors: all MPI routines (except MPI_Wtime and MPI_Wtick) return an error value β€” C routines return it as the value of the function, Fortran routines put it in that last argument. before that value comes back, the current MPI error handler gets called. by default, that error handler aborts the MPI job. 😭

you can change the error handler:

  • 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. and the predefined error handler MPI_ERRORS_RETURN may be used to make error values actually get returned.

⚠️ also, important: MPI does not guarantee that an MPI program can continue past an error. however, MPI implementations will attempt to continue whenever possible. so like… attempt, not promise, iykyk.

the error codes, one by one, no skipping:

  • MPI_SUCCESS β€” no error; MPI routine completed successfully. the dream. ✨
  • 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.

okay that's the whole page, you ate it bestie πŸ“ go forth and be persistent (in the MPI request sense, not in the texting-your-ex sense). mwah πŸ’–

β€” with love, from the MPI docs, dated 4/10/2026. xoxo, your favorite manpage fairy πŸ§šβ€β™€οΈπŸ’…

πŸ“¦ where this page comes from