1 // RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
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 -fsyntax-only -verify %s -ast-print | FileCheck %s
5 // RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s | FileCheck %s
6 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s
7 // RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
8 // expected-no-diagnostics
13 typedef void **omp_allocator_handle_t
;
14 extern const omp_allocator_handle_t omp_null_allocator
;
15 extern const omp_allocator_handle_t omp_default_mem_alloc
;
16 extern const omp_allocator_handle_t omp_large_cap_mem_alloc
;
17 extern const omp_allocator_handle_t omp_const_mem_alloc
;
18 extern const omp_allocator_handle_t omp_high_bw_mem_alloc
;
19 extern const omp_allocator_handle_t omp_low_lat_mem_alloc
;
20 extern const omp_allocator_handle_t omp_cgroup_mem_alloc
;
21 extern const omp_allocator_handle_t omp_pteam_mem_alloc
;
22 extern const omp_allocator_handle_t omp_thread_mem_alloc
;
28 operator T() {return T();}
30 #pragma omp threadprivate(TS)
33 // CHECK: template <class T> struct S {
34 // CHECK: static T TS;
35 // CHECK-NEXT: #pragma omp threadprivate(S::TS)
37 // CHECK: template<> struct S<int> {
38 // CHECK: static int TS;
39 // CHECK-NEXT: #pragma omp threadprivate(S<int>::TS)
41 // CHECK: template<> struct S<char> {
42 // CHECK: static char TS;
43 // CHECK-NEXT: #pragma omp threadprivate(S<char>::TS)
46 template <typename T
, int C
>
47 T
tmain(T argc
, T
*argv
) {
48 T b
= argc
, c
, d
, e
, f
, g
;
51 T arr
[C
][10], arr1
[C
];
53 #pragma omp target parallel
55 #pragma omp target parallel allocate(omp_large_cap_mem_alloc:argv) default(none), private(argc,b) firstprivate(argv) shared (d) if (parallel:argc > 0) num_threads(C) proc_bind(master) reduction(+:c, arr1[argc]) reduction(max:e, arr[:C][0:10]) uses_allocators(omp_large_cap_mem_alloc)
57 #pragma omp target parallel if (C) num_threads(s) proc_bind(close) reduction(^:e, f, arr[0:C][:argc]) reduction(&& : g) allocate(g)
59 #pragma omp target parallel if (target:argc > 0)
61 #pragma omp target parallel if (parallel:argc > 0)
63 #pragma omp target parallel if (C)
65 #pragma omp target parallel map(i)
67 #pragma omp target parallel map(a[0:10], i)
69 #pragma omp target parallel map(to: i) map(from: j)
71 #pragma omp target parallel map(always,alloc: i)
73 #pragma omp target parallel nowait
75 #pragma omp target parallel depend(in : argc, argv[i:argc], a[:])
77 #pragma omp target parallel defaultmap(tofrom: scalar)
82 // CHECK: template <typename T, int C> T tmain(T argc, T *argv) {
83 // CHECK-NEXT: T b = argc, c, d, e, f, g;
84 // CHECK-NEXT: static T h;
85 // CHECK-NEXT: S<T> s;
86 // CHECK-NEXT: T arr[C][10], arr1[C];
87 // CHECK-NEXT: T i, j, a[20]
88 // CHECK-NEXT: #pragma omp target parallel{{$}}
90 // CHECK-NEXT: #pragma omp target parallel allocate(omp_large_cap_mem_alloc: argv) default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(C) proc_bind(master) reduction(+: c,arr1[argc]) reduction(max: e,arr[:C][0:10]) uses_allocators(omp_large_cap_mem_alloc)
92 // CHECK-NEXT: #pragma omp target parallel if(C) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:C][:argc]) reduction(&&: g) allocate(g)
94 // CHECK-NEXT: #pragma omp target parallel if(target: argc > 0)
96 // CHECK-NEXT: #pragma omp target parallel if(parallel: argc > 0)
98 // CHECK-NEXT: #pragma omp target parallel if(C)
100 // CHECK-NEXT: #pragma omp target parallel map(tofrom: i)
102 // CHECK-NEXT: #pragma omp target parallel map(tofrom: a[0:10],i)
104 // CHECK-NEXT: #pragma omp target parallel map(to: i) map(from: j)
106 // CHECK-NEXT: #pragma omp target parallel map(always,alloc: i)
108 // CHECK-NEXT: #pragma omp target parallel nowait
110 // CHECK-NEXT: #pragma omp target parallel depend(in : argc,argv[i:argc],a[:])
112 // CHECK-NEXT: #pragma omp target parallel defaultmap(tofrom: scalar)
114 // CHECK: template<> int tmain<int, 5>(int argc, int *argv) {
115 // CHECK-NEXT: int b = argc, c, d, e, f, g;
116 // CHECK-NEXT: static int h;
117 // CHECK-NEXT: S<int> s;
118 // CHECK-NEXT: int arr[5][10], arr1[5];
119 // CHECK-NEXT: int i, j, a[20]
120 // CHECK-NEXT: #pragma omp target parallel
121 // CHECK-NEXT: h = 2;
122 // CHECK-NEXT: #pragma omp target parallel allocate(omp_large_cap_mem_alloc: argv) 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]) uses_allocators(omp_large_cap_mem_alloc)
124 // CHECK-NEXT: #pragma omp target parallel if(5) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:5][:argc]) reduction(&&: g) allocate(g)
126 // CHECK-NEXT: #pragma omp target parallel if(target: argc > 0)
128 // CHECK-NEXT: #pragma omp target parallel if(parallel: argc > 0)
130 // CHECK-NEXT: #pragma omp target parallel if(5)
132 // CHECK-NEXT: #pragma omp target parallel map(tofrom: i)
134 // CHECK-NEXT: #pragma omp target parallel map(tofrom: a[0:10],i)
136 // CHECK-NEXT: #pragma omp target parallel map(to: i) map(from: j)
138 // CHECK-NEXT: #pragma omp target parallel map(always,alloc: i)
140 // CHECK-NEXT: #pragma omp target parallel nowait
142 // CHECK-NEXT: #pragma omp target parallel depend(in : argc,argv[i:argc],a[:])
144 // CHECK-NEXT: #pragma omp target parallel defaultmap(tofrom: scalar)
146 // CHECK: template<> char tmain<char, 1>(char argc, char *argv) {
147 // CHECK-NEXT: char b = argc, c, d, e, f, g;
148 // CHECK-NEXT: static char h;
149 // CHECK-NEXT: S<char> s;
150 // CHECK-NEXT: char arr[1][10], arr1[1];
151 // CHECK-NEXT: char i, j, a[20]
152 // CHECK-NEXT: #pragma omp target parallel
153 // CHECK-NEXT: h = 2;
154 // CHECK-NEXT: #pragma omp target parallel allocate(omp_large_cap_mem_alloc: argv) default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(1) proc_bind(master) reduction(+: c,arr1[argc]) reduction(max: e,arr[:1][0:10]) uses_allocators(omp_large_cap_mem_alloc)
156 // CHECK-NEXT: #pragma omp target parallel if(1) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:1][:argc]) reduction(&&: g) allocate(g)
158 // CHECK-NEXT: #pragma omp target parallel if(target: argc > 0)
160 // CHECK-NEXT: #pragma omp target parallel if(parallel: argc > 0)
162 // CHECK-NEXT: #pragma omp target parallel if(1)
164 // CHECK-NEXT: #pragma omp target parallel map(tofrom: i)
166 // CHECK-NEXT: #pragma omp target parallel map(tofrom: a[0:10],i)
168 // CHECK-NEXT: #pragma omp target parallel map(to: i) map(from: j)
170 // CHECK-NEXT: #pragma omp target parallel map(always,alloc: i)
172 // CHECK-NEXT: #pragma omp target parallel nowait
174 // CHECK-NEXT: #pragma omp target parallel depend(in : argc,argv[i:argc],a[:])
176 // CHECK-NEXT: #pragma omp target parallel defaultmap(tofrom: scalar)
179 // CHECK-LABEL: int main(int argc, char **argv) {
180 int main (int argc
, char **argv
) {
182 // CHECK-NEXT: int i, j, a[20]
183 #pragma omp target parallel
184 // CHECK-NEXT: #pragma omp target parallel
186 // CHECK-NEXT: foo();
187 #pragma omp target parallel if (argc > 0)
188 // CHECK-NEXT: #pragma omp target parallel if(argc > 0)
190 // CHECK-NEXT: foo();
192 #pragma omp target parallel if (target: argc > 0)
193 // CHECK-NEXT: #pragma omp target parallel if(target: argc > 0)
195 // CHECK-NEXT: foo();
197 #pragma omp target parallel if (parallel: argc > 0)
198 // CHECK-NEXT: #pragma omp target parallel if(parallel: argc > 0)
200 // CHECK-NEXT: foo();
202 #pragma omp target parallel map(i) if(argc>0)
203 // CHECK-NEXT: #pragma omp target parallel map(tofrom: i) if(argc > 0)
205 // CHECK-NEXT: foo();
207 #pragma omp target parallel map(i)
208 // CHECK-NEXT: #pragma omp target parallel map(tofrom: i)
210 // CHECK-NEXT: foo();
212 #pragma omp target parallel map(a[0:10], i)
213 // CHECK-NEXT: #pragma omp target parallel map(tofrom: a[0:10],i)
215 // CHECK-NEXT: foo();
217 #pragma omp target parallel map(to: i) map(from: j)
218 // CHECK-NEXT: #pragma omp target parallel map(to: i) map(from: j)
220 // CHECK-NEXT: foo();
222 #pragma omp target parallel map(always,alloc: i)
223 // CHECK-NEXT: #pragma omp target parallel map(always,alloc: i)
225 // CHECK-NEXT: foo();
227 #pragma omp target parallel nowait
228 // CHECK-NEXT: #pragma omp target parallel nowait
230 // CHECK-NEXT: foo();
232 #pragma omp target parallel depend(in : argc, argv[i:argc], a[:])
233 // CHECK-NEXT: #pragma omp target parallel depend(in : argc,argv[i:argc],a[:])
235 // CHECK-NEXT: foo();
237 #pragma omp target parallel defaultmap(tofrom: scalar) reduction(task, +:argc)
238 // CHECK-NEXT: #pragma omp target parallel defaultmap(tofrom: scalar) reduction(task, +: argc)
241 #pragma omp cancellation point parallel
242 #pragma omp cancel parallel
245 // CHECK-NEXT: foo();
246 // CHECK-NEXT: #pragma omp cancellation point parallel
247 // CHECK-NEXT: #pragma omp cancel parallel
250 return tmain
<int, 5>(argc
, &argc
) + tmain
<char, 1>(argv
[0][0], argv
[0]);
253 extern template int S
<int>::TS
;
254 extern template char S
<char>::TS
;