MPI_Scan_init(3)

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

πŸ’– MPI_Scan_init β€” persistent scan requests, bestie edition πŸ’–

okay so this is a page from the MPI manual, MPI_Scan_init(3), and it's literally about making a persistent request for a scan. Think of it as: you set up the scan once, and then you can fire it off again and again without re-doing all the setup. main character energy, honestly. πŸ¦‹


✨ NAME ✨

MPI_Scan_init β€” Create a persistent request for scan.


πŸŽ€ SYNOPSIS πŸŽ€

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

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

two flavors, same vibe. the _c one just takes an MPI_Count for count instead of an int. slay. πŸ’…


🌸 INPUT PARAMETERS 🌸

  • sendbuf β€” where your send buffer starts (choice).
  • count β€” how many elements are chillin' in the input buffer (non-negative integer, so no negative nonsense).
  • datatype β€” the data type of the elements in the input buffer (handle).
  • op β€” the operation (handle).
  • comm β€” the communicator (handle).
  • info β€” the info argument (handle).

πŸ’œ OUTPUT PARAMETERS πŸ’œ

  • recvbuf β€” where your receive buffer starts (choice).
  • request β€” the communication request (handle).

🫢 THREAD AND INTERRUPT SAFETY 🫢

good news: this routine is thread-safe. that means multiple threads can use it at the same time, no user-provided thread locks required, we love that for us. ✨

but bestie… it is not interrupt safe. 😭 typically that's because it uses memory allocation routines like malloc or other non-MPICH runtime routines, and those are themselves not interrupt-safe. so like, keep that in mind, k? πŸ’€


🧚 NOTES FOR FORTRAN 🧚

every MPI routine in Fortran (except MPI_WTIME and MPI_WTICK) has an extra argument ierr tacked onto the end of the argument list. ierr is an integer and it means the 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.

also, all MPI objects (like MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. iconic. πŸ‘‘


🌈 ERRORS 🌈

so all MPI routines (except MPI_Wtime and MPI_Wtick) return an error value β€” C routines return it as the value of the function, and Fortran routines put it in the last argument. before that value comes back to you, the current MPI error handler gets called. by default, that error handler aborts the MPI job. yeah. 😳

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 its use is deprecated. the predefined error handler MPI_ERRORS_RETURN can be used to make error values actually get returned instead.

⚠️ note that MPI does not guarantee that an MPI program can continue past an error. however, MPI implementations will attempt to continue whenever possible. so like… maybe? πŸ™ˆ

the error codes, one by one:

  • MPI_SUCCESS β€” No error; MPI routine completed successfully. we love a happy ending. πŸ’–
  • 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 that fr fr πŸ“ this was MPI_Scan_init(3) from MPI, dated 4/10/2026. go forth and scan persistently, bestie. πŸ’…βœ¨

πŸ“¦ where this page comes from