MPI_BARRIER_INIT(3)

πŸ“¦
version 5.0.10 Β· 4 versions
, in ubuntu stonking

πŸ’– MPI_BARRIER_INIT(3) πŸ’–

okay bestie, gather round, because this is the Open MPI manpage for MPI_Barrier, MPI_Ibarrier, and MPI_Barrier_init β€” the whole squad of synchronization routines. That's "Synchronization between MPI processes in a group", for the record. it's giving group project but everyone actually shows up on time ✨


✨ SYNTAX ✨

πŸ“ C Syntax

#include <mpi.h>

int MPI_Barrier(MPI_Comm)
int MPI_Ibarrier(MPI_Comm comm, MPI_Request *request)
int MPI_Barrier_init(MPI_Comm comm, MPI_Info info, MPI_Request *request)

πŸ’œ Fortran Syntax

USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_BARRIER(COMM, IERROR)
    INTEGER COMM, IERROR
MPI_IBARRIER(COMM, REQUEST, IERROR)
    INTEGER COMM, REQUEST, IERROR
MPI_BARRIER_INIT(COMM, INFO, REQUEST, IERROR)
    INTEGER COMM, INFO, REQUEST, IERROR
ngl the INCLUDE 'mpif.h' one is the older form, so if you're out here using it, no judgment, but like… bestie, the glow-up is right there πŸ’…

πŸ¦‹ Fortran 2008 Syntax

USE mpi_f08
MPI_Barrier(comm, ierror)
    TYPE(MPI_Comm), INTENT(IN) :: comm
    INTEGER, OPTIONAL, INTENT(OUT) :: ierror
MPI_Ibarrier(comm, request, ierror)
    TYPE(MPI_Comm), INTENT(IN) :: comm
    TYPE(MPI_Request), INTENT (OUT) :: request
    INTEGER, OPTIONAL, INTENT(OUT) :: ierror
MPI_Barrier_init(comm, info, request, ierror)
    TYPE(MPI_Comm), INTENT(IN) :: comm
    TYPE(MPI_Info), INTENT(IN) :: info
    TYPE(MPI_Request), INTENT (OUT) :: request
    INTEGER, OPTIONAL, INTENT(OUT) :: ierror

🌸 INPUT PARAMETER 🌸

  • comm β€” the Communicator (handle). your little group chat, basically πŸ‘‘
  • info β€” the Info (handle, persistent only). yes bestie, persistent only β€” that's the _init one, iykyk ✨

πŸŽ€ OUTPUT PARAMETERS πŸŽ€

  • request β€” Request (handle, non-blocking only). so this one's for the non-blocking crew only πŸ™ˆ
  • ierror β€” Fortran only: Error status (integer). very much a Fortran thing πŸ’œ

🌈 DESCRIPTION 🌈

okay so here's the whole vibe: an MPI barrier completes after all group members have entered the barrier.

that's it. that's the tea. everyone has to walk in through the door before anybody gets to leave. no skipping the line, no main character shortcuts, periodt πŸ’…


πŸ’€ WHEN COMMUNICATOR IS AN INTER-COMMUNICATOR πŸ’€

so when your communicator is an inter-communicator, the barrier operation gets performed across all processes in both groups. yes, both. the whole thing.

and here's the cute part: all processes in the first group may exit the barrier when all processes in the second group have entered the barrier. so group one can dip once group two has shown up. it's giving "you can go ahead, i'll wait for the others" 🫢


😭 ERRORS 😭

okay so almost all MPI routines return an error value. C routines give it back as the return result of the function, and Fortran routines put it in the last argument. noted, bestie πŸ“

Before that error value comes back, the current MPI error handler that's associated with the communication object (like a communicator, window, or file β€” yes those count) gets called. And if there's no communication object associated with the MPI call at all? Then the call is considered attached to MPI_COMM_SELF and it'll call the associated MPI error handler. cute, right? πŸ’–

When MPI_COMM_SELF isn't initialized β€” meaning before MPI_Init/MPI_Init_thread, after MPI_Finalize, or when you're using the Sessions Model exclusively β€” the error raises the initial error handler. and that initial error handler can be changed by:

  • calling MPI_Comm_set_errhandler on MPI_COMM_SELF when using the World model, or
  • the mpi_initial_errhandler CLI argument to mpiexec, or
  • an info key to MPI_Comm_spawn/MPI_Comm_spawn_multiple

and if no other appropriate error handler has been set? then MPI_ERRORS_RETURN gets called for MPI I/O functions, and MPI_ERRORS_ABORT gets called for all other MPI functions. that's the rule, no cap πŸ”₯

Open MPI ships three predefined error handlers you can use:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. yeah. everybody. dramatic but effective πŸ’€
  • MPI_ERRORS_ABORT β€” an error handler that can be invoked on a communicator, window, file, or session. when it's called on a communicator, it acts as if MPI_Abort was called on that communicator. if it's called on a window or file, it acts as if MPI_Abort was called on a communicator containing the group of processes in the corresponding window or file. if it's called on a session, it aborts only the local process. so like, context matters bestie ✨
  • MPI_ERRORS_RETURN β€” returns an error code to the application. the polite one 🫢

MPI applications can also implement their own error handlers by calling:

  • MPI_Comm_create_errhandler then MPI_Comm_set_errhandler
  • MPI_File_create_errhandler then MPI_File_set_errhandler
  • MPI_Session_create_errhandler then MPI_Session_set_errhandler or at MPI_Session_init
  • MPI_Win_create_errhandler then MPI_Win_set_errhandler
⚠️ heads up: MPI does not guarantee that an MPI program can continue past an error. like, it's not promised. don't build your whole personality on it surviving 🫠

See the MPI man page for a full list of MPI error codes.

See the Error Handling section of the MPI-3.1 standard for more information.

πŸ‘€ See also:

  • MPI_Bcast

okay legal moment, stay with me: 2003-2026, The Open MPI Community. iconique. protected. periodt πŸ‘‘


and that's the whole page, bestie! this was Open MPI's MPI_BARRIER_INIT(3), dated Sep 10, 2026 β€” go forth and synchronize responsibly, you absolute legend πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒˆπŸ‘‘

πŸ“¦ where this page comes from