Barrier Synchronization
Parallel applications in a distributed memory environment sometimes require explicit or implicit synchronization. Like other message-passing libraries, MPI provides a routine, MPI_BARRIER, to synchronize all processes within a communicator. A barrier is simply a synchronization primitive. Any process calling it will be blocked until all the processes within the group have called it. Once all the processes in the communicator group have reached the barrier, the function will return, and all processes in the group can continue.
The syntax of MPI_BARRIER for both C and Fortran programs is given below:
int MPI_Barrier(MPI_Comm comm)
where:
comm
- is a communicator C structure
- return value
- is an integer value error code
MPI_BARRIER(comm, ierr)
where:
comm
- is an integer denoting a communicator
ierr
- is an integer return error code