MPI_Barrier_init(3)
β¨ NAME β¨
MPI_Barrier_init β the one that creates a persistent request for a barrier, bestie π (it's an MPI man page, iykyk)
π SYNOPSIS π
int MPI_Barrier_init(MPI_Comm comm, MPI_Info info, MPI_Request *request)
π INPUT PARAMETERS π
commβ the communicator, aka a handle π«Άinfoβ the info argument, also a handle β¨
π OUTPUT PARAMETERS π
requestβ the communication request (handle, bestie, it's a handle) π
π₯ THREAD AND INTERRUPT SAFETY π₯
Okay so good news first: this routine is thread-safe π. Which means multiple threads can use it at the same time and you do not need to bring your own thread locks, no cap. She's independent, she's thriving, main character energy.
But β and I need you to hear me on this β she is not interrupt safe. π Typically that's because of memory allocation routines like malloc, or other non-MPICH runtime routines, which are themselves not interrupt-safe. So like, thread-safe yes, interrupt-safe no. Vibe check: passed on one front, failed on the other. Noted. π
π¦ NOTES FOR FORTRAN π¦
Every single MPI routine in Fortran (with the exception of MPI_WTIME and MPI_WTICK, those two are doing their own thing) has an extra argument called ierr tacked on at the end of the argument list. ierr is an integer and it means exactly the same thing as the return value of the routine in C. Same energy, different language.
Also, in Fortran, MPI routines are subroutines, and you invoke them with the call statement. Periodt.
And one more: all MPI objects (like MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. Not handles, not structs, just INTEGER. She's simple like that. π
π ERRORS π
All MPI routines (except MPI_Wtime and MPI_Wtick, they're the rebels) return an error value. C routines return it as the value of the function, and Fortran routines put it in that last argument we just talked about.
Before the value gets returned, the current MPI error handler is called. By default? That error handler aborts the MPI job. Like, full stop, rip to your run. π
You can change the error handler though:
MPI_Comm_set_errhandlerβ for communicatorsMPI_File_set_errhandlerβ for filesMPI_Win_set_errhandlerβ for RMA windows
There's also the MPI-1 routine MPI_Errhandler_set, but heads up, its use is deprecated. β οΈ Old, tired, legacy behavior.
The predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned instead. And fr fr, note that MPI does not guarantee that an MPI program can continue past an error β though MPI implementations will attempt to continue whenever possible. Manifesting success, I guess. π
Here's the error roster:
MPI_SUCCESSβ No error; MPI routine completed successfully. Slay. β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 (which isn't even allowed inMPI_Comm_rank, so you know it's bad). π©MPI_ERR_INFOβ Invalid InfoMPI_ERR_OTHERβ Other error; useMPI_Error_stringto get more information about this error code. π΅οΈ
β οΈ real talk: passing a null communicator? absolutely not, the ancestors said no, not even MPI_Comm_rank will let that slide
okay that's the whole page bestie, go forth and initialize your barriers πβ¨πΈ
β xx, from the MPI manual, dated 4/10/2026, MPI_Barrier_init(3) π (that's the version and the date, brought to you with love, no cap)
π¦ 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