MPI_Iexscan(3)
π« MPI_Iexscan β the manual, but make it make sense π«
okay bestie, gather round, because we're talking about MPI_Iexscan from the MPI manual, and she is that girl. no cap.
β¨ NAME β¨
MPI_Iexscan β she computes the exclusive scan (aka partial reductions) of your data across a whole collection of processes, and she does it in a nonblocking way. nonblocking!! she's not gonna sit there and make you wait, she has β¨thingsβ¨ to do. π¦
πΈ SYNOPSIS πΈ
the way you call her, verbatim, do not freestyle this:
int MPI_Iexscan(const void *sendbuf, void *recvbuf, int count,
MPI_Datatype datatype, MPI_Op op, MPI_Comm comm,
MPI_Request *request)
and the big-count version:
int MPI_Iexscan_c(const void *sendbuf, void *recvbuf, MPI_Count count,
MPI_Datatype datatype, MPI_Op op, MPI_Comm comm,
MPI_Request *request)
π INPUT PARAMETERS π
these are the things you gotta hand her. she's not picky, she just needs them.
sendbufβ the starting address of the send buffer (choice). this is your stuff, your data, your moment. πcountβ number of elements in the input buffer, as a non-negative integer. negative counts? absolutely not, we don't do that here. πdatatypeβ the data type of the elements in your input buffer (handle).opβ the operation you want (handle). the vibe of the reduction, if you will.commβ an intra-communicator (handle). the group chat she's doing this in.
π OUTPUT PARAMETERS π
what she hands back to you:
recvbufβ the starting address of the receive buffer (choice). where the results land.requestβ the communication request (handle). hold onto this, bestie, you'll need it to actually finish the thing later. π«Ά
π NOTES ON COLLECTIVE OPERATIONS π
okay this part is a little dramatic but it's important, so listen up.
the reduction functions (MPI_Op) do not return an error value. periodt. so likeβ¦ if those functions detect an error, all they can do is either call MPI_Abort or silently skip the problem. π that's it. that's the whole toolkit.
so if you change the error handler away from MPI_ERRORS_ARE_FATAL to something else β for example, MPI_ERRORS_RETURN β then no error may be indicated. you justβ¦ won't know. π
and why is it like this?? the manual says the reason is the performance problems in ensuring that all collective routines return the same error value. so it's a trade-off and that's the trade they made.
π§ THREAD AND INTERRUPT SAFETY π§
good news: this routine is thread-safe. slay! that means your multiple threads can use it safely without you having to bring your own user-provided thread locks. no lock drama. πΈ
bad news: the routine is not interrupt safe. typically this is because it uses memory allocation routines such as malloc, or other non-MPICH runtime routines that are themselves not interrupt-safe. so like, she's safe with your threads but not with your interrupts, iykyk. π
π NOTES FOR FORTRAN π
all MPI routines in Fortran (except for MPI_WTIME and MPI_WTICK) have an additional argument ierr at the end of the argument list. ierr is an integer and has the same meaning as the return value of the routine in C. π«
in Fortran, MPI routines are subroutines, and they are invoked with the call statement.
and also: all MPI objects (e.g., MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. no vibes, just integers.
π₯ ERRORS π₯
all MPI routines (except MPI_Wtime and MPI_Wtick) return an error value; C routines as the value of the function, and Fortran routines in the last argument. before that value is returned, the current MPI error handler is called. by default, this error handler aborts the MPI job. π harsh but true.
the error handler may be changed 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 to cause error values to be returned. note that MPI does not guarantee that an MPI program can continue past an error; however, MPI implementations will attempt to continue whenever possible. π«Ά
here's the whole error cast, no cuts:
MPI_SUCCESSβ no error; MPI routine completed successfully. iconic behavior, we love to see it.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). yes, even that one. πMPI_ERR_COUNTβ invalid count argument. count arguments must be non-negative; a count of zero is often valid.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.
bestie if you take nothing else from this page: nonblocking exclusive scan, hand hersendbuf,count,datatype,op,comm, get backrecvbufand arequest, and please, PLEASE remember that the reduction functions will not tell you when they're upset. π
okay that's the whole thing, you ate it, you understood it, main character energy all around. π β¨
MPI manual, page MPI_Iexscan(3) β dated 4/10/2026. mwah, goodnight. π
π¦ 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