MPI_Reduce_scatter_block_init(3)
π 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_WTIMEandMPI_WTICK) gets an extra argumentierrat the 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. - 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 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. 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 inMPI_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 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.
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
- 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