[libc] Update dependency for __support_fputil_nearest_integer in bazel overlay.
[llvm-project.git] / flang / docs / OpenMP-4.5-grammar.md
blobbc8a18a84e50047fb1cbcd83b78541a350eb40f7
1 # OpenMP 4.5 Grammar
3 Grammar used by Flang to parse OpenMP 4.5.
5 ## OpenMP 4.5 Specifications
6 ```
7 2 omp-directive -> sentinel directive-name [clause[ [,] clause]...]
8 2.1.1 sentinel -> !$omp | c$omp | *$omp
9 2.1.2 sentinel -> !$omp
10 ```
12 ## directive-name
13 ```
14 2.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
25 2.5 end-parallel -> END PARALLEL
27 2.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
37 2.7.1 end-do -> END DO [nowait-clause]
39 2.7.2 sections -> SECTIONS [sections-clause[ [,] sections-clause]...]
40       sections-clause -> private-clause |
41                          firstprivate-clause |
42                          lastprivate-clause |
43                          reduction-clause
45 2.7.2 section -> SECTION
47 2.7.2 end-sections -> END SECTIONS [nowait-clause]
49 2.7.3 single -> SINGLE [single-clause[ [,] single-clause]...]
50       single-clause -> private-clause |
51                        firstprivate-clause
53 2.7.3 end-single -> END SINGLE [end-single-clause[ [,] end-single-clause]...]
54       end-single-clause -> copyprivate-clause |
55                            nowait-clause
57 2.7.4 workshare -> WORKSHARE
59 2.7.4 end-workshare -> END WORKSHARE [nowait-clause]
61 2.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
71 2.8.1 end-simd -> END SIMD
73 2.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
81 2.8.3 do-simd -> DO SIMD [do-simd-clause[ [,] do-simd-clause]...]
82       do-simd-clause -> do-clause |
83                         simd-clause
85 2.8.3 end-do-simd -> END DO SIMD [nowait-clause]
87 2.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
99 2.9.1 end-task -> END TASK
101 2.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
117 2.9.2 end-taskloop -> END TASKLOOP
119 2.9.3 taskloop-simd -> TASKLOOP SIMD [taskloop-simd-clause[ [,] taskloop-simd-clause]...]
120       taskloop-simd-clause -> taskloop-clause |
121                               simd-clause
123 2.9.3 end-taskloop-simd -> END TASKLOOP SIMD
125 2.9.4 taskyield -> TASKYIELD
127 2.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
133 2.10.1 end-target-data -> END TARGET DATA
135 2.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
142 2.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
149 2.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
160 2.10.4 end-target -> END TARGET
162 2.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
171 2.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
176 2.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
185 2.10.7 end-teams -> END TEAMS
187 2.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
194 2.10.8 end-distribute -> END DISTRIBUTE
196 2.10.9 distribute-simd -> DISTRIBUTE SIMD [distribute-simd-clause[ [,] distribute-simd-clause]...]
197        distribute-simd-clause -> distribute-clause |
198                                  simd-clause
200 2.10.9 end-distribute-simd -> END DISTRIBUTE SIMD
202 2.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
207 2.10.10 end-distribute-parellel-do -> END DISTRIBUTE PARALLEL DO
209 2.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
214 2.10.11 end-distribute-parallel-do-simd -> END DISTRIBUTE PARALLEL DO SIMD
216 2.11.1 parallel-do -> PARALLEL DO [parallel-do-clause[ [,] parallel-do-clause]...]
217        parallel-do-clause -> parallel-clause |
218                              do-clause
220 2.11.1 end-parallel-do -> END PARALLEL DO
222 2.11.2 parallel-sections -> PARALLEL SECTIONS [parallel-sections-clause[ [,] parallel-sections-clause]...]
223        parallel-sections-clause -> parallel-clause |
224                                    sections-clause
226 2.11.2 end-parallel-sections -> END PARALLEL SECTIONS
228 2.11.3 parallel-workshare -> PARALLEL WORKSHARE [parallel-workshare-clause[ [,] parallel-workshare-clause]...]
229        parallel-workshare-clause -> parallel-clause
231 2.11.3 end-parallel-workshare -> END PARALLEL WORKSHARE
233 2.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
237 2.11.4 end-parallel-do-simd -> END PARALLEL DO SIMD
239 2.11.5 target-parallel -> TARGET PARALLEL [target-parallel-clause[ [,] target-parallel-clause]...]
240        target-parallel-clause -> target-clause |
241                                  parallel-clause
243 2.11.5 end-target-parallel -> END TARGET PARALLEL
245 2.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
249 2.11.6 end-target-parallel-do -> END TARGET PARALLEL DO
251 2.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
256 2.11.7 end-target-parallel-do-simd -> END TARGET PARALLEL DO SIMD
258 2.11.8 target-simd -> TARGET SIMD [target-simd-clause[ [,] target-simd-clause]...]
259        target-simd-clause -> target-clause |
260                              simd-clause
262 2.11.8 end-target-simd -> END TARGET SIMD
264 2.11.9 target-teams -> TARGET TEAMS [target-teams-clause[ [,] target-teams-clause]...]
265        target-teams-clause -> target-clause |
266                               teams-clause
268 2.11.9 end-target-teams -> END TARGET TEAMS
270 2.11.10 teams-distribute -> TEAMS DISTRIBUTE [teams-distribute-clause[ [,] teams-distribute-clause]...]
271         teams-distribute-clause -> teams-clause |
272                                    distribute-clause
274 2.11.10 end-teams-distribute -> END TEAMS DISTRIBUTE
276 2.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
281 2.11.11 end-teams-distribute-simd -> END TEAMS DISTRIBUTE SIMD
283 2.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
288 2.11.12 end-target-teams-distribute -> END TARGET TEAMS DISTRIBUTE
290 2.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
295 2.11.13 end-target-teams-distribute-simd -> END TARGET TEAMS DISTRIBUTE SIMD
297 2.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
302 2.11.14 end-teams-distribute-parallel-do -> END TEAMS DISTRIBUTE PARALLEL DO
304 2.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
309 2.11.15 end-target-teams-distribute-parallel-do -> END TARGET TEAMS DISTRIBUTE PARALLEL DO
311 2.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
316 2.11.16 end-teams-distribute-parallel-do-simd -> END TEAMS DISTRIBUTE PARALLEL DO SIMD
318 2.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
323 2.11.17 end-target-teams-distribute-parallel-do-simd -> END TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD
325 2.13.1 master -> MASTER
327 2.13.1 end-master -> END MASTER
329 2.13.2 critical -> CRITICAL [(name) [HINT(hint-expr)]]
331 2.13.2 end-critical -> END CRITICAL [(name)]
333 2.13.3 barrier -> BARRIER
335 2.13.4 taskwait -> TASKWAIT
337 2.13.5 taskgroup -> TASKGROUP
339 2.13.5 end-taskgroup -> END TASKGROUP
341 2.13.6 atomic -> ATOMIC [seq_cst[,]] atomic-clause [[,]seq_cst] |
342                  ATOMIC [seq_cst]
343        atomic-clause -> READ | WRITE | UPDATE | CAPTURE
345 2.13.6 end-atomic -> END ATOMIC
347 2.13.7 flush -> FLUSH [(variable-name-list)]
349 2.13.8 ordered -> ORDERED ordered-construct-clause [[[,] ordered-construct-clause]...]
350        ordered-construct-clause -> depend-clause
352 2.13.8 end-ordered -> END ORDERED
354 2.14.1 cancel -> CANCEL construct-type-clause [ [,] if-clause]
355        construct-type-clause -> PARALLEL |
356                                 SECTIONS |
357                                 DO |
358                                 TASKGROUP
360 2.14.2 cancellation-point -> CANCELLATION POINT construct-type-clause
362 2.15.2 threadprivate -> THREADPRIVATE (variable-name-list)
364 2.16 declare-reduction -> DECLARE REDUCTION (reduction-identifier : type-list : combiner) [initializer-clause]
366 # Clauses
367 2.5 proc-bind-clause -> PROC_BIND (MASTER | CLOSE | SPREAD)
369 2.5 num-threads-clause -> NUM_THREADS (scalar-int-expr)
371 2.7.1 schedule-clause -> SCHEDULE ([sched-modifier] [, sched-modifier]:]
372                                    kind[, chunk_size])
374 2.7.1 kind -> STATIC | DYNAMIC | GUIDED | AUTO | RUNTIME
376 2.7.1 sched-modifier -> MONOTONIC | NONMONOTONIC | SIMD
378 2.7.1 chunk_size -> scalar-int-expr
380 2.7.1 collapse-clause -> COLLAPSE (scalar-constant)
382 2.7.1 ordered-clause -> ORDERED [(scalar-constant)]
384 2.7.1 nowait-clause -> NOWAIT
386 2.8.1 aligned-clause -> ALIGNED (variable-name-list[ : scalar-constant])
388 2.8.1 safelen-clause -> SAFELEN (scalar-constant)
390 2.8.1 simdlen-clause -> SIMDLEN (scalar-contant)
392 2.8.2 uniform-clause -> UNIFORM (dummy-arg-name-list)
394 2.8.2 inbranch-clause -> INBRANCH
396 2.8.2 notinbranch-clause -> NOTINBRANCH
398 2.13.9 depend-clause -> DEPEND (((IN | OUT | INOUT) : variable-name-list) |
399                                 SOURCE |
400                                 SINK : vec)
401                  vec -> iterator [+/- scalar-int-expr],..., iterator[...]
403 2.9.2 num-tasks-clause -> NUM_TASKS (scalar-int-expr)
405 2.9.2 grainsize-clause -> GRAINSIZE (scalar-int-expr)
407 2.9.2 nogroup-clause -> NOGROUP
409 2.9.2 untied-clause -> UNTIED
411 2.9.2 priority-clause -> PRIORITY (scalar-int-expr)
413 2.9.2 mergeable-clause -> MERGEABLE
415 2.9.2 final-clause -> FINAL (scalar-int-expr)
417 2.10.1 use-device-ptr-clause -> USE_DEVICE_PTR (variable-name-list)
419 2.10.1 device-clause -> DEVICE (scalar-integer-expr)
421 2.10.4 is-device-ptr-clause -> IS_DEVICE_PTR (variable-name-list)
423 2.10.5 to-clause -> TO (variable-name-list)
425 2.10.5 from-clause -> FROM (variable-name-list)
427 2.10.6 link-clause -> LINK (variable-name-list)
429 2.10.7 num-teams-clause -> NUM_TEAMS (scalar-integer-expr)
431 2.10.7 thread-limit-clause -> THREAD_LIMIT (scalar-integer-expr)
433 2.10.8 dist-schedule-clause -> DIST_SCHEDULE (STATIC [ , chunk_size])
435 2.12 if-clause -> IF ([ directive-name-modifier :] scalar-logical-expr)
437 2.15.3.1 default-clause -> DEFAULT (PRIVATE | FIRSTPRIVATE | SHARED | NONE)
439 2.15.3.2 shared-clause -> SHARED (variable-name-list)
441 2.15.3.3 private-clause -> PRIVATE (variable-name-list)
443 2.15.3.4 firstprivate-clause -> FIRSTPRIVATE (variable-name-list)
445 2.15.3.5 lastprivate-clause -> LASTPRIVATE (variable-name-list)
447 2.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
452 2.15.3.7 linear-clause -> LINEAR (linear-list[ : linear-step])
453          linear-list -> list | modifier(list)
454          modifier -> REF | VAL | UVAL
456 2.15.4.1 copyin-clause -> COPYIN (variable-name-list)
458 2.15.4.2 copyprivate-clause -> COPYPRIVATE (variable-name-list)
460 2.15.5.1 map -> MAP ([ [ALWAYS[,]] map-type : ] variable-name-list)
461          map-type -> TO | FROM | TOFROM |
462                      ALLOC | RELEASE | DELETE
464 2.15.5.2 defaultmap -> DEFAULTMAP (TOFROM:SCALAR)