0% found this document useful (0 votes)
70 views16 pages

Getting Started: Openmp 5.2 Api Syntax Reference Guide

Uploaded by

Anis Salhi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views16 pages

Getting Started: Openmp 5.2 Api Syntax Reference Guide

Uploaded by

Anis Salhi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

OpenMP API 5.

2 www.openmp.org Page 1

OpenMP 5.2 API Syntax Reference Guide


The OpenMP® API is a scalable model that OpenMP is suitable for a wide range of
®
gives parallel programmers a simple and algorithms running on multicore nodes and
openmp.org flexible interface for developing portable chips, NUMA systems, GPUs, and other such
parallel applications in C/C++ and Fortran. devices attached to a CPU.
C/C++ C/C++ content | Fortran or For Fortran content | [n.n.n] Sections in 5.2. spec | [n.n.n] Sections in 5.1. spec | 9 See Clause info on pg. 9

Getting Started
Navigating this reference guide OpenMP directive syntax
Directives and Constructs ....... 1 Environment Variables ...... 14 A directive is a combination of the base-language
Clauses ................................... 9 ICV values .......................... 15 Examples:
Runtime Library Routines ..... 10 Using OpenMP Tools ......... 16 mechanism and a directive-specification (the directive- C/C++ #pragma omp directive-specification
name followed by optional clauses). A construct consists
of a directive and, often, additional base language code. C++ [[omp :: directive( directive-specification )]]
OpenMP Examples Document C++ [[using omp : directive( directive-specification )]]
C/C++ C directives are formed exclusively with pragmas.
An Examples Document and a link to a GitHub repository C++ directives are formed from either pragmas or attributes. For !$omp directive-specification
with code samples is at link.openmp.org/examples51. For !$omp directive-specification
Fortran Fortran directives are formed with comments in
!$omp end directive-name
free form and fixed form sources (codes).

Directives and Constructs


OpenMP constructs consist of a directive and, if defined in the syntax, an associated structured block that follows. • OpenMP directives except simd and any
declarative directive may not appear in Fortran PURE procedures. • structured-block is a construct or block of executable statements with a single entry at the top
and a single exit at the bottom. • strictly-structured-block is a structured block that is a Fortran BLOCK construct. • loosely-structured-block is a structured block that
isn't strictly structured and doesn't start with a Fortran BLOCK construct. • omp-integer-expression is of a C/C++ scalar int type or Fortran scalar integer type.
• omp-logical-expression is a C/C++ scalar expression or Fortran logical expression.

Data environment directives scan [5.6] [2.11.8] allocate [6.6] [2.13.3]


threadprivate [5.2] [2.21.2] Specifies that scan computations update the list items on Specifies how a set of variables is allocated.
each iteration of an enclosing loop nest associated with a
Specifies that variables are replicated, with each thread

Fortran C/C++
worksharing-loop, worksharing-loop SIMD, or simd directive. #pragma omp allocate (list) [clause[ [, ]clause] ... ]
having its own copy. Each copy of a threadprivate variable
is initialized once prior to the first reference to that copy. {
structured-block-sequence !$omp allocate (list) [clause[ [,]clause] ... ]
C/C++

#pragma omp scan clause


Fortran C/C++

#pragma omp threadprivate (list) structured-block-sequence


} clause:
align (alignment)
!$omp threadprivate (list) structured-block-sequence
Fortran

!$omp scan clause alignment: An integer power of 2.


list: structured-block-sequence allocator (allocator)
C/C++ A comma-separated list of file-scope, clause: allocator:
namespace-scope, or static block-scope variables exclusive (list) C/C++ type omp_allocator_handle_t
that do not have incomplete types. inclusive (list) For kind omp_allocator_handle_kind
For A comma-separated list of named variables
and named common blocks. Common block declare mapper [5.8.8] [2.21.7.4] allocators [6.7]
names must appear between slashes. Declares a user-defined mapper for a given type, and may Specifies that OpenMP memory allocators are used for
define a mapper-identifier for use in a map clause. certain variables that are allocated by the associated
declare reduction [5.5.11] [2.21.5.7] #pragma omp declare mapper ([mapper-identifier : ] \
allocate-stmt.
Fortran C/C++

Declares a reduction-identifier that can be used in a type var) [clause[ [,] clause] ... ] !$omp allocators [clause[ [, ]clause] ... ]
Fortran

reduction, in_reduction, or task_reduction clause. allocate-stmt


!$omp declare mapper ([mapper-identifier: ]type :: var) & [ !$omp end allocators ]
#pragma omp declare reduction ( \ [clause[ [,] clause] ... ]
C/C++

reduction-identifier : typename-list : combiner) \ clause: allocate 9


[initializer-clause] clause: allocate-stmt: A Fortran ALLOCATE statement.
!$omp declare reduction & map ([ [map-modifier, [map-modifier, ... ] ]
Fortran

map-type : ] list) 9
(reduction-identifier : type-list : combiner)
map-type: alloc, from, to, tofrom
Variant directives
[initializer-clause]
combiner: map-modifier: always, close, present, mapper(default), [begin ]metadirective [7.4.3, 7.4.4] [2.3.4]
C/C++ An expression iterator(iterator-definitions) A directive that can specify multiple directive variants,
one of which may be conditionally selected to replace the
For An assignment statement or a subroutine mapper-identifier: metadirective based on the enclosing OpenMP context.
name followed by an argument list. A base-language identifier or default 9
#pragma omp metadirective [clause[ [,] clause] ... ]
initializer-clause: initializer (initializer-expr) type: A valid type in scope - or -
C/C++

initializer-expr: omp_priv = initializer or var: A valid base-language identifier #pragma omp begin metadirective [clause[ [,] clause] ... ]
function-name (argument-list) stmt(s)
reduction-identifier: Memory management directives #pragma omp end metadirective
C/C++ A base language identifier (for C), or an !$omp metadirective [clause[ [,] clause] ... ]
id-expression (for C++), or one of the following Memory spaces [6.1] [2.13.1] - or -
Fortran

operators: +, *, &, |, ^, &&, || Predefined memory spaces represent storage resources


for storage and retrieval of variables. !$omp begin metadirective [clause[ [,] clause] ... ]
For A base language identifier, user-defined Memory space Storage selection intent
stmt(s)
operator, or one of the following operators: +, *, !$omp end metadirective
omp_default_mem_space Default storage clause:
.and., .or., .eqv., .negv.; or one of the following
intrinsic procedure names: max, min, iand, ior, omp_large_cap_mem_space Large capacity when (context-selector-specification: [directive-variant])
ieor. omp_const_mem_space Variables with constant values Conditionally select a directive variant.
C/C++ typename-list: A list of type names omp_high_bw_mem_space High bandwidth otherwise ([directive-variant])
For type-list: A list of type specifiers that must not be omp_low_lat_mem_space Low latency Conditionally select a directive variant. otherwise
was named default in previous versions. Continued
CLASS(*) or abstract type. 4
© 2021 OpenMP ARB OMP1121
OpenMP API 5.2 C/C++ C/C++ content | Fortran or For Fortran content | [n.n.n] Sections in 5.2. spec | [n.n.n] Sections in 5.1. spec | 9 See Clause info on pg. 9 2

Directives and Constructs (continued)


[begin ]declare variant [7.5.4-5] [2.3.5] declare simd [7.7] [2.11.5.3] Informational and utility directives
Declares a specialized variant of a base function and the Applied to a function or subroutine to enable creation of requires [8.2] [2.5.1]
context in which it is used. one or more versions to process multiple arguments using
SIMD instructions from a single invocation in a SIMD loop. Specifies the features that an implementation must provide
#pragma omp declare variant(variant-func-id) \ in order for the code to compile and to execute correctly.
clause [[ [,] clause] ... ] #pragma omp declare simd [clause[ [,]clause] ... ]

Fortran C/C++
[#pragma omp declare variant(variant-func-id) \ #pragma omp requires clause [ [ [,] clause] ... ]

C/C++
clause [[ [,] clause] ... ] [#pragma omp declare simd [clause[ [, clause] ... ] ]
[ ... ]] [... ]
C/C++

function definition or declaration function definition or declaration !$omp requires clause [ [ [,] clause] ... ]
- or -

Fortran
!$omp declare simd [(proc-name)] [clause[ [,]clause] ... ] clause:
#pragma omp begin declare variant clause-match atomic_default_mem_order (seq_cst | acq_rel | relaxed)
declaration-definition-seq
#pragma omp end declare variant clause: dynamic_allocators
aligned (argument-list[ : alignment]) Enables memory allocators to be used in a target
Fortran

!$omp declare variant ([base-proc-name : ] & Declares one or more list items to be aligned to region without specifying the uses_allocators
variant-proc-name) clause [[ [,] clause] ... ] the specified number of bytes. clause on the corresponding target construct.
(See target on page 5 of this guide.)
clause: alignment: Optional constant positive integer
adjust_args (adjust-op : argument-list) expression reverse_offload
adjust-op: nothing, need_device_ptr inbranch Requires an implementation to guarantee that
linear (linear-list[ : linear-step]) 9 if a target construct specifies a device clause in
append_args (append-op[[, append-op ]... ]) which the ancestor modifier appears, the target
append-op: interop ( notinbranch
region can execute on the parent device of an
interop-type[ [ , interop-type ]... ]) simdlen (length)
enclosing target region. (See target on page 5.)
enter Specifies the preferred number of iterations to
be executed concurrently. unified_address
link Requires that all devices accessible through
match (context-selector-specification) uniform (argument-list)
OpenMP API routines and directives use a
REQUIRED. Specifies how to adjust the Declares arguments to have an invariant value unified address space.
arguments of the base function when a specified for all concurrent invocations of the function in
the execution of a single SIMD loop. unified_shared_memory
variant function is selected for replacement.
Guarantees that in addition to the requirement
C/C++ variant-func-id of unified_address, storage locations in memory
The name of a function variant that is a base [begin ]declare target [7.8.1-2] [2.14.7] are accessible to threads on all available devices.
language identifier, or for C++, a template-id. A declarative directive that specifies that variables,
functions, and subroutines are mapped to a device.
For variant-proc-name assume, [begin ]assumes [8.3.2-4] [2.5.2]
#pragma omp declare target (extended-list) Provides invariants to the implementation that may be
The name of a function variant that is a base
language identifier. - or - used for optimization purposes.
#pragma omp declare target clause[ [,]clause ... ]
clause-match: #pragma omp assumes clause [ [ [,] clause] ... ]
C/C++

- or -
match (context-selector-specification) - or -
REQUIRED match clause #pragma omp begin declare target \
[clause[[,]clause] ... ] #pragma omp begin assumes clause [ [ [,] clause] ... ]
declaration-definition-seq
C/C++

declarations-definition-seq
dispatch [7.6] [2.3.6] #pragma omp end declare target #pragma omp end assumes
Controls whether variant substitution occurs for a function !$omp declare target (extended-list) - or -
Fortran

call in the structured block. - or - #pragma omp assume clause [ [ [,] clause] ... ]
structured-block
#pragma omp dispatch [clause [ [,] clause] ... ] !$omp declare target [clause[ [,]clause] ...]
C/C++

function-dispatch-structured-block clause: !$omp assumes clause [ [ [,] clause] ... ]


device_type (host | nohost | any) - or -
!$omp dispatch [clause [ [,] clause] ... ]
Fortran

enter (extended-list) !$omp assume clause [ [ [,] clause] ... ]


function-dispatch-structured-block
[!$omp end dispatch] A comma-separated list of named variables, loosely-structured-block
Fortran

clause: procedure names, and named common blocks. !$omp end assume
depend ([depend-modifier, ] dependence-type : locator-list) indirect[(invoked-by-fptr)] - or -
9 Determines if the procedures in an enter clause !$omp assume clause [ [ [,] clause] ... ]
device (omp-integer-expression) 9 may be invoked indirectly. strictly-structured-block
Identifies the target device that is associated link (list) [ !$omp end assume]
with a device construct.
Supports compilation of functions called in a clause:
is_device_ptr (list) target region that refer to the list items. absent (directive-name [ [, directive-name] ... ])
list: device pointers Lists directives absent in the scope.
nocontext (omp-logical-expression) • For the second C/C++ form of declare target, at least
one clause must be enter or link. contains (directive-name [ [, directive-name] ... ])
If omp-logical-expression evaluates to true, the Lists directives likely to be in the scope.
construct is not added to the construct set of • For begin declare target, the enter and link clauses
the OpenMP context. holds (omp-logical-expression)
are not permitted.
An expression guaranteed to be true in the
novariants (omp-logical-expression)
scope.
If omp-logical-expression evaluates to true, no
function variant is selected for the call in the no_openmp
applicable dispatch region. Indicates that no OpenMP code is in the scope.
nowait 9 no_openmp_routines
Indicates that no OpenMP runtime library calls
are executed in the scope.
no_parallelism
Indicates that no OpenMP tasks or SIMD
constructs will be executed in the scope.

4
Continued

© 2021 OpenMP ARB www.openmp.org OMPSC21


OpenMP API 5.2 C/C++ C/C++ content | Fortran or For Fortran content | [n.n.n] Sections in 5.2. spec | [n.n.n] Sections in 5.1. spec | 9 See Clause info on pg. 9 3

Directives and Constructs (continued)


nothing [8.4] [2.5.3] teams [10.2] [2.7] Work-distribution constructs
Indicates explicitly that the intent is to have no effect. Creates a league of initial teams where the initial thread single [11.1] [2.10.2]
of each team executes the region.
Specifies that the associated structured block is executed
Fortran C/C++

#pragma omp nothing #pragma omp teams [clause[ [,]clause] ... ] by only one of the threads in the team.

C/C++
structured-block
#pragma omp single [clause[ [,]clause] ... ]

C/C++
!$omp nothing !$omp teams [clause[ [,]clause] ... ] structured-block
loosely-structured-block
!$omp end teams !$omp single [clause[ [,]clause] ... ]

Fortran
error [8.5] [2.5.4] - or -
loosely-structured-block
Instructs the compiler or runtime to display a message and !$omp end single [end-clause[ [,]end-clause] ...]

Fortran
!$omp teams [clause[ [,]clause] ...] - or -
to perform an error action. strictly-structured-block
[!$omp end teams] !$omp single [clause[ [,]clause] ...]
Fortran C/C++

#pragma omp error [clause [ [,] clause] ... ] clause: strictly-structured-block


allocate 9 [!$omp end single [end-clause[ [,]end-clause] ...] ]
default (data-sharing-attribute) 9 clause:
!$omp error [clause [ [,] clause] ... ] allocate 9
firstprivate (list) 9
num_teams ([lower-bound : ] upper-bound) copyprivate (list)
clause: firstprivate (list) 9
at (compilation | execution) private (list) 9
reduction 9 nowait 9
message (msg-string) private (list) 9
severity (fatal | warning) shared (list) 9
thread_limit (omp-integer-expression) end-clause:
copyprivate (list)
Loop transformation constructs simd [10.4] [2.11.5.1] nowait 9
tile [9.1] [2.11.9.1] Applied to a loop to indicate that the loop can be
Tiles one or more loops.
transformed into a SIMD loop. workshare [11.4] [2.10.3]
#pragma omp simd [clause[ [,]clause] ... ] Divides the execution of the enclosed structured block
Fortran C/C++

#pragma omp tile clause


Fortran C/C++

loop-nest into separate units of work, each executed only once by


loop-nest one thread.
!$omp simd [clause[ [,]clause] ... ]
!$omp tile clause loop-nest !$omp workshare [clause]
loop-nest [!$omp end simd] loosely structured-block
[!$omp end tile] !$omp end workshare [clause]
clause:

Fortran
clause: sizes (size-list) aligned (list[ : alignment]) - or -
Declares one or more list items to be aligned to !$omp workshare [clause]
unroll [9.2] [2.11.9.2] the specified number of bytes. strictly structured-block
Fully or partially unrolls a loop. [!$omp end workshare [clause]]
alignment: Optional constant positive integer
#pragma omp unroll [clause] clause:
Fortran C/C++

expression
loop-nest nowait 9
collapse (n) 9
!$omp unroll [clause] if ([simd : ] omp-logical-expression) 9
loop-nest lastprivate ([lastprivate-modifier : ] list) 9 scope [11.2] [2.9]
[!$omp end unroll] linear (list[ : linear-step]) 9 Defines a structured block that is executed by all threads
clause: nontemporal (list) in a team but where additional OpenMP operations can
full Accesses to the storage locations in list have low be specified.
partial [(unroll-factor)] temporal locality across the iterations in which #pragma omp scope [clause[ [,]clause] ... ]
C/C++

those storage locations are accessed. structured-block


Parallelism constructs order ([ order-modifier : ] concurrent) 9 !$omp scope [clause[ [,]clause] ... ]
order-modifier: reproducible or unconstrained loosely-structured-block
parallel [10.1] [2.6] !$omp end scope [nowait]
private (list) 9
Fortran

Creates a team of OpenMP threads that execute the


region. reduction 9 - or -
safelen (length) !$omp scope [clause[ [,]clause] ...]
#pragma omp parallel [clause[ [,]clause] ... ]
C/C++

If used then no two iterations executed strictly-structured-block


structured-block [!$omp end scope [nowait]]
concurrently with SIMD instructions can have
!$omp parallel [clause[ [,]clause] ...] a greater distance in the logical iteration space clause:
loosely-structured-block than the value of length. allocate 9
!$omp end parallel firstprivate (list) 9
Fortran

simdlen (length)
- or - nowait 9
Specifies the preferred number of iterations to private (list) 9
!$omp parallel [clause[ [,]clause] ...] be executed concurrently.
strictly-structured-block reduction 9
[ !$omp end parallel]
clause: masked [10.5] [2.8]
allocate 9 Specifies a structured block that is executed by a subset
copyin (list) of the threads of the current team.
default (data-sharing-attribute) 9 #pragma omp masked [ clause ]
C/C++

firstprivate (list) 9 structured-block


num_threads (nthreads) $omp masked [ clause ]
Specifies the number of threads to execute. loosely-structured-block
private (list) 9 !$omp end masked
Fortran

proc_bind (close | primary | spread) - or -


close: Instructs the execution environment to !$omp masked [ clause ]
assign the threads in the team to places close to strictly-structured-block
the place of the parent thread. [ !$omp end masked]
primary: Instructs the execution environment clause:
to assign every thread in the team to the same filter (thread_num)
place as the primary thread. Selects which thread executes.
spread: Creates a sparse distribution for a team
of T threads among the P places of the parent’s
place partition.
reduction 9
shared (list) 9 4
Continued

© 2021 OpenMP ARB www.openmp.org OMPSC21


OpenMP API 5.2 C/C++ C/C++ content | Fortran or For Fortran content | [n.n.n] Sections in 5.2. spec | [n.n.n] Sections in 5.1. spec | 9 See Clause info on pg. 9 4

Directives and Constructs (continued)


section and sections [11.3] [2.10.1] distribute [11.6] [2.11.6.1] taskloop [12.6] [2.12.2]
A non-iterative worksharing construct that contains a set Specifies loops which are executed by the initial teams. Specifies that the iterations of one or more associated
of structured blocks that are to be distributed among and loops will be executed in parallel using OpenMP tasks.
#pragma omp distribute [clause[ [,]clause] ... ]

Fortran C/C++
executed by the threads in a team. #pragma omp taskloop [clause[ [,]clause] ... ]
loop-nest

Fortran C/C++
#pragma omp sections [clause[ [,] clause] ... ] loop-nest
!$omp distribute [clause[ [,]clause] ... ]
{ loop-nest !$omp taskloop [clause[ [,]clause] ... ]
[#pragma omp section] [!$omp end distribute] loop-nest
structured-block-sequence
C/C++

clause: [!$omp end taskloop ]


[#pragma omp section
structured-block-sequence] allocate 9 clause:
... collapse (n) 9 allocate 9
} dist_schedule (kind[, chunk_size]) collapse (n) 9
firstprivate (list) 9 default (data-sharing-attribute) 9
!$omp sections [clause[ [,] clause] ... ] final (omp-logical-expression)
[!$omp section] lastprivate (list) 9
structured-block-sequence linear (linear-list[ : linear-step]) 9 The generated tasks will be final tasks if the
Fortran

[!$omp section order ([ order-modifier :] concurrent) 9 expression evaluates to true.


structured-block-sequence] order-modifier: reproducible or unconstrained firstprivate (list) 9
... grainsize ([ strict : ] grain-size)
!$omp end sections [nowait] private (list) 9
Causes the number of logical loop iterations
clause: assigned to each created task to be greater than
allocate 9 loop [11.7] [2.11.7]
Specifies that the iterations of the associated loops may or equal to the minimum of the value of the
firstprivate (list) 9 grain-size expression and the number of logical
lastprivate ([lastprivate-modifier: ] list) 9 execute concurrently and permits the encountering
thread(s) to execute the loop accordingly. loop iterations, but less than twice the value of
nowait 9 the grain-size expression. strict forces use of
private (list) 9 #pragma omp loop [clause[ [,]clause] ... ] exact grain size, except for last iteration.
Fortran C/C++

reduction 9 loop-nest if ([ taskloop : ] omp-logical-expression) 9


!$omp loop [clause[ [,]clause] ... ] in_reduction (reduction-identifier : list) 9
do and for [11.5.1-2] [2.11.4] loop-nest lastprivate (list) 9
Specifies that the iterations of associated loops will be [!$omp end loop] mergeable
executed in parallel by threads in the team. clause: nogroup
bind (binding) Prevents creation of implicit taskgroup
#pragma omp for [clause[ [,]clause] ... ]
Fortran C/C++

loop-nest binding: teams, parallel, or thread. region.


collapse (n) 9 num_tasks ([ strict : ] num-tasks)
!$omp do [clause[ [,]clause] ... ] lastprivate (list) 9
loop-nest Create as many tasks as the minimum of the
[!$omp end do [nowait] ] order ([ order-modifier :] concurrent) 9 num-tasks expression and the number of logical
order-modifier: reproducible or unconstrained loop iterations. strict forces exactly num-tasks
clause: tasks to be created.
allocate 9 private (list) 9
collapse (n) 9 reduction 9 priority (priority-value)
firstprivate (list) 9 Hint to the runtime to set the max priority value.
lastprivate ([lastprivate-modifier: ] list) 9 Tasking constructs If omitted, priority is zero (lowest).
linear (list[ : linear-step]) 9 task [12.5] [2.12.1] private (list) 9
nowait 9 Defines an explicit task. The data environment of the task reduction 9
order ([ order-modifier : ] concurrent) 9 is created according to the data-sharing attribute clauses shared (list) 9
order-modifier: reproducible, unconstrained on the task construct, per-data environment ICVs, and untied
ordered [(n)] any defaults that apply. Generted task is an untied task, meaning any
The loops or how many loops to associate with thread in the team can resume the task region
#pragma omp task [clause[ [,]clause] ... ]
C/C++

a construct. after a suspension.


structured-block
private (list) 9 !$omp task [clause[ [, ]clause] ... ]
reduction 9 loosely-structured-block taskyield [12.7] [2.12.4]
schedule ([modifier [, modifier] : ] kind [, chunk_size]) !$omp end task Specifies that the current task can be suspended in favor
Fortran

- or - of execution of a different task.


Values for schedule kind:
!$omp task [clause[ [, ]clause] ...]
Fortran C/C++

static: Iterations are divided into chunks of size strictly-structured-block #pragma omp taskyield
chunk_size and assigned to team threads in [!$omp end task]
round-robin fashion in order of thread number. clause: !$omp taskyield
dynamic: Each thread executes a chunk of affinity ([aff-modifier : ] locator-list)
iterations then requests another chunk until aff-modifier: iterator(iterators-definition)
none remain.
guided: Same as dynamic, except chunk size is
allocate 9 Device directives and construct
default (data-sharing-attribute) 9 target data [13.5] [2.14.2]
different for each chunk, with each successive detach (event-handle)
chunk smaller than the last. Maps variables to a device data environment for the
Task does not complete until given event is extent of the region.
auto: Compiler and/or runtime decides. fulfilled. (Also see omp_fulfilled_event)
runtime: Uses run-sched-var ICV. #pragma omp target data clause[ [ [,]clause] ... ]
C/C++

event-handle: structured-block
Values for schedule modifier: C/C++ type omp_event_handle_t
For kind omp_event_handle_kind $omp target data clause [ [ [,] clause] ... ]
monotonic: Each thread executes its assigned loosely-structured-block
chunks in increasing logical iteration order. A if ([ task : ] omp-logical-expression) 9 !$omp end target data
Fortran

schedule (static) clause or order clause implies in_reduction (reduction-identifier : list) 9


monotonic. - or -
final (omp-logical-expression)
!$omp target data clause [ [ [,] clause] ... ]
nonmonotonic: Chunks are assigned to threads The generated task will be a final task if the strictly-structured-block
in any order and the behavior of an application expression evaluates to true. [ !$omp end target data]
that depends on execution order of the chunks firstprivate (list) 9
is unspecified. clause:
mergeable device (omp-integer-expression) 9
simd: Ignored when the loop is not associated priority (priority-value) if ( [target data : ] omp-logical-expression) 9
with a SIMD construct, else new_chunk_size for Hint to the runtime. Sets max priority value. map ([ [map-modifier, [map-modifier, ... ] ]
all except the first and last chunks is map-type : ] list) 9
chunk_size/simd_width * simd_width private (list) 9 shared (list) 9
untied use_device_ptr (list)
(simd_width: implementation-defined value). use_device_addr (list)
Task is an untied task, meaning any thread in
the team can resume the task region after a
suspension. 4
Continued

© 2021 OpenMP ARB www.openmp.org OMPSC21


OpenMP API 5.2 C/C++ C/C++ content | Fortran or For Fortran content | [n.n.n] Sections in 5.2. spec | [n.n.n] Sections in 5.1. spec | 9 See Clause info on pg. 9 5

Directives and Constructs (continued)


target enter data [13.6] [2.14.3] target update [13.9] [2.14.6] barrier [15.3.1] [2.19.2]
Maps variables to a device data environment. Makes the corresponding list items in the device data Specifies an explicit barrier that prevents any thread in a
environment consistent with their original list items, team from continuing past the barrier until all threads in
Fortran C/C++

#pragma omp target enter data [clause[ [,]clause] ... ] according to the specified motion clauses. the team encounter the barrier.

Fortran C/C++

Fortran C/C++
#pragma omp target update clause[ [ [,]clause] ... ] #pragma omp barrier
!$omp target enter data [clause[ [,]clause] ... ]

clause: !$omp target update clause[ [ [,]clause] ... ] !$omp barrier


depend ([depend-modifier, ] dependence-type : locator-list)
9 clause:
device (omp-integer-expression) 9 nowait 9 taskgroup [15.4] [2.19.6]
if ( [target data : ] omp-logical-expression) 9 depend ([depend-modifier, ] dependence-type : locator-list)
9 Specifies a region which a task cannot leave until all its
map ([ [map-modifier, [map-modifier, ... ] ] descendant tasks generated inside the dynamic scope of
map-type : ] list) 9 device (omp-integer-expression) 9
the region have completed.
nowait 9 from ([motion-modifier[, ] [motion-modifier[, ] ... ] : ]
locator-list) #pragma omp taskgroup [clause[ [, ]clause] ... ]

C/C++
motion-modifier: present, mapper (mapper- structured-block
target exit data [13.7] [2.14.4] identifier), iterator (iterators-definition) !$omp taskgroup [clause[ [, ]clause] ... ]
Unmaps variables from a device data environment. loosely-structured-block
if ([ target update : ] omp-logical-expression) 9
!$omp end taskgroup
Fortran C/C++

#pragma omp target exit data [clause[ [,]clause] ... ] to ([motion-modifier[, ] [motion-modifier[, ] ... ] : ]

Fortran
locator-list) - or -
motion-modifier: present, mapper (mapper- !$omp taskgroup [clause[ [, ]clause] ... ]
!$omp target exit data [clause[ [,]clause] ... ] identifier), iterator (iterators-definition) strictly-structured-block
clause: Any clause used for target enter data. See [!$omp end taskgroup]
exception for the map clause. clause:
Interoperability construct allocate 9
target [13.8] [2.14.5] interop [14.1] [2.15.1] task_reduction (reduction-identifier : list)
Map variables to a device data environment and execute Retrieves interoperability properties from the OpenMP reduction-identifier: See reduction 9
the construct on that device. implementation to enable interoperability with foreign
execution contexts. taskwait [15.5] [2.19.5]
#pragma omp target [clause[ [,]clause] ... ]
C/C++

structured-block Specifies a wait on the completion of child tasks of the


Fortran C/C++

#pragma omp interop clause [ [ [,] clause] ... ] current task.


$omp target [clause[ [,]clause] ... ]
loosely-structured-block

Fortran C/C++
!$omp interop clause [ [ [,] clause] ... ] #pragma omp taskwait [clause[ [,] clause] ... ]
!$omp end target
Fortran

- or -
clause: !$omp taskwait [clause[ [,] clause] ... ]
!$omp target [clause[ [,]clause] ... ] device(omp-integer-expression) 9
strictly-structured-block depend ([depend-modifier, ] dependence-type : locator-list)
[!$omp end target] clause:
9
clause: depend ([depend-modifier, ] dependence-type : locator-list)
destroy(interop-var) 9
allocate 9 init([ interop-modifier,] [interop-type,] nowait 9
allocator: interop-type: interop-var)
C/C++ Identifier of type omp_allocator_handle_t interop-modifier: prefer_type(preference-list)
For Integer expression of interop-type: target, targetsync flush [15.8.5] [2.19.8]
omp_allocator_handle_kind kind There can be at most only two interop-type. Makes a thread’s temporary view of memory consistent
with memory, and enforces an order on the memory
defaultmap (implicit-behavior[: variable-category]) nowait 9 operations of the variables.
implicit-behavior: alloc, default, firstprivate, use(interop-var)
Fortran C/C++

from, none, present, to, tofrom #pragma omp flush [memory-order-clause] [(list)]
variable-category: aggregate, all, pointer, scalar, Synchronization constructs
For allocatable
critical [15.2] [2.19.1] !$omp flush [memory-order-clause] [(list)]
depend ([depend-modifier, ] dependence-type : locator-list)
9 Restricts execution of the associated structured block to a
single thread at a time. memory-order-clause:
device([device-modifier: ] omp-integer-expression) 9 seq_cst, acq_rel, release, acquire, relaxed
device-modifier: ancestor, device_num #pragma omp critical [(name) [[,] hint (hint-expression)]]
C/C++

firstprivate (list) 9 structured-block depobj [15.9.4] [2.19.10.1]


has_device_addr (list) !$omp critical [(name) [ [,] hint (hint-expression)] ] Stand-alone directive that initalizes, updates, or destroys
Indicates that list items already have device loosely-structured-block an OpenMP depend object.
addresses, so may be directly accessed from !$omp end critical [(name)]
Fortran

Fortran C/C++

target device. May include array sections. - or - #pragma omp depobj (depend-object) clause
if ([ target : ] omp-logical-expression) 9 !$omp critical [(name) [ [,] hint (hint-expression)] ]
in_reduction (reduction-identifier : list) 9 strictly-structured-block !$omp depobj (depend-object) clause
is_device_ptr(list) [ !$omp end critical [(name)] ]
Indicates list items are device pointers. hint-expression: clause:
map ([ [map-modifier, [map-modifier, ... ] ] omp_sync_hint_uncontended depend (dependence-type : locator) 9
map-type : ] list) 9 omp_sync_hint_contended destroy (depend-object)
nowait 9 private (list) 9 omp_sync_hint_speculative update (task-dependence-type)
thread_limit (omp-integer-expression) omp_sync_hint_nonspeculative Sets the dependence type of an OpenMP
uses_allocators ([[alloc-mod ,] alloc-mod]: allocator) depend object to task-dependence-type.
Enables the use of each specified allocator in the task-dependence-type: in, out, inout, inoutset,
region associated with the directive. mutexinoutset
alloc-mod:
memspace( mem-space-handle )
traits( traits-array )
mem-space-handle:
C/C++ Variable of memspace_handle_t type
For Integer of memspace_handle_kind kind
traits-array: Constant array of traits each of type:
C/C++ omp_alloctrait_t
For type(omp_alloctrait)
4
Continued

© 2021 OpenMP ARB www.openmp.org OMPSC21


OpenMP API 5.2 C/C++ C/C++ content | Fortran or For Fortran content | [n.n.n] Sections in 5.2. spec | [n.n.n] Sections in 5.1. spec | 9 See Clause info on pg. 9 6

Directives and Constructs (continued)


atomic [15.8.4] [2.19.7] atomic (continued) Cancellation constructs
Ensures a specific storage location is accessed atomically. For capture-statement: Has the form v = x cancel [16.1] [2.20.1]
#pragma omp atomic [clause [ [,] clause] ... ] Activates cancellation of the innermost enclosing region
C/C++

For statement:
statement if atomic clause is... statement: of the type specified.
!$omp atomic [clause[ [ [,] clause] ... ] ] #pragma omp cancel construct-type-clause[ [ , ] \

Fortran C/C++
read v=x
statement if-clause]
write x = expr
[!$omp end atomic]
- or - update x = x operator expr !$omp cancel construct-type-clause[ [ , ] if-clause]
x = expr operator x
!$omp atomic [clause[ [ [,] clause] ... ] [, ] ] capture & x = intrinsic_procedure_name (x, expr-list)
[ [,] clause [ [ [,] clause] ...] ] if-clause: if ([ cancel : ] omp-logical-expression)
x = intrinsic_procedure_name (expr-list, x)
statement construct-type-clause:
Fortran

capture-statement intrinsic_procedure_name: MAX, MIN, IAND, IOR, IEOR C/C++ parallel, sections, taskgroup, for
[!$omp end atomic] operator is one of +, *, /, .AND., .OR., .EQV., .NEQV. For parallel, sections, taskgroup, do
- or - if capture is present and statement x = expr, in addition to
!$omp atomic [clause[ [ [,] clause] ... ] [, ] ] capture & is preceded or followed by
[ [,] clause [ [ [,] clause] ...] ] capture-statement
any other allowed cancellation point [16.2] [2.20.2]
capture-statement Introduces a user-defined cancellation point at which
if (x == e) then
statement x=d tasks check if cancellation of the innermost enclosing
[!$omp end atomic] if compare is present end if region of the type specified has been activated.
clause:

Fortran C/C++
atomic-clause: read, write, update if (x == e) x = d #pragma omp cancellation point construct-type-clause
memory-order-clause: seq_cst, acq_rel, release, if the compare and capture clauses if (x == e) then
acquire, relaxed are both present, and statement is x=d !$omp cancellation point construct-type-clause
extended-atomic: capture, compare, fail, weak not preceded or followed by else v = x
capture: Capture the value of the variable being capture-statement end if
construct-type-clause:
updated atomically. parallel
compare: Perform the atomic update
ordered [15.10.2] [2.19.9] sections
Specifies a structured block that is to be executed in loop taskgroup
conditionally. iteration order in a parallelized loop, or it specifies cross C/C++ for
fail (seq_cst | acquire | relaxed): Specify iteration dependences in a doacross loop nest. For do
the memory ordering requirements for #pragma omp ordered [clause [[,] clause] ]
any comparison performed by any atomic structured-block
C/C++

conditional update that fails. Its argument


- or - Combined Constructs and Directives
overrides any other specified memory ordering. The following combined constructs and directives are
#pragma omp ordered clause[ [ [,] clause] ... ] created following the parameters defined in section 17
weak: Specify that the comparison performed
by a conditional atomic update may spuriously !$omp ordered [clause[ [, ] clause] ] of the OpenMP API version 5.2 specification and were
fail, evaluating to not equal even when the loosely-structured-block explicitly defined in previous versions.
values are equal. !$omp end ordered
- or - do simd and for simd [17] [2.11.5.2]
hint (hint-expression)
Fortran

!$omp ordered [clause [[,] clause] ] Specifies that the iterations of associated loops will
C/C++ statement: strictly-structured-block be executed in parallel by threads in the team and the
if atomic clause is... statement: [ !$omp end ordered] iterations executed by each thread can also be executed
read v = x; - or - concurrently using SIMD instructions.
write x = expr; !$omp ordered clause[ [ [,] clause] ... ]
#pragma omp for simd [clause[ [,]clause] ... ]
C/C++

x++; x--; ++x; --x; clause (for the structured-block forms only): loop-nest
update x binop = expr; x = x binop expr; threads
!$omp do simd [clause[ [,]clause] ... ]
Fortran

x = expr binop x; simd


loop-nest
cond-expr-stmt: threads or simd indicate the parallelization level [!$omp end do simd [nowait] ]
x = expr ordop x ? expr : x; with which to associate a construct.
x = x ordop expr ? expr : x; clause: Any of the clauses accepted by the simd, for, or
x = x == e ? d : x; clause (for the standalone forms only): do directives.
compare is present doacross (dependence-type : [ vector])
cond-update-stmt:
if(expr ordop x) { x = expr; } Identifies cross-iteration dependences that distribute simd [17] [2.11.6.2]
if(x ordop expr) { x = expr; } imply additional constraints on the scheduling of
if(x == e) { x = d; } Specifies a loop that will be distributed across the primary
loop iterations. threads of the teams region and executed concurrently
v = expr-stmt using SIMD instructions.
{ v = x; expr-stmt } dependence-type:
capture is present { expr-stmt v = x; } source #pragma omp distribute simd [clause[ [,]clause] ... ]
Fortran C/C++

(expr-stmt: write-expr-stmt, Specifies the satisfaction of cross-iteration loop-nest


update-expr-stmt, or cond-expr-stmt.) dependences that arise from the current !$omp distribute simd [clause[ [,]clause] ... ]
{ v = x; cond-update-stmt } iteration. If source is specified, then the vector loop-nest
{ cond-update-stmt v = x; } argument is optional; if vector is omitted, it is
both compare and
if(x == e) { x = d; } else { v = x; }
[!$omp end distribute simd]
capture are present assumed to be omp_cur_iteration. At most one
{ r = x == e; if(r) { x = d; } } doacross clause can be specified on a directive clause: Any of the clauses accepted by distribute or simd.
{ r = x == e; if(r) { x = d; } else { v = x; } }
with source as the dependence-type.
sink distribute parallel do and
Continued in next column Specifies a cross-iteration dependence, where distribute parallel for
vector indicates the iteration that satisfies the [17] [2.11.6.3]
dependence. If vector does not occur in the Specify a loop that can be executed in parallel by multiple
iteration space, the doacross clause is ignored. If threads that are members of multiple teams.
all doacross clauses on an ordered construct are #pragma omp distribute parallel for [clause[ [,]clause] ... ]
Fortran C/C++

ignored then the construct is ignored. loop-nest


!$omp distribute parallel do [clause[ [,]clause] ... ]
loop-nest
[!$omp end distribute parallel do]
clause: Any clause used for distribute, parallel for,or
parallel do.

4
Continued

© 2021 OpenMP ARB www.openmp.org OMPSC21


OpenMP API 5.2 C/C++ C/C++ content | Fortran or For Fortran content | [n.n.n] Sections in 5.2. spec | [n.n.n] Sections in 5.1. spec | 9 See Clause info on pg. 9 7

Directives and Constructs (continued)


distribute parallel do simd and parallel workshare [17] [2.16.4] parallel masked taskloop simd [17] [2.16.10]
distribute parallel for simd [17] [2.11.6.4] Shortcut for specifying a parallel construct containing a Shortcut for specifying a parallel construct containing
Specifies a loop that can be executed concurrently using workshare construct and no other statements. a masked taskloop simd construct and no other
SIMD instructions in parallel by multiple threads that are statements.
$omp parallel workshare [clause[ [,]clause] ... ]
members of multiple teams. loosely-structured-block #pragma omp parallel masked taskloop simd \

C/C++
#pragma omp distribute parallel for simd \ !$omp end parallel workshare [clause[ [, ]clause] ... ]

Fortran
C/C++

[clause[ [,]clause] ... ] - or - loop-nest


loop-nest !$omp parallel workshare [clause[ [,]clause] ...] !$omp parallel masked taskloop simd [clause[ [, ] &
strictly-structured-block

Fortran
!$omp distribute parallel do simd [clause[ [,]clause] ... ] clause] ... ]
Fortran

loop-nest [!$omp end parallel workshare] loop-nest


[!$omp end distribute parallel do simd] clause: Any clause used for parallel. [$omp end parallel masked taskloop simd]
clause: Any clause used for distribute, parallel for simd, clause: Any clause used for masked taskloop simd or
or parallel do simd. parallel do simd and parallel except the in_reduction clause.
parallel for simd [17] [2.16.5]
taskloop simd [17] [2.12.3] Shortcut for specifying a parallel construct containing teams distribute [17] [2.16.11]
Specifies that a loop can be executed concurrently using only one worksharing-loop SIMD construct. Shortcut for specifying a teams construct containing a
distribute construct and no other statements. .
SIMD instructions, and that those iterations will also be #pragma omp parallel for simd [clause[ [,]clause] ... ]
C/C++
executed in parallel using OpenMP tasks. #pragma omp teams distribute [clause[ [,]clause] ... ]

C/C++
loop-nest
#pragma omp taskloop simd [clause[ [,]clause] ... ] loop-nest
Fortran C/C++

!$omp parallel do simd [clause[ [,]clause] ... ]


Fortran

loop-nest !$omp teams distribute [clause[ [,]clause] ... ]


loop-nest

Fortran
!$omp taskloop simd [clause[ [,]clause] ... ] [!$omp end parallel do simd] loop-nest
loop-nest clause: Any clause used for parallel, for simd, or do simd [!$omp end teams distribute]
[!$omp end taskloop simd] [C/C++ except the nowait clause]. clause: Any clause used for teams or distribute.
clause: Any clause used for simd or taskloop.
parallel masked [17] [2.16.6] teams distribute simd [17] [2.16.12]
parallel do and parallel for [17] [2.16.1] Shortcut for specifying a parallel construct containing a Shortcut for specifying a teams construct containing a
Specifies a parallel construct containing a worksharing- masked construct and no other statements. distribute simd construct and no other statements.
loop construct with a canonical loop nest and no other #pragma omp teams distribute simd \
#pragma omp parallel masked [clause[ [,]clause] ... ]
C/C++

statements.

C/C++
structured-block [clause[ [,] clause] ... ]
#pragma omp parallel for [clause[ [,]clause] ... ] loop-nest
Fortran C/C++

loop-nest $omp parallel masked [clause[ [,]clause] ... ]


!$omp teams distribute simd [clause[ [,]clause] ... ]

Fortran
!$omp parallel do [clause[ [,]clause] ... ] loosely-structured-block
!$omp end parallel masked loop-nest
loop-nest
Fortran

[!$omp end teams distribute simd]


[!$omp end parallel do] - or -
!$omp parallel masked [clause[ [, ]clause] ...] clause: Any clause used for teams or distribute simd.
clause: Any clause used for parallel, for, or do except the
nowait clause. strictly-structured-block
[!$omp end parallel masked] teams distribute parallel do and
parallel loop [17] [2.16.2] clause: Any clause used for parallel or masked. teams distribute parallel for [17] [2.16.13]
Shortcut for specifying a teams construct containing a
Shortcut for specifying a parallel construct containing a distribute parallel worksharing-loop construct and no
loop construct with a canonical loop nest and no other masked taskloop [17] [2.16.7] other statements.
statements. Shortcut for specifying a masked construct containing a
taskloop construct and no other statements. #pragma omp teams distribute parallel for \
C/C++

#pragma omp parallel loop [clause[ [,]clause] ... ]


C/C++

[clause[ [,]clause] ... ]


loop-nest #pragma omp masked taskloop [clause[ [,]clause] ... ]
C/C++

loop-nest
loop-nest
!$omp parallel loop [clause[ [,]clause] ... ]
Fortran

!$omp teams distribute parallel do [clause[ [, ] &


loop-nest !$omp masked taskloop [clause[ [,]clause] ... ]
Fortran
Fortran

clause] ... ]
[!$omp end parallel loop] loop-nest loop-nest
clause: Any clause used for parallel or loop. [$omp end masked taskloop] [!$omp end teams distribute parallel do]
clause: Any clause used for taskloop or masked. clause: Any clause used for teams, distribute parallel for, or
parallel sections [17] [2.16.3] distribute parallel do.
Shortcut for specifying a parallel construct containing a masked taskloop simd [17] [2.16.8]
sections construct and no other statements. Shortcut for specifying a masked construct containing a teams distribute parallel do simd and
taskloop simd construct and no other statements.
#pragma omp parallel sections [clause[ [,]clause] ... ] teams distribute parallel for simd [17] [2.16.14]
{ #pragma omp masked taskloop simd \ Shortcut for specifying a teams construct containing a
C/C++

[#pragma omp section] [clause[ [,]clause] ... ] distribute parallel for simd or distribute parallel do simd
structured-block-sequence loop-nest construct and no other statements.
C/C++

[#pragma omp section


!$omp masked taskloop simd [clause[ [,]clause] ... ] #pragma omp teams distribute parallel for simd \
Fortran

structured-block-sequence]
C/C++

... loop-nest [clause[ [,]clause] ... ]


} [$omp end masked taskloop simd] loop-nest
clause: Any clause used for masked or taskloop simd. !$omp teams distribute parallel do simd
!$omp parallel sections [clause[ [,]clause] ... ]
Fortran

[!$omp section] [clause[ [,]clause] ... ]


structured-block-sequence parallel masked taskloop [17] [2.16.9] loop-nest
Fortran

[!$omp section Shortcut for specifying a parallel construct containing a [!$omp end teams distribute parallel do simd]
structured-block-sequence] masked taskloop construct and no other statements. clause: Any clause used for teams, distribute parallel
... for simd, or distribute parallel do simd.
!$omp end parallel sections #pragma omp parallel masked taskloop \
C/C++

[clause[ [,]clause] ... ]


clause: Any clause used for parallel or sections loop-nest teams loop [17] [2.16.15]
[C/C++ except the nowait clause]. Shortcut for specifying a teams construct containing a
!$omp parallel masked taskloop [clause[ [,]clause] ... ] loop construct and no other statements.
Fortran

loop-nest
#pragma omp teams loop [clause[ [,]clause] ... ]
C/C++

[$omp end parallel masked taskloop]


loop-nest
clause: Any clause used for parallel or masked taskloop
except the in_reduction clause. !$omp teams loop [clause[ [,]clause] ... ]
Fortran

loop-nest
[!$omp end teams loop]
clause: Any clause used for teams or loop.
4
Continued

© 2021 OpenMP ARB www.openmp.org OMPSC21


OpenMP API 5.2 C/C++ C/C++ content | Fortran or For Fortran content | [n.n.n] Sections in 5.2. spec | [n.n.n] Sections in 5.1. spec | 9 See Clause info on pg. 9 8

Directives and Constructs (continued)


target parallel [17] [2.16.16] target simd [17] [2.16.20] target teams loop [17] [2.16.24]
Shortcut for specifying a target construct containing a Shortcut for specifying a target construct containing a Shortcut for specifying a target construct containing a
parallel construct and no other statements. simd construct and no other statements. teams loop construct and no other statements.
#pragma omp target parallel [clause[ [,]clause] ... ]
C/C++

#pragma omp target simd [clause[ [,]clause] ... ] #pragma omp target teams loop [clause[ [, ]clause] ... ]

C/C++

C/C++
structured-block loop-nest loop-nest
$omp target parallel [clause[ [,]clause] ... ] !$omp target simd [clause[ [,]clause] ... ] !$omp target teams loop [clause[ [, ]clause] ... ]

Fortran

Fortran
loosely-structured-block loop-nest loop-nest
!$omp end target parallel [!$omp end target simd] [!$omp end target teams loop]
Fortran

- or - clause: Any clause used for target or simd. clause: Any clause used for target or teams loop.
!$omp target parallel [clause[ [,]clause] ... ]
strictly-structured-block target teams [17] [2.16.21] target teams distribute parallel do and
[!$omp end target parallel] Shortcut for specifying a target construct containing a
teams construct and no other statements.
target teams distribute parallel for
clause: Clauses used for target or parallel except for copyin. [17] [2.16.25]
#pragma omp target teams [clause[ [,]clause] ... ] Shortcut for specifying a target construct containing
C/C++
target parallel do and structured-block teams distribute parallel for, teams distribute parallel do
target parallel for [17] [2.16.17] and no other statements.
Shortcut for specifying a target construct with a parallel $omp target teams [clause[ [, ]clause] ... ]
worksharing-loop construct and no other statements. loosely-structured-block #pragma omp target teams distribute parallel for \

C/C++
!$omp end target teams [clause[ [, ]clause] ... ]
Fortran

#pragma omp target parallel for [clause[ [,] clause] ... ]


C/C++

- or - loop-nest
loop-nest
!$omp target teams [clause[ [,]clause] ... ] !$omp target teams distribute parallel do &
strictly-structured-block

Fortran
!$omp target parallel do [clause[ [,]clause] ... ] [clause[ [, ]clause] ... ]
Fortran

loop-nest [ !$omp end target teams] loop-nest


[!$omp end target parallel do] clause: Any clause used for target or teams. [$omp end target teams distribute parallel do]
clause: Any clause used for target, parallel for, or clause:
parallel do, except for copyin. target teams distribute [17] [2.16.22] Any clause used for target, teams distribute parallel
Shortcut for specifying a target construct containing a for, or teams distribute parallel do.
target parallel do simd and teams distribute construct and no other statements.
target parallel for simd [17] [2.16.18] target teams distribute parallel do simd
#pragma omp target teams distribute [clause[ [, ] \
Shortcut for specifying a target construct with a parallel target teams distribute parallel for simd
C/C++

worksharing-loop SIMD construct and no other statements. clause] ... ]


loop-nest [17] [2.16.26]
#pragma omp target parallel for simd \ Shortcut for specifying a target construct containing
!$omp target teams distribute [clause[ [, ]clause] ... ]
C/C++

Fortran

[clause[ [,]clause] ... ] a teams distribute parallel worksharing-loop SIMD


loop-nest construct and no other statements.
loop-nest [!$omp end target teams distribute]
!$omp target parallel do simd [clause[ [,]clause] ... ] clause: Any clause used for target or teams distribute. #pragma omp target teams distribute parallel for simd \
C/C++
Fortran

loop-nest [clause[ [, ]clause] ... ]


[!$omp end target parallel do simd] loop-nest
target teams distribute simd [17] [2.16.23] !$omp target teams distribute parallel do simd &
clause: Any clause used for target, parallel for simd, or Shortcut for specifying a target construct containing a
Fortran

parallel do simd, except for copyin. [clause[ [,]clause] ... ]


teams distribute simd construct and no other statements. loop-nest
[!$omp end target teams distribute parallel do simd]
target parallel loop [17] [2.16.19] #pragma omp target teams distribute simd \
C/C++

[clause[ [, ]clause] ... ] clause: Any clause used for target, teams distribute
Shortcut for specifying a target construct containing a parallel for simd, or teams distribute parallel do
parallel loop construct and no other statements. loop-nest
simd.
!$omp target teams distribute simd [clause[ [, ]clause] ... ]
Fortran

#pragma omp target parallel loop [clause[ [,] \


C/C++

clause] ... ] loop-nest


loop-nest [!$omp end target teams distribute simd]
clause: Any clause used for target or teams distribute simd.
!$omp target parallel loop [clause[ [,]clause] ... ]
Fortran

loop-nest
[!$omp end target parallel loop]
clause: Clauses used for target or parallel loop except copyin.

Notes

© 2021 OpenMP ARB www.openmp.org OMPSC21


OpenMP API 5.2 C/C++ C/C++ content | Fortran or For Fortran content | [n.n.n] Sections in 5.2. spec | [n.n.n] Sections in 5.1. spec | 9 See Clause info on pg. 9 9

Clauses
All list items appearing in a clause must be visible according to the scoping rules of the base language.

Data sharing attribute clauses [5.4] [2.21.4] collapse clause [4.4.3] map clause [5.8.3] [2.21.7.1]
Additional data sharing attribute clauses are is_device_ptr, collapse (n) map ([[map-modifier, [map-modifier, ... ]
use_device_ptr, has_device_addr, and use_device_addr. A constant positive integer expression that specifies how map-type : ] locator-list)
These clauses are described at the directives that accept many loops are associated with the construct. Maps data from the task’s environment to the device
them. environment.
Used in: distribute (4), do and for (4), loop (4), simd (3),
taskloop (4) map-type: alloc, to, from, tofrom, release, delete
default (shared | firstprivate | private | none)
For the target or target data directives:
Default data-sharing attributes are disabled. All variables
depend clause [15.9.5] [2.19.11] map-type: alloc, to, from, tofrom, release
in a construct must be declared inside the construct or
appear in a data-sharing attribute clause. Enforces additional constraints on the scheduling of For the target enter data directive:
tasks or loop iterations, establishing dependences only map-type: alloc, to, from, tofrom
Used in: parallel (3), task (4), taskloop (4), teams (3) For the target exit data directive:
between sibling tasks or between loop iterations.
map-type: to, from, tofrom, release, delete
shared (list) depend ([depend-modifier,]dependence-type : locator-list)
map-modifier: always, close, present,
Variables in list are shared between threads or explicit depend-modifier: iterator (iterators-definition) mapper(mapper-id), iterator(iterators-definition)
tasks executing the construct. dependence-type: in, out, inout, mutexinoutset,
Used in: declare mapper (1), target (5), target data (4),
Used in: parallel (3), task (4), taskloop (4), teams (3) inoutset, depobj target enter data (5), target exit data (5)
• in: The generated task will be a dependent task of
private (list) all previously generated sibling tasks that reference
Creates a new variable for each item in list that is private at least one of the list items in an out or inout order clause [10.3] [2.11.3]
to each thread or explicit task. The private variable is not dependence-type list. order ([order-modifier : ] concurrent)
given an initial value. • out and inout: The generated task will be a order-modifier: reproducible, unconstrained
Used in: distribute (4), do and for (4), loop (4), parallel (3), dependent task of all previously generated sibling
scope (3), section (4), simd (3), single (3), target (5), tasks that reference at least one of the list items Specifies an expected order of execution for the iterations
task (4), taskloop (4), teams (3)
in an in, out, mutexinoutset, inout, or inoutset of the associated loops of a loop-associated directive.
dependence-type list. Used in: distribute (4), do and for (4), loop (4), simd (3)
firstprivate (list)
Declares list items to be private to each thread or explicit • mutexinoutset: If the storage location of at least
task and assigns them the value the original variable has one of the list items is the same as that of a list item nowait clause [15.6]
at the time the construct is encountered. appearing in a depend clause with an in, out, inout,
nowait
or inoutset dependence-type on a construct from
Used in: distribute (4), do and for (4), parallel (3), which a sibling task was previously generated, then Overrides any synchronization that would otherwise
scope (3), section (4), simd (3), target (5), task (4),
the generated task will be a dependent task of that occur at the end of a construct. It can also specify that
taskloop (4), teams (3)
sibling task. If the storage location of at least one an interoperability requirement set includes the nowait
of the list items is the same as that of a list item property. If the construct includes an implicit barrier, the
lastprivate ([ lastprivate-modifier:] list) nowait clause specifies that the barrier will not occur.
appearing in a depend clause with a mutexinoutset
After the last loop ends, the variables in list will be copied dependence-type on a construct from which a sibling Used in: dispatch (2), do and for (4), interop (5), scope (3),
to the primary thread. task was previously generated, then the sibling tasks section (4), single (3), target (5), target enter data (5),
lastprivate-modifier: conditional will be mutually exclusive tasks. target exit data (5), target update (5), taskwait (5),
workshare (3)
conditional: Uses the value from the thread that • inoutset: If the storage location of at least one of the
executed the highest index iteration number. list items matches the storage location of a list item
Used in: distribute (4), do and for (4), loop (4), section (4), appearing in a depend clause with an in, out, inout, reduction clause [5.5.8] [2.21.5.4]
simd (3), taskloop (4) or mutexinoutset dependence-type on a construct reduction ([ reduction-modifier , ] reduction-identifier : list)
from which a sibling task was previously generated, Specifies a reduction-identifier and one or more list items.
linear (linear-list [ : linear-step] ) then the generated task will be a dependent task of
reduction-modifier: inscan, task, default
linear (linear-list [: linear-modifier [, linear-modifier]]) that sibling task.
C++ reduction-identifier:
Declares each linear-list item to have a linear value or • depobj: The task dependences are derived from the
address with respect to the iteration space of the loop. depend clause specified in the depobj constructs Either an id-expression or one of the following
that initialized dependences represented by the operators: +, *, &, |, ^, &&, ||
linear-list: list (or for declare simd argument-list)
depend objects specified in the depend clause as if C reduction-identifier:
linear-modifier: step(linear-step), linear-type-modifier the depend clauses of the depobj constructs were Either an identifier or one of the following operators:
linear-step: OpenMP integer expression (1 is default) specified in the current construct. +, *, &, |, ^, &&, ||
linear-type-modifier: val, ref, uval (val is default) Used in: depobj (5), dispatch (2), interop (5), target (5), For reduction-identifier:
val: The value is linear
target enter data (5), target exit data (5), target update (5), Either a base language identifier, a user-defined
task (4), taskwait (5)
operator, one of the following operators:
ref: The address is linear (C++ and Fortran only) +, *, .and., .or., .eqv., .neqv.,
uval: The value is linear, may not be modified device clause [13.2] or one of the following intrinsic procedure names:
(C++ and Fortran only) device ([ancestor | device_num : ] device-description) max, min, iand, ior, ieor.
The ref and uval modifiers may only be specified for a Identifies the target device that is associated with a Used in: do and for (4), loop (4), parallel (3), scope (3),
linear clause on the declare simd directive, and only for device construct. section (4), simd (3), taskloop (4), teams (3)
arguments that are passed by reference. device-description: An expression of type integer that
Used in: declare simd (2), distribute (4), do and for (4), refers to the device number or, if ancestor modifier is iterator [3.2.6] [2.1.6]
simd (3) specified, must be 1. Identifiers that expand to multiple values in the clause
Used in: dispatch (2), interop (5), target (5), target data (4), on which they appear.
allocate clause [6.6] [2.13.4] target enter data (5), target exit data (5), target update (5) iterator (iterators-definition)
allocate ([allocator : ] list) iterators-definition:
allocate(allocate-modifier [, allocate-modifier ] : list) if clause [3.4] [2.18] iterator-specifier [, iterators-definition ]
The effect of the if clause depends on the construct iterators-specifier:
allocate-modifier: to which it is applied. For combined or composite [ iterator-type ] identifier = range-specification
allocator (allocator) constructs, it only applies to the semantics of the
allocator: is an expression of: identifier: A base language identifier.
C/C++ type omp_allocator_handle_t construct named in the directive-name-modifier if one
For kind omp_allocator_handle_kind is specified. If no modifier is specified for a combined range-specification: begin : end[: step]
align (alignment) or composite construct then the if clause applies to all begin, end: Expressions for which their types
alignment: A constant positive integer power of 2. constructs to which an if clause can apply. can be converted to iterator-type
if ([directive-name-modifier : ] omp-logical-expression) step: An integral expression.
Used in: distribute (4), do and for (4), parallel (3), scope (3),
section (4), single (3), target (5), task (4), taskgroup (5), Used in: cancel (6), parallel (3), simd (3), target (5), iterator-type: C/C++ A type name. For A type specifier.
taskloop (4), teams (3) target data (4), target enter data (5), target exit data (5),
target update (5), task (4), taskloop (4), teams (3)

© 2021 OpenMP ARB www.openmp.org OMPSC21


OpenMP API 5.2 C/C++ C/C++ content | Fortran or For Fortran content | [n.n.n] Sections in 5.2. spec | [n.n.n] Sections in 5.1. spec | 9 See Clause info on pg. 9 10

Runtime Library Routines


Thread team routines omp_set_schedule [18.2.11] [3.2.11] omp_get_ancestor_thread_num [18.2.18] [3.2.18]
Affects the schedule that is applied when runtime is used Returns, for a given nested level of the current thread, the
omp_set_num_threads [18.2.1] [3.2.1] as schedule kind, by setting the value of the run-sched-var thread number of the ancestor of the current thread.
Affects the number of threads used for subsequent parallel ICV.

Fortran C/C++
constructs not specifying a num_threads clause, by setting int omp_get_ancestor_thread_num (int level);
the value of the first element of the nthreads-var ICV of the void omp_set_schedule(omp_sched_t kind,

C/C++
current task to num_threads. int chunk_size); integer function omp_get_ancestor_thread_num (level)
integer level
Fortran C/C++

void omp_set_num_threads (int num_threads); subroutine omp_set_schedule (kind, chunk_size)

Fortran
integer (kind=omp_sched_kind) kind omp_get_team_size [18.2.19] [3.2.19]
subroutine omp_set_num_threads (num_threads) integer chunk_size
Returns, for a given nested level of the current thread,
integer num_threads See omp_get_schedule for kind. the size of the thread team to which the ancestor or the
current thread belongs.
omp_get_num_threads [18.2.2] [3.2.2] omp_get_schedule [18.2.12] [3.2.12]

Fortran C/C++
Returns the number of threads in the current team. The Returns the schedule applied when runtime schedule is int omp_get_team_size (int level);
binding region for an omp_get_num_threads region is used. ICV: run-sched-var
the innermost enclosing parallel region. If called from the integer function omp_get_team_size (level)
void omp_get_schedule (
C/C++
sequential part of a program, this routine returns 1. integer level
omp_sched_t *kind, int *chunk_size);
Fortran C/C++

int omp_get_num_threads (void); Fortran


subroutine omp_get_schedule (kind, chunk_size) omp_get_active_level [18.2.20] [3.2.20]
integer (kind=omp_sched_kind) kind Returns the number of active, nested parallel regions on
integer function omp_get_num_threads () integer chunk_size the device enclosing the task containing the call.
ICV: active-level-var
kind for omp_set_schedule and omp_get_schedule is an
omp_get_max_threads [18.2.3] [3.2.3]

Fortran C/C++
implementation-defined schedule or: int omp_get_active_level (void);
Returns an upper bound on the number of threads that omp_sched_static
could be used to form a new team if a parallel construct omp_sched_dynamic
without a num_threads clause were encountered after omp_sched_guided integer function omp_get_active_level ()
execution returns from this routine. omp_sched_auto
Use + or | operators (C/C++) or the + operator (For)
Fortran C/C++

int omp_get_max_threads (void); to combine the kinds with the modifier Thread affinity routines
omp_sched_monotonic. omp_get_proc_bind [18.3.1] [3.3.1]
integer function omp_get_max_threads () Returns the thread affinity policy to be used for the
omp_get_thread_limit [18.2.13] [3.2.13]
subsequent nested parallel regions that do not specify a
Returns the maximum number of OpenMP threads proc_bind clause.
omp_get_thread_num [18.2.4] [3.2.4] available in contention group. ICV: thread-limit-var
Returns the thread number of the calling thread, within the

Fortran C/C++
omp_proc_bind_t omp_get_proc_bind (void);
Fortran C/C++

current team. int omp_get_thread_limit (void);


Fortran C/C++

int omp_get_thread_num (void); integer (kind=omp_proc_bind_kind) &


integer function omp_get_thread_limit () function omp_get_proc_bind ()
integer function omp_get_thread_num () Valid return values include:
omp_get_supported_active_levels [18.2.14] [3.2.14] omp_proc_bind_false
Returns the number of active levels of parallelism supported. omp_proc_bind_true
omp_in_parallel [18.2.5] [3.2.5] omp_proc_bind_primary
Fortran C/C++

Returns true if the active-levels-var ICV is greater than zero; int omp_get_supported_active_levels (void); omp_proc_bind_close
otherwise it returns false. omp_proc_bind_spread
Fortran C/C++

int omp_in_parallel (void); integer function omp_get_supported_active_levels () omp_get_num_places [18.3.2] [3.3.2]


Returns the number of places available to the execution
logical function omp_in_parallel () omp_set_max_active_levels [18.2.15] [3.2.15] environment in the place list.
Limits the number of nested active parallel regions when a
Fortran C/C++

new nested parallel region is generated by the current task, int omp_get_num_places (void);
omp_set_dynamic [18.2.6] [3.2.6] by setting max-active-levels-var ICV.
Enables or disables dynamic adjustment of the number of
integer function omp_get_num_places ()
Fortran C/C++

threads available for the execution of subsequent parallel void omp_set_max_active_levels (int max_levels);
regions by setting the value of the dyn-var ICV.
subroutine omp_set_max_active_levels (max_levels) omp_get_place_num_procs [18.3.3] [3.3.3]
Fortran C/C++

void omp_set_dynamic (int dynamic_threads); integer max_levels Returns the number of processors available to the
execution environment in the specified place.
subroutine omp_set_dynamic (dynamic_threads) omp_get_max_active_levels [18.2.16] [3.2.16]
C/C++

logical dynamic_threads Returns the maximum number of nested active parallel int omp_get_place_num_procs (int place_num);
regions when the innermost parallel region is generated by
omp_get_dynamic [18.2.7] [3.2.7] the current task. ICV: max-active-levels-var integer function &
Fortran

Returns true if dynamic adjustment of the number of omp_get_place_num_procs (place_num)


Fortran C/C++

threads is enabled for the current task. ICV: dyn-var int omp_get_max_active_levels (void); integer place_num
Fortran C/C++

int omp_get_dynamic (void); omp_get_place_proc_ids [18.3.4] [3.3.4]


integer function omp_get_max_active_levels () Returns numerical identifiers of the processors available to
logical function omp_get_dynamic () the execution environment in the specified place.
omp_get_level [18.2.17] [3.2.17]
void omp_get_place_proc_ids (
C/C++

omp_get_cancellation [18.2.8] [3.2.8] Returns the number of nested parallel regions on the int place_num, int *ids);
device that enclose the task containing the call.
Returns true if cancellation is enabled; otherwise it returns ICV: levels-var
false. ICV: cancel-var subroutine omp_get_place_proc_ids(place_num, ids)
Fortran

integer place_num
Fortran C/C++

int omp_get_level (void);


Fortran C/C++

int omp_get_cancellation (void); integer ids (*)

integer function omp_get_level () omp_get_place_num [18.3.5] [3.3.5]


logical function omp_get_cancellation () Returns the place number of the place to which the
encountering thread is bound.
Fortran C/C++

int omp_get_place_num (void);

integer function omp_get_place_num ()

4
Continued

© 2021 OpenMP ARB www.openmp.org OMPSC21


OpenMP API 5.2 C/C++ C/C++ content | Fortran or For Fortran content | [n.n.n] Sections in 5.2. spec | [n.n.n] Sections in 5.1. spec | 9 See Clause info on pg. 9 11

Runtime Library Routines (continued)


omp_get_partition_num_places [18.3.6] [3.3.6] omp_get_max_teams [18.4.4] [3.4.4] omp_set_default_device [18.7.2] [3.7.2]
Returns the number of places in the place-partition-var ICV Returns an upper bound on the number of teams that could Assigns the value of the default-device-var ICV, which
of the innermost implicit task. be created by a teams construct without a num_teams determines default target device.
clause that is encountered after execution returns from this
Fortran C/C++

Fortran C/C++
int omp_get_partition_num_places (void); routine. ICV: nteams-var void omp_set_default_device (int device_num);

Fortran C/C++
integer function omp_get_partition_num_places () int omp_get_max_teams (void); subroutine omp_set_default_device (device_num)
integer device_num
omp_get_partition_place_nums [18.3.7] [3.3.7] integer function omp_get_max_teams()
omp_get_default_device [18.7.3] [3.7.3]
Returns the list of place numbers corresponding to the Returns the value of the default-device-var ICV, which
places in the place-partition-var ICV of the innermost omp_set_teams_thread_limit [18.4.5] [3.4.5] determines the default target device.
implicit task. Sets the maximum number of OpenMP threads that can

Fortran C/C++
void omp_get_partition_place_nums ( participate in each contention group created by a teams int omp_get_default_device (void);
Fortran C/C++

int *place_nums); construct by setting the value of teams-thread-limit-var ICV.

C/C++
subroutine omp_get_partition_place_nums( & void omp_set_teams_thread_limit(int thread_limit); integer function omp_get_default_device ()
place_nums)
integer place_nums (*) subroutine & omp_get_num_devices [18.7.4] [3.7.4]
Fortran
omp_set_affinity_format [18.3.8] [3.3.8] omp_set_teams_thread_limit(thread_limit) Returns the number of non-host devices available for
Sets the affinity format to be used on the device by setting integer thread_limit offloading code or data.
the value of the affinity-format-var ICV.
omp_get_teams_thread_limit [18.4.6] [3.4.6]

Fortran C/C++
int omp_get_num_devices (void);
Fortran C/C++

void omp_set_affinity_format (const char *format); Returns the maximum number of OpenMP threads available
to participate in each contention group created by a teams
construct. integer function omp_get_num_devices ()
subroutine omp_set_affinity_format (format)
character(len=*), intent(in) :: format
Fortran C/C++

int omp_get_teams_thread_limit (void); omp_get_device_num [18.7.5] [3.7.5]


omp_get_affinity_format [18.3.9] [3.3.9] Returns the device number of the device on which the
Returns the value of the affinity-format-var ICV on the integer function omp_get_teams_thread_limit () calling thread is executing.
device.

Fortran C/C++
int omp_get_device_num (void);
size_t omp_get_affinity_format (char *buffer,
Fortran C/C++

size_t size); Tasking routines


integer function omp_get_affinity_format (buffer) integer function omp_get_device_num ()
character(len=*), intent(out) :: buffer omp_get_max_task_priority [18.5.1] [3.5.1]
Returns the maximum value that can be specified in the omp_is_initial_device [18.7.6] [3.7.6]
omp_display_affinity [18.3.10] [3.3.10] priority clause.
Returns true if the current task is executing on the host
Prints the OpenMP thread affinity information using the device; otherwise, it returns false.
Fortran C/C++

format specification provided. int omp_get_max_task_priority (void);

Fortran C/C++
int omp_is_initial_device (void);
Fortran C/C++

void omp_display_affinity (const char *format); integer function omp_get_max_task_priority ()


subroutine omp_display_affinity (format) logical function omp_is_initial_device ()
character(len=*), intent(in) :: format omp_in_final [18.5.3] [3.5.2]
Returns true if the routine is executed in a final task region; omp_get_initial_device [18.7.7] [3.7.7]
omp_capture_affinity [18.3.11] [3.3.11] otherwise, it returns false. Returns a device number representing the host device.
Prints the OpenMP thread affinity information into a buffer
Fortran C/C++

int omp_in_final (void);


Fortran C/C++

using the format specification provided. int omp_get_initial_device (void);


size_t omp_capture_affinity (char *buffer, size_t size,
C/C++

const char *format) logical function omp_in_final () integer function omp_get_initial_device()


integer function omp_capture_affinity (buffer, format)
Fortran

character(len=*), intent(out) :: buffer


character(len=*), intent(in) :: format Resource relinquishing routines Device memory routines
omp_pause_resource [18.6.1] [3.6.1] These routines support allocation and management of
omp_pause_resource_all [18.6.2] [3.6.2] pointers in the data environments of target devices.
Teams region routines
Allows the runtime to relinquish resources used by omp_target_alloc [18.8.1] [3.8.1]
omp_get_num_teams [18.4.1] [3.4.1] OpenMP on the specified device. Valid kind values include Allocates memory in a device data environment and returns
Returns the number of initial teams in the current teams omp_pause_soft and omp_pause_hard. a device pointer to that memory.
region.
int omp_pause_resource (
C/C++

void *omp_target_alloc (size_t size, int device_num);


Fortran C/C++

int omp_get_num_teams (void); omp_pause_resource_t kind, int device_num);


C/C++

int omp_pause_resource_all ( type(c_ptr) function omp_target_alloc( &


integer function omp_get_num_teams () omp_pause_resource_t kind); size, device_num) bind(c)
Fortran

use, intrinsic :: iso_c_binding, only : c_ptr, &


integer function omp_pause_resource ( & c_size_t, c_int
omp_get_team_num [18.4.2] [3.4.2] kind, device_num)
Returns the initial team number of the calling thread. integer(c_size_t), value :: size
integer (kind=omp_pause_resource_kind) kind
Fortran

integer(c_int), value :: device_num


integer device_num
Fortran C/C++

int omp_get_team_num (void); integer function omp_pause_resource_all (kind) omp_target_free [18.8.2] [3.8.2]
integer (kind=omp_pause_resource_kind) kind Frees the device memory allocated by the
integer function omp_get_team_num () omp_target_alloc routine.
Device information routines void omp_target_free (void *device_ptr,
C/C++

omp_set_num_teams [18.4.3] [3.4.3] int device_num);


Sets the value of the nteams-var ICV of the current device, omp_get_num_procs [18.7.1] [3.7.1]
affecting the number of threads to be used for subsequent Returns the number of processors that are available to the subroutine omp_target_free(device_ptr, device_num) &
teams regions that do not specify a num_teams clause. device at the time the routine is called. bind(c)
Fortran

use, intrinsic :: iso_c_binding, only : c_ptr, c_int


Fortran C/C++
Fortran C/C++

void omp_set_num_teams (int num_teams); int omp_get_num_procs (void); type(c_ptr), value :: device_ptr
integer(c_int), value :: device_num
subroutine omp_set_num_teams(num_teams) integer function omp_get_num_procs ()
integer num_teams
4
Continued

© 2021 OpenMP ARB www.openmp.org OMPSC21


OpenMP API 5.2 C/C++ C/C++ content | Fortran or For Fortran content | [n.n.n] Sections in 5.2. spec | [n.n.n] Sections in 5.1. spec | 9 See Clause info on pg. 9 12

Runtime Library Routines (continued)


omp_target_is_present [18.8.3] [3.8.3] omp_target_memcpy_async [18.8.7] [3.8.7] omp_get_mapped_ptr [18.8.11] [3.8.11]
Tests whether a host pointer refers to storage that is Performs a copy between any combination of host and Returns the device pointer that is associated with a host
mapped to a given device. device pointers asynchronously. pointer for a given device.
int omp_target_memcpy_async (void *dst, void *omp_get_mapped_ptr (const void *ptr,

C/C++
int omp_target_is_present (const void *ptr,
C/C++

int device_num); const void *src, size_t length, size_t dst_offset, int device_num);

C/C++
size_t src_offset, int dst_device_num,
integer(c_int) function omp_target_is_present( & int src_device_num, int depobj_count, type(c_ptr) function omp_get_mapped_ptr( &
ptr, device_num) bind(c) omp_depend_t *depobj_list); ptr, device_num) bind(c)

Fortran
Fortran

use, intrinsic :: iso_c_binding, only : c_ptr, c_int use, intrinsic :: iso_c_binding, only : c_ptr, c_int
type(c_ptr), value :: ptr integer(c_int) function omp_target_memcpy_async( & type(c_ptr), value :: ptr
integer(c_int), value :: device_num dst, src, length, dst_offset, src_offset, & integer(c_int), value :: device_num
dst_device_num, src_device_num, depobj_count, &
omp_target_is_accessible [18.8.4] [3.8.4] depobj_list) bind(c)
Tests whether host memory is accessible from a given use, intrinsic :: iso_c_binding, only : c_ptr, c_int, & Lock routines

Fortran
device. c_size_t General-purpose lock routines. Two types of locks are
type(c_ptr), value :: dst, src supported: simple locks and nestable locks. A nestable
int omp_target_is_accessible (const void *ptr, integer(c_size_t), value :: length, dst_offset, src_offset lock can be set multiple times by the same task before
C/C++

size_t size, int device_num); integer(c_int), value :: dst_device_num, & being unset; a simple lock cannot be set if it is already
src_device_num, depobj_count owned by the task trying to set it.
integer(c_int) function omp_target_is_accessible( & integer(omp_depend_kind), optional :: depobj_list(*)
ptr, size, device_num) bind(c) Initialize lock [18.9.1] [3.9.1]
use, intrinsic :: iso_c_binding, only : & omp_target_memcpy_rect_async [18.8.8] [3.8.8]
Fortran

c_ptr, c_size_t, c_int Asynchronously performs a copy between any combination void omp_init_lock (omp_lock_t *lock);

C/C++
type(c_ptr), value :: ptr of host and device pointers.
integer(c_size_t), value :: size void omp_init_nest_lock (omp_nest_lock_t *lock);
integer(c_int), value :: device_num int omp_target_memcpy_rect_async (void *dst, subroutine omp_init_lock (svar)
const void *src, size_t element_size, int num_dims, integer (kind=omp_lock_kind) svar

Fortran
omp_target_memcpy [18.8.5] [3.8.5] const size_t *volume, const size_t *dst_offsets,
C/C++

Copies memory between any combination of host and const size_t *src_offsets, const size_t *dst_dimensions, subroutine omp_init_nest_lock (nvar)
device pointers. const size_t *src_dimensions, int dst_device_num, integer (kind=omp_nest_lock_kind) nvar
int src_device_num, int depobj_count,
int omp_target_memcpy (void *dst, const void *src, omp_depend_t *depobj_list); Initialize lock with hint [18.9.2] [3.9.2]
C/C++

size_t length, size_t dst_offset, size_t src_offset,


int dst_device_num, int src_device_num); integer(c_int) function & void omp_init_lock_with_hint (
omp_target_memcpy_rect_async ( & omp_lock_t *lock,
integer(c_int) function omp_target_memcpy( & dst, src, element_size, num_dims, volume, & omp_sync_hint_t hint);

C/C++
dst, src, length, dst_offset, src_offset, & dst_offsets, src_offsets, dst_dimensions, &
dst_device_num, src_device_num) bind(c) src_dimensions, dst_device_num, src_device_num, & void omp_init_nest_lock_with_hint (
use, intrinsic :: iso_c_binding, only : c_ptr, & depobj_count, depobj_list) bind(c) omp_nest_lock_t *lock,
Fortran

c_int, c_size_t use, intrinsic :: iso_c_binding, only : c_ptr, c_int, & omp_sync_hint_t hint);
Fortran

type(c_ptr), value :: dst, src c_size_t


integer(c_size_t), value :: length, dst_offset, src_offset subroutine omp_init_lock_with_hint (svar, hint)
type(c_ptr), value :: dst, src integer (kind=omp_lock_kind) svar
integer(c_int), value :: dst_device_num, & integer(c_size_t), value :: element_size integer (kind=omp_sync_hint_kind) hint
Fortran

src_device_num integer(c_int), value :: num_dims, dst_device_num, &


src_device_num, depobj_count subroutine omp_init_nest_lock_with_hint (nvar, hint)
omp_target_memcpy_rect [18.8.6] [3.8.6] integer(c_size_t), intent(in) :: volume(*), dst_offsets(*), & integer (kind=omp_nest_lock_kind) nvar
Copies a rectangular subvolume from a multi-dimensional src_offsets(*), dst_dimensions(*), src_dimensions(*) integer (kind=omp_sync_hint_kind) hint
array to another multi-dimensional array. integer(omp_depobj_kind), optional :: depobj_list(*) hint: See [15.1][2.19.12] in the specification.
int omp_target_memcpy_rect (void *dst, omp_target_associate_ptr [18.8.9] [3.8.9] Destroy lock [18.9.3] [3.9.3]
const void *src, size_t element_size, int num_dims, Maps a device pointer, which may be returned from
const size_t *volume, const size_t *dst_offsets, Ensure that the OpenMP lock is uninitialized.
omp_target_alloc or implementation-defined runtime
C/C++

const size_t *src_offsets, routines, to a host pointer. void omp_destroy_lock (omp_lock_t *lock);
C/C++

const size_t *dst_dimensions,


const size_t *src_dimensions, int dst_device_num, int omp_target_associate_ptr (const void *host_ptr, void omp_destroy_nest_lock (omp_nest_lock_t *lock);
C/C++

int src_device_num); const void *device_ptr, size_t size,


size_t device_offset, int device_num); subroutine omp_destroy_lock (svar)
integer(c_int) function omp_target_memcpy_rect( & integer (kind=omp_lock_kind) svar
Fortran

dst, src ,element_size, num_dims, volume, & integer(c_int) function omp_target_associate_ptr(&


dst_offsets, src_offsets, dst_dimensions, & subroutine omp_destroy_nest_lock (nvar)
host_ptr, device_ptr, size, device_offset, & integer (kind=omp_nest_lock_kind) nvar
src_dimensions, dst_device_num, & device_num) bind(c)
Fortran

src_device_num) bind(c) use, intrinsic :: iso_c_binding, only : c_ptr, &


use, intrinsic :: iso_c_binding, only : c_ptr, c_int, & c_size_t, c_int
Set lock [18.9.4] [3.9.4]
Fortran

c_size_t type(c_ptr), value :: host_ptr, device_ptr Sets an OpenMP lock. The calling task region is suspended
type(c_ptr), value :: dst, src integer(c_size_t), value :: size, device_offset until the lock is set.
integer(c_size_t), value :: element_size integer(c_int), value :: device_num void omp_set_lock (omp_lock_t *lock);
C/C++

integer(c_int), value :: num_dims, dst_device_num, &


src_device_num omp_target_disassociate_ptr [18.8.10] [3.8.10] void omp_set_nest_lock (omp_nest_lock_t *lock);
integer(c_size_t), intent(in) :: volume(*), dst_offsets(*), & Removes the association between a host pointer and a
src_offsets(*), dst_dimensions(*), src_dimensions(*) device address on a given device. subroutine omp_set_lock (svar)
integer (kind=omp_lock_kind) svar
Fortran

int omp_target_disassociate_ptr (const void *ptr,


C/C++

subroutine omp_set_nest_lock (nvar)


int device_num); integer (kind=omp_nest_lock_kind) nvar
integer(c_int) function omp_target_disassociate_ptr(&
ptr, device_num) bind(c) Unset lock [18.9.5] [3.9.5]
Fortran

use, intrinsic :: iso_c_binding, only : c_ptr, c_int void omp_unset_lock (omp_lock_t *lock);
C/C++

type(c_ptr), value :: ptr


integer(c_int), value :: device_num void omp_unset_nest_lock (omp_nest_lock_t *lock);
subroutine omp_unset_lock (svar)
integer (kind=omp_lock_kind) svar
Fortran

subroutine omp_unset_nest_lock (nvar)


integer (kind=omp_nest_lock_kind) nvar

4
Continued

© 2021 OpenMP ARB www.openmp.org OMPSC21


OpenMP API 5.2 C/C++ C/C++ content | Fortran or For Fortran content | [n.n.n] Sections in 5.2. spec | [n.n.n] Sections in 5.1. spec | 9 See Clause info on pg. 9 13

Runtime Library Routines (continued)


Test lock [18.9.6] [3.9.6] omp_get_interop_name [18.12.5] [3.12.5] omp_alloc and omp_aligned_alloc [18.13.6] [3.13.6]
Attempt to set an OpenMP lock but do not suspend Retrieves a property name from an omp_interop_t object. Request a memory allocation from a memory allocator.
execution of the task executing the routine.
const char* omp_get_interop_name ( void *omp_alloc (size_t size,

C/C++
int omp_test_lock (omp_lock_t *lock); omp_interop_t interop, omp_allocator_handle_t allocator);
C/C++

omp_interop_property_t property_id);

C
int omp_test_nest_lock (omp_nest_lock_t *lock); void *omp_aligned_alloc (size_t alignment,
omp_get_interop_type_desc [18.12.6] [3.12.6] size_t size, omp_allocator_handle_t allocator);
logical function omp_test_lock (svar) Retrieves a description of the type of a property associated
integer (kind=omp_lock_kind) svar void *omp_alloc (size_t size,
Fortran

with an omp_interop_t object.


omp_allocator_handle_t allocator
integer function omp_test_nest_lock (nvar) = omp_null_allocator);
integer (kind=omp_nest_lock_kind) nvar const char* omp_get_interop_type_desc (

C/C++
omp_interop_t interop,

C++
void *omp_aligned_alloc (size_t size,
omp_interop_property_t property_id); size_t alignment,
Timing routines omp_allocator_handle_t allocator
Timing routines support a portable wall clock timer. These omp_get_interop_rc_desc [18.12.7] [3.12.7] = omp_null_allocator);
record elapsed time per-thread and are not guaranteed to Retrieves a description of the return code associated with
be globally consistent across all the threads participating an omp_interop_t object. type(c_ptr) function omp_alloc (size, allocator) bind(c)
in an application. use, intrinsic :: iso_c_binding, only : c_ptr, c_size_t
const char* omp_get_interop_rc_desc (
C/C++
integer(c_size_t), value :: size
omp_get_wtime [18.10.1] [3.10.1] omp_interop_t ret_code); integer(omp_allocator_handle_kind), value :: allocator

Fortran
Returns elapsed wall clock time in seconds. type(c_ptr) function omp_aligned_alloc ( &
Memory management routines alignment, size, allocator) bind(c)
Fortran C/C++

double omp_get_wtime (void); use, intrinsic :: iso_c_binding, only : c_ptr, c_size_t


Memory Management Types [18.13.1] [3.13.1] integer(c_size_t), value :: alignment, size
double precision function omp_get_wtime () The omp_alloctrait_t struct in C/C++ and omp_alloctrait integer(omp_allocator_handle_kind), value :: allocator
type in Fortran define members named key and value,
with these types and values: omp_free [18.13.7] [3.13.7]
omp_get_wtick [18.10.2] [3.10.2] Deallocates previously allocated memory.
Returns the precision of the timer (seconds between ticks) C/C++ enum omp_alloctrait_key_t
used by omp_get_wtime. For integer omp_alloctrait_key_kind
void omp_free (void *ptr,

C
omp_atk_X where X may be one of sync_hint, alignment, omp_allocator_handle_t allocator);
Fortran C/C++

double omp_get_wtick (void); access, pool_size, fallback, fb_data, pinned, partition


void omp_free (void *ptr,
C/C++ enum omp_alloctrait_value_t

C++
omp_allocator_handle_t allocator
For integer omp_alloctrait_val_kind = omp_null_allocator);
double precision function omp_get_wtick ()
omp_atv_X where X may be one of false, true, default,
contended, uncontended, serialized, private, all, subroutine omp_free (ptr, allocator) bind(c)

Fortran
thread, pteam, cgroup, default_mem_fb, null_fb, use, intrinsic :: iso_c_binding, only : c_ptr
Event routine abort_fb, allocator_fb, environment, nearest, type(c_ptr), value :: ptr
Event routines support OpenMP event objects, which blocked, interleaved integer(omp_allocator_handle_kind), value :: allocator
must be accessed through the routines described in this
section or through the detach clause. omp_init_allocator [18.13.2] [3.13.2] omp_calloc and omp_aligned_calloc [18.13.8] [3.13.8]
Initializes allocator and associates it with a memory space. Request a zero-initialized memory allocation from a
omp_fulfill_event [18.11.1] [3.11.1] memory allocator.
Fulfills and destroys an OpenMP event. omp_allocator_handle_t omp_init_allocator (
C/C++

omp_memspace_handle_t memspace, void *omp_calloc (size_t nmemb, size_t size,


Fortran C/C++

void omp_fulfill_event (omp_event_handle_t event); int ntraits, const omp_alloctrait_t traits[]); omp_allocator_handle_t allocator);
integer (kind=omp_allocator_handle_kind) function & void *omp_aligned_calloc (size_t alignment,
C

subroutine omp_fulfill_event (event) omp_init_allocator (memspace, ntraits, traits size_t nmemb, size_t size,
integer (kind=omp_event_handle_kind) event
Fortran

integer (kind=omp_memspace_handle_kind), & omp_allocator_handle_t allocator);


intent (in) :: memspace
integer, intent (in) :: ntraits void *omp_calloc (size_t nmemb, size_t size,
Interoperability routines type (omp_alloctrait), intent (in) :: traits (*) omp_allocator_handle_t allocator
omp_get_num_interop_properties [18.12.1] [3.12.1] = omp_null_allocator);
omp_destroy_allocator [18.13.3] [3.13.3]
C++

Retrieves the number of implementation-defined void *omp_aligned_calloc (size_t alignment,


properties available for an omp_interop_t object. Releases all resources used by the allocator handle. size_t nmemb, size_t size,
void omp_destroy_allocator ( omp_allocator_handle_t allocator
C/C++

int omp_get_num_interop_properties (
C/C++

omp_allocator_handle_t allocator); = omp_null_allocator);


omp_interop_t interop);
subroutine omp_destroy_allocator (allocator) type(c_ptr) function omp_calloc (nmemb, size, &
Fortran

omp_get_interop_int [18.12.2] [3.12.2] integer (kind=omp_allocator_handle_kind), & allocator) bind(c)


Retrieves an integer property from an omp_interop_t object. intent (in) :: allocator use, intrinsic :: iso_c_binding, only : c_ptr, c_size_t
integer(c_size_t), value :: nmemb, size
omp_intptr_t omp_get_interop_int ( omp_set_default_allocator [18.13.4] [3.13.4] integer(omp_allocator_handle_kind), value :: allocator
Fortran

const omp_interop_t interop,


C/C++

Sets the default memory allocator to be used by allocation type(c_ptr) function omp_aligned_calloc ( &
omp_interop_property_t property_id, calls, allocate directives, and allocate clauses that do not alignment, nmemb, size, allocator) bind(c)
int *ret_code ); specify an allocator. use, intrinsic :: iso_c_binding, only : c_ptr, c_size_t
integer(c_size_t), value :: alignment, nmemb, size
omp_get_interop_ptr [18.12.3] [3.12.3] void omp_set_default_allocator (
C/C++

integer(omp_allocator_handle_kind), value :: allocator


Retrieves a pointer property from an omp_interop_t object. omp_allocator_handle_t allocator);
subroutine omp_set_default_allocator (allocator)
Fortran

void *omp_get_interop_ptr (
const omp_interop_t interop, integer (kind=omp_allocator_handle_kind), &
C/C++

omp_interop_property_t property_id, intent (in) :: allocator


int *ret_code ); omp_get_default_allocator [18.13.5] [3.13.5]
omp_get_interop_str [18.12.4] [3.12.4] Returns the memory allocator to be used by allocation calls,
allocate directives, and allocate clauses that do not specify
Retrieves a string property from an omp_interop_t object. an allocator.
const char* omp_get_interop_str ( omp_allocator_handle_t
Fortran C/C++

const omp_interop_t interop,


C/C++

omp_get_default_allocator (void);
omp_interop_property_t property_id,
int *ret_code ); integer (kind=omp_allocator_handle_kind) &
function omp_get_default_allocator ()

Continued
4
© 2021 OpenMP ARB www.openmp.org OMPSC21
OpenMP API 5.2 C/C++ C/C++ content | Fortran or For Fortran content | [n.n.n] Sections in 5.2. spec | [n.n.n] Sections in 5.1. spec | 9 See Clause info on pg. 9 14

Runtime Library Routines (continued)


omp_realloc [18.13.9] [3.13.9] Tool control routine Environment display routine
Reallocates the given area of memory originally allocated
by free_allocator using allocator, moving and resizing if omp_control_tool [18.14] [3.14] omp_display_env [18.15] [3.15]
necessary. Enables a program to pass commands to an active tool. Displays the OpenMP version number and the values of
ICVs associated with environment variables.
int omp_control_tool (int command, int modifier,

C/C++
void *omp_realloc (void *ptr, size_t size,

Fortran C/C++
omp_allocator_handle_t allocator, void *arg); void omp_display_env (int verbose);
C

omp_allocator_handle_t free_allocator); integer function omp_control_tool (command, &


subroutine omp_display_env (verbose)

Fortran
void *omp_realloc (void *ptr, size_t size, modifier)
omp_allocator_handle_t allocator integer (kind=omp_control_tool_kind) command logical, intent(in) :: verbose
integer modifier
C++

= omp_null_allocator,
omp_allocator_handle_t free_allocator command:
= omp_null_allocator); omp_control_tool_start
type(c_ptr) function omp_realloc ( & Start or restart monitoring if it is off. If monitoring
ptr, size, allocator, free_allocator) bind(c) is already on, this command is idempotent. If
use, intrinsic :: iso_c_binding, only : c_ptr, c_size_t monitoring has already been turned off permanently,
Fortran

type(c_ptr), value :: ptr this command will have no effect.


integer(c_size_t), value :: size omp_control_tool_pause
integer(omp_allocator_handle_kind), value :: & Temporarily turn monitoring off. If monitoring is
allocator, free_allocator already off, it is idempotent.
omp_control_tool_flush
Flush any data buffered by a tool. This command may
be applied whether monitoring is on or off.
omp_control_tool_end
Turn monitoring off permanently; the tool finalizes
itself and flushes all output.

Environment Variables
Environment variable names are upper case. The values assigned to them are case insensitive and may have leading and trailing white space.
OMP_AFFINITY_FORMAT format [21.2.5] [6.14] Allocator traits & allowed values [Table 6.2 2.9] OMP_DISPLAY_AFFINITY var [21.2.4] [6.13]
Sets the initial value of the affinity-format-var ICV defining sync_hint contended, uncontended, serialized, private Instructs the runtime to display formatted affinity
the format when displaying OpenMP thread affinity alignment 1 byte; Positive integer value that is a power of 2 information for all OpenMP threads in the parallel
information. The format is a character string that may access all, cgroup, pteam, thread region. The information is displayed upon entering the
contain as substrings one or more field specifiers, in first parallel region and when there is any change in the
pool_size Positive integer value (default is impl. defined)
addition to other characters. The value is case-sensitive, information accessible by the format specifiers listed
and leading and trailing whitespace is significant. The fallback default_mem_fb, null_fb, abort_fb, allocator_fb in the table for OMP_AFFINITY_FORMAT. If there is
format of each field specifier is: %[[[0].]size]type, where fb_data An allocator handle (No default) a change of affinity of any thread in a parallel region,
the field type may be either the short or long names pinned true, false thread affinity information for all threads in that region
listed below [Table 21.2 6.2]. partition environment, nearest, blocked, interleaved will be displayed. var may be true or false.
t team_num n thread_num
T num_teams N num_threads
Predefined allocators, memory space, and trait values [Table 6.3 2.10] OMP_DISPLAY_ENV var [21.7] [6.12]
omp_default_mem_alloc omp_default_mem_space If var is true, instructs the runtime to display the OpenMP
L nesting_level a ancestor_tnum fallback:null_fb version number and the value of the ICVs associated with
P process_id A thread_affinity
omp_large_cap_mem_alloc omp_large_cap_mem_space the environment variables as name=value pairs. If var is
H host i native_thread_id (none) verbose, the runtime may also display vendor-specific
omp_const_mem_space variables. If var is false, no information is displayed.
OMP_ALLOCATOR [21.5.1] [6.22] omp_const_mem_alloc (none)
OpenMP memory allocators can be used to make
allocation requests. This environment variable sets the omp_high_bw_mem_alloc omp_high_bw_mem_space
(none)
OMP_DYNAMIC var [21.1.1] [6.3]
Sets the initial value of the dyn-var ICV. var may be true
initial value of def-allocator-var ICV that specifies the omp_low_lat_mem_space or false. If true, the implementation may dynamically
default allocator for allocation calls, directives, and omp_low_lat_mem_alloc (none) adjust the number of threads to use for executing
clauses that do not specify an allocator. The value is Implementation defined parallel regions.
a predefined allocator or a predefined memory space omp_cgroup_mem_alloc access:cgroup
optionally followed by one or more allocator traits. Implementation defined OMP_MAX_ACTIVE_LEVELS levels [21.1.4] [6.8]
omp_pteam_mem_alloc access:pteam
• Predefined memory spaces are listed in Table 6.1 2.8 Sets the initial value of the max-active-levels-var ICV that
• Allocator traits are listed in Table 6.2 2.9 omp_thread_mem_alloc Implementation defined controls the maximum number of nested active parallel
• Predefined allocators are listed in Table 6.3 2.10 access:thread regions.

Examples OMP_CANCELLATION [21.2.6] [6.11] OMP_MAX_TASK_PRIORITY level [21.2.9] [6.16]


Sets the initial value of the cancel-var ICV. The value must Sets the initial value of the max-task-priority-var ICV that
setenv OMP_ALLOCATOR omp_high_bw_mem_alloc controls the use of task priorities.
be true or false. If true, the effects of the cancel construct
setenv OMP_ALLOCATOR \ and of cancellation points are enabled and cancellation
omp_large_cap_mem_space : alignment=16, \ is activated. OMP_NUM_TEAMS [21.6.1] [6.23]
pinned=true Sets the maximum number of teams created by a teams
OMP_DEBUG [21.4.1] [6.21] construct by setting the nteams-var ICV.
setenv OMP_ALLOCATOR \
Sets the debug-var ICV. The value must be enabled or
omp_high_bw_mem_space : pool_size=1048576, \
disabled. If enabled, the OpenMP implementation will OMP_NUM_THREADS list [21.1.2] [6.2]
fallback=allocator_fb, fb_data=omp_low_lat_mem_alloc collect additional runtime information to be provided to Sets the initial value of the nthreads-var ICV for the
a third-party tool. If disabled, only reduced functionality number of threads to use for parallel regions.
Memory space names [Table 6.1 2.8] might be available in the debugger.
omp_default_mem_space omp_high_bw_mem_space OMP_PLACES places [21.1.6] [6.5]
omp_large_cap_mem_space omp_low_lat_mem_space OMP_DEFAULT_DEVICE device [21.2.7] [6.15] Sets the initial value of the place-partition-var ICV that
omp_const_mem_space Sets the initial value of the default-device-var ICV that defines the OpenMP places available to the execution
controls the default device number to use in device environment. places is an abstract name (threads, cores,
constructs. sockets, ll_caches, numa_domains) or an ordered list of
places where each place of brace-delimited numbers is an
unordered set of processors on a device.

© 2021 OpenMP ARB www.openmp.org OMPSC21


OpenMP API 5.2 C/C++ C/C++ content | Fortran or For Fortran content | [n.n.n] Sections in 5.2. spec | [n.n.n] Sections in 5.1. spec | 9 See Clause info on pg. 9 15

Environment Variables
OMP_PROC_BIND policy [21.1.7] [6.4] OMP_TARGET_OFFLOAD [21.2.8] [6.17] OMP_TOOL_LIBRARIES library-list [21.3.2] [6.19]
Sets the initial value of the global bind-var ICV, setting Sets the initial value of the target-offload-var ICV. The Sets the tool-libraries-var ICV to a list of tool libraries
the thread affinity policy to use for parallel regions at the value must be one of mandatory, disabled, or default. that will be considered for use on a device where an
corresponding nested level. policy can have the values OpenMP implementation is being initialized. library-list is
true, false, or a comma-separated list of primary, close, OMP_TEAMS_THREAD_LIMIT [21.6.2] [6.24] a space-separated list of dynamically-linked libraries, each
or spread in quotes. Sets the maximum number of OpenMP threads to use in specified by an absolute path.
each contention group created by a teams construct by
OMP_SCHEDULE [modifier:]kind[, chunk] [21.2.1] [6.1] setting the teams-thread-limit-var ICV. OMP_TOOL_VERBOSE_INIT [21.3.3] [6.20]
Sets the run-sched-var ICV for the runtime schedule Sets the tool-verbose-init-var ICV, which controls whether
kind and chunk size. modifier is one of monotonic or OMP_THREAD_LIMIT limit [21.1.3] [6.10] an OpenMP implementation will verbosely log the
nonmonotonic; kind is one of static, dynamic, guided, Sets the maximum number of OpenMP threads to use in registration of a tool. The value must be a filename or one
or auto. a contention group by setting the thread-limit-var ICV. of disabled, stdout, or stderr.

OMP_STACKSIZE size[ B | K | M | G ] [21.2.2] [6.6] OMP_TOOL (enabled|disabled) [21.3.1] [6.18] OMP_WAIT_POLICY policy [21.2.3] [6.7]
Sets the stacksize-var ICV that specifies the size of Sets the tool-var ICV. If disabled, no first-party tool will be Sets the wait-policy-var ICV that provides a hint to an
the stack for threads created by the OpenMP imple- activated. If enabled the OpenMP implementation will try OpenMP implementation about the desired behavior of
mentation. size is a positive integer that specifies stack to find and activate a first-party tool. waiting threads. Valid values for policy are active (waiting
size. B is bytes, K is kilobytes, M is megabytes, and G is threads consume processor cycles while waiting) and
gigabytes. If unit is not specified, size is in units of K. passive. Default is implementation defined.

Internal Control Variables (ICV) Values


Host and target device ICVs are initialized before OpenMP API constructs or routines execute. After initial values are assigned, the values of environment variables set
by the user are read and the associated ICVs for host and target devices are modified accordingly. Certain environment variables may be extended with device-specific
environment variables with the following syntax: <ENV_VAR>_DEV[_<device_num>]. Device-specific environment variables must not correspond to environment variables
that initialize ICVs with the global scope.
Table of ICV Initial Values, Ways to Modify and to Retrieve ICV Values, and Scope [Tables 2.1-3] [2.1-3]
ICV Environment variable Initial value Ways to modify value Ways to retrieve value Scope Env. Var. Ref.
active-levels-var (none) zero (none) omp_get_active_level() Data env. ---
affinity-format-var OMP_AFFINITY_FORMAT Implementation defined. omp_set_affinity_format() omp_get_affinity_format() Device [21.2.5] [6.14]
bind-var OMP_PROC_BIND Implementation defined. (none) omp_get_proc_bind() Data env. [21.1.7] [6.4]
cancel-var OMP_CANCELLATION false (none) omp_get_cancellation() Global [21.2.6] [6.11]
debug-var OMP_DEBUG disabled (none) (none) Global [21.4.1] [6.21]
def-allocator-var OMP_ALLOCATOR Implementation defined. omp_set_default_allocator() omp_get_default_allocator() Impl. Task [21.5.1] [6.22]
def-sched-var (none) Implementation defined. (none) (none) Device ---
default-device-var OMP_DEFAULT_DEVICE Implementation defined. omp_set_default_device() omp_get_default_device() Data env. [21.2.7] [6.15]
display-affinity-var OMP_DISPLAY_AFFINITY false (none) (none) Global [21.2.4] [6.13]
Implementation-defined if the
dyn-var OMP_DYNAMIC implementation supports dynamic omp_set_dynamic() omp_get_dynamic() Data env. [21.1.1] [6.3]
adjustment of the number of threads;
otherwise, the initial value is false.
explicit-task-var (none) false omp_in_explicit_task()
final-task-var (none) false (none) omp_in_final() Data env. ---
levels-var (none) zero (none) omp_get_level() Data env. ---
OMP_MAX_ACTIVE_LEVELS, Device
[21.1.4] [6.8]
max-active-levels-var OMP_NUM_THREADS, Implementation defined. omp_set_max_active_levels() omp_get_max_active_levels() Data env.
[21.1.2] [6.9]
OMP_PROC_BIND [21.1.7] [6.2]
max-task-priority-var OMP_MAX_TASK_PRIORITY zero (none) omp_get_max_task_priority() Global [21.2.9] [6.16]
nteams-var OMP_NUM_TEAMS zero omp_set_num_teams() omp_get_max_teams() Device [21.6.1] [6.23]
nthreads-var OMP_NUM_THREADS Implementation defined. omp_set_num_threads() omp_get_max_threads() Data env. [21.1.2] [6.2]
num-procs-var (none) Implementation defined. (none) omp_get_num_procs() Device ---
omp_get_partition_num_places()
omp_get_partition_place_nums()
place-partition-var OMP_PLACES Implementation defined. (none) Impl. Task [21.1.6] [6.5]
omp_get_place_num_procs()
omp_get_place_proc_ids()
run-sched-var OMP_SCHEDULE Implementation defined. omp_set_schedule() omp_get_schedule() Data env. [21.2.1] [6.1]
stacksize-var OMP_STACKSIZE Implementation defined. (none) (none) Device [21.2.2] [6.6]
target-offload-var OMP_TARGET_OFFLOAD DEFAULT (none) (none) Global [21.2.8] [6.17]
team-size-var (none) one (none) omp_get_num_threads() Team ---
teams-thread-limit-var OMP_TEAMS_THREAD_LIMIT zero omp_set_teams_thread_limit() omp_get_teams_thread_limit() Device [21.6.2] [6.24]
thread-limit-var OMP_THREAD_LIMIT Implementation defined. target and teams constructs omp_get_thread_limit() Data env. [21.1.3] [6.10]
thread-num-var (none) zero (none) omp_get_thread_num() Impl. Task ---
tool-libraries-var OMP_TOOL_LIBRARIES empty string (none) (none) Global [21.3.2] [6.19]
tool-var OMP_TOOL enabled (none) (none) Global [21.3.1] [6.18]
tool-verbose-init-var OMP_TOOL_VERBOSE_INIT disabled (none) (none) Global [21.3.3] [6.20]
wait-policy-var OMP_WAIT_POLICY Implementation defined. (none) (none) Device [21.2.3] [6.7]

© 2021 OpenMP ARB www.openmp.org OMPSC21


OpenMP API 5.2 www.openmp.org Page 16

Using OpenMP Tools


A tool indicates its interest in using the OMPT • Introducing a dynamically linked library that includes You can use omp_tool_verbose_init to help understand
interface by providing a non-null pointer to an the tool’s definition of ompt_start_tool into the issues with loading or activating tools. This runtime library
ompt_start_tool_result_t structure to an OpenMP application’s address space. routine sets the tool-verbose-init-var ICV, which controls
implementation as a return value from the whether an OpenMP implementation will verbosely log
• Providing the name of a dynamically linked
ompt_start_tool function. the registration of a tool.
library appropriate for the architecture and
There are three ways that a tool can provide a definition operating system used by the application in the
of ompt_start_tool to an OpenMP implementation: tool-libraries-var ICV (via omp_tool_libraries).
• Statically linking the tool’s definition of
ompt_start_tool into an OpenMP application.

OpenMP API 5.2 Reference Guide Index

Clauses‑9 loop‑4 taskloop‑4


Loop transformation constructs‑3 taskwait‑5
Directives and Constructs-1–8 tile‑3 taskyield‑4
allocate, allocators‑1 unroll‑3 teams‑3
assume, assumes‑2 masked‑3 threadprivate‑1
atomic‑6 Memory management directives‑1 tile‑3
barrier‑5 allocate‑1
allocators‑1 unroll‑3
begin assumes‑2 Variant directives‑1
Memory spaces‑1
begin declare target‑2 [begin ]declare target‑2
metadirective‑1
cancel‑6 declare simd‑2
nothing‑3 declare variant‑2
Cancellation constructs
cancel‑6 ordered‑6 dispatch‑2
cancellation point‑6 parallel‑3 metadirective‑1
cancellation point‑6 Parallelism constructs‑3 Work-distribution constructs‑3
Combined forms‑6–8 masked‑3 distribute‑4
parallel‑3 do‑4
critical‑5 simd‑3 for‑4
Data environment directives‑1 teams‑3 loop‑4
declare mapper‑1 requires‑2 scope‑3
declare reduction‑1 section, sections‑4
scan‑1 scan‑1
single‑3
threadprivate‑1 scope‑3 workshare‑3
declare mapper‑1 section, sections‑4 workshare‑3
declare reduction‑1 simd‑3
declare simd‑2 single‑3 Environment Variables‑14–15
declare target‑2 Synchronization constructs‑5
atomic‑6
Internal Control Variable (ICV) Values‑15
declare variant‑2
barrier‑5
depobj‑5 Runtime Library Routines-10–14
critical‑5
Device directives and construct‑4 depobj‑5 Device information routines‑11
target‑5 flush‑5 Device memory routines‑11–12
target data‑4 ordered‑6 Environment display routine‑14
target enter data‑5 taskgroup‑5
target exit data‑5
Event routine‑13
taskwait‑5
target update‑5 Interoperability routines‑13
target‑5
dispatch‑2 Lock routines‑12–13
target data‑4
distribute‑4 Memory management routines‑13
target enter data‑5
do‑4 Resource relinquishing routines‑11
target exit data‑5
flush‑5 Tasking routines‑11
target update‑5
for‑4 Teams region routines‑11
task‑4
Informational & utility directives‑2 Thread affinity routines‑10–11
taskgroup‑5
assume, [begin ]assumes‑2 Thread team routines‑10
error‑3 Tasking constructs‑4
task‑4 Timing routines‑13
nothing‑3 Tool control routine‑14
requires‑2 taskloop‑4
taskyield‑4
interop‑5

Copyright © 2021 OpenMP Architecture Review Board. based on one or more of the OpenMP specifications must
Permission to copy without fee all or part of this material is acknowledge the copyright by displaying the following
granted, provided the OpenMP Architecture Review Board statement: “OpenMP is a trademark of the OpenMP
copyright notice and the title of this document appear. Architecture Review Board. Portions of this product/
®
Notice is given that copying is by permission of the OpenMP publication may have been derived from the OpenMP
Architecture Review Board. Products or publications Language Application Program Interface Specification.”

© 2021 OpenMP ARB OMP1121

You might also like