OpenMP API5.0 Page 1 OpenMP OpenMP 5.0 API Syntax Reference Guide The OpenMP API is a portable,scalable Fortran.OpenMP is suitable for a wide range model that gives parallel programmers a of algorithms running on multicore nodes and openmp.org simple and flexible interface for developing chips,NUMA systems,GPUs,and other such portable parallel applications in C/C++and devices attached to a CPU. Fortran content Functionality new/changed in OpenMP 5.0 is in this color,and in OpenMP 4.5 is in this color. C/C++content [nSections in the 5.0spec. [n.n.n]Sections in the 4.5 spec. Deprecated in the5.0 spec. Directives and Constructs variant directives parallel construct Metadirectives I2341 arallel I2611251 vate (s)firstprivate(s) reates a team of OpenMP threads that execute the 侧 metadirective based on context. pragmaomp ause) d pam0mpmebdiotveousd0bug- allel[.Idousel] single [2.8.)7.) irective [clause(L]cause]] du) inetadreive cue omp ingle uselouse Somp end single [end_cause([Jend_clause]-] Somp end metadirective ego6eso fpa面 decare variant 2 default (sharedfrstprivate privateoe) edvariant of a base function and the teams construct eamsj2ioat where the int unctiondefnitionordeclorotion ISomp end workshare (nowait) Worksharing-loop construct te。u8s for/do29227.1 language identifer o doueus r-expression requires directive omp end do nowait Worksharing constructs 5 ections2.8.1]27.2 pragma omp requires clouse[[L clause) Somp requires douse [douse).] pragma omp sections [dausel[]cause).] order(seq_cstl acq_rel relaxed) round-robin fashion in order of thread number. red-block (Somp section ructured-block] Somp end sections nowait Continued) 2019 OpenMP ARB OMP0519-01,OMP5
© 2019 OpenMP ARB OMP0519-01-OMP5 OpenMP API 5.0 Page 1 OpenMP 5.0 API Syntax Reference Guide ® Directives and Constructs An OpenMP executable directive applies to the succeeding structured block. A structured-block is an OpenMP construct or a block of executable statements with a single entry at the top and a single exit at the bottom. OpenMP directives except simd and any declarative directive may not appear in Fortran PURE procedures. variant directives Metadirectives [2.3.4] A directive that can specify multiple directive variants, one of which may be conditionally selected to replace the metadirective based on the enclosing OpenMP context. C/C++ #pragma omp metadirective [clause[ [,] clause] ... ] - or - #pragma omp begin metadirective [clause[ [,] clause] ... ] stmt(s) #pragma omp end metadirective For !$omp metadirective [clause[ [,] clause] ... ] - or - !$omp begin metadirective [clause[ [,] clause] ... ] stmt(s) !$omp end metadirective clause: when (context-selector-specification: [directive-variant]) default (directive-variant) declare variant [2.3.5] Declares a specialized variant of a base function and the context in which it is used. C/C++ #pragma omp declare variant(variant-func-id) clause [#pragma omp declare variant(variant-func-id) clause] [ ... ] function definition or declaration For!$omp declare variant ( & [base-proc-name: ]variant-proc-name) clause clause: match (context-selector-specification) variant-func-id: C/C++ The name of a function variant that is a base language identifier, or, for C++, a template-id. variant-proc-name: For The name of a function variant that is a base language identifier. requires directive requires [2.4] Specifies the features that an implementation must provide in order for the code to compile and to execute correctly. C/C++ #pragma omp requires clause [ [ [,] clause] ... ] For !$omp requires clause [ [ [,] clause] ... ] clause: reverse_offload unified_address unified_shared_memory atomic_default_mem_order(seq_cst | acq_rel | relaxed) dynamic_allocators parallel construct parallel [2.6] [2.5] Creates a team of OpenMP threads that execute the region. C/C++#pragma omp parallel [clause[ [, ]clause] ...] structured-block For!$omp parallel [clause[ [, ]clause] ...] structured-block !$omp end parallel clause: private (list), firstprivate (list), shared (list) copyin (list) reduction ([reduction-modifier, ] reduction-identifier: list) proc_bind (master | close | spread) allocate ([allocator : ]list) C/C++ if ([ parallel : ] scalar-expression) C/C++ num_threads (integer-expression) C/C++ default (shared | none) For if ([ parallel : ] scalar-logical-expression) For num_threads (scalar-integer-expression) For default (shared | firstprivate | private | none) teams construct teams [2.7] [2.10.7] Creates a league of initial teams where the initial thread of each team executes the region. C/C++#pragma omp teams [clause[ [, ]clause] ...] structured-block For!$omp teams [clause[ [, ]clause] ...] structured-block !$omp end teams clause: private (list), firstprivate (list), shared (list) reduction ([default ,] reduction-identifier : list) allocate ([allocator : ]list) C/C++ num_teams (integer-expression) C/C++ thread_limit (integer-expression) C/C++ default (shared | none) For num_teams (scalar-integer-expression) For thread_limit (scalar-integer-expression) For default (shared | firstprivate | private | none) Worksharing constructs sections[2.8.1] [2.7.2] A noniterative worksharing construct that contains a set of structured blocks that are to be distributed among and executed by the threads in a team. C/C++ #pragma omp sections [clause[ [, ] clause] ...] { [#pragma omp section] structured-block [#pragma omp section structured-block] ... } For !$omp sections [clause[[,] clause] ...] [!$omp section] structured-block [!$omp section structured-block] ... !$omp end sections [nowait] clause: private (list), firstprivate (list) lastprivate ([lastprivate-modifier: ] list) reduction ([reduction-modifier,] reduction-identifier: list) allocate ([allocator : ]list) C/C++ nowait single [2.8.2] [2.7.3] Specifies that the associated structured block is executed by only one of the threads in the team. C/C++#pragma omp single [clause[ [, ]clause] ...] structured-block For!$omp single [clause[ [, ]clause] ...] structured-block !$omp end single [end_clause[ [, ]end_clause] ...] clause: private (list), firstprivate (list) allocate ([allocator : ]list) C/C++ copyprivate (list) C/C++ nowait end_clause: For copyprivate (list), nowait workshare [2.8.3] [2.7.4] Divides the execution of the enclosed structured block into separate units of work, each executed only once by one thread. For!$omp workshare structured-block !$omp end workshare [nowait] Worksharing-loop construct for / do [2.9.2] [2.7.1] Specifies that the iterations of associated loops will be executed in parallel by threads in the team. C/C++#pragma omp for [clause[ [, ]clause] ...] for-loops For!$omp do [clause[ [, ]clause] ...] do-loops [!$omp end do [nowait] ] clause: private (list), firstprivate (list) lastprivate ([lastprivate-modifier: ] list) linear (list[ : linear-step]) schedule ([modifier [, modifier] : ] kind[, chunk_size]) collapse (n), ordered [(n)] allocate ([allocator : ]list) order (concurrent) reduction ([reduction-modifier,] reduction-identifier: list) C/C++ nowait kind: • static: Iterations are divided into chunks of size chunk_size and assigned to threads in the team in round-robin fashion in order of thread number. • dynamic: Each thread executes a chunk of iterations then requests another chunk until none remain. • guided: Each thread executes a chunk of iterations then requests another chunk until no chunks remain to be assigned. Chunk size is different for each chunk, with each successive chunk smaller than the last. openmp.org The OpenMP® API is a portable, scalable model that gives parallel programmers a simple and flexible interface for developing portable parallel applications in C/C++ and Fortran. OpenMP is suitable for a wide range of algorithms running on multicore nodes and chips, NUMA systems, GPUs, and other such devices attached to a CPU. Functionality new/changed in OpenMP 5.0 is in this color, and in OpenMP 4.5 is in this color. C/C++ [n.n.n] Sections in the 5.0 spec. [n.n.n] Sections in the 4.5 spec. • Deprecated in the 5.0 spec. C/C++ content For Fortran content Continued4
Page2 OpenMP API5.0 Directives and Constructs (continued) distribute loop constructs scan directive puteeeeautedbyheinitalteam Somp end distribute tonic:Ch s are assigned to thread e be se (n) ienerdhenheloenotd chu distribute simd 】 currently using s: SIMD directives stribute simd [clouse[[lciouse].] octorsnmd, simd stnbute simd &m by distribute or sime Distribute Parallel Worksharing-Loop Tasking constructs task ateenegtl.simdenength task constr apply pr8miopntdou5dL Somp distribute parallel do /oouse!clouse]... on-identfer:st) end (dep Distribute Parallel Worksharing-Loop SIMD Worksharing-Loop SIMD 2 IM cnophtcanhectdwta tribute parallel do simd cousef/clouse).. sion) e6a eclare simd loop construct will be eet pragm ncetondetinaoncrdedbroto Somp dedare simd fproc-nomel![clouse!L,Jdouse). nd loop nel n(argument-list) t e ecto8ut./econltenha:时 if (tas (tas (priv for final 20190 penMP ARB OMP0519-01-OMPS
Page 2 OpenMP API 5.0 © 2019 OpenMP ARB OMP0519-01-OMP5 Directives and Constructs (continued) • auto: The decision regarding scheduling is delegated to the compiler and/or runtime system. • runtime: The schedule and chunk size are taken from the run-sched-var ICV. modifier: • monotonic: Each thread executes the chunks that it is assigned in increasing logical iteration order. Default for static schedule. • nonmonotonic: Chunks are assigned to threads in any order and the behavior of an application that depends on execution order of the chunks is unspecified. Default for all schedule kinds except static. • simd: Ignored when the loop is not associated with a SIMD construct, otherwise the new_chunk_size for all except the first and last chunks is chunk_size/ simd_width * simd_width where simd_width is an implementation-defined value. SIMD directives simd [2.9.3.1] [2.8.1] Applied to a loop to indicate that the loop can be transformed into a SIMD loop. C/C++#pragma omp simd [clause[ [, ]clause] ...] for-loops For!$omp simd [clause[ [, ]clause] ...] do-loops [!$omp end simd] clause: safelen (length), simdlen (length) linear (list[ : linear-step]) aligned (list[ : alignment]) nontemporal (list) private (list) lastprivate ([lastprivate-modifier : ] list) reduction ([ reduction-modifier, ] reduction-identifier : list) collapse (n) order (concurrent) C/C++ if ([simd :] scalar-expression) For if ([simd :] scalar-logical-expression) Worksharing-Loop SIMD [2.9.3.2] [2.8.3] Applied to a loop to indicate that the loop can be transformed into a SIMD loop that will be executed in parallel by threads in the team. C/C++#pragma omp for simd [clause[ [, ]clause] ...] for-loops For!$omp do simd [clause[ [, ]clause] ...] do-loops [!$omp end do simd[nowait] ] clause: Any of the clauses accepted by the simd or for/do directives with identical meanings and restrictions. declare simd [2.9.3.3] [2.8.2] Applied to a function or a subroutine to enable the creation of one or more versions that can process multiple arguments using SIMD instructions from a single invocation in a SIMD loop. C/C++ #pragma omp declare simd [clause[ [, ]clause] ...] [#pragma omp declare simd [clause[ [, ]clause] ...]] [...] function definition or declaration For !$omp declare simd [(proc-name)] [clause[ [, ]clause] ...] clause: simdlen (length) linear (linear-list[ : linear-step]) aligned (argument-list[ : alignment]) uniform (argument-list) inbranch notinbranch distribute loop constructs distribute [2.9.4.1] [2.10.8] Specifies loops which are executed by the initial teams. C/C++#pragma omp distribute [clause[ [, ]clause] ...] for-loops For!$omp distribute [clause[ [, ]clause] ...] do-loops [!$omp end distribute] clause: private (list) firstprivate (list) lastprivate (list) collapse (n) dist_schedule (kind[, chunk_size]) allocate ([allocator : ]list) distribute simd [2.9.4.2] [2.10.9] Specifies loops which are executed concurrently using SIMD instructions and the initial teams. C/C++#pragma omp distribute simd [clause[ [, ]clause] ...] for-loops For!$omp distribute simd [clause[ [, ]clause] ...] do-loops [!$omp end distribute simd] clause: Any of the clauses accepted by distribute or simd. Distribute Parallel Worksharing-Loop [2.9.4.3] [2.10.10] These constructs specify a loop that can be executed in parallel by multiple threads that are members of multiple teams. C/C++#pragma omp distribute parallel for [clause[ [, ]clause] ...] for-loops For!$omp distribute parallel do [clause[ [, ]clause] ...] do-loops [!$omp end distribute parallel do] clause: Any accepted by the distribute or parallel worksharing-loop directives with identical meanings and restrictions. Distribute Parallel Worksharing-Loop SIMD [2.9.4.4] [2.10.11] Specifies a loop that can be executed concurrently using SIMD instructions in parallel by multiple threads that are members of multiple teams. C/C++#pragma omp distribute parallel for simd \ [clause[ [ , ]clause] ...] for-loops For!$omp distribute parallel do simd [clause[ [, ]clause] ...] do-loops [!$omp end distribute parallel do simd] clause: Any accepted by the distribute or parallel worksharing-loop SIMD directives with identical meanings and restrictions. loop construct loop [2.9.5] Specifies that the iterations of the associated loops may execute concurrently and permits the encountering thread(s) to execute the loop accordingly. C/C++#pragma omp loop [clause[ [, ]clause] ...] for-loops For!$omp loop [clause[ [, ]clause] ...] do-loops [!$omp end loop ] clause: bind (binding) collapse (n) order (concurrent) private (list) lastprivate (list) reduction ([default ,]reduction-identifier : list) binding: teams, parallel, thread scan directive scan [2.9.6] Specifies that each iteration of scan computations update the list items. C/C++ loop-associated-directive for-loop-headers { structured-block #pragma omp scan clause structured-block } For loop-associated-directive do-loop-headers structured-block !$omp scan clause structured-block do-termination-stmts(s) [end-loop-associated-directive ] clause: inclusive (list), exclusive (list) loop-associated-directive directives: C/C++ for, for simd, simd [end-]loop-associated-directive directives: For do (end do) do simd (end do simd) simd (end simd) Tasking constructs task [2.10.1] [2.9.1] Defines an explicit task. The data environment of the task is created according to the data-sharing attribute clauses on the task construct and any defaults that apply. C/C++#pragma omp task [clause[ [, ]clause] ...] structured-block For!$omp task [clause[ [, ]clause] ...] structured-block !$omp end task clause: untied, mergeable private (list), firstprivate (list), shared (list) in_reduction (reduction-identifier: list) depend ([depend-modifier, ] dependence-type : locator-list) priority(priority-value) allocate([allocator: ]list) affinity ([aff-modifier: ] locator-list) - where aff-modifier is iterator(iterators-definition) detach (event-handle) - where event-handle is of: type omp_event_handle_t C/C++ kind omp_event_handle_kind For C/C++ default (shared | none) C/C++ if ([ task : ] scalar-expression) C/C++ final (scalar-expression) For default (private | firstprivate | shared | none) For if ([ task : ] scalar-logical-expression) For final (scalar-logical-expression) taskloop [2.10.2] [2.9.2] Specifies that the iterations of one or more associated loops will be executed in parallel using OpenMP tasks. C/C++#pragma omp taskloop [clause[ [, ]clause] ...] for-loops For!$omp taskloop [clause[ [, ]clause] ...] do-loops [!$omp end taskloop ] clause: shared (list), private (list) firstprivate (list), lastprivate (list) reduction ([default ,] reduction-identifier : list) in_reduction (reduction-identifier : list) grainsize (grain-size), num_tasks (num-tasks) collapse (n), priority (priority-value) untied, mergeable, nogroup allocate ([allocator: ]list) C/C++ if ([ taskloop : ] scalar-expression) C/C++ default (shared | none) C/C++ final (scalar-expr) For if ([ taskloop : ] scalar-logical-expression) For default (private | firstprivate | shared | none) For final (scalar-logical-expr) Continued4
OpenMP API5.0 Page3 Directives and Constructs(continued) taskloop simd21o.2到 depend (depend-modifier dependence-type:locator-fist) declare target +h enterdbh:lscotoreprsso op simd (idausel. target exit data Hpragma omp target exit data (clousel[,Iclause/... Somp tareet exdit data fdousel L.Iclousel1 taskyield [2.10.4]12.11.2) n be suspended in favo decare target fclouselL jdousel.... pragma omp taskyield ) Somp taskyield Memory management directive Combined constructs Parallel Worksharing Loop 5 prama omptaretdouse ause lel do [clousef[idause]. omo const mem soace sepepanldb eepteaRh2aeltoodectve parallel loop) promp allocate)cuse m-behavofvrob-c 5 omp allocate作dause epnden-ype amc圆 豆 difier:scal r-expression) ehrtEebtepaaleoropdnetves evice_num Device directives and construct ession of kind omp allocator handle kind target data P3ponsousetbusel- somtegeoed ISomp target update clousel_.] arget enter data es to a econstnahndnooterttetanine #pragma omp target enter data (clousel jclousel.... 50m areet enter data [clousel f.Iclousel.I pmp-type-modiferl 92019 OpenMP AR OMP0519-01-OMP
© 2019 OpenMP ARB OMP0519-01-OMP5 OpenMP API 5.0 Page 3 Directives and Constructs (continued) taskloop simd [2.10.3] [2.9.3] Specifies that a loop can be executed concurrently using SIMD instructions, and that those iterations will also be executed in parallel using OpenMP tasks. C/C++#pragma omp taskloop simd [clause[ [, ]clause] ...] for-loops For!$omp taskloop simd [clause[ [, ]clause] ...] do-loops [!$omp end taskloop simd] clause: Any accepted by the simd or taskloop directives with identical meanings and restrictions. taskyield [2.10.4] [2.11.2] Specifies that the current task can be suspended in favor of execution of a different task. C/C++ #pragma omp taskyield For !$omp taskyield Memory management directive Memory spaces [2.11.1] Predefined memory spaces [Table 2.8, below] represent storage resources for storage and retrieval of variables. Memory space Storage selection intent omp_default_mem_space System default storage. omp_large_cap_mem_space Storage with large capacity. omp_const_mem_space Storage optimized for variables with constant values. omp_high_bw_mem_space Storage with high bandwidth. omp_low_lat_mem_space Storage with low latency. allocate [2.11.3] Specifies how a set of variables is allocated. C/C++ #pragma omp allocate (list) [clause] For !$omp allocate (list) [clause] or !$omp allocate [ (list) ] clause [ !$omp allocate (list) clause [...]] allocate statement clause: allocator (allocator) - where allocator is an expression of: C/C++ type omp_allocator_handle_t For kind omp_allocator_handle_kind Device directives and construct target data [2.12.2] [2.10.1] Creates a device data environment for te extent of the region. C/C++#pragma omp target data clause[ [ [, ]clause] ...] structured-block For!$omp target data clause[ [ [, ]clause] ...] structured-block !$omp end target data clause: map ([[map-type-modifier[ ,] [map-type-modifier[,] ...] map-type: ] locator-list) use_device_ptr (ptr-list), use_device_addr (list) C/C++ if ( [target data : ] scalar-expression) C/C++ device (scalar-expression) For if ( [target data : ] scalar-logical-expression) For device (scalar-integer-expression) target enter data [2.12.3] [2.10.2] Maps variables to a device data environment. C/C++ #pragma omp target enter data [clause[ [, ]clause] ...] For !$omp target enter data [clause[ [, ]clause] ...] clause: map ([map-type-modifier[ ,] [map-type-modifier[ ,] ...] map-type: locator-list) depend ([depend-modifier,] dependence-type : locator-list) nowait C/C++ if ([ target enter data : ] scalar-expression) C/C++ device (integer-expression) For if ([ target enter data : ] scalar-logical-expression) For device (scalar-integer-expression) target exit data [2.12.4] [2.10.3] Unmaps variables from a device data environment. C/C++ #pragma omp target exit data [clause[ [, ]clause] ...] For !$omp target exit data [clause[ [, ]clause] ...] clause: map ([map-type-modifier[ ,] [map-type-modifier[ ,] ...] map-type: locator-list) depend ([depend-modifier, ] dependence-type : locator-list) nowait C/C++ if ([ target exit data : ] scalar-expression) C/C++ device (integer-expression) For if ([ target exit data : ] scalar-logical-expression) For device (scalar-integer-expression) target[2.12.5] [2.10.4] Map variables to a device data environment and execute the construct on that device. C/C++#pragma omp target [clause[ [, ]clause] ...] structured-block For!$omp target [clause[ [, ]clause] ...] structured-block !$omp end target clause: private (list), firstprivate (list) in_reduction (reduction-identifier : list) map ([[map-type-modifier[ ,] [map-type-modifier[,] ...] map-type: ] locator-list) is_device_ptr (list) defaultmap (implicit-behavior[:variable-category]) nowait depend([depend-modifier, ] dependence-type : locator-list) allocate ([allocator : ] list) uses_allocators (allocator[ (allocator-traits-array)] [,allocator[ (allocator-traits-array) ] ...] ) C/C++ if ([ target : ] scalar-expression) C/C++ device([device-modifier:] integer-expression) For if ([ target : ] scalar-logical-expression) For device ([device-modifier:] scalar-integer-expression) device-modifier: ancestor, device_num allocator: C/C++ Identifier of type omp_allocator_handle_t allocator: For Integer expression of kind omp_allocator_handle_kind allocator-traits-array: C/C++ Identifier of const omp_alloctrait_t * type. allocator-traits-array: For Array of type(omp_alloctrait) type target update [2.12.6] [2.10.5] Makes the corresponding list items in the device data environment consistent with their original list items, according to the specified motion clauses. C/C++ #pragma omp target update clause[ [ [, ]clause] ...] For !$omp target update clause[ [ [, ]clause] ...] clause: motion-clause or one of: nowait depend ([depend-modifier, ] dependence-type : locator-list) C/C++ if ([ target update : ] scalar-expression) C/C++ device (integer-expression) For if ([ target update : ] scalar-logical-expression) For device (scalar-integer-expression) motion-clause: to ([mapper(mapper-identifier) : ] locator-list) from ([mapper(mapper-identifier) : ] locator-list) declare target[2.12.7] [2.10.6] A declarative directive that specifies that variables, functions, and subroutines are mapped to a device. C/C++ #pragma omp declare target declarations-definition-seq #pragma omp end declare target - or - #pragma omp declare target (extended-list) - or - #pragma omp declare target clause[ [, ]clause ...] For !$omp declare target (extended-list) - or - !$omp declare target [clause[ [, ]clause] ...] clause: to (extended-list), link (list) device_type (host | nohost | any) extended-list: A comma-separated list of named variables, procedure names, and named common blocks. Combined constructs Parallel Worksharing Loop [2.13.1] [2.11.1] Specifies a parallel construct containing a worksharingloop construct with one or more associated loops. C/C++#pragma omp parallel for [clause[ [, ]clause] ...] for-loop For!$omp parallel do [clause[ [, ]clause] ...] do-loops [!$omp end parallel do] clause: Any accepted by the parallel or for/do directives, except the nowait clause, with identical meanings and restrictions. parallel loop [2.13.2] Shortcut for specifying a parallel construct containing a loop construct with one or more associated loops and no other statements. C/C++#pragma omp parallel loop [clause[ [, ]clause] ...] for-loops For!$omp parallel loop [clause[ [, ]clause] ...] do-loops [!$omp end parallel loop] clause: Any accepted by the parallel or loop directives, with identical meanings and restrictions. parallel sections [2.13.3] [2.11.2] Shortcut for specifying a parallel construct containing a sections construct and no other statements. C/C++ #pragma omp parallel sections [clause[ [, ]clause] ...] { [#pragma omp section] structured-block [#pragma omp section structured-block] ... } For !$omp parallel sections [clause[ [, ]clause] ...] [!$omp section] structured-block [!$omp section structured-block] ... !$omp end parallel sections clause: Any clauses accepted by the parallel or sections directives, with identical meanings and restrictions. parallel workshare [2.13.4] [2.11.3] Shortcut for specifying a parallel construct containing a workshare construct and no other statements. For!$omp parallel workshare [clause[ [, ]clause] ...] structured-block !$omp end parallel workshare clause: Any of the clauses accepted by the parallel directive, with identical meanings and restrictions. Continued4 Continued4
Page4 OpenMPAPI5.0 Directives and Constructs (continued) arlel Worksharin-oo SiMD Worksharing-oo target parallel for [clouselL_ tormning itnd retco e directive allel Worksharing-Loop SIMD paralle do simd se allel do simd eyhetaetorao7oim ute parall target arallel loop arget parallel loop /douselLcouse distrbute parallel do (cbousel[clouse] o-oop 5oaseoatpanleloplobusalLjtbusel ctandgmerannime ,2mePamdeon Tea s Distribute Parallel Worksharing-Loop target simd 2 aster taskloop simd/ oa7baetsndaousalos pendtargetsnmd target teams opletouseljtousal- LCmasterasto re-l cdouseclouse] ns loop (. parallel master taskloop simd otrt86anaraaooteneha target teams distribute ining mastertasoop simd copyin, estric 2019 OpenMP ARB OMP0519-01-OMPS
Page 4 OpenMP API 5.0 © 2019 OpenMP ARB OMP0519-01-OMP5 Directives and Constructs (continued) Parallel Worksharing-Loop SIMD [2.13.5] [2.11.4] Shortcut for specifying a parallel construct containing only one worksharing-loop SIMD construct. C/C++#pragma omp parallel for simd [clause[ [, ]clause] ...] for-loops For!$omp parallel do simd [clause[ [, ]clause] ...] do-loops [!$omp end parallel do simd] clause: Any accepted by the parallel or for/do simd directives except for nowait, with identical meanings and restrictions. parallel master [2.13.6] Shortcut for specifying a parallel construct containing a master construct and no other statements. C/C++#pragma omp parallel master [clause[ [, ]clause] ...] structured-block For!$omp parallel master [clause[ [, ]clause] ...] structured-block $omp end parallel master clause: Any clause used for parallel directive with identical meanings and restrictions. master taskloop [2.13.7] Shortcut for specifying a master construct containing a taskloop construct and no other statements. C/C++#pragma omp master taskloop [clause[ [, ]clause] ...] for-loops For!$omp master taskloop [clause[ [, ]clause] ...] do-loops [$omp end master taskloop] clause: Any clause used for the taskloop directive with identical meanings and restrictions. master taskloop simd [2.13.8] Shortcut for specifying a master construct containing a taskloop simd construct and no other statements. C/C++#pragma omp master taskloop simd \ [clause[ [, ]clause] ...] for-loops For!$omp master taskloop simd [clause[ [, ]clause] ...] do-loops [$omp end master taskloop simd] clause: Any clause used for taskloop simd directive with identical meanings and restrictions. parallel master taskloop [2.13.9] Shortcut for specifying a parallel construct containing a master taskloop construct and no other statements. C/C++#pragma omp parallel master taskloop \ [clause[ [, ]clause] ...] for-loops For!$omp parallel master taskloop [clause[ [, ]clause] ...] do-loops [$omp end parallel master taskloop] clause: Any clause used for parallel or master taskloop directives, except the in_reduction clause, with identical meanings and restrictions. parallel master taskloop simd [2.13.10] Shortcut for specifying a parallel construct containing a master taskloop simd construct and no other statements. C/C++#pragma omp parallel master taskloop simd \ [clause[ [, ]clause] ...] for-loops For!$omp parallel master taskloop simd [clause[ [, ]clause] ...] do-loops [$omp end parallel master taskloop simd] clause: Any clause used for parallel or master taskloop simd directives, except the in_reduction clause, with identical meanings and restrictions. teams distribute [2.13.11] [2.11.10] Shortcut for specifying a teams construct containing a distribute construct and no other statements. . C/C++#pragma omp teams distribute [clause[ [, ]clause] ...] for-loops For!$omp teams distribute [clause[ [, ]clause] ...] do-loops [!$omp end teams distribute] clause: Any accepted by the teams or distribute directives with identical meanings and restrictions. teams distribute simd [2.13.12] [2.11.11] Shortcut for specifying a teams construct containing a distribute simd construct and no other statements. C/C++#pragma omp teams distribute simd \ [clause[ [, ] clause] ...] for-loops For!$omp teams distribute simd [clause[ [, ]clause] ...] do-loops [!$omp end teams distribute simd] clause: Any accepted by the teams or distribute simd directives with identical meanings and restrictions. Teams Distribute Parallel WorksharingLoop [2.13.13] [2.11.14] Shortcut for specifying a teams construct containing a distribute parallel worksharing-loop construct and no other statements. C/C++#pragma omp teams distribute parallel for \ [clause[ [, ]clause] ...] for-loops For!$omp teams distribute parallel do [clause[ [, clause] ...] do-loops [!$omp end teams distribute parallel do] clause: Any clause used for teams or distribute parallel for/ do directives with identical meanings and restrictions. Teams Distribute Parallel Worksharing-Loop SIMD [2.13.14] [2.11.16] Shortcut for specifying a teams construct containing a distribute parallel work-sharing-loop SIMD construct and no other statements. C/C++#pragma omp teams distribute parallel for simd \ [clause[ [, ]clause] ...] for-loops For !$omp teams distribute parallel do simd [clause[ [, ]clause] ...] do-loops [!$omp end teams distribute parallel do simd] clause: Any accepted by teams or distribute parallel for/ do simd, with identical meanings and restrictions. teams loop [2.13.15] Shortcut for specifying a teams construct containing a loop construct and no other statements. C/C++#pragma omp teams loop [clause[ [, ]clause] ...] for -loops For!$omp teams loop [clause[ [, ]clause] ...] do-loops [!$omp end teams loop] clause: Any accepted by the teams or loop directives with identical meanings and restrictions. target parallel [2.13.16] [2.11.5] Shortcut for specifying a target construct containing a parallel construct and no other statements. C/C++#pragma omp target parallel [clause[ [, ]clause] ...] structured-block For!$omp target parallel [clause[ [, ]clause] ...] structured-block [!$omp end target parallel] clause: Any accepted by the target or parallel directives, except for copyin, with identical meanings and restrictions. Target Parallel Worksharing-Loop [2.13.17] [2.11.6] Shortcut for specifying a target construct with a parallel worksharing-loop construct and no other statements. C/C++#pragma omp target parallel for [clause[ [, ]clause] ...] for -loops For!$omp target parallel do [clause[ [, ]clause] ...] do-loops [!$omp end target parallel do] clause: Any accepted by the target or parallel for/do directives, except for copyin, with identical meanings and restrictions. Target Parallel Worksharing-Loop SIMD [2.13.18] [2.11.7] Shortcut for specifying a target construct with a parallel worksharing-loop SIMD construct and no other statements. C/C++#pragma omp target parallel for simd \ [clause[ [, ]clause] ...] for-loops For!$omp target parallel do simd [clause[ [, ]clause] ...] do-loops [!$omp end target parallel do simd] clause: Any accepted by the target or parallel for/do simd directives, except for copyin, with identical meanings and restrictions. target parallel loop [2.13.19] Shortcut for specifying a target construct containing a parallel loop construct and no other statements. C/C++#pragma omp target parallel loop [clause[ [, ]clause] ...] for-loops For!$omp target parallel loop [clause[ [, ]clause] ...] do-loops [!$omp end target parallel loop] clause: Any accepted by the target or parallel loop directives with identical meanings and restrictions. target simd [2.13.20] [2.11.8] Shortcut for specifying a target construct containing a simd construct and no other statements. C/C++#pragma omp target simd [clause[ [, ]clause] ...] for-loops For!$omp target simd [clause[ [, ]clause] ...] do-loops [!$omp end target simd] clause: Any accepted by the target or simd directives with identical meanings and restrictions. target teams [2.13.21] [2.11.9] Shortcut for specifying a target construct containing a teams construct and no other statements. C/C++#pragma omp target teams [clause[ [, ]clause] ...] structured-block For!$omp target teams [clause[ [, ]clause] ...] structured-block !$omp end target teams clause: Any accepted by the target or teams directives with identical meanings and restrictions. target teams distribute [2.13.22] [2.11.12] Shortcut for specifying a target construct containing a teams distribute construct and no other statements. C/C++#pragma omp target teams distribute [clause[ [, ] \ clause] ...] for-loops For!$omp target teams distribute [clause[ [, ]clause] ...] do-loops [!$omp end target teams distribute] clause: Any accepted by the target or teams distribute directives with identical meanings and restrictions. Continued4
OpenMP API5.0 Page5 Directives and Constructs (continued) Synchronization constructs other sta critical [2.1.1 1213.21 associated structured block to a inele thread at a time pagmaomprtcalhomelhtthteprespnl /ISomp end target teams distribute simd 5onmpengm hserCoateessoathatevalsisod Target Teams Loop2B2 d,write,update,capture der-clouse or hint (hint-expression) ssion-stm on-stmr #pragma omp barrier =pe cut for spe ct containing a no other stateme tpragma omp taskwait [clousel[I clouse]] of the followine form eependen-type omdisribue paraedo atrCwnsortpootcstotcmcmt D232211切 suctured-block eeeiawenshamg4opsMD arallel for simd u5h27周23 osofhevaniables naompflushmemryorder-causs tSomp fush memory-order-clouses master construct ory-order-clause:acq rel,release,or acquire erihrea制theesthgteaautedbythe ordered (m me6h omp end maste 2-pe& ]cause]- the first form):threads or simd Continued in columnn poreereependlsnk:ved 2019 OpenMP ARB OMP0519-01-OMP
© 2019 OpenMP ARB OMP0519-01-OMP5 OpenMP API 5.0 Page 5 Directives and Constructs (continued) target teams distribute simd [2.13.23] [2.11.13] Shortcut for specifying a target construct containing a teams distribute simd construct and no other statements. C/C++#pragma omp target teams distribute simd \ [clause[ [, ]clause] ...] for-loops For!$omp target teams distribute simd [clause[ [, ]clause] ...] do-loops [!$omp end target teams distribute simd] clause: Any accepted by the target or teams distribute simd directives with identical meanings and restrictions. Target Teams Loop [2.13.24] Shortcut for specifying a target construct containing a teams loop construct and no other statements. C/C++#pragma omp target teams loop [clause[ [, ]clause] ...] for-loops For!$omp target teams loop [clause[ [, ]clause] ...] do-loops [!$omp end target teams loop] clause: Any clause used for target or teams loop directives with identical meanings and restrictions. Target Teams Distribute Parallel Worksharing-Loop [2.13.25] [2.11.15] Shortcut for specifying a target construct containing a teams distribute parallel worksharing-loop construct and no other statements. C/C++#pragma omp target teams distribute parallel for \ [clause[ [, ]clause] ...] for-loops For !$omp target teams distribute parallel do & [clause[ [, ]clause] ...] do-loops [$omp end target teams distribute parallel do] clause: Any clause used for target or teams distribute parallel for/do directives with identical meanings and restrictions. Target Teams Distribute Parallel Worksharing-Loop SIMD[2.13.26] [2.11.17] Shortcut for specifying a target construct containing a teams distribute parallel worksharing-loop SIMD construct and no other statements. C/C++#pragma omp target teams distribute parallel for simd \ [clause[ [, ]clause] ...] for-loops For !$omp target teams distribute parallel do simd & [clause[ [, ]clause] ...] do-loops [!$omp end target teams distribute parallel do simd] clause: Any clause used for target or teams distribute parallel for/do simd directives with identical meanings and restrictions. master construct master[2.16] [2.13.1] Specifies a structured block that is executed by the master thread of the team. C/C++#pragma omp master structured-block For!$omp master structured-block !$omp end master Synchronization constructs critical [2.17.1] [2.13.2] Restricts execution of the associated structured block to a single thread at a time. C/C++#pragma omp critical [(name) [[,] hint (hint-expression)]] structured-block For!$omp critical [(name) [[,] hint (hint-expression)] ] structured-block !$omp end critical [(name)] hint-expression: C/C++ An integer constant expression that evaluates to a valid synchronization hint hint-expression: For A constant expression that evaluates to a scalar value with kind omp_sync_hint_kind and a value that is a valid synchronization hint barrier[2.17.2] [2.13.3] Specifies an explicit barrier that prevents any thread in a team from continuing past the barrier until all threads in the team encounter the barrier. C/C++ #pragma omp barrier For !$omp barrier taskwait[2.17.5] [2.13.4] Specifies a wait on the completion of child tasks of the current task. C/C++ #pragma omp taskwait [clause[ [, ] clause] ...] For !$omp taskwait [clause[ [, ] clause] ...] clause: depend ([depend-modifier, ] dependence-type : locator-list) taskgroup [2.17.6] [2.13.5] Specifies a region which a task cannot leave until all its descendant tasks generated inside the dynamic scope of the region have completed C/C++#pragma omp taskgroup [clause[ [, ]clause] ...] structured-block For!$omp taskgroup [clause[ [, ]clause] ...] structured-block !$omp end taskgroup clause: task_reduction (reduction-identifier : list) allocate ([allocator: ]list) atomic [2.17.7] [2.13.6] Ensures a specific storage location is accessed atomically. May take one of the following seven forms: C/C++ #pragma omp atomic [clause[[[,] clause] ... ] [,]] \ atomic-clause [[,] clause [[[,] clause] ...]] expression-stmt #pragma omp atomic [clause[[,] clause] ...] expression-stmt #pragma omp atomic [clause[[[,] clause] ... ] [,]] capture \ [[,] clause [[[,] clause] ... ]] structured-block For !$omp atomic [clause[[[,] clause] ... ] [,]] read & [[,] clause [[[,] clause] ...]] capture-statement [!$omp end atomic] !$omp atomic [clause[[[,] clause] ... ] [,]] write & [[,] clause [[[,] clause] ...]] write-statement [!$omp end atomic] !$omp atomic [clause[[[,] clause] ... ] [,]] update & [[,] clause [[[,] clause] ...]] update-statement [!$omp end atomic] !$omp atomic [clause[[,] clause] ...] update-statement [!$omp end atomic] Continued in next column For !$omp atomic [clause[[[,] clause] ... ] [,]] capture & [[,] clause [[[,] clause] ...]] update-statement capture-statement !$omp end atomic !$omp atomic [clause[[[,] clause] ... ] [,]] capture & [[,] clause [[[,] clause] ...]] capture-statement update-statement !$omp end atomic !$omp atomic [clause[[[,] clause] ... ] [,]] capture & [[,] clause [[[,] clause] ...]] capture-statement write-statement !$omp end atomic atomic-clause: read, write, update, capture memory-order-clause: seq_cst, acq_rel, release, acquire, relaxed clause: memory-order-clause or hint (hint-expression) C/C++ expression-stmt: if atomic clause is... expression-stmt: read v = x; write x = expr; update or is not present x++; x--; ++x; --x; x binop= expr; x = x binop expr; x = expr binop x; capture v=x++; v=x--; v=++x; v= --x; v=x binop= expr; v=x = x binop expr; v=x = expr binop x; C/C++ structured-block may be one of the following forms: {v = x; x binop= expr;} {x binop= expr; v = x;} {v = x; x = x binop expr;} {v = x; x = expr binop x;} {x = x binop expr; v = x;} {x = expr binop x; v = x;} {v = x; x = expr;} {v = x; x++;} {v = x; ++x;} {++x; v = x;} {x++; v = x;} {v = x; x--;} {v = x; --x;} {--x; v = x;} {x--; v = x;} For capture-, write-, or update-statement: if atomic clause is... capture or read capture-statement: v = x capture or write write-statement : x = expr capture or update or is not present update-statement: x = x operator expr x = expr operator x x = intrinsic_procedure_name ( x, expr_list) x = intrinsic_procedure_name ( expr_list, x) intrinsic_procedure_name: MAX, MIN, IAND, IOR, IEOR operator is one of +, *, -, /, .AND., .OR., .EQV., .NEQV. flush [2.17.8] [2.13.7] Makes a thread’s temporary view of memory consistent with memory, and enforces an order on the memory operations of the variables. C/C++ #pragma omp flush [memory-order-clause] [(list)] For !$omp flush [memory-order-clause] [(list)] memory-order-clause: acq_rel, release, or acquire ordered [2.17.9] [2.13.8] Specifies a structured block that is to be executed in loop iteration order in a parallelized loop, or it specifies cross iteration dependences in a doacross loop nest. C/C++ #pragma omp ordered [clause[[, ] clause] ] structured-block - or - #pragma omp ordered clause[[[, ] clause]...] For !$omp ordered [clause[[, ] clause]] structured-block !$omp end ordered - or - !$omp ordered clause[[[, ]clause] ...] clause (for the first form): threads or simd clause (for the second form): depend (source) or depend (sink : vec) Continued4 Continued4