MPIX_Threadcomm_start(3)
β¨ MPIX_Threadcomm_start(3) β¨
okay so bestie, we're in the MPI manual today and the page we're reading is MPIX_Threadcomm_start(3) β and no cap, it's a whole mood: it's the one that starts up / activates a thread communicator for you, and it does it inside thread parallel regions. π
πΈ NAME πΈ
MPIX_Threadcomm_start β start/activate a thread communicator (and yes, inside thread parallel regions, that's the whole point, iykyk). π
π¦ SYNOPSIS π¦
int MPIX_Threadcomm_start(MPI_Comm threadcomm)
π INPUT PARAMETERS π
threadcommβ the thread communicator, as a handle. that's it, that's the whole input, she's lowkey simple like that. π«Ά
π THREAD AND INTERRUPT SAFETY π
good news first, bestie: this routine is thread-safe. so multiple threads can call it with zero user-provided thread locks, none, nada, you don't have to build a whole little fence around it. slay. π₯
but β and hear me out β it is not interrupt safe. π typically that's because it's out here using memory allocation routines like malloc, or other non-MPICH runtime routines that themselves aren't interrupt-safe. so like. thread-safe but not interrupt-safe, those are two different vibe checks, don't mix them up. π
π§ NOTES FOR FORTRAN π§
Okay so if you're doing Fortran, the rules are a little different and you need to know this:
- Every MPI routine in Fortran β except for
MPI_WTIMEandMPI_WTICKβ gets one extra argument calledierrtacked onto the end of the argument list. β¨ ierris 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
callstatement. - Also, all MPI objects (like
MPI_Datatype,MPI_Comm) are of typeINTEGERin Fortran.
periodt. π
π ERRORS π
Okay so every single MPI routine β except MPI_Wtime and MPI_Wtick β returns an error value. In C routines that's the value of the function, and in Fortran routines it's in that last argument we just talked about. Before the value even comes back to you, the current MPI error handler gets called. And by default? That error handler aborts the whole MPI job. π so like, no drama, but also yes drama.
The error handler can be changed with MPI_Comm_set_errhandler (for communicators), MPI_File_set_errhandler (for files), and MPI_Win_set_errhandler (for RMA windows). There's also the MPI-1 routine MPI_Errhandler_set, which you may use, but heads up: its use is deprecated, so, like, it's giving legacy. π«
You can also use the predefined error handler MPI_ERRORS_RETURN to make error values come back to you instead of aborts β very "I'll handle it myself, thanks." And note that MPI does not guarantee a program can continue past an error; however, MPI implementations will attempt to continue whenever possible.
Here's the actual lineup of error codes:
MPI_SUCCESSβ no error, the MPI routine completed successfully, we love her, we stan. βMPI_ERR_COMMβ invalid communicator. a super common way to hit this is passing a null communicator into a call (which isn't even allowed inMPI_Comm_rank, so like, bold of you). πMPI_ERR_OTHERβ other error. useMPI_Error_stringto get more info about this error code. π
π SEE ALSO π
MPIX_Threadcomm_initMPIX_Threadcomm_finishMPIX_Threadcomm_free
go read those next, bestie, they're the rest of the threadcomm friend group. π¦π
one tiny aside bc I love you: this page is from the MPI manual, MPIX_Threadcomm_start(3), and the whole thing is dated 4/10/2026. okay bye, go start your thread communicator! πβ¨πΈ
π¦ 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