• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# OpenMP 4.5 Grammar
2
3Grammar used by Flang to parse OpenMP 4.5.
4
5## OpenMP 4.5 Specifications
6```
72 omp-directive -> sentinel directive-name [clause[ [,] clause]...]
82.1.1 sentinel -> !$omp | c$omp | *$omp
92.1.2 sentinel -> !$omp
10```
11
12## directive-name
13```
142.5 parallel -> PARALLEL [parallel-clause[ [,] parallel-clause]...]
15    parallel-clause -> if-clause |
16                       num-threads-clause |
17                       default-clause |
18                       private-clause |
19                       firstprivate-clause |
20                       shared-clause |
21                       copyin-clause |
22                       reduction-clause |
23                       proc-bind-clause
24
252.5 end-parallel -> END PARALLEL
26
272.7.1 do -> DO [do-clause[ [,] do-clause]...]
28      do-clause -> private-clause |
29                   firstprivate-clause |
30                   lastprivate-clause |
31                   linear-clause |
32                   reduction-clause |
33                   schedule-clause |
34                   collapse-clause |
35                   ordered-clause
36
372.7.1 end-do -> END DO [nowait-clause]
38
392.7.2 sections -> SECTIONS [sections-clause[ [,] sections-clause]...]
40      sections-clause -> private-clause |
41                         firstprivate-clause |
42                         lastprivate-clause |
43                         reduction-clause
44
452.7.2 section -> SECTION
46
472.7.2 end-sections -> END SECTIONS [nowait-clause]
48
492.7.3 single -> SINGLE [single-clause[ [,] single-clause]...]
50      single-clause -> private-clause |
51                       firstprivate-clause
52
532.7.3 end-single -> END SINGLE [end-single-clause[ [,] end-single-clause]...]
54      end-single-clause -> copyprivate-clause |
55                           nowait-clause
56
572.7.4 workshare -> WORKSHARE
58
592.7.4 end-workshare -> END WORKSHARE [nowait-clause]
60
612.8.1 simd -> SIMD [simd-clause[ [,] simd-clause]...]
62      simd-clause -> safelen-clause |
63                     simdlen-clause |
64                     linear-clause |
65                     aligned-clause |
66                     private-clause |
67                     lastprivate-clause |
68                     reduction-clause |
69                     collapse-clause
70
712.8.1 end-simd -> END SIMD
72
732.8.2 declare-simd -> DECLARE SIMD [(proc-name)] [declare-simd-clause[ [,] declare-simd-clause]...]
74      declare-simd-clause -> simdlen-clause |
75                             linear-clause |
76                             aligned-clause |
77                             uniform-clause |
78                             inbranch-clause |
79                             notinbranch-clause
80
812.8.3 do-simd -> DO SIMD [do-simd-clause[ [,] do-simd-clause]...]
82      do-simd-clause -> do-clause |
83                        simd-clause
84
852.8.3 end-do-simd -> END DO SIMD [nowait-clause]
86
872.9.1 task -> TASK [task-clause[ [,] task-clause]...]
88      task-clause -> if-clause |
89                     final-clause |
90                     untied-clause |
91                     default-clause |
92                     mergeable-clause |
93                     private-clause |
94                     firstprivate-clause |
95                     shared-clause |
96                     depend-clause |
97                     priority-clause
98
992.9.1 end-task -> END TASK
100
1012.9.2 taskloop -> TASKLOOP [taskloop-clause[ [,] taskloop-clause]...]
102      taskloop-clause -> if-clause |
103                         shared-clause |
104                         private-clause |
105                         firstprivate-clause |
106                         lastprivate-clause |
107                         default-clause |
108                         grainsize-clause |
109                         num-tasks-clause |
110                         collapse-clause |
111                         final-clause |
112                         priority-clause |
113                         untied-clause |
114                         mergeable-clause |
115                         nogroup-clause
116
1172.9.2 end-taskloop -> END TASKLOOP
118
1192.9.3 taskloop-simd -> TASKLOOP SIMD [taskloop-simd-clause[ [,] taskloop-simd-clause]...]
120      taskloop-simd-clause -> taskloop-clause |
121                              simd-clause
122
1232.9.3 end-taskloop-simd -> END TASKLOOP SIMD
124
1252.9.4 taskyield -> TASKYIELD
126
1272.10.1 target-data -> TARGET DATA target-data-clause[ [ [,] target-data-clause]...]
128       target-data-clause -> if-clause |
129                             device-clause |
130                             map-clause |
131                             use-device-ptr-clause
132
1332.10.1 end-target-data -> END TARGET DATA
134
1352.10.2 target-enter-data -> TARGET ENTER DATA [ target-enter-data-clause[ [,] target-enter-data-clause]...]
136       target-enter-data-clause -> if-clause |
137                                   device-clause |
138                                   map-clause |
139                                   depend-clause |
140                                   nowait-clause
141
1422.10.3 target-exit-data -> TARGET EXIT DATA [ target-exit-data-clause[ [,] target-exit-data-clause]...]
143       target-exit-data-clause -> if-clause |
144                                  device-clause |
145                                  map-clause |
146                                  depend-clause |
147                                  nowait-clause
148
1492.10.4 target -> TARGET [target-clause[ [,] target-clause]...]
150       target-clause -> if-clause |
151                        device-clause |
152                        private-clause |
153                        firstprivate-clause |
154                        map-clause |
155                        is-device-ptr-clause |
156                        defaultmap-clause |
157                        nowait-clause |
158                        depend-clause
159
1602.10.4 end-target -> END TARGET
161
1622.10.5 target-update -> TARGET UPDATE target-update-clause[ [ [,] target-update-clause]...]
163       target-update-clause -> motion-clause |
164                               if-clause |
165                               device-clause |
166                               nowait-clause |
167                               depend-clause
168       motion-clause -> to-clause |
169                        from-clause
170
1712.10.6 declare-target -> DECLARE TARGET (extended-list) |
172                         DECLARE TARGET [declare-target-clause[ [,] declare-target-clause]...]
173       declare-target-clause -> to-clause |
174                                link-clause
175
1762.10.7 teams -> TEAMS [teams-clause[ [,] teams-clause]...]
177       teams-clause -> num-teams-clause |
178                       thread-limit-clause |
179                       default-clause |
180                       private-clause |
181                       firstprivate-clause |
182                       shared-clause |
183                       reduction-clause
184
1852.10.7 end-teams -> END TEAMS
186
1872.10.8 distribute -> DISTRIBUTE [distribute-clause[ [,] distribute-clause]...]
188       distribute-clause -> private-clause |
189                            firstprivate-clause |
190                            lastprivate-clause |
191                            collapse-clause |
192                            dist-schedule-clause
193
1942.10.8 end-distribute -> END DISTRIBUTE
195
1962.10.9 distribute-simd -> DISTRIBUTE SIMD [distribute-simd-clause[ [,] distribute-simd-clause]...]
197       distribute-simd-clause -> distribute-clause |
198                                 simd-clause
199
2002.10.9 end-distribute-simd -> END DISTRIBUTE SIMD
201
2022.10.10 distribute-parellel-do ->
203           DISTRIBUTE PARALLEL DO [distribute-parallel-do-clause[ [,] distribute-parallel-do-clause]...]
204        distribute-parallel-do-clause -> distribute-clause |
205                                         parallel-do-clause
206
2072.10.10 end-distribute-parellel-do -> END DISTRIBUTE PARALLEL DO
208
2092.10.11 distribute-parallel-do-simd ->
210           DISTRIBUTE PARALLEL DO SIMD [distribute-parallel-do-simd-clause[ [,] distribute-parallel-do-simd-clause]...]
211        distribute-parallel-do-simd-clause -> distribute-clause |
212                                              parallel-do-simd-clause
213
2142.10.11 end-distribute-parallel-do-simd -> END DISTRIBUTE PARALLEL DO SIMD
215
2162.11.1 parallel-do -> PARALLEL DO [parallel-do-clause[ [,] parallel-do-clause]...]
217       parallel-do-clause -> parallel-clause |
218                             do-clause
219
2202.11.1 end-parallel-do -> END PARALLEL DO
221
2222.11.2 parallel-sections -> PARALLEL SECTIONS [parallel-sections-clause[ [,] parallel-sections-clause]...]
223       parallel-sections-clause -> parallel-clause |
224                                   sections-clause
225
2262.11.2 end-parallel-sections -> END PARALLEL SECTIONS
227
2282.11.3 parallel-workshare -> PARALLEL WORKSHARE [parallel-workshare-clause[ [,] parallel-workshare-clause]...]
229       parallel-workshare-clause -> parallel-clause
230
2312.11.3 end-parallel-workshare -> END PARALLEL WORKSHARE
232
2332.11.4 parallel-do-simd -> PARALLEL DO SIMD [parallel-do-simd-clause[ [,] parallel-do-simd-clause]...]
234       parallel-do-simd-clause -> parallel-clause |
235                                  do-simd-clause
236
2372.11.4 end-parallel-do-simd -> END PARALLEL DO SIMD
238
2392.11.5 target-parallel -> TARGET PARALLEL [target-parallel-clause[ [,] target-parallel-clause]...]
240       target-parallel-clause -> target-clause |
241                                 parallel-clause
242
2432.11.5 end-target-parallel -> END TARGET PARALLEL
244
2452.11.6 target-parallel-do -> TARGET PARALLEL DO [target-parallel-do-clause[ [,] target-parallel-do-clause]...]
246       target-parallel-do-clause -> target-clause |
247                                    parallel-do-clause
248
2492.11.6 end-target-parallel-do -> END TARGET PARALLEL DO
250
2512.11.7 target-parallel-do-simd ->
252          TARGET PARALLEL DO SIMD [target-parallel-do-simd-clause[ [,] target-parallel-do-simd-clause]...]
253       target-parallel-do-simd-clause -> target-clause |
254                                         parallel-do-simd-clause
255
2562.11.7 end-target-parallel-do-simd -> END TARGET PARALLEL DO SIMD
257
2582.11.8 target-simd -> TARGET SIMD [target-simd-clause[ [,] target-simd-clause]...]
259       target-simd-clause -> target-clause |
260                             simd-clause
261
2622.11.8 end-target-simd -> END TARGET SIMD
263
2642.11.9 target-teams -> TARGET TEAMS [target-teams-clause[ [,] target-teams-clause]...]
265       target-teams-clause -> target-clause |
266                              teams-clause
267
2682.11.9 end-target-teams -> END TARGET TEAMS
269
2702.11.10 teams-distribute -> TEAMS DISTRIBUTE [teams-distribute-clause[ [,] teams-distribute-clause]...]
271        teams-distribute-clause -> teams-clause |
272                                   distribute-clause
273
2742.11.10 end-teams-distribute -> END TEAMS DISTRIBUTE
275
2762.11.11 teams-distribute-simd ->
277           TEAMS DISTRIBUTE SIMD [teams-distribute-simd-clause[ [,] teams-distribute-simd-clause]...]
278        teams-distribute-simd-clause -> teams-clause |
279                                        distribute-simd-clause
280
2812.11.11 end-teams-distribute-simd -> END TEAMS DISTRIBUTE SIMD
282
2832.11.12 target-teams-distribute ->
284           TARGET TEAMS DISTRIBUTE [target-teams-distribute-clause[ [,] target-teams-distribute-clause]...]
285        target-teams-distribute-clause -> target-clause |
286                                          teams-distribute-clause
287
2882.11.12 end-target-teams-distribute -> END TARGET TEAMS DISTRIBUTE
289
2902.11.13 target-teams-distribute-simd ->
291           TARGET TEAMS DISTRIBUTE SIMD [target-teams-distribute-simd-clause[ [,] target-teams-distribute-simd-clause]...]
292        target-teams-distribute-simd-clause -> target-clause |
293                                               teams-distribute-simd-clause
294
2952.11.13 end-target-teams-distribute-simd -> END TARGET TEAMS DISTRIBUTE SIMD
296
2972.11.14 teams-distribute-parallel-do ->
298           TEAMS DISTRIBUTE PARALLEL DO [teams-distribute-parallel-do-clause[ [,] teams-distribute-parallel-do-clause]...]
299        teams-distribute-parallel-do-clause -> teams-clause |
300                                               distribute-parallel-do-clause
301
3022.11.14 end-teams-distribute-parallel-do -> END TEAMS DISTRIBUTE PARALLEL DO
303
3042.11.15 target-teams-distribute-parallel-do ->
305           TARGET TEAMS DISTRIBUTE PARALLEL DO [target-teams-distribute-parallel-do-clause[ [,] target-teams-distribute-parallel-do-clause]...]
306        target-teams-distribute-parallel-do-clause -> target-clause |
307                                                      teams-distribute-parallel-do-clause
308
3092.11.15 end-target-teams-distribute-parallel-do -> END TARGET TEAMS DISTRIBUTE PARALLEL DO
310
3112.11.16 teams-distribute-parallel-do-simd ->
312           TEAMS DISTRIBUTE PARALLEL DO SIMD [teams-distribute-parallel-do-simd-clause[ [,] teams-distribute-parallel-do-simd-clause]...]
313        teams-distribute-parallel-do-simd-clause -> teams-clause |
314                                                    distribute-parallel-do-simd-clause
315
3162.11.16 end-teams-distribute-parallel-do-simd -> END TEAMS DISTRIBUTE PARALLEL DO SIMD
317
3182.11.17 target-teams-distribute-parallel-do-simd ->
319           TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD [target-teams-distribute-parallel-do-simd-clause[ [,] target-teams-distribute-parallel-do-simd-clause]...]
320        target-teams-distribute-parallel-do-simd-clause -> target-clause |
321                                                           teams-distribute-parallel-do-simd-clause
322
3232.11.17 end-target-teams-distribute-parallel-do-simd -> END TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD
324
3252.13.1 master -> MASTER
326
3272.13.1 end-master -> END MASTER
328
3292.13.2 critical -> CRITICAL [(name) [HINT(hint-expr)]]
330
3312.13.2 end-critical -> END CRITICAL [(name)]
332
3332.13.3 barrier -> BARRIER
334
3352.13.4 taskwait -> TASKWAIT
336
3372.13.5 taskgroup -> TASKGROUP
338
3392.13.5 end-taskgroup -> END TASKGROUP
340
3412.13.6 atomic -> ATOMIC [seq_cst[,]] atomic-clause [[,]seq_cst] |
342                 ATOMIC [seq_cst]
343       atomic-clause -> READ | WRITE | UPDATE | CAPTURE
344
3452.13.6 end-atomic -> END ATOMIC
346
3472.13.7 flush -> FLUSH [(variable-name-list)]
348
3492.13.8 ordered -> ORDERED ordered-construct-clause [[[,] ordered-construct-clause]...]
350       ordered-construct-clause -> depend-clause
351
3522.13.8 end-ordered -> END ORDERED
353
3542.14.1 cancel -> CANCEL construct-type-clause [ [,] if-clause]
355       construct-type-clause -> PARALLEL |
356                                SECTIONS |
357                                DO |
358                                TASKGROUP
359
3602.14.2 cancellation-point -> CANCELLATION POINT construct-type-clause
361
3622.15.2 threadprivate -> THREADPRIVATE (variable-name-list)
363
3642.16 declare-reduction -> DECLARE REDUCTION (reduction-identifier : type-list : combiner) [initializer-clause]
365
366# Clauses
3672.5 proc-bind-clause -> PROC_BIND (MASTER | CLOSE | SPREAD)
368
3692.5 num-threads-clause -> NUM_THREADS (scalar-int-expr)
370
3712.7.1 schedule-clause -> SCHEDULE ([sched-modifier] [, sched-modifier]:]
372                                   kind[, chunk_size])
373
3742.7.1 kind -> STATIC | DYNAMIC | GUIDED | AUTO | RUNTIME
375
3762.7.1 sched-modifier -> MONOTONIC | NONMONOTONIC | SIMD
377
3782.7.1 chunk_size -> scalar-int-expr
379
3802.7.1 collapse-clause -> COLLAPSE (scalar-constant)
381
3822.7.1 ordered-clause -> ORDERED [(scalar-constant)]
383
3842.7.1 nowait-clause -> NOWAIT
385
3862.8.1 aligned-clause -> ALIGNED (variable-name-list[ : scalar-constant])
387
3882.8.1 safelen-clause -> SAFELEN (scalar-constant)
389
3902.8.1 simdlen-clause -> SIMDLEN (scalar-contant)
391
3922.8.2 uniform-clause -> UNIFORM (dummy-arg-name-list)
393
3942.8.2 inbranch-clause -> INBRANCH
395
3962.8.2 notinbranch-clause -> NOTINBRANCH
397
3982.13.9 depend-clause -> DEPEND (((IN | OUT | INOUT) : variable-name-list) |
399                                SOURCE |
400                                SINK : vec)
401                 vec -> iterator [+/- scalar-int-expr],..., iterator[...]
402
4032.9.2 num-tasks-clause -> NUM_TASKS (scalar-int-expr)
404
4052.9.2 grainsize-clause -> GRAINSIZE (scalar-int-expr)
406
4072.9.2 nogroup-clause -> NOGROUP
408
4092.9.2 untied-clause -> UNTIED
410
4112.9.2 priority-clause -> PRIORITY (scalar-int-expr)
412
4132.9.2 mergeable-clause -> MERGEABLE
414
4152.9.2 final-clause -> FINAL (scalar-int-expr)
416
4172.10.1 use-device-ptr-clause -> USE_DEVICE_PTR (variable-name-list)
418
4192.10.1 device-clause -> DEVICE (scalar-integer-expr)
420
4212.10.4 is-device-ptr-clause -> IS_DEVICE_PTR (variable-name-list)
422
4232.10.5 to-clause -> TO (variable-name-list)
424
4252.10.5 from-clause -> FROM (variable-name-list)
426
4272.10.6 link-clause -> LINK (variable-name-list)
428
4292.10.7 num-teams-clause -> NUM_TEAMS (scalar-integer-expr)
430
4312.10.7 thread-limit-clause -> THREAD_LIMIT (scalar-integer-expr)
432
4332.10.8 dist-schedule-clause -> DIST_SCHEDULE (STATIC [ , chunk_size])
434
4352.12 if-clause -> IF ([ directive-name-modifier :] scalar-logical-expr)
436
4372.15.3.1 default-clause -> DEFAULT (PRIVATE | FIRSTPRIVATE | SHARED | NONE)
438
4392.15.3.2 shared-clause -> SHARED (variable-name-list)
440
4412.15.3.3 private-clause -> PRIVATE (variable-name-list)
442
4432.15.3.4 firstprivate-clause -> FIRSTPRIVATE (variable-name-list)
444
4452.15.3.5 lastprivate-clause -> LASTPRIVATE (variable-name-list)
446
4472.15.3.6 reduction-clause -> REDUCTION (reduction-identifier: variable-name-list)
448         reduction-identifier -> + | - | * |
449                                 .AND. | .OR. | .EQV. | .NEQV. |
450                                 MAX | MIN | IAND | IOR | IEOR
451
4522.15.3.7 linear-clause -> LINEAR (linear-list[ : linear-step])
453         linear-list -> list | modifier(list)
454         modifier -> REF | VAL | UVAL
455
4562.15.4.1 copyin-clause -> COPYIN (variable-name-list)
457
4582.15.4.2 copyprivate-clause -> COPYPRIVATE (variable-name-list)
459
4602.15.5.1 map -> MAP ([ [ALWAYS[,]] map-type : ] variable-name-list)
461         map-type -> TO | FROM | TOFROM |
462                     ALLOC | RELEASE | DELETE
463
4642.15.5.2 defaultmap -> DEFAULTMAP (TOFROM:SCALAR)
465```
466