1 // RUN: %clang_cc1 -verify -fopenmp -ast-print %s -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP45
2 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -verify %s -ast-print -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP45
4 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -DOMP5 -ast-print %s -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
5 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 -x c++ -std=c++11 -emit-pch -o %t %s
6 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 -std=c++11 -include-pch %t -verify %s -ast-print -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
7 // RUN: %clang_cc1 -verify -fopenmp -DOMP51 -ast-print %s -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
8 // RUN: %clang_cc1 -fopenmp -DOMP51 -x c++ -std=c++11 -emit-pch -o %t %s
9 // RUN: %clang_cc1 -fopenmp -DOMP51 -std=c++11 -include-pch %t -verify %s -ast-print -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
11 // RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP45
12 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s
13 // RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -verify %s -ast-print -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP45
14 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 -DOMP5 -ast-print %s -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
15 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -DOMP5 -x c++ -std=c++11 -emit-pch -o %t %s
16 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -DOMP5 -std=c++11 -include-pch %t -verify %s -ast-print -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
17 // RUN: %clang_cc1 -verify -fopenmp-simd -DOMP51 -ast-print %s -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
18 // RUN: %clang_cc1 -fopenmp-simd -DOMP51 -x c++ -std=c++11 -emit-pch -o %t %s
19 // RUN: %clang_cc1 -fopenmp-simd -DOMP51 -std=c++11 -include-pch %t -verify %s -ast-print -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
20 // expected-no-diagnostics
41 S7(typename
T::type v
) : a(v
) {
43 #pragma omp teams distribute simd private(a) private(this->a) private(T::a)
44 for (int k
= 0; k
< a
.a
; ++k
)
47 S7
&operator=(S7
&s
) {
50 #pragma omp teams distribute simd private(a) private(this->a) linear(k)
51 for (k
= 0; k
< s
.a
.a
; ++k
)
56 int b
, argv
, d
, c
, e
, f
;
58 #pragma omp teams distribute simd default(none), private(b) firstprivate(argv) shared(d) reduction(+:c) reduction(max:e) num_teams(f) thread_limit(d)
59 for (int k
= 0; k
< a
.a
; ++k
)
69 #pragma omp teams distribute simd simdlen(slen1) safelen(slen2) aligned(arr:alen) if(arr[0])
71 #pragma omp teams distribute simd simdlen(slen1) safelen(slen2) aligned(arr:alen)
73 for (int k
= 0; k
< a
.a
; ++k
)
77 // CHECK: #pragma omp target
78 // CHECK-NEXT: #pragma omp teams distribute simd private(this->a) private(this->a) private(T::a)
79 // CHECK: #pragma omp target
80 // CHECK-NEXT: #pragma omp teams distribute simd private(this->a) private(this->a) linear(k)
81 // CHECK: #pragma omp target
82 // CHECK-NEXT: #pragma omp teams distribute simd default(none) private(b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d)
83 // CHECK: #pragma omp target
84 // OMP45-NEXT: #pragma omp teams distribute simd simdlen(slen1) safelen(slen2) aligned(arr: alen)
85 // OMP50-NEXT: #pragma omp teams distribute simd simdlen(slen1) safelen(slen2) aligned(arr: alen) if(arr[0])
86 // CHECK: #pragma omp target
87 // CHECK-NEXT: #pragma omp teams distribute simd private(this->a) private(this->a) private(this->S::a)
89 class S8
: public S7
<S
> {
95 #pragma omp teams distribute simd private(a) private(this->a) private(S7 <S>::a)
96 for (int k
= 0; k
< a
.a
; ++k
)
99 S8
&operator=(S8
&s
) {
101 #pragma omp teams distribute simd private(a) private(this->a)
102 for (int k
= 0; k
< s
.a
.a
; ++k
)
107 int b
, argv
, d
, c
, e
, f
;
109 #pragma omp teams distribute simd default(none), private(b) firstprivate(argv) shared(d) reduction(+:c) reduction(max:e) num_teams(f) thread_limit(d)
110 for (int k
= 0; k
< a
.a
; ++k
)
119 #pragma omp teams distribute simd simdlen(slen1) safelen(slen2) aligned(arr:alen)
120 for (int k
= 0; k
< a
.a
; ++k
)
124 // CHECK: #pragma omp target
125 // CHECK-NEXT: #pragma omp teams distribute simd private(this->a) private(this->a) private(this->S7<S>::a)
126 // CHECK: #pragma omp target
127 // CHECK-NEXT: #pragma omp teams distribute simd private(this->a) private(this->a)
128 // CHECK: #pragma omp target
129 // CHECK-NEXT: #pragma omp teams distribute simd default(none) private(b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d)
130 // CHECK: #pragma omp target
131 // CHECK-NEXT: #pragma omp teams distribute simd simdlen(slen1) safelen(slen2) aligned(arr: alen)
133 template <class T
, int N
>
135 T b
= argc
, c
, d
, e
, f
, g
;
137 // CHECK: static T a;
142 #pragma omp teams distribute simd
143 for (int i
=0; i
< 2; ++i
)
145 // CHECK: #pragma omp target
146 // CHECK-NEXT: #pragma omp teams distribute simd{{$}}
147 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
148 // CHECK-NEXT: a = 2;
150 #pragma omp teams distribute simd allocate(b) private(argc, b), firstprivate(c, d), collapse(2) allocate(c)
151 for (int i
= 0; i
< 10; ++i
)
152 for (int j
= 0; j
< 10; ++j
)
154 // CHECK: #pragma omp target
155 // CHECK-NEXT: #pragma omp teams distribute simd allocate(b) private(argc,b) firstprivate(c,d) collapse(2) allocate(c)
156 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
157 // CHECK-NEXT: for (int j = 0; j < 10; ++j)
158 // CHECK-NEXT: foo();
159 for (int i
= 0; i
< 10; ++i
)
161 // CHECK: for (int i = 0; i < 10; ++i)
162 // CHECK-NEXT: foo();
164 #pragma omp teams distribute simd
165 for (int i
= 0; i
< 10; ++i
)
167 // CHECK: #pragma omp target
168 // CHECK-NEXT: #pragma omp teams distribute simd
169 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
170 // CHECK-NEXT: foo();
172 #pragma omp teams distribute simd default(none), private(b) firstprivate(argc) shared(d) reduction(+:c) reduction(max:e) num_teams(f) thread_limit(d)
173 for (int k
= 0; k
< 10; ++k
)
175 // CHECK: #pragma omp target
176 // CHECK-NEXT: #pragma omp teams distribute simd default(none) private(b) firstprivate(argc) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d)
177 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
178 // CHECK-NEXT: e += d + argc;
180 #pragma omp teams distribute simd simdlen(clen-1)
181 for (int k
= 0; k
< 10; ++k
)
183 // CHECK: #pragma omp target
184 // CHECK-NEXT: #pragma omp teams distribute simd simdlen(clen - 1)
185 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
186 // CHECK-NEXT: e += d + argc;
188 #pragma omp teams distribute simd safelen(clen-1) aligned(arr:alen)
189 for (int k
= 0; k
< 10; ++k
)
190 e
+= d
+ argc
+ arr
[k
];
191 // CHECK: #pragma omp target
192 // CHECK-NEXT: #pragma omp teams distribute simd safelen(clen - 1) aligned(arr: alen)
193 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
194 // CHECK-NEXT: e += d + argc + arr[k];
198 int main (int argc
, char **argv
) {
199 int b
= argc
, c
, d
, e
, f
, g
;
201 // CHECK: static int a;
206 #pragma omp teams distribute simd
207 for (int i
=0; i
< 2; ++i
)
209 // CHECK: #pragma omp target
210 // CHECK-NEXT: #pragma omp teams distribute simd
211 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
212 // CHECK-NEXT: a = 2;
214 #pragma omp teams distribute simd private(argc,b),firstprivate(argv, c), collapse(2)
215 for (int i
= 0; i
< 10; ++i
)
216 for (int j
= 0; j
< 10; ++j
)
218 // CHECK: #pragma omp target
219 // CHECK-NEXT: #pragma omp teams distribute simd private(argc,b) firstprivate(argv,c) collapse(2)
220 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
221 // CHECK-NEXT: for (int j = 0; j < 10; ++j)
222 // CHECK-NEXT: foo();
223 for (int i
= 0; i
< 10; ++i
)
225 // CHECK: for (int i = 0; i < 10; ++i)
226 // CHECK-NEXT: foo();
228 #pragma omp teams distribute simd
229 for (int i
= 0; i
< 10; ++i
)foo();
230 // CHECK: #pragma omp target
231 // CHECK-NEXT: #pragma omp teams distribute simd
232 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
233 // CHECK-NEXT: foo();
235 #pragma omp teams distribute simd default(none), private(b) firstprivate(argc) shared(d) reduction(+:c) reduction(max:e) num_teams(f) thread_limit(d)
236 for (int k
= 0; k
< 10; ++k
)
238 // CHECK: #pragma omp target
239 // CHECK-NEXT: #pragma omp teams distribute simd default(none) private(b) firstprivate(argc) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d)
240 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
241 // CHECK-NEXT: e += d + argc;
243 #pragma omp teams distribute simd simdlen(clen-1)
244 for (int k
= 0; k
< 10; ++k
)
246 // CHECK: #pragma omp target
247 // CHECK-NEXT: #pragma omp teams distribute simd simdlen(clen - 1)
248 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
249 // CHECK-NEXT: e += d + argc;
252 #pragma omp teams distribute simd safelen(clen-1) aligned(arr:N+6) if(simd:b) nontemporal(argc, c, d) order(unconstrained:concurrent)
254 #pragma omp teams distribute simd safelen(clen-1) aligned(arr:N+6) if(simd:b) nontemporal(argc, c, d) order(concurrent)
256 #pragma omp teams distribute simd safelen(clen-1) aligned(arr:N+6)
258 for (int k
= 0; k
< 10; ++k
)
259 e
+= d
+ argc
+ arr
[k
];
260 // CHECK: #pragma omp target
261 // OMP45-NEXT: #pragma omp teams distribute simd safelen(clen - 1) aligned(arr: N + 6)
262 // OMP50-NEXT: #pragma omp teams distribute simd safelen(clen - 1) aligned(arr: N + 6) if(simd: b) nontemporal(argc,c,d) order(concurrent)
263 // OMP51-NEXT: #pragma omp teams distribute simd safelen(clen - 1) aligned(arr: N + 6) if(simd: b) nontemporal(argc,c,d) order(unconstrained: concurrent)
264 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
265 // CHECK-NEXT: e += d + argc + arr[k];