MPI_Iexscan(3)

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

πŸ’« 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 in MPI_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 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.

bestie if you take nothing else from this page: nonblocking exclusive scan, hand her sendbuf, count, datatype, op, comm, get back recvbuf and a request, 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