MPI_Reduce_scatter_init(3)
โจ MPI_Reduce_scatter_init โจ
okay bestie, so this is a page from the MPI manual (that's the Message Passing Interface, the whole "many computers pretending to be one brain" situation ๐
), and we're gonna talk about MPI_Reduce_scatter_init.
๐ NAME ๐
MPI_Reduce_scatter_init โ create a persistent request for reduce_scatter.
like, you know how a regular reduce_scatter is a whole thing you do over and over in a loop and it keeps re-doing all the setup? yeah. this one sets it up once and hands you a request you can fire off again and again. iconic behavior honestly. ๐ฅ
๐ฆ SYNOPSIS ๐ฆ
int MPI_Reduce_scatter_init(const void *sendbuf, void *recvbuf,
const int recvcounts[], MPI_Datatype datatype,
MPI_Op op, MPI_Comm comm, MPI_Info info,
MPI_Request *request)
int MPI_Reduce_scatter_init_c(const void *sendbuf, void *recvbuf,
const MPI_Count recvcounts[],
MPI_Datatype datatype, MPI_Op op, MPI_Comm comm,
MPI_Info info, MPI_Request *request)
two versions bestie โ the classic one and the _c one with big boi MPI_Count counts. both valid, both slaying. โจ
๐ธ INPUT PARAMETERS ๐ธ
sendbufโ the starting address of the send buffer. it's a choice, so you get options. (look at you having options ๐ )recvcountsโ a non-negative integer array that says how many elements of the result each process gets. it's giving "we divided the vibes up equally-ish". โ ๏ธ this array must be identical on all calling processes โ no cap, everyone has to agree or it's chaos.datatypeโ the data type of the elements in the input buffer (a handle).opโ the operation you're doing (a handle).commโ the communicator (a handle).infoโ the info argument (a handle).
๐ OUTPUT PARAMETERS ๐
recvbufโ the starting address of the receive buffer (again, a choice).requestโ the communication request (a handle). hold onto this one, it's your little persistent ticket. ๐๏ธ
๐ง THREAD AND INTERRUPT SAFETY ๐ง
this routine is thread-safe. meaning: multiple threads can call it at the same time and you do not need to bring your own thread locks. she handles herself. ๐โโ๏ธ
however โ and this is the important part bestie โ the routine is not interrupt safe. ๐จ typically this is because it uses memory allocation routines like malloc, or other non-MPICH runtime routines that are themselves not interrupt-safe. so like, don't be interrupting her mid-alloc. ๐
๐ฎ NOTES FOR FORTRAN ๐ฎ
so in Fortran, all MPI routines (except MPI_WTIME and MPI_WTICK) get an extra argument ierr tacked onto 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.
also in Fortran, MPI routines are subroutines and they're invoked with the call statement. very retro, very demure. ๐
and! all MPI objects (like MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. that's just the way it is. โญ
๐ ERRORS ๐
okay so every MPI routine (except MPI_Wtime and MPI_Wtick) returns an error value โ C routines return it as the value of the function, and Fortran routines put it in that last argument. before the value comes back, the current MPI error handler gets called. by default, that error handler aborts the MPI job. like, full stop, everyone out of the pool. ๐ญ
you can change the error handler 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 heads up โ its use is deprecated. โ ๏ธ the predefined error handler MPI_ERRORS_RETURN may be used to make error values get returned instead.
note that MPI does not guarantee an MPI program can continue past an error. however, MPI implementations will attempt to continue whenever possible. so like... fingers crossed ๐ค
here's the error roster, all of them, no skips:
MPI_SUCCESSโ no error; MPI routine completed successfully. we love a happy 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 isn't valid. ๐MPI_ERR_COMMโ invalid communicator. a common one is using a null communicator in a call (which is 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.
that's literally the whole page bestie, you ate it up. now go make a persistent request and be the main character of your own communicator. ๐๐
โง๏ฝฅ๏พ: โง๏ฝฅ๏พ:
signing off from the MPI manual, dated 4/10/2026, page MPI_Reduce_scatter_init(3) โ mwah, love u, bye ๐๐
๐ฆ 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