An official website of the United States government

Official websites use .gov
A .gov website belongs to an official government organization in the United States.

Secure .gov websites use HTTPS
A lock ( ) or https:// means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.


Home

OpenMP Directives: Synchronization Constructs: BARRIER Directive

Purpose:

The BARRIER directive synchronizes all threads in the team.

When a BARRIER directive is reached, a thread will wait at that point until all other threads have reached that barrier. All threads then resume executing in parallel the code that follows the barrier.

Format:

Fortran

!$OMP BARRIER

###C/C++

#pragma omp barrier  newline

Restrictions:

All threads in a team (or none) must execute the BARRIER region.

The sequence of work-sharing regions and barrier regions encountered must be the same for every thread in a team.