1 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
2 // RUN: -fsyntax-only -verify %s
4 // expected-no-diagnostics
6 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
7 // RUN: -ast-print %s | FileCheck %s --check-prefix=PRINT
9 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
10 // RUN: -ast-dump %s | FileCheck %s --check-prefix=DUMP
12 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
13 // RUN: -emit-pch -o %t %s
15 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
16 // RUN: -include-pch %t -ast-dump-all %s | FileCheck %s --check-prefix=DUMP
18 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
19 // RUN: -include-pch %t -ast-print %s | FileCheck %s --check-prefix=PRINT
24 //PRINT: template <typename T, int C> void templ_foo(T t) {
26 //PRINT: #pragma omp simd collapse(C) reduction(+: z) lastprivate(j)
27 //PRINT: for (T i = 0; i < t; ++i)
28 //PRINT: for (j = 0; j < t; ++j)
31 //DUMP: FunctionTemplateDecl{{.*}}templ_foo
32 //DUMP: TemplateTypeParmDecl{{.*}}T
33 //DUMP: NonTypeTemplateParmDecl{{.*}}C
34 //DUMP: OMPSimdDirective
35 //DUMP: OMPCollapseClause
36 //DUMP: DeclRefExpr{{.*}}'C' 'int'
37 //DUMP: OMPReductionClause
38 //DUMP: DeclRefExpr{{.*}}'z' 'T'
39 //DUMP: OMPLastprivateClause
40 //DUMP: DeclRefExpr{{.*}}'j' 'T'
44 //PRINT: template<> void templ_foo<int, 2>(int t) {
46 //PRINT: #pragma omp simd collapse(2) reduction(+: z) lastprivate(j)
47 //PRINT: for (int i = 0; i < t; ++i)
48 //PRINT: for (j = 0; j < t; ++j)
51 //DUMP: FunctionDecl{{.*}}templ_foo 'void (int)'
52 //DUMP: TemplateArgument type 'int'
53 //DUMP: TemplateArgument integral 2
54 //DUMP: ParmVarDecl{{.*}}'int'
55 //DUMP: OMPSimdDirective
56 //DUMP: OMPCollapseClause
57 //DUMP: ConstantExpr{{.*}}'int'
59 //DUMP: OMPReductionClause
60 //DUMP: DeclRefExpr{{.*}}'z' 'int'
61 //DUMP: OMPLastprivateClause
62 //DUMP: DeclRefExpr{{.*}}'j' 'int'
64 template <typename T
, int C
>
68 #pragma omp loop collapse(C) reduction(+:z) lastprivate(j) bind(thread)
69 for (T i
= 0; i
<t
; ++i
)
75 //PRINT: void test() {
76 //DUMP: FunctionDecl {{.*}}test 'void ()'
78 constexpr int N
= 100;
82 //PRINT: #pragma omp target teams distribute parallel for map(tofrom: MTX)
83 //PRINT: #pragma omp simd
84 //DUMP: OMPTargetTeamsDistributeParallelForDirective
88 //DUMP: OMPSimdDirective
89 #pragma omp target teams distribute parallel for map(MTX)
90 for (auto i
= 0; i
< N
; ++i
) {
92 for (auto j
= 0; j
< N
; ++j
) {
97 //PRINT: #pragma omp target teams
98 //PRINT: #pragma omp distribute
99 //DUMP: OMPTargetTeamsDirective
102 //DUMP: OMPDistributeDirective
103 #pragma omp target teams
104 for (int i
=0; i
<1000; ++i
) {
106 for (int j
=0; j
<100; j
++) {
112 //PRINT: #pragma omp for collapse(2) private(z) lastprivate(j) order(concurrent) reduction(+: z1)
113 //DUMP: OMPForDirective
114 //DUMP: OMPCollapseClause
115 //DUMP: IntegerLiteral{{.*}}2
116 //DUMP: OMPPrivateClause
117 //DUMP-NEXT: DeclRefExpr{{.*}}'z'
118 //DUMP: OMPLastprivateClause
119 //DUMP-NEXT: DeclRefExpr{{.*}}'j'
120 //DUMP: OMPOrderClause
121 //DUMP: OMPReductionClause
122 //DUMP-NEXT: DeclRefExpr{{.*}}'z1'
125 #pragma omp loop collapse(2) private(z) lastprivate(j) order(concurrent) \
126 reduction(+:z1) bind(parallel)
127 for (auto i
= 0; i
< N
; ++i
) {
128 for (j
= 0; j
< N
; ++j
) {
135 //PRINT: #pragma omp target teams
136 //PRINT: #pragma omp distribute
137 //DUMP: OMPTargetTeamsDirective
138 //DUMP: OMPDistributeDirective
140 #pragma omp target teams
141 #pragma omp loop bind(teams)
142 for (auto i
= 0; i
< N
; ++i
) { }
144 //PRINT: #pragma omp target
145 //PRINT: #pragma omp teams
146 //PRINT: #pragma omp distribute
147 //DUMP: OMPTargetDirective
148 //DUMP: OMPTeamsDirective
149 //DUMP: OMPDistributeDirective
153 #pragma omp loop bind(teams)
154 for (auto i
= 0; i
< N
; ++i
) { }