MPI_Session_init(3)
π MPI_Session_init(3) π
okay bestie, welcome to the MPI_Session_init(3) page from the MPI manual set β yeah, that MPI, the parallel-computing one, and yes it IS iconic. sit down, grab a strawberry, we're gonna get you a whole new session. πβ¨
πΈ NAME πΈ
MPI_Session_init β initialize an MPI session. that's it, that's the vibe. main character moment for your program fr fr.
β¨ SYNOPSIS β¨
int MPI_Session_init(MPI_Info info, MPI_Errhandler errhandler,
MPI_Session *session)
look at that signature. clean. no notes. π
π INPUT PARAMETERS π
infoβ the info object where you tell it what thread support level you want plus whatever MPI-implementation-specific resources you're feeling. it's a handle.errhandlerβ the error handler that gets invoked if something goes wrong during this function call. also a handle. yes, you're picking who yells at you if you mess up, and honestly? respect. π
π«Ά OUTPUT PARAMETERS π«Ά
sessionβ your brand new session. it's a handle. your little baby. nurture it. π
π§ INFO HINTS π§
β FOLLOWING KEYS ARE SUPPORTED β
"thread_level"β sets the MPI thread level. the default isMPI_THREAD_MULTIPLE. okay and listen, this is different from the default inMPI_Init, so don't come for me. also: MPICH does not support different thread levels in different sessions. the thread level you get is the one set by the firstMPI_Session_init,MPI_Init, orMPI_Init_thread. first one wins, periodt."mpi_memory_alloc_kinds"β sets the memory allocation kinds to be used by the calling MPI process on MPI objects derived from the Session. (yes the original says "by by", we are being so real about it. it's giving typo, but the info gets conveyed. π)
π₯ THREAD AND INTERRUPT SAFETY π₯
this routine is thread-safe. meaning: multiple threads can use it safely, no user-provided thread locks required, no cap. you're freeee. π¦
but β and this is a big but β it is NOT interrupt safe. typically that's because it uses memory allocation routines like malloc or other non-MPICH runtime routines that are themselves not interrupt-safe. so don't try it. seriously.
π NOTES FOR FORTRAN π
all MPI routines in Fortran (except for MPI_WTIME and MPI_WTICK) have an extra argument ierr at the very end of the argument list. ierr is an integer and means exactly the same thing as the return value of the routine does in C. in Fortran, MPI routines are subroutines, and you invoke them with the call statement. iykyk.
also, all MPI objects (like MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. that's just how it is.
π ERRORS π
all MPI routines (except MPI_Wtime and MPI_Wtick) return an error value β C routines return it as the value of the function, 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, the whole thing. gone. π
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 still be used but its use is deprecated, bestie, please move on. π©
the predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be 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. fingers crossed energy. π«Ά
here's the error code lineup:
MPI_SUCCESSβ no error; the MPI routine completed successfully. slay. β¨MPI_ERR_ARGβ invalid argument. some argument is invalid and isn't identified by a specific error class (e.g.,MPI_ERR_RANK). one of your inputs is sus and we don't know which. πMPI_ERR_INFOβ invalid Info.MPI_ERR_OTHERβ other error; useMPI_Error_stringto get more information about this error code. it's giving unlabeled mystery box. π
and that's the page, bestie!! sourced from the MPI manual, dated 4/10/2026, and filed under MPI_Session_init(3). now go forth and init that session. you got this. πβ¨ππ¦π
π¦ 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