#pragma omp barrier
Purpose
The omp barrier directive identifies a synchronization point at which threads in a parallel region will not execute beyond the omp barrier until all other threads in the team complete all explicit tasks in the region.
Usage
The omp barrier directive
must appear within a block or compound statement. For example:
if (x!=0) {
#pragma omp barrier /* valid usage */
}
if (x!=0)
#pragma omp barrier /* invalid usage */