HOME
| OPENMP API Specification: "Version 5.2 -- GIT rev 95b2e3a44"

PIC

OpenMP
Application Programming
Interface

Copyright ©1997-2021 OpenMP Architecture Review Board.
Permission to copy without fee all or part of this material is granted, provided the OpenMP Architecture Review Board copyright notice and the title of this document appear. Notice is given that copying is by permission of the OpenMP Architecture Review Board.

This page intentionally left blank in published version.

Contents
List of Figures
List of Tables
1  Overview of the OpenMP API
 1.1  Scope
 1.2  Glossary
  1.2.1  Threading Concepts
  1.2.2  OpenMP Language Terminology
  1.2.3  Loop Terminology
  1.2.4  Synchronization Terminology
  1.2.5  Tasking Terminology
  1.2.6  Data Terminology
  1.2.7  Implementation Terminology
  1.2.8  Tool Terminology
 1.3  Execution Model
 1.4  Memory Model
  1.4.1  Structure of the OpenMP Memory Model
  1.4.2  Device Data Environments
  1.4.3  Memory Management
  1.4.4  The Flush Operation
  1.4.5  Flush Synchronization and Happens Before
  1.4.6  OpenMP Memory Consistency
 1.5  Tool Interfaces
  1.5.1  OMPT
  1.5.2  OMPD
 1.6  OpenMP Compliance
 1.7  Normative References
 1.8  Organization of this Document
2  Internal Control Variables
 2.1  ICV Descriptions
 2.2  ICV Initialization
 2.3  Modifying and Retrieving ICV Values
 2.4  How the Per-Data Environment ICVs Work
 2.5  ICV Override Relationships
3  Directive and Construct Syntax
 3.1  Directive Format
  3.1.1  Fixed Source Form Directives
  3.1.2  Free Source Form Directives
 3.2  Clause Format
  3.2.1  OpenMP Argument Lists
  3.2.2  Reserved Locators
  3.2.3  OpenMP Operations
  3.2.4  Array Shaping
  3.2.5  Array Sections
  3.2.6  iterator Modifier
 3.3  Conditional Compilation
  3.3.1  Fixed Source Form Conditional Compilation Sentinels
  3.3.2  Free Source Form Conditional Compilation Sentinel
 3.4  if Clause
 3.5  destroy Clause
4  Base Language Formats and Restrictions
 4.1  OpenMP Types and Identifiers
 4.2  OpenMP Stylized Expressions
 4.3  Structured Blocks
  4.3.1  OpenMP Context-Specific Structured Blocks
 4.4  Loop Concepts
  4.4.1  Canonical Loop Nest Form
  4.4.2  OpenMP Loop-Iteration Spaces and Vectors
  4.4.3  collapse Clause
  4.4.4  ordered Clause
  4.4.5  Consistent Loop Schedules
5  Data Environment
 5.1  Data-Sharing Attribute Rules
  5.1.1  Variables Referenced in a Construct
  5.1.2  Variables Referenced in a Region but not in a Construct
 5.2  threadprivate Directive
 5.3  List Item Privatization
 5.4  Data-Sharing Attribute Clauses
  5.4.1  default Clause
  5.4.2  shared Clause
  5.4.3  private Clause
  5.4.4  firstprivate Clause
  5.4.5  lastprivate Clause
  5.4.6  linear Clause
  5.4.7  is_device_ptr Clause
  5.4.8  use_device_ptr Clause
  5.4.9  has_device_addr Clause
  5.4.10  use_device_addr Clause
 5.5  Reduction Clauses and Directives
  5.5.1  OpenMP Reduction Identifiers
  5.5.2  OpenMP Reduction Expressions
  5.5.3  Implicitly Declared OpenMP Reduction Identifiers
  5.5.4  initializer Clause
  5.5.5  Properties Common to All Reduction Clauses
  5.5.6  Reduction Scoping Clauses
  5.5.7  Reduction Participating Clauses
  5.5.8  reduction Clause
  5.5.9  task_reduction Clause
  5.5.10  in_reduction Clause
  5.5.11  declare reduction Directive
 5.6  scan Directive
  5.6.1  inclusive Clause
  5.6.2  exclusive Clause
 5.7  Data Copying Clauses
  5.7.1  copyin Clause
  5.7.2  copyprivate Clause
 5.8  Data-Mapping Control
  5.8.1  Implicit Data-Mapping Attribute Rules
  5.8.2  Mapper Identifiers and mapper Modifiers
  5.8.3  map Clause
  5.8.4  enter Clause
  5.8.5  link Clause
  5.8.6  Pointer Initialization for Device Data Environments
  5.8.7  defaultmap Clause
  5.8.8  declare mapper Directive
 5.9  Data-Motion Clauses
  5.9.1  to Clause
  5.9.2  from Clause
 5.10  uniform Clause
 5.11  aligned Clause
6  Memory Management
 6.1  Memory Spaces
 6.2  Memory Allocators
 6.3  align Clause
 6.4  allocator Clause
 6.5  allocate Directive
 6.6  allocate Clause
 6.7  allocators Construct
 6.8  uses_allocators Clause
7  Variant Directives
 7.1  OpenMP Contexts
 7.2  Context Selectors
 7.3  Matching and Scoring Context Selectors
 7.4  Metadirectives
  7.4.1  when Clause
  7.4.2  otherwise Clause
  7.4.3  metadirective
  7.4.4  begin metadirective
 7.5  Declare Variant Directives
  7.5.1  match Clause
  7.5.2  adjust_args Clause
  7.5.3  append_args Clause
  7.5.4  declare variant Directive
  7.5.5  begin declare variant Directive
 7.6  dispatch Construct
  7.6.1  novariants Clause
  7.6.2  nocontext Clause
 7.7  declare simd Directive
  7.7.1  branch Clauses
 7.8  Declare Target Directives
  7.8.1  declare target Directive
  7.8.2  begin declare target Directive
  7.8.3  indirect Clause
8  Informational and Utility Directives
 8.1  at Clause
 8.2  requires Directive
  8.2.1  requirement Clauses
 8.3  Assumption Directives
  8.3.1  assumption Clauses
  8.3.2  assumes Directive
  8.3.3  assume Directive
  8.3.4  begin assumes Directive
 8.4  nothing Directive
 8.5  error Directive
  8.5.1  severity Clause
  8.5.2  message Clause
9  Loop Transformation Constructs
 9.1  tile Construct
  9.1.1  sizes Clause
 9.2  unroll Construct
  9.2.1  full Clause
  9.2.2  partial Clause
10  Parallelism Generation and Control
 10.1  parallel Construct
  10.1.1  Determining the Number of Threads for a parallel Region
  10.1.2  num_threads Clause
  10.1.3  Controlling OpenMP Thread Affinity
  10.1.4  proc_bind Clause
 10.2  teams Construct
  10.2.1  num_teams Clause
 10.3  order Clause
 10.4  simd Construct
  10.4.1  nontemporal Clause
  10.4.2  safelen Clause
  10.4.3  simdlen Clause
 10.5  masked Construct
  10.5.1  filter Clause
11  Work-Distribution Constructs
 11.1  single Construct
 11.2  scope Construct
 11.3  sections Construct
  11.3.1  section Directive
 11.4  workshare Construct
 11.5  Worksharing-Loop Constructs
  11.5.1  for Construct
  11.5.2  do Construct
  11.5.3  schedule Clause
 11.6  distribute Construct
  11.6.1  dist_schedule Clause
 11.7  loop Construct
  11.7.1  bind Clause
12  Tasking Constructs
 12.1  untied Clause
 12.2  mergeable Clause
 12.3  final Clause
 12.4  priority Clause
 12.5  task Construct
  12.5.1  affinity Clause
  12.5.2  detach Clause
 12.6  taskloop Construct
  12.6.1  grainsize Clause
  12.6.2  num_tasks Clause
 12.7  taskyield Construct
 12.8  Initial Task
 12.9  Task Scheduling
13  Device Directives and Clauses
 13.1  device_type Clause
 13.2  device Clause
 13.3  thread_limit Clause
 13.4  Device Initialization
 13.5  target data Construct
 13.6  target enter data Construct
 13.7  target exit data Construct
 13.8  target Construct
 13.9  target update Construct
14  Interoperability
 14.1  interop Construct
  14.1.1  OpenMP Foreign Runtime Identifiers
  14.1.2  init Clause
  14.1.3  use Clause
 14.2  Interoperability Requirement Set
15  Synchronization Constructs and Clauses
 15.1  Synchronization Hints
  15.1.1  Synchronization Hint Type
  15.1.2  hint Clause
 15.2  critical Construct
 15.3  Barriers
  15.3.1  barrier Construct
  15.3.2  Implicit Barriers
  15.3.3  Implementation-Specific Barriers
 15.4  taskgroup Construct
 15.5  taskwait Construct
 15.6  nowait Clause
 15.7  nogroup Clause
 15.8  OpenMP Memory Ordering
  15.8.1  memory-order Clauses
  15.8.2  atomic Clauses
  15.8.3  extended-atomic Clauses
  15.8.4  atomic Construct
  15.8.5  flush Construct
  15.8.6  Implicit Flushes
 15.9  OpenMP Dependences
  15.9.1  task-dependence-type Modifier
  15.9.2  Depend Objects
  15.9.3  update Clause
  15.9.4  depobj Construct
  15.9.5  depend Clause
  15.9.6  doacross Clause
 15.10  ordered Construct
  15.10.1  Stand-alone ordered Construct
  15.10.2  Block-associated ordered Construct
  15.10.3  parallelization-level Clauses
16  Cancellation Constructs
 16.1  cancel Construct
 16.2  cancellation point Construct
17  Composition of Constructs
 17.1  Nesting of Regions
 17.2  Clauses on Combined and Composite Constructs
 17.3  Combined and Composite Directive Names
 17.4  Combined Construct Semantics
 17.5  Composite Construct Semantics
18  Runtime Library Routines
 18.1  Runtime Library Definitions
 18.2  Thread Team Routines
  18.2.1  omp_set_num_threads
  18.2.2  omp_get_num_threads
  18.2.3  omp_get_max_threads
  18.2.4  omp_get_thread_num
  18.2.5  omp_in_parallel
  18.2.6  omp_set_dynamic
  18.2.7  omp_get_dynamic
  18.2.8  omp_get_cancellation
  18.2.9  omp_set_nested (Deprecated)
  18.2.10  omp_get_nested (Deprecated)
  18.2.11  omp_set_schedule
  18.2.12  omp_get_schedule
  18.2.13  omp_get_thread_limit
  18.2.14  omp_get_supported_active_levels
  18.2.15  omp_set_max_active_levels
  18.2.16  omp_get_max_active_levels
  18.2.17  omp_get_level
  18.2.18  omp_get_ancestor_thread_num
  18.2.19  omp_get_team_size
  18.2.20  omp_get_active_level
 18.3  Thread Affinity Routines
  18.3.1  omp_get_proc_bind
  18.3.2  omp_get_num_places
  18.3.3  omp_get_place_num_procs
  18.3.4  omp_get_place_proc_ids
  18.3.5  omp_get_place_num
  18.3.6  omp_get_partition_num_places
  18.3.7  omp_get_partition_place_nums
  18.3.8  omp_set_affinity_format
  18.3.9  omp_get_affinity_format
  18.3.10  omp_display_affinity
  18.3.11  omp_capture_affinity
 18.4  Teams Region Routines
  18.4.1  omp_get_num_teams
  18.4.2  omp_get_team_num
  18.4.3  omp_set_num_teams
  18.4.4  omp_get_max_teams
  18.4.5  omp_set_teams_thread_limit
  18.4.6  omp_get_teams_thread_limit
 18.5  Tasking Routines
  18.5.1  omp_get_max_task_priority
  18.5.2  omp_in_explicit_task
  18.5.3  omp_in_final
 18.6  Resource Relinquishing Routines
  18.6.1  omp_pause_resource
  18.6.2  omp_pause_resource_all
 18.7  Device Information Routines
  18.7.1  omp_get_num_procs
  18.7.2  omp_set_default_device
  18.7.3  omp_get_default_device
  18.7.4  omp_get_num_devices
  18.7.5  omp_get_device_num
  18.7.6  omp_is_initial_device
  18.7.7  omp_get_initial_device
 18.8  Device Memory Routines
  18.8.1  omp_target_alloc
  18.8.2  omp_target_free
  18.8.3  omp_target_is_present
  18.8.4  omp_target_is_accessible
  18.8.5  omp_target_memcpy
  18.8.6  omp_target_memcpy_rect
  18.8.7  omp_target_memcpy_async
  18.8.8  omp_target_memcpy_rect_async
  18.8.9  omp_target_associate_ptr
  18.8.10  omp_target_disassociate_ptr
  18.8.11  omp_get_mapped_ptr
 18.9  Lock Routines
  18.9.1  omp_init_lock and omp_init_nest_lock
  18.9.2  omp_init_lock_with_hint and omp_init_nest_lock_with_hint
  18.9.3  omp_destroy_lock and omp_destroy_nest_lock
  18.9.4  omp_set_lock and omp_set_nest_lock
  18.9.5  omp_unset_lock and omp_unset_nest_lock
  18.9.6  omp_test_lock and omp_test_nest_lock
 18.10  Timing Routines
  18.10.1  omp_get_wtime
  18.10.2  omp_get_wtick
 18.11  Event Routine
  18.11.1  omp_fulfill_event
 18.12  Interoperability Routines
  18.12.1  omp_get_num_interop_properties
  18.12.2  omp_get_interop_int
  18.12.3  omp_get_interop_ptr
  18.12.4  omp_get_interop_str
  18.12.5  omp_get_interop_name
  18.12.6  omp_get_interop_type_desc
  18.12.7  omp_get_interop_rc_desc
 18.13  Memory Management Routines
  18.13.1  Memory Management Types
  18.13.2  omp_init_allocator
  18.13.3  omp_destroy_allocator
  18.13.4  omp_set_default_allocator
  18.13.5  omp_get_default_allocator
  18.13.6  omp_alloc and omp_aligned_alloc
  18.13.7  omp_free
  18.13.8  omp_calloc and omp_aligned_calloc
  18.13.9  omp_realloc
 18.14  Tool Control Routine
 18.15  Environment Display Routine
19  OMPT Interface
 19.1  OMPT Interfaces Definitions
 19.2  Activating a First-Party Tool
  19.2.1  ompt_start_tool
  19.2.2  Determining Whether a First-Party Tool Should be Initialized
  19.2.3  Initializing a First-Party Tool
  19.2.4  Monitoring Activity on the Host with OMPT
  19.2.5  Tracing Activity on Target Devices with OMPT
 19.3  Finalizing a First-Party Tool
 19.4  OMPT Data Types
  19.4.1  Tool Initialization and Finalization
  19.4.2  Callbacks
  19.4.3  Tracing
  19.4.4  Miscellaneous Type Definitions
 19.5  OMPT Tool Callback Signatures and Trace Records
  19.5.1  Initialization and Finalization Callback Signature
  19.5.2  Event Callback Signatures and Trace Records
 19.6  OMPT Runtime Entry Points for Tools
  19.6.1  Entry Points in the OMPT Callback Interface
  19.6.2  Entry Points in the OMPT Device Tracing Interface
  19.6.3  Lookup Entry Points: ompt_function_lookup_t
20  OMPD Interface
 20.1  OMPD Interfaces Definitions
 20.2  Activating a Third-Party Tool
  20.2.1  Enabling Runtime Support for OMPD
  20.2.2  ompd_dll_locations
  20.2.3  ompd_dll_locations_valid
 20.3  OMPD Data Types
  20.3.1  Size Type
  20.3.2  Wait ID Type
  20.3.3  Basic Value Types
  20.3.4  Address Type
  20.3.5  Frame Information Type
  20.3.6  System Device Identifiers
  20.3.7  Native Thread Identifiers
  20.3.8  OMPD Handle Types
  20.3.9  OMPD Scope Types
  20.3.10  ICV ID Type
  20.3.11  Tool Context Types
  20.3.12  Return Code Types
  20.3.13  Primitive Type Sizes
 20.4  OMPD Third-Party Tool Callback Interface
  20.4.1  Memory Management of OMPD Library
  20.4.2  Context Management and Navigation
  20.4.3  Accessing Memory in the OpenMP Program or Runtime
  20.4.4  Data Format Conversion: ompd_callback_device_host_fn_t
  20.4.5  ompd_callback_print_string_fn_t
  20.4.6  The Callback Interface
 20.5  OMPD Tool Interface Routines
  20.5.1  Per OMPD Library Initialization and Finalization
  20.5.2  Per OpenMP Process Initialization and Finalization
  20.5.3  Thread and Signal Safety
  20.5.4  Address Space Information
  20.5.5  Thread Handles
  20.5.6  Parallel Region Handles
  20.5.7  Task Handles
  20.5.8  Querying Thread States
  20.5.9  Display Control Variables
  20.5.10  Accessing Scope-Specific Information
 20.6  Runtime Entry Points for OMPD
  20.6.1  Beginning Parallel Regions
  20.6.2  Ending Parallel Regions
  20.6.3  Beginning Task Regions
  20.6.4  Ending Task Regions
  20.6.5  Beginning OpenMP Threads
  20.6.6  Ending OpenMP Threads
  20.6.7  Initializing OpenMP Devices
  20.6.8  Finalizing OpenMP Devices
21  Environment Variables
 21.1  Parallel Region Environment Variables
  21.1.1  OMP_DYNAMIC
  21.1.2  OMP_NUM_THREADS
  21.1.3  OMP_THREAD_LIMIT
  21.1.4  OMP_MAX_ACTIVE_LEVELS
  21.1.5  OMP_NESTED (Deprecated)
  21.1.6  OMP_PLACES
  21.1.7  OMP_PROC_BIND
 21.2  Program Execution Environment Variables
  21.2.1  OMP_SCHEDULE
  21.2.2  OMP_STACKSIZE
  21.2.3  OMP_WAIT_POLICY
  21.2.4  OMP_DISPLAY_AFFINITY
  21.2.5  OMP_AFFINITY_FORMAT
  21.2.6  OMP_CANCELLATION
  21.2.7  OMP_DEFAULT_DEVICE
  21.2.8  OMP_TARGET_OFFLOAD
  21.2.9  OMP_MAX_TASK_PRIORITY
 21.3  OMPT Environment Variables
  21.3.1  OMP_TOOL
  21.3.2  OMP_TOOL_LIBRARIES
  21.3.3  OMP_TOOL_VERBOSE_INIT
 21.4  OMPD Environment Variables
  21.4.1  OMP_DEBUG
 21.5  Memory Allocation Environment Variables
  21.5.1  OMP_ALLOCATOR
 21.6  Teams Environment Variables
  21.6.1  OMP_NUM_TEAMS
  21.6.2  OMP_TEAMS_THREAD_LIMIT
 21.7  OMP_DISPLAY_ENV
A  OpenMP Implementation-Defined Behaviors
B  Features History
 B.1  Deprecated Features
 B.2  Version 5.1 to 5.2 Differences
 B.3  Version 5.0 to 5.1 Differences
 B.4  Version 4.5 to 5.0 Differences
 B.5  Version 4.0 to 4.5 Differences
 B.6  Version 3.1 to 4.0 Differences
 B.7  Version 3.0 to 3.1 Differences
 B.8  Version 2.5 to 3.0 Differences