• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -ast-print %s | FileCheck %s
2 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -std=c++11 -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
4 
5 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 -ast-print %s | FileCheck %s
6 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -std=c++11 -emit-pch -o %t %s
7 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
8 // expected-no-diagnostics
9 
10 #ifndef HEADER
11 #define HEADER
12 
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;
23 
foo()24 void foo() {}
25 
26 template <class T>
27 struct S {
operator TS28   operator T() {return T();}
29   static T TS;
30   #pragma omp threadprivate(TS)
31 };
32 
33 // CHECK:      template <class T> struct S {
34 // CHECK:        static T TS;
35 // CHECK-NEXT:   #pragma omp threadprivate(S::TS)
36 // CHECK:      };
37 // CHECK:      template<> struct S<int> {
38 // CHECK:        static int TS;
39 // CHECK-NEXT:   #pragma omp threadprivate(S<int>::TS)
40 // CHECK-NEXT: }
41 // CHECK:      template<> struct S<char> {
42 // CHECK:        static char TS;
43 // CHECK-NEXT:   #pragma omp threadprivate(S<char>::TS)
44 // CHECK-NEXT: }
45 
46 template <typename T, int C>
tmain(T argc,T * argv)47 T tmain(T argc, T *argv) {
48   T b = argc, c, d, e, f, g;
49   static T h;
50   S<T> s;
51   T arr[C][10], arr1[C];
52   T i, j, a[20];
53 #pragma omp target parallel
54   h=2;
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)
56   foo();
57 #pragma omp target parallel if (C) num_threads(s) proc_bind(close) reduction(^:e, f, arr[0:C][:argc]) reduction(&& : g) allocate(g)
58   foo();
59 #pragma omp target parallel if (target:argc > 0)
60   foo();
61 #pragma omp target parallel if (parallel:argc > 0)
62   foo();
63 #pragma omp target parallel if (C)
64   foo();
65 #pragma omp target parallel map(i)
66   foo();
67 #pragma omp target parallel map(a[0:10], i)
68   foo();
69 #pragma omp target parallel map(to: i) map(from: j)
70   foo();
71 #pragma omp target parallel map(always,alloc: i)
72   foo();
73 #pragma omp target parallel nowait
74   foo();
75 #pragma omp target parallel depend(in : argc, argv[i:argc], a[:])
76   foo();
77 #pragma omp target parallel defaultmap(tofrom: scalar)
78   foo();
79   return 0;
80 }
81 
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{{$}}
89 // CHECK-NEXT: h = 2;
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)
91 // CHECK-NEXT: foo()
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)
93 // CHECK-NEXT: foo()
94 // CHECK-NEXT: #pragma omp target parallel if(target: argc > 0)
95 // CHECK-NEXT: foo()
96 // CHECK-NEXT: #pragma omp target parallel if(parallel: argc > 0)
97 // CHECK-NEXT: foo()
98 // CHECK-NEXT: #pragma omp target parallel if(C)
99 // CHECK-NEXT: foo()
100 // CHECK-NEXT: #pragma omp target parallel map(tofrom: i)
101 // CHECK-NEXT: foo()
102 // CHECK-NEXT: #pragma omp target parallel map(tofrom: a[0:10],i)
103 // CHECK-NEXT: foo()
104 // CHECK-NEXT: #pragma omp target parallel map(to: i) map(from: j)
105 // CHECK-NEXT: foo()
106 // CHECK-NEXT: #pragma omp target parallel map(always,alloc: i)
107 // CHECK-NEXT: foo()
108 // CHECK-NEXT: #pragma omp target parallel nowait
109 // CHECK-NEXT: foo()
110 // CHECK-NEXT: #pragma omp target parallel depend(in : argc,argv[i:argc],a[:])
111 // CHECK-NEXT: foo()
112 // CHECK-NEXT: #pragma omp target parallel defaultmap(tofrom: scalar)
113 // CHECK-NEXT: foo()
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)
123 // CHECK-NEXT: foo()
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)
125 // CHECK-NEXT: foo()
126 // CHECK-NEXT: #pragma omp target parallel if(target: argc > 0)
127 // CHECK-NEXT: foo()
128 // CHECK-NEXT: #pragma omp target parallel if(parallel: argc > 0)
129 // CHECK-NEXT: foo()
130 // CHECK-NEXT: #pragma omp target parallel if(5)
131 // CHECK-NEXT: foo()
132 // CHECK-NEXT: #pragma omp target parallel map(tofrom: i)
133 // CHECK-NEXT: foo()
134 // CHECK-NEXT: #pragma omp target parallel map(tofrom: a[0:10],i)
135 // CHECK-NEXT: foo()
136 // CHECK-NEXT: #pragma omp target parallel map(to: i) map(from: j)
137 // CHECK-NEXT: foo()
138 // CHECK-NEXT: #pragma omp target parallel map(always,alloc: i)
139 // CHECK-NEXT: foo()
140 // CHECK-NEXT: #pragma omp target parallel nowait
141 // CHECK-NEXT: foo()
142 // CHECK-NEXT: #pragma omp target parallel depend(in : argc,argv[i:argc],a[:])
143 // CHECK-NEXT: foo()
144 // CHECK-NEXT: #pragma omp target parallel defaultmap(tofrom: scalar)
145 // CHECK-NEXT: foo()
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)
155 // CHECK-NEXT: foo()
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)
157 // CHECK-NEXT: foo()
158 // CHECK-NEXT: #pragma omp target parallel if(target: argc > 0)
159 // CHECK-NEXT: foo()
160 // CHECK-NEXT: #pragma omp target parallel if(parallel: argc > 0)
161 // CHECK-NEXT: foo()
162 // CHECK-NEXT: #pragma omp target parallel if(1)
163 // CHECK-NEXT: foo()
164 // CHECK-NEXT: #pragma omp target parallel map(tofrom: i)
165 // CHECK-NEXT: foo()
166 // CHECK-NEXT: #pragma omp target parallel map(tofrom: a[0:10],i)
167 // CHECK-NEXT: foo()
168 // CHECK-NEXT: #pragma omp target parallel map(to: i) map(from: j)
169 // CHECK-NEXT: foo()
170 // CHECK-NEXT: #pragma omp target parallel map(always,alloc: i)
171 // CHECK-NEXT: foo()
172 // CHECK-NEXT: #pragma omp target parallel nowait
173 // CHECK-NEXT: foo()
174 // CHECK-NEXT: #pragma omp target parallel depend(in : argc,argv[i:argc],a[:])
175 // CHECK-NEXT: foo()
176 // CHECK-NEXT: #pragma omp target parallel defaultmap(tofrom: scalar)
177 // CHECK-NEXT: foo()
178 
179 // CHECK-LABEL: int main(int argc, char **argv) {
main(int argc,char ** argv)180 int main (int argc, char **argv) {
181   int i, j, a[20];
182 // CHECK-NEXT: int i, j, a[20]
183 #pragma omp target parallel
184 // CHECK-NEXT: #pragma omp target parallel
185   foo();
186 // CHECK-NEXT: foo();
187 #pragma omp target parallel if (argc > 0)
188 // CHECK-NEXT: #pragma omp target parallel if(argc > 0)
189   foo();
190 // CHECK-NEXT: foo();
191 
192 #pragma omp target parallel if (target: argc > 0)
193 // CHECK-NEXT: #pragma omp target parallel if(target: argc > 0)
194   foo();
195 // CHECK-NEXT: foo();
196 
197 #pragma omp target parallel if (parallel: argc > 0)
198 // CHECK-NEXT: #pragma omp target parallel if(parallel: argc > 0)
199   foo();
200 // CHECK-NEXT: foo();
201 
202 #pragma omp target parallel map(i) if(argc>0)
203 // CHECK-NEXT: #pragma omp target parallel map(tofrom: i) if(argc > 0)
204   foo();
205 // CHECK-NEXT: foo();
206 
207 #pragma omp target parallel map(i)
208 // CHECK-NEXT: #pragma omp target parallel map(tofrom: i)
209   foo();
210 // CHECK-NEXT: foo();
211 
212 #pragma omp target parallel map(a[0:10], i)
213 // CHECK-NEXT: #pragma omp target parallel map(tofrom: a[0:10],i)
214   foo();
215 // CHECK-NEXT: foo();
216 
217 #pragma omp target parallel map(to: i) map(from: j)
218 // CHECK-NEXT: #pragma omp target parallel map(to: i) map(from: j)
219   foo();
220 // CHECK-NEXT: foo();
221 
222 #pragma omp target parallel map(always,alloc: i)
223 // CHECK-NEXT: #pragma omp target parallel map(always,alloc: i)
224   foo();
225 // CHECK-NEXT: foo();
226 
227 #pragma omp target parallel nowait
228 // CHECK-NEXT: #pragma omp target parallel nowait
229   foo();
230 // CHECK-NEXT: foo();
231 
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[:])
234   foo();
235 // CHECK-NEXT: foo();
236 
237 #pragma omp target parallel defaultmap(tofrom: scalar) reduction(task, +:argc)
238 // CHECK-NEXT: #pragma omp target parallel defaultmap(tofrom: scalar) reduction(task, +: argc)
239   {
240   foo();
241 #pragma omp cancellation point parallel
242 #pragma omp cancel parallel
243   }
244 // CHECK-NEXT: {
245 // CHECK-NEXT: foo();
246 // CHECK-NEXT: #pragma omp cancellation point parallel
247 // CHECK-NEXT: #pragma omp cancel parallel
248 // CHECK-NEXT: }
249 
250   return tmain<int, 5>(argc, &argc) + tmain<char, 1>(argv[0][0], argv[0]);
251 }
252 
253 extern template int S<int>::TS;
254 extern template char S<char>::TS;
255 
256 #endif
257