MPI_Scan_init(3)
π 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 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 InfoMPI_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 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
- 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