HOME
| OPENMP API Specification: Version 5.1 November 2020

PIC

OpenMP
Application Programming
Interface

This HTML version of the specification is a translation from the official PDF specification. If the translation process has introduced any differences, the official PDF version takes precedent.

Copyright 1997-2020 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  Directives
 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
3  Runtime Library Routines
 3.1  Runtime Library Definitions
 3.2  Thread Team Routines
  3.2.1  omp_set_num_threads
  3.2.2  omp_get_num_threads
  3.2.3  omp_get_max_threads
  3.2.4  omp_get_thread_num
  3.2.5  omp_in_parallel
  3.2.6  omp_set_dynamic
  3.2.7  omp_get_dynamic
  3.2.8  omp_get_cancellation
  3.2.9  omp_set_nested (Deprecated)
  3.2.10  omp_get_nested (Deprecated)
  3.2.11  omp_set_schedule
  3.2.12  omp_get_schedule
  3.2.13  omp_get_thread_limit
  3.2.14  omp_get_supported_active_levels
  3.2.15  omp_set_max_active_levels
  3.2.16  omp_get_max_active_levels
  3.2.17  omp_get_level
  3.2.18  omp_get_ancestor_thread_num
  3.2.19  omp_get_team_size
  3.2.20  omp_get_active_level
 3.3  Thread Affinity Routines
  3.3.1  omp_get_proc_bind
  3.3.2  omp_get_num_places
  3.3.3  omp_get_place_num_procs
  3.3.4  omp_get_place_proc_ids
  3.3.5  omp_get_place_num
  3.3.6  omp_get_partition_num_places
  3.3.7  omp_get_partition_place_nums
  3.3.8  omp_set_affinity_format
  3.3.9  omp_get_affinity_format
  3.3.10  omp_display_affinity
  3.3.11  omp_capture_affinity
 3.4  Teams Region Routines
  3.4.1  omp_get_num_teams
  3.4.2  omp_get_team_num
  3.4.3  omp_set_num_teams
  3.4.4  omp_get_max_teams
  3.4.5  omp_set_teams_thread_limit
  3.4.6  omp_get_teams_thread_limit
 3.5  Tasking Routines
  3.5.1  omp_get_max_task_priority
  3.5.2  omp_in_final
 3.6  Resource Relinquishing Routines
  3.6.1  omp_pause_resource
  3.6.2  omp_pause_resource_all
 3.7  Device Information Routines
  3.7.1  omp_get_num_procs
  3.7.2  omp_set_default_device
  3.7.3  omp_get_default_device
  3.7.4  omp_get_num_devices
  3.7.5  omp_get_device_num
  3.7.6  omp_is_initial_device
  3.7.7  omp_get_initial_device
 3.8  Device Memory Routines
  3.8.1  omp_target_alloc
  3.8.2  omp_target_free
  3.8.3  omp_target_is_present
  3.8.4  omp_target_is_accessible
  3.8.5  omp_target_memcpy
  3.8.6  omp_target_memcpy_rect
  3.8.7  omp_target_memcpy_async
  3.8.8  omp_target_memcpy_rect_async
  3.8.9  omp_target_associate_ptr
  3.8.10  omp_target_disassociate_ptr
  3.8.11  omp_get_mapped_ptr
 3.9  Lock Routines
  3.9.1  omp_init_lock and omp_init_nest_lock
  3.9.2  omp_init_lock_with_hint and
omp_init_nest_lock_with_hint

  3.9.3  omp_destroy_lock and omp_destroy_nest_lock
  3.9.4  omp_set_lock and omp_set_nest_lock
  3.9.5  omp_unset_lock and omp_unset_nest_lock
  3.9.6  omp_test_lock and omp_test_nest_lock
 3.10  Timing Routines
  3.10.1  omp_get_wtime
  3.10.2  omp_get_wtick
 3.11  Event Routine
  3.11.1  omp_fulfill_event
 3.12  Interoperability Routines
  3.12.1  omp_get_num_interop_properties
  3.12.2  omp_get_interop_int
  3.12.3  omp_get_interop_ptr
  3.12.4  omp_get_interop_str
  3.12.5  omp_get_interop_name
  3.12.6  omp_get_interop_type_desc
  3.12.7  omp_get_interop_rc_desc
 3.13  Memory Management Routines
  3.13.1  Memory Management Types
  3.13.2  omp_init_allocator
  3.13.3  omp_destroy_allocator
  3.13.4  omp_set_default_allocator
  3.13.5  omp_get_default_allocator
  3.13.6  omp_alloc and omp_aligned_alloc
  3.13.7  omp_free
  3.13.8  omp_calloc and omp_aligned_calloc
  3.13.9  omp_realloc
 3.14  Tool Control Routine
 3.15  Environment Display Routine
4  OMPT Interface
 4.1  OMPT Interfaces Definitions
 4.2  Activating a First-Party Tool
  4.2.1  ompt_start_tool
  4.2.2  Determining Whether a First-Party Tool Should be Initialized
  4.2.3  Initializing a First-Party Tool
  4.2.4  Monitoring Activity on the Host with OMPT
  4.2.5  Tracing Activity on Target Devices with OMPT
 4.3  Finalizing a First-Party Tool
 4.4  OMPT Data Types
  4.4.1  Tool Initialization and Finalization
  4.4.2  Callbacks
  4.4.3  Tracing
  4.4.4  Miscellaneous Type Definitions
 4.5  OMPT Tool Callback Signatures and Trace Records
  4.5.1  Initialization and Finalization Callback Signature
  4.5.2  Event Callback Signatures and Trace Records
 4.6  OMPT Runtime Entry Points for Tools
  4.6.1  Entry Points in the OMPT Callback Interface
  4.6.2  Entry Points in the OMPT Device Tracing Interface
  4.6.3  Lookup Entry Points: ompt_function_lookup_t
5  OMPD Interface
 5.1  OMPD Interfaces Definitions
 5.2  Activating a Third-Party Tool
  5.2.1  Enabling Runtime Support for OMPD
  5.2.2  ompd_dll_locations
  5.2.3  ompd_dll_locations_valid
 5.3  OMPD Data Types
  5.3.1  Size Type
  5.3.2  Wait ID Type
  5.3.3  Basic Value Types
  5.3.4  Address Type
  5.3.5  Frame Information Type
  5.3.6  System Device Identifiers
  5.3.7  Native Thread Identifiers
  5.3.8  OMPD Handle Types
  5.3.9  OMPD Scope Types
  5.3.10  ICV ID Type
  5.3.11  Tool Context Types
  5.3.12  Return Code Types
  5.3.13  Primitive Type Sizes
 5.4  OMPD Third-Party Tool Callback Interface
  5.4.1  Memory Management of OMPD Library
  5.4.2  Context Management and Navigation
  5.4.3  Accessing Memory in the OpenMP Program or Runtime
  5.4.4  Data Format Conversion: ompd_callback_device_host_fn_t
  5.4.5  ompd_callback_print_string_fn_t
  5.4.6  The Callback Interface
 5.5  OMPD Tool Interface Routines
  5.5.1  Per OMPD Library Initialization and Finalization
  5.5.2  Per OpenMP Process Initialization and Finalization
  5.5.3  Thread and Signal Safety
  5.5.4  Address Space Information
  5.5.5  Thread Handles
  5.5.6  Parallel Region Handles
  5.5.7  Task Handles
  5.5.8  Display Control Variables
  5.5.9  Accessing Scope-Specific Information
 5.6  Runtime Entry Points for OMPD
  5.6.1  Beginning Parallel Regions
  5.6.2  Ending Parallel Regions
  5.6.3  Beginning Task Regions
  5.6.4  Ending Task Regions
  5.6.5  Beginning OpenMP Threads
  5.6.6  Ending OpenMP Threads
  5.6.7  Initializing OpenMP Devices
  5.6.8  Finalizing OpenMP Devices
6  Environment Variables
 6.1  OMP_SCHEDULE
 6.2  OMP_NUM_THREADS
 6.3  OMP_DYNAMIC
 6.4  OMP_PROC_BIND
 6.5  OMP_PLACES
 6.6  OMP_STACKSIZE
 6.7  OMP_WAIT_POLICY
 6.8  OMP_MAX_ACTIVE_LEVELS
 6.9  OMP_NESTED (Deprecated)
 6.10  OMP_THREAD_LIMIT
 6.11  OMP_CANCELLATION
 6.12  OMP_DISPLAY_ENV
 6.13  OMP_DISPLAY_AFFINITY
 6.14  OMP_AFFINITY_FORMAT
 6.15  OMP_DEFAULT_DEVICE
 6.16  OMP_MAX_TASK_PRIORITY
 6.17  OMP_TARGET_OFFLOAD
 6.18  OMP_TOOL
 6.19  OMP_TOOL_LIBRARIES
 6.20  OMP_TOOL_VERBOSE_INIT
 6.21  OMP_DEBUG
 6.22  OMP_ALLOCATOR
 6.23  OMP_NUM_TEAMS
 6.24  OMP_TEAMS_THREAD_LIMIT
A  OpenMP Implementation-Defined Behaviors
B  Features History
 B.1  Deprecated Features
 B.2  Version 5.0 to 5.1 Differences
 B.3  Version 4.5 to 5.0 Differences
 B.4  Version 4.0 to 4.5 Differences
 B.5  Version 3.1 to 4.0 Differences
 B.6  Version 3.0 to 3.1 Differences
 B.7  Version 2.5 to 3.0 Differences

[next]