HOME
| OPENMP API Specification: Version 5.1 November 2020

2.19.2  barrier Construct

Summary The barrier construct specifies an explicit barrier at the point at which the construct appears. The barrier construct is a stand-alone directive.

Syntax

SVG-Viewer needed.

The syntax of the barrier construct is as follows:  

 
#pragma omp barrier new-line  

SVG-Viewer needed.

SVG-Viewer needed.

The syntax of the barrier construct is as follows:  

 
!$omp barrier  

SVG-Viewer needed.

Binding The binding thread set for a barrier region is the current team. A barrier region binds to the innermost enclosing parallel region.

Description All threads of the team that is executing the binding parallel region must execute the barrier region and complete execution of all explicit tasks bound to this parallel region before any are allowed to continue execution beyond the barrier.

The barrier region includes an implicit task scheduling point in the current task region.

Execution Model Events The explicit-barrier-begin event occurs in each thread that encounters the barrier construct on entry to the barrier region.

The explicit-barrier-wait-begin event occurs when a task begins an interval of active or passive waiting in a barrier region.

The explicit-barrier-wait-end event occurs when a task ends an interval of active or passive waiting and resumes execution in a barrier region.

The explicit-barrier-end event occurs in each thread that encounters the barrier construct after the barrier synchronization on exit from the barrier region.

A cancellation event occurs if cancellation is activated at an implicit cancellation point in a barrier region.

Tool Callbacks A thread dispatches a registered ompt_callback_sync_region callback with ompt_sync_region_barrier_explicit as its kind argument and ompt_scope_begin as its endpoint argument for each occurrence of an explicit-barrier-begin event. Similarly, a thread dispatches a registered ompt_callback_sync_region callback with ompt_sync_region_barrier_explicit as its kind argument and ompt_scope_end as its endpoint argument for each occurrence of an explicit-barrier-end event. These callbacks occur in the context of the task that encountered the barrier construct and have type signature ompt_callback_sync_region_t.

A thread dispatches a registered ompt_callback_sync_region_wait callback with ompt_sync_region_barrier_explicit as its kind argument and ompt_scope_begin as its endpoint argument for each occurrence of an explicit-barrier-wait-begin event. Similarly, a thread dispatches a registered ompt_callback_sync_region_wait callback with ompt_sync_region_barrier_explicit as its kind argument and ompt_scope_end as its endpoint argument for each occurrence of an explicit-barrier-wait-end event. These callbacks occur in the context of the task that encountered the barrier construct and have type signature ompt_callback_sync_region_t.

A thread dispatches a registered ompt_callback_cancel callback with ompt_cancel_detected as its flags argument for each occurrence of a cancellation event in that thread. The callback occurs in the context of the encountering task. The callback has type signature ompt_callback_cancel_t.

Restrictions Restrictions to the barrier construct are as follows:

Cross References