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_WTIME and MPI_WTICK β€” gets one extra argument called 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.

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 in MPI_Comm_rank, so like, bold of you). πŸ’€
  • MPI_ERR_OTHER β€” other error. use MPI_Error_string to get more info about this error code. πŸ”

🌈 SEE ALSO 🌈

  • MPIX_Threadcomm_init
  • MPIX_Threadcomm_finish
  • MPIX_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