MPIX_Threadcomm_init(3)
π MPIX_Threadcomm_init(3) π β the MPI girlies' guide
okay so bestie, welcome to the glossary entry for MPIX_Threadcomm_init π
it lives in the MPI manual (section 3), and it's all about spinning up a thread communicator β and we're doing it outside thread parallel regions, so keep that in mind, it's giving "setup era, not chaos era" β¨
πΈ NAME πΈ
MPIX_Threadcomm_init β initialize a thread communicator (outside thread parallel regions) π§
β¨ SYNOPSIS β¨
int MPIX_Threadcomm_init(MPI_Comm comm, int num_threads,
MPI_Comm *newthreadcomm)
π INPUT PARAMETERS π
commβ the communicator (a handle). your little squad, basically π«Άnum_threadsβ number of participating threads. it's a non-negative integer, so don't come at it with a negative number, that's not the vibe π
π¦ OUTPUT PARAMETERS π¦
newthreadcommβ the new thread communicator (a handle). brand new baby comm, freshly initialized, no cap π
π₯ THREAD AND INTERRUPT SAFETY π₯
This routine is thread-safe, bestie. what that means: multiple threads can use it at the same time, no user-provided thread locks required. it's basically the most well-adjusted function at the function party π
BUT. it is not interrupt safe, and the reason is β usually β memory allocation stuff like malloc or other non-MPICH runtime routines that are themselves not interrupt-safe. so like, not its fault, it's the company it keeps π
β interrupt safe β thread safe. don't conflate them. i said what i said.
π 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're invoked with the call statement. periodt π
Also: all MPI objects (e.g., MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. yes, even the ones that feel like they shouldn't be. iconic behavior honestly π
β 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 the value is returned, the current MPI error handler is called. and default behavior? it aborts the MPI job. like, full on leaving the group chat π
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 β so, like, technically available, but it's giving expired trends, don't. 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 error lineup:
MPI_SUCCESSβ no error; MPI routine completed successfully. slay, we love a clean run β¨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_COMMβ invalid communicator. a common error is to use a null communicator in a call (not even allowed inMPI_Comm_rank). bestie. please. not the null comm πMPI_ERR_OTHERβ other error; useMPI_Error_stringto get more information about this error code. it's the "miscellaneous" bin, go read the label π
π SEE ALSO π
MPIX_Threadcomm_startMPIX_Threadcomm_finishMPIX_Threadcomm_free
the whole threadcomm cinematic universe, go read all of them, you'll be obsessed π«Ά
and that's the whole page, no notes π this edition of MPIX_Threadcomm_init(3) (MPI manual, section 3) is dated 4/10/2026 β go forth and initialize your thread communicators responsibly, bestie. mwah πβ¨
π¦ 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