HOME
| OPENMP API Specification: Version 5.1 November 2020

2  Directives

This chapter describes the syntax and behavior of OpenMP directives.

SVG-Viewer needed.

OpenMP directives are specified with the #pragma mechanism provided by the C standard.

SVG-Viewer needed.

SVG-Viewer needed.

OpenMP directives are specified with attribute specifiers or the #pragma mechanism provided by the C++ standard.

SVG-Viewer needed.

SVG-Viewer needed.

OpenMP directives are specified with stylized comments that are identified by unique sentinels. Also, a stylized comment form is available for conditional compilation.

If a directive appears in the declarative part of a module then the behavior is as if that directive appears after any references to that module.

SVG-Viewer needed.

Compilers can therefore ignore OpenMP directives and conditionally compiled code if support of the OpenMP API is not provided or enabled. A compliant implementation must provide an option or interface that ensures that underlying support of all OpenMP directives and OpenMP conditional compilation mechanisms is enabled. In the remainder of this document, the phrase OpenMP compilation is used to mean a compilation with these OpenMP features enabled.

SVG-Viewer needed.

This chapter uses NULL as a generic term for a null pointer constant, true as a generic term for a non-zero integer value and false as a generic term for an integer value of zero.

SVG-Viewer needed.

SVG-Viewer needed.

This chapter uses NULL as a generic term for the named constant C_NULL_PTR, true as a generic term for a logical value of .TRUE. and false as a generic term for a logical value of .FALSE..

SVG-Viewer needed.

Restrictions The following restrictions apply to OpenMP directives:

SVG-Viewer needed.

SVG-Viewer needed.

  • A declarative directive may not be used in place of a substatement in a selection statement, in place of the loop body in an iteration statement, or in place of the statement that follows a label.

SVG-Viewer needed.

SVG-Viewer needed.

  • A declarative directive may not be used in place of a substatement in a selection statement or iteration statement, or in place of the statement that follows a label.

SVG-Viewer needed.

SVG-Viewer needed.

SVG-Viewer needed.

SVG-Viewer needed.

 2.1  Directive Format
  2.1.1  Fixed Source Form Directives
  2.1.2  Free Source Form Directives
  2.1.3  Stand-Alone Directives
  2.1.4  Array Shaping
  2.1.5  Array Sections
  2.1.6  Iterators
 2.2  Conditional Compilation
  2.2.1  Fixed Source Form Conditional Compilation Sentinels
  2.2.2  Free Source Form Conditional Compilation Sentinel
 2.3  Variant Directives
  2.3.1  OpenMP Context
  2.3.2  Context Selectors
  2.3.3  Matching and Scoring Context Selectors
  2.3.4  Metadirectives
  2.3.5  Declare Variant Directive
  2.3.6  dispatch Construct
 2.4  Internal Control Variables
  2.4.1  ICV Descriptions
  2.4.2  ICV Initialization
  2.4.3  Modifying and Retrieving ICV Values
  2.4.4  How ICVs are Scoped
  2.4.5  ICV Override Relationships
 2.5  Informational and Utility Directives
  2.5.1  requires Directive
  2.5.2  Assume Directive
  2.5.3  nothing Directive
  2.5.4  error Directive
 2.6  parallel Construct
  2.6.1  Determining the Number of Threads for a parallel Region
  2.6.2  Controlling OpenMP Thread Affinity
 2.7  teams Construct
 2.8  masked Construct
 2.9  scope Construct
 2.10  Worksharing Constructs
  2.10.1  sections Construct
  2.10.2  single Construct
  2.10.3  workshare Construct
 2.11  Loop-Related Directives
  2.11.1  Canonical Loop Nest Form
  2.11.2  Consistent Loop Schedules
  2.11.3  order Clause
  2.11.4  Worksharing-Loop Construct
  2.11.5  SIMD Directives
  2.11.6  distribute Loop Constructs
  2.11.7  loop Construct
  2.11.8  scan Directive
  2.11.9  Loop Transformation Constructs
 2.12  Tasking Constructs
  2.12.1  task Construct
  2.12.2  taskloop Construct
  2.12.3  taskloop simd Construct
  2.12.4  taskyield Construct
  2.12.5  Initial Task
  2.12.6  Task Scheduling
 2.13  Memory Management Directives
  2.13.1  Memory Spaces
  2.13.2  Memory Allocators
  2.13.3  allocate Directive
  2.13.4  allocate Clause
 2.14  Device Directives
  2.14.1  Device Initialization
  2.14.2  target data Construct
  2.14.3  target enter data Construct
  2.14.4  target exit data Construct
  2.14.5  target Construct
  2.14.6  target update Construct
  2.14.7  Declare Target Directive
 2.15  Interoperability
  2.15.1  interop Construct
  2.15.2  Interoperability Requirement Set
 2.16  Combined Constructs
  2.16.1  Parallel Worksharing-Loop Construct
  2.16.2  parallel loop Construct
  2.16.3  parallel sections Construct
  2.16.4  parallel workshare Construct
  2.16.5  Parallel Worksharing-Loop SIMD Construct
  2.16.6  parallel masked Construct
  2.16.7  masked taskloop Construct
  2.16.8  masked taskloop simd Construct
  2.16.9  parallel masked taskloop Construct
  2.16.10  parallel masked taskloop simd Construct
  2.16.11  teams distribute Construct
  2.16.12  teams distribute simd Construct
  2.16.13  Teams Distribute Parallel Worksharing-Loop Construct
  2.16.14  Teams Distribute Parallel Worksharing-Loop SIMD Construct
  2.16.15  teams loop Construct
  2.16.16  target parallel Construct
  2.16.17  Target Parallel Worksharing-Loop Construct
  2.16.18  Target Parallel Worksharing-Loop SIMD Construct
  2.16.19  targetparallelloop Construct
  2.16.20  target simd Construct
  2.16.21  target teams Construct
  2.16.22  target teams distribute Construct
  2.16.23  target teams distribute simd Construct
  2.16.24  target teams loop Construct
  2.16.25  Target Teams Distribute Parallel Worksharing-Loop Construct
  2.16.26  Target Teams Distribute Parallel Worksharing-Loop SIMD Construct
 2.17  Clauses on Combined and Composite Constructs
 2.18  if Clause
 2.19  Synchronization Constructs and Clauses
  2.19.1  critical Construct
  2.19.2  barrier Construct
  2.19.3  Implicit Barriers
  2.19.4  Implementation-Specific Barriers
  2.19.5  taskwait Construct
  2.19.6  taskgroup Construct
  2.19.7  atomic Construct
  2.19.8  flush Construct
  2.19.9  ordered Construct
  2.19.10  Depend Objects
  2.19.11  depend Clause
  2.19.12  Synchronization Hints
 2.20  Cancellation Constructs
  2.20.1  cancel Construct
  2.20.2  cancellation point Construct
 2.21  Data Environment
  2.21.1  Data-Sharing Attribute Rules
  2.21.2  threadprivate Directive
  2.21.3  List Item Privatization
  2.21.4  Data-Sharing Attribute Clauses
  2.21.5  Reduction Clauses and Directives
  2.21.6  Data Copying Clauses
  2.21.7  Data-Mapping Attribute Rules, Clauses, and Directives
 2.22  Nesting of Regions