1 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -ast-print %s -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
2 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -std=c++11 -emit-pch -o %t %s -Wno-openmp-mapping
3 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
4 // RUN: %clang_cc1 -verify -fopenmp -ast-print %s -Wno-openmp-mapping -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
5 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s -Wno-openmp-mapping -DOMP51
6 // 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
8 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 -ast-print %s -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
9 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -std=c++11 -emit-pch -o %t %s -Wno-openmp-mapping
10 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
11 // RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s -Wno-openmp-mapping -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
12 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s -Wno-openmp-mapping -DOMP51
13 // 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
14 // expected-no-diagnostics
19 typedef void **omp_allocator_handle_t
;
20 extern const omp_allocator_handle_t omp_null_allocator
;
21 extern const omp_allocator_handle_t omp_default_mem_alloc
;
22 extern const omp_allocator_handle_t omp_large_cap_mem_alloc
;
23 extern const omp_allocator_handle_t omp_const_mem_alloc
;
24 extern const omp_allocator_handle_t omp_high_bw_mem_alloc
;
25 extern const omp_allocator_handle_t omp_low_lat_mem_alloc
;
26 extern const omp_allocator_handle_t omp_cgroup_mem_alloc
;
27 extern const omp_allocator_handle_t omp_pteam_mem_alloc
;
28 extern const omp_allocator_handle_t omp_thread_mem_alloc
;
46 S7(typename
T::type v
) : a(v
) {
47 #pragma omp target parallel for private(a) private(this->a) private(T::a)
48 for (int k
= 0; k
< a
.a
; ++k
)
51 S7
&operator=(S7
&s
) {
52 #pragma omp target parallel for private(a) private(this->a)
53 for (int k
= 0; k
< s
.a
.a
; ++k
)
59 // CHECK: #pragma omp target parallel for private(this->a) private(this->a) private(T::a){{$}}
60 // CHECK: #pragma omp target parallel for private(this->a) private(this->a)
61 // CHECK: #pragma omp target parallel for private(this->a) private(this->a) private(this->S::a)
63 class S8
: public S7
<S
> {
68 #pragma omp target parallel for private(a) private(this->a) private(S7<S>::a)
69 for (int k
= 0; k
< a
.a
; ++k
)
72 S8
&operator=(S8
&s
) {
73 #pragma omp target parallel for private(a) private(this->a)
74 for (int k
= 0; k
< s
.a
.a
; ++k
)
80 // CHECK: #pragma omp target parallel for private(this->a) private(this->a) private(this->S7<S>::a)
81 // CHECK: #pragma omp target parallel for private(this->a) private(this->a)
83 template <class T
, int N
>
84 T
tmain(T argc
, T
*argv
) {
85 T b
= argc
, c
, d
, e
, f
, h
;
86 T arr
[N
][10], arr1
[N
];
92 #pragma omp threadprivate(g)
94 #pragma omp target parallel for schedule(dynamic) default(none) linear(a) allocate(a) order(reproducible:concurrent)
96 #pragma omp target parallel for schedule(dynamic) default(none) linear(a) allocate(a) order(concurrent)
98 // OMP51: #pragma omp target parallel for schedule(dynamic) default(none) linear(a) allocate(a) order(reproducible: concurrent)
99 // OMP50: #pragma omp target parallel for schedule(dynamic) default(none) linear(a) allocate(a) order(concurrent)
100 for (int i
= 0; i
< 2; ++i
)
102 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
103 // CHECK-NEXT: a = 2;
104 #pragma omp target parallel for allocate(b) private(argc, b), firstprivate(c, d), lastprivate(d, f) collapse(N) schedule(static, N) ordered(N) if (parallel :argc) num_threads(N) default(shared) shared(e) reduction(+ : h)
105 for (int i
= 0; i
< 2; ++i
)
106 for (int j
= 0; j
< 2; ++j
)
107 for (int j
= 0; j
< 2; ++j
)
108 for (int j
= 0; j
< 2; ++j
)
109 for (int j
= 0; j
< 2; ++j
)
110 for (int i
= 0; i
< 2; ++i
)
111 for (int j
= 0; j
< 2; ++j
)
112 for (int j
= 0; j
< 2; ++j
)
113 for (int j
= 0; j
< 2; ++j
)
114 for (int j
= 0; j
< 2; ++j
)
116 // CHECK-NEXT: #pragma omp target parallel for allocate(b) private(argc,b) firstprivate(c,d) lastprivate(d,f) collapse(N) schedule(static, N) ordered(N) if(parallel: argc) num_threads(N) default(shared) shared(e) reduction(+: h)
117 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
118 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
119 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
120 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
121 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
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();
128 #pragma omp target parallel for 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])
129 for (int i
= 0; i
< 2; ++i
) {}
130 // CHECK-NEXT: #pragma omp target parallel for 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])
131 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
133 #pragma omp target parallel for if (N) num_threads(s) proc_bind(close) reduction(^:e, f, arr[0:N][:argc]) reduction(&& : h)
134 // CHECK-NEXT: #pragma omp target parallel for if(N) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:N][:argc]) reduction(&&: h)
135 for (int i
= 0; i
< 2; ++i
) {}
136 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
138 #pragma omp target parallel for if (target:argc > 0)
139 // CHECK-NEXT: #pragma omp target parallel for if(target: argc > 0)
140 for (int i
= 0; i
< 2; ++i
) {}
141 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
143 #pragma omp target parallel for if (parallel:argc > 0)
144 // CHECK-NEXT: #pragma omp target parallel for if(parallel: argc > 0)
145 for (int i
= 0; i
< 2; ++i
) {}
146 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
148 #pragma omp target parallel for if (N)
149 // CHECK-NEXT: #pragma omp target parallel for if(N)
150 for (int i
= 0; i
< 2; ++i
) {}
151 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
153 #pragma omp target parallel for map(i)
154 // CHECK-NEXT: #pragma omp target parallel for map(tofrom: i)
155 for (int i
= 0; i
< 2; ++i
) {}
156 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
158 #pragma omp target parallel for map(arr1[0:10], i)
159 // CHECK-NEXT: #pragma omp target parallel for map(tofrom: arr1[0:10],i)
160 for (int i
= 0; i
< 2; ++i
) {}
161 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
163 #pragma omp target parallel for map(to: i) map(from: j)
164 // CHECK-NEXT: #pragma omp target parallel for map(to: i) map(from: j)
165 for (int i
= 0; i
< 2; ++i
) {}
166 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
168 #pragma omp target parallel for map(always,alloc: i)
169 // CHECK-NEXT: #pragma omp target parallel for map(always,alloc: i)
170 for (int i
= 0; i
< 2; ++i
) {}
171 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
173 #pragma omp target parallel for nowait
174 // CHECK-NEXT: #pragma omp target parallel for nowait
175 for (int i
= 0; i
< 2; ++i
) {}
176 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
178 #pragma omp target parallel for depend(in : argc, arr[i:argc], arr1[:])
179 // CHECK-NEXT: #pragma omp target parallel for depend(in : argc,arr[i:argc],arr1[:])
180 for (int i
= 0; i
< 2; ++i
) {}
181 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
183 #pragma omp target parallel for defaultmap(tofrom: scalar)
184 // CHECK-NEXT: #pragma omp target parallel for defaultmap(tofrom: scalar)
185 for (int i
= 0; i
< 2; ++i
) {}
186 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
192 int main(int argc
, char **argv
) {
193 int b
= argc
, c
, d
, e
, f
, h
;
194 int arr
[5][10], arr1
[5];
198 // CHECK: static int a;
200 #pragma omp threadprivate(g)
201 #pragma omp target parallel for schedule(guided, argc) default(none) linear(a) shared(argc)
202 // CHECK: #pragma omp target parallel for schedule(guided, argc) default(none) linear(a) shared(argc)
203 for (int i
= 0; i
< 2; ++i
)
205 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
206 // CHECK-NEXT: a = 2;
207 #pragma omp target parallel for 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)
208 for (int i
= 0; i
< 10; ++i
)
209 for (int j
= 0; j
< 10; ++j
)
211 // CHECK-NEXT: #pragma omp target parallel for 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))
212 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
213 // CHECK-NEXT: for (int j = 0; j < 10; ++j)
214 // CHECK-NEXT: foo();
215 #pragma omp target parallel for 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])
216 for (int i
= 0; i
< 2; ++i
) {}
217 // CHECK-NEXT: #pragma omp target parallel for 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])
218 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
220 #pragma omp target parallel for if (5) num_threads(s) proc_bind(close) reduction(^:e, f, arr[0:5][:argc]) reduction(&& : h) allocate(omp_const_mem_alloc: h) uses_allocators(omp_const_mem_alloc)
221 // CHECK-NEXT: #pragma omp target parallel for if(5) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:5][:argc]) reduction(&&: h) allocate(omp_const_mem_alloc: h) uses_allocators(omp_const_mem_alloc)
222 for (int i
= 0; i
< 2; ++i
) {}
223 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
225 #pragma omp target parallel for if (target:argc > 0)
226 // CHECK-NEXT: #pragma omp target parallel for if(target: argc > 0)
227 for (int i
= 0; i
< 2; ++i
) {}
228 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
230 #pragma omp target parallel for if (parallel:argc > 0)
231 // CHECK-NEXT: #pragma omp target parallel for if(parallel: argc > 0)
232 for (int i
= 0; i
< 2; ++i
) {}
233 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
235 #pragma omp target parallel for if (5)
236 // CHECK-NEXT: #pragma omp target parallel for if(5)
237 for (int i
= 0; i
< 2; ++i
) {}
238 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
240 #pragma omp target parallel for map(i)
241 // CHECK-NEXT: #pragma omp target parallel for map(tofrom: i)
242 for (int i
= 0; i
< 2; ++i
) {}
243 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
245 #pragma omp target parallel for map(arr1[0:10], i)
246 // CHECK-NEXT: #pragma omp target parallel for map(tofrom: arr1[0:10],i)
247 for (int i
= 0; i
< 2; ++i
) {}
248 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
250 #pragma omp target parallel for map(to: i) map(from: j)
251 // CHECK-NEXT: #pragma omp target parallel for map(to: i) map(from: j)
252 for (int i
= 0; i
< 2; ++i
) {}
253 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
255 #pragma omp target parallel for map(always,alloc: i)
256 // CHECK-NEXT: #pragma omp target parallel for map(always,alloc: i)
257 for (int i
= 0; i
< 2; ++i
) {}
258 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
260 #pragma omp target parallel for nowait
261 // CHECK-NEXT: #pragma omp target parallel for nowait
262 for (int i
= 0; i
< 2; ++i
) {}
263 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
265 #pragma omp target parallel for depend(in : argc, arr[i:argc], arr1[:])
266 // CHECK-NEXT: #pragma omp target parallel for depend(in : argc,arr[i:argc],arr1[:])
267 for (int i
= 0; i
< 2; ++i
) {}
268 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
270 #pragma omp target parallel for defaultmap(tofrom: scalar) reduction(task, +: argc)
271 // CHECK-NEXT: #pragma omp target parallel for defaultmap(tofrom: scalar) reduction(task, +: argc)
272 for (int i
= 0; i
< 2; ++i
) {}
273 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
275 return (tmain
<int, 5>(argc
, &argc
) + tmain
<char, 1>(argv
[0][0], argv
[0]));