1 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -ast-print %s -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP45
2 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -emit-pch -o %t %s -Wno-openmp-mapping
3 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP45
4 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -ast-print %s -Wno-openmp-mapping -DOMP5 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
5 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -std=c++11 -emit-pch -o %t %s -Wno-openmp-mapping -DOMP5
6 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -Wno-openmp-mapping -DOMP5 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
7 // RUN: %clang_cc1 -verify -fopenmp -ast-print %s -Wno-openmp-mapping -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
8 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s -Wno-openmp-mapping -DOMP51
9 // RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -Wno-openmp-mapping -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
10 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=52 -ast-print %s -Wno-openmp-mapping -DOMP52 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP52
11 // RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -x c++ -std=c++11 -emit-pch -o %t %s -Wno-openmp-mapping -DOMP52
12 // RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -Wno-openmp-mapping -DOMP52 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP52
14 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -ast-print %s -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP45
15 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -emit-pch -o %t %s -Wno-openmp-mapping
16 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP45
17 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 -ast-print %s -Wno-openmp-mapping -DOMP5 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
18 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -std=c++11 -emit-pch -o %t %s -Wno-openmp-mapping -DOMP5
19 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -Wno-openmp-mapping -DOMP5 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
20 // RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s -Wno-openmp-mapping -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
21 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s -Wno-openmp-mapping -DOMP51
22 // RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -Wno-openmp-mapping -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
23 // expected-no-diagnostics
24 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=52 -ast-print %s -Wno-openmp-mapping -DOMP52 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP52
25 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=52 -x c++ -std=c++11 -emit-pch -o %t %s -Wno-openmp-mapping -DOMP52
26 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=52 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -Wno-openmp-mapping -DOMP52 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP52
27 // expected-no-diagnostics
32 typedef void **omp_allocator_handle_t
;
33 extern const omp_allocator_handle_t omp_null_allocator
;
34 extern const omp_allocator_handle_t omp_default_mem_alloc
;
35 extern const omp_allocator_handle_t omp_large_cap_mem_alloc
;
36 extern const omp_allocator_handle_t omp_const_mem_alloc
;
37 extern const omp_allocator_handle_t omp_high_bw_mem_alloc
;
38 extern const omp_allocator_handle_t omp_low_lat_mem_alloc
;
39 extern const omp_allocator_handle_t omp_cgroup_mem_alloc
;
40 extern const omp_allocator_handle_t omp_pteam_mem_alloc
;
41 extern const omp_allocator_handle_t omp_thread_mem_alloc
;
59 S7(typename
T::type v
) : a(v
) {
60 #pragma omp target parallel for simd private(a) private(this->a) private(T::a)
61 for (int k
= 0; k
< a
.a
; ++k
)
64 S7
&operator=(S7
&s
) {
65 #pragma omp target parallel for simd private(a) private(this->a)
66 for (int k
= 0; k
< s
.a
.a
; ++k
)
72 // CHECK: #pragma omp target parallel for simd private(this->a) private(this->a) private(T::a){{$}}
73 // CHECK: #pragma omp target parallel for simd private(this->a) private(this->a)
74 // CHECK: #pragma omp target parallel for simd private(this->a) private(this->a) private(this->S::a)
76 class S8
: public S7
<S
> {
81 #pragma omp target parallel for simd private(a) private(this->a) private(S7<S>::a)
82 for (int k
= 0; k
< a
.a
; ++k
)
85 S8
&operator=(S8
&s
) {
86 #pragma omp target parallel for simd private(a) private(this->a)
87 for (int k
= 0; k
< s
.a
.a
; ++k
)
93 // CHECK: #pragma omp target parallel for simd private(this->a) private(this->a) private(this->S7<S>::a)
94 // CHECK: #pragma omp target parallel for simd private(this->a) private(this->a)
96 template <class T
, int N
>
97 T
tmain(T argc
, T
*argv
) {
98 T b
= argc
, c
, d
, e
, f
, h
;
99 T arr
[N
][10], arr1
[N
];
103 // CHECK: static T a;
106 // CHECK: T clen = 5;
107 #pragma omp threadprivate(g)
108 #pragma omp target parallel for simd schedule(dynamic) default(none) linear(a) allocate(a)
109 // CHECK: #pragma omp target parallel for simd schedule(dynamic) default(none) linear(a) allocate(a)
110 for (T i
= 0; i
< 2; ++i
)
112 // CHECK-NEXT: for (T i = 0; i < 2; ++i)
113 // CHECK-NEXT: a = 2;
114 #pragma omp target parallel for simd allocate(d) private(argc, b), firstprivate(c, d), lastprivate(d, f) collapse(N) schedule(static, N) ordered if (parallel :argc) num_threads(N) default(shared) shared(e) reduction(+ : h)
115 for (int i
= 0; i
< 2; ++i
)
116 for (int j
= 0; j
< 2; ++j
)
117 for (int j
= 0; j
< 2; ++j
)
118 for (int j
= 0; j
< 2; ++j
)
119 for (int j
= 0; j
< 2; ++j
)
121 // CHECK-NEXT: #pragma omp target parallel for simd allocate(d) private(argc,b) firstprivate(c,d) lastprivate(d,f) collapse(N) schedule(static, N) ordered if(parallel: argc) num_threads(N) default(shared) shared(e) reduction(+: h)
122 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
123 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
124 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
125 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
126 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
127 // CHECK-NEXT: foo();
129 #pragma omp target parallel for simd default(none), private(argc,b) firstprivate(argv) shared (d) if(parallel:argc > 0) num_threads(N) proc_bind(master) reduction(+:c, arr1[argc]) reduction(max:e, arr[:N][0:10])
130 for (T i
= 0; i
< 2; ++i
) {}
131 // CHECK: #pragma omp target parallel for simd default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(N) proc_bind(master) reduction(+: c,arr1[argc]) reduction(max: e,arr[:N][0:10])
132 // CHECK-NEXT: for (T i = 0; i < 2; ++i) {
135 #pragma omp target parallel for simd if(N) num_threads(s) proc_bind(close) reduction(^:e, f, arr[0:N][:argc]) reduction(&& : h)
136 for (T i
= 0; i
< 2; ++i
) {}
137 // CHECK: #pragma omp target parallel for simd if(N) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:N][:argc]) reduction(&&: h)
138 // CHECK-NEXT: for (T i = 0; i < 2; ++i) {
141 #if defined(OMP51) || defined(OMP52)
142 #pragma omp target parallel for simd if(target:argc > 0) if (simd: argc) nontemporal(argc, c, d) order(unconstrained:concurrent) allocate(omp_high_bw_mem_alloc:f) private(f) uses_allocators(omp_high_bw_mem_alloc)
144 #pragma omp target parallel for simd if(target:argc > 0) if (simd: argc) nontemporal(argc, c, d) order(concurrent) allocate(omp_high_bw_mem_alloc:f) private(f) uses_allocators(omp_high_bw_mem_alloc)
146 #pragma omp target parallel for simd if(target:argc > 0)
148 for (T i
= 0; i
< 2; ++i
) {}
149 // OMP45: #pragma omp target parallel for simd if(target: argc > 0)
150 // OMP50: #pragma omp target parallel for simd if(target: argc > 0) if(simd: argc) nontemporal(argc,c,d) order(concurrent) allocate(omp_high_bw_mem_alloc: f) private(f) uses_allocators(omp_high_bw_mem_alloc)
151 // OMP51: #pragma omp target parallel for simd if(target: argc > 0) if(simd: argc) nontemporal(argc,c,d) order(unconstrained: concurrent) allocate(omp_high_bw_mem_alloc: f) private(f) uses_allocators(omp_high_bw_mem_alloc)
152 // OMP52: #pragma omp target parallel for simd if(target: argc > 0) if(simd: argc) nontemporal(argc,c,d) order(unconstrained: concurrent) allocate(omp_high_bw_mem_alloc: f) private(f) uses_allocators(omp_high_bw_mem_alloc)
153 // CHECK-NEXT: for (T i = 0; i < 2; ++i) {
156 #pragma omp target parallel for simd if(parallel:argc > 0)
157 for (T i
= 0; i
< 2; ++i
) {}
158 // CHECK: #pragma omp target parallel for simd if(parallel: argc > 0)
159 // CHECK-NEXT: for (T i = 0; i < 2; ++i) {
162 #pragma omp target parallel for simd if(N)
163 for (T i
= 0; i
< 2; ++i
) {}
164 // CHECK: #pragma omp target parallel for simd if(N)
165 // CHECK-NEXT: for (T i = 0; i < 2; ++i) {
168 #pragma omp target parallel for simd map(i)
169 for (T i
= 0; i
< 2; ++i
) {}
170 // CHECK: #pragma omp target parallel for simd map(tofrom: i)
171 // CHECK-NEXT: for (T i = 0; i < 2; ++i) {
174 #pragma omp target parallel for simd map(arr1[0:10], i)
175 for (T i
= 0; i
< 2; ++i
) {}
176 // CHECK: #pragma omp target parallel for simd map(tofrom: arr1[0:10],i)
177 // CHECK-NEXT: for (T i = 0; i < 2; ++i) {
180 #pragma omp target parallel for simd map(to: i) map(from: j)
181 for (T i
= 0; i
< 2; ++i
) {}
182 // CHECK: #pragma omp target parallel for simd map(to: i) map(from: j)
183 // CHECK-NEXT: for (T i = 0; i < 2; ++i) {
186 #pragma omp target parallel for simd map(always,alloc: i)
187 for (T i
= 0; i
< 2; ++i
) {}
188 // CHECK: #pragma omp target parallel for simd map(always,alloc: i)
189 // CHECK-NEXT: for (T i = 0; i < 2; ++i) {
192 #pragma omp target parallel for simd nowait
193 for (T i
= 0; i
< 2; ++i
) {}
194 // CHECK: #pragma omp target parallel for simd nowait
195 // CHECK-NEXT: for (T i = 0; i < 2; ++i) {
198 #pragma omp target parallel for simd depend(in : argc, arr[i:argc], arr1[:])
199 for (T i
= 0; i
< 2; ++i
) {}
200 // CHECK: #pragma omp target parallel for simd depend(in : argc,arr[i:argc],arr1[:])
201 // CHECK-NEXT: for (T i = 0; i < 2; ++i) {
204 #pragma omp target parallel for simd defaultmap(tofrom: scalar)
205 for (T i
= 0; i
< 2; ++i
) {}
206 // CHECK: #pragma omp target parallel for simd defaultmap(tofrom: scalar)
207 // CHECK-NEXT: for (T i = 0; i < 2; ++i) {
210 #pragma omp target parallel for simd safelen(clen-1)
211 for (T i
= 0; i
< 2; ++i
) {}
212 // CHECK: #pragma omp target parallel for simd safelen(clen - 1)
213 // CHECK-NEXT: for (T i = 0; i < 2; ++i) {
216 #pragma omp target parallel for simd simdlen(clen-1)
217 for (T i
= 0; i
< 2; ++i
) {}
218 // CHECK: #pragma omp target parallel for simd simdlen(clen - 1)
219 // CHECK-NEXT: for (T i = 0; i < 2; ++i) {
222 #pragma omp target parallel for simd aligned(arr1:N-1)
223 for (T i
= 0; i
< N
; ++i
) {}
224 // CHECK: #pragma omp target parallel for simd aligned(arr1: N - 1)
225 // CHECK-NEXT: for (T i = 0; i < N; ++i) {
231 int main(int argc
, char **argv
) {
232 int b
= argc
, c
, d
, e
, f
, h
;
233 int arr
[5][10], arr1
[5];
237 // CHECK: static int a;
239 // CHECK: int clen = 5;
241 #pragma omp threadprivate(g)
242 #pragma omp target parallel for simd schedule(guided, argc) default(none) linear(a) shared(argc)
243 // CHECK: #pragma omp target parallel for simd schedule(guided, argc) default(none) linear(a) shared(argc)
244 for (int i
= 0; i
< 2; ++i
)
246 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
247 // CHECK-NEXT: a = 2;
249 #pragma omp target parallel for simd private(argc, b), firstprivate(argv, c), lastprivate(d, f) collapse(2) schedule(auto) ordered if (target: argc) num_threads(a) default(shared) shared(e) reduction(+ : h) linear(a: step(-5))
251 #pragma omp target parallel for simd private(argc, b), firstprivate(argv, c), lastprivate(d, f) collapse(2) schedule(auto) ordered if (target: argc) num_threads(a) default(shared) shared(e) reduction(+ : h) linear(a:-5)
253 for (int i
= 0; i
< 10; ++i
)
254 for (int j
= 0; j
< 10; ++j
)
256 // CHECK: #pragma omp target parallel for simd private(argc,b) firstprivate(argv,c) lastprivate(d,f) collapse(2) schedule(auto) ordered if(target: argc) num_threads(a) default(shared) shared(e) reduction(+: h) linear(a: step(-5))
257 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
258 // CHECK-NEXT: for (int j = 0; j < 10; ++j)
259 // CHECK-NEXT: foo();
261 #pragma omp target parallel for simd default(none), private(argc,b) firstprivate(argv) shared (d) if (parallel:argc > 0) num_threads(5) proc_bind(master) reduction(+:c, arr1[argc]) reduction(max:e, arr[:5][0:10])
262 for (int i
= 0; i
< 2; ++i
) {}
263 // CHECK: #pragma omp target parallel for simd default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(5) proc_bind(master) reduction(+: c,arr1[argc]) reduction(max: e,arr[:5][0:10])
264 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
267 #pragma omp target parallel for simd if (5) num_threads(s) proc_bind(close) reduction(^:e, f, arr[0:5][:argc]) reduction(&& : h)
268 for (int i
= 0; i
< 2; ++i
) {}
269 // CHECK: #pragma omp target parallel for simd if(5) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:5][:argc]) reduction(&&: h)
270 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
273 #pragma omp target parallel for simd if (target:argc > 0)
274 for (int i
= 0; i
< 2; ++i
) {}
275 // CHECK: #pragma omp target parallel for simd if(target: argc > 0)
276 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
279 #if defined(OMP51) || defined(OMP52)
280 #pragma omp target parallel for simd if (parallel:argc > 0)
282 #pragma omp target parallel for simd if (parallel:argc > 0) if(simd: argc)
284 #pragma omp target parallel for simd if (parallel:argc > 0)
286 for (int i
= 0; i
< 2; ++i
) {}
287 // OMP45: #pragma omp target parallel for simd if(parallel: argc > 0)
288 // OMP50: #pragma omp target parallel for simd if(parallel: argc > 0) if(simd: argc)
289 // OMP51: #pragma omp target parallel for simd if(parallel: argc > 0)
290 // OMP52: #pragma omp target parallel for simd if(parallel: argc > 0)
291 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
294 #pragma omp target parallel for simd if (5)
295 for (int i
= 0; i
< 2; ++i
) {}
296 // CHECK: #pragma omp target parallel for simd if(5)
297 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
300 #pragma omp target parallel for simd map(i)
301 for (int i
= 0; i
< 2; ++i
) {}
302 // CHECK: #pragma omp target parallel for simd map(tofrom: i)
303 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
306 #pragma omp target parallel for simd map(arr1[0:10], i)
307 for (int i
= 0; i
< 2; ++i
) {}
308 // CHECK: #pragma omp target parallel for simd map(tofrom: arr1[0:10],i)
309 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
312 #pragma omp target parallel for simd map(to: i) map(from: j)
313 for (int i
= 0; i
< 2; ++i
) {}
314 // CHECK: #pragma omp target parallel for simd map(to: i) map(from: j)
315 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
318 #pragma omp target parallel for simd map(always,alloc: i)
319 for (int i
= 0; i
< 2; ++i
) {}
320 // CHECK: #pragma omp target parallel for simd map(always,alloc: i)
321 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
324 #pragma omp target parallel for simd nowait
325 for (int i
= 0; i
< 2; ++i
) {}
326 // CHECK: #pragma omp target parallel for simd nowait
327 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
330 #pragma omp target parallel for simd depend(in : argc, arr[i:argc], arr1[:])
331 for (int i
= 0; i
< 2; ++i
) {}
332 // CHECK: #pragma omp target parallel for simd depend(in : argc,arr[i:argc],arr1[:])
333 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
336 #pragma omp target parallel for simd defaultmap(tofrom: scalar)
337 for (int i
= 0; i
< 2; ++i
) {}
338 // CHECK: #pragma omp target parallel for simd defaultmap(tofrom: scalar)
339 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
342 #pragma omp target parallel for simd safelen(clen-1)
343 for (int i
= 0; i
< 2; ++i
) {}
344 // CHECK: #pragma omp target parallel for simd safelen(clen - 1)
345 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
348 #pragma omp target parallel for simd simdlen(clen-1)
349 for (int i
= 0; i
< 2; ++i
) {}
350 // CHECK: #pragma omp target parallel for simd simdlen(clen - 1)
351 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
354 #pragma omp target parallel for simd aligned(arr1:4)
355 for (int i
= 0; i
< 2; ++i
) {}
356 // CHECK: #pragma omp target parallel for simd aligned(arr1: 4)
357 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
360 return (tmain
<int, 5>(argc
, &argc
));