target_parallel_ast_print.cpp
8.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -ast-print %s | FileCheck %s
// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -emit-pch -o %t %s
// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -ast-print %s | FileCheck %s
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -emit-pch -o %t %s
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
// expected-no-diagnostics
#ifndef HEADER
#define HEADER
void foo() {}
template <class T>
struct S {
operator T() {return T();}
static T TS;
#pragma omp threadprivate(TS)
};
// CHECK: template <class T> struct S {
// CHECK: static T TS;
// CHECK-NEXT: #pragma omp threadprivate(S::TS)
// CHECK: };
// CHECK: template<> struct S<int> {
// CHECK: static int TS;
// CHECK-NEXT: #pragma omp threadprivate(S<int>::TS)
// CHECK-NEXT: }
// CHECK: template<> struct S<char> {
// CHECK: static char TS;
// CHECK-NEXT: #pragma omp threadprivate(S<char>::TS)
// CHECK-NEXT: }
template <typename T, int C>
T tmain(T argc, T *argv) {
T b = argc, c, d, e, f, g;
static T h;
S<T> s;
T arr[C][10], arr1[C];
T i, j, a[20];
#pragma omp target parallel
h=2;
#pragma omp target parallel allocate(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])
foo();
#pragma omp target parallel if (C) num_threads(s) proc_bind(close) reduction(^:e, f, arr[0:C][:argc]) reduction(&& : g) allocate(g)
foo();
#pragma omp target parallel if (target:argc > 0)
foo();
#pragma omp target parallel if (parallel:argc > 0)
foo();
#pragma omp target parallel if (C)
foo();
#pragma omp target parallel map(i)
foo();
#pragma omp target parallel map(a[0:10], i)
foo();
#pragma omp target parallel map(to: i) map(from: j)
foo();
#pragma omp target parallel map(always,alloc: i)
foo();
#pragma omp target parallel nowait
foo();
#pragma omp target parallel depend(in : argc, argv[i:argc], a[:])
foo();
#pragma omp target parallel defaultmap(tofrom: scalar)
foo();
return 0;
}
// CHECK: template <typename T, int C> T tmain(T argc, T *argv) {
// CHECK-NEXT: T b = argc, c, d, e, f, g;
// CHECK-NEXT: static T h;
// CHECK-NEXT: S<T> s;
// CHECK-NEXT: T arr[C][10], arr1[C];
// CHECK-NEXT: T i, j, a[20]
// CHECK-NEXT: #pragma omp target parallel{{$}}
// CHECK-NEXT: h = 2;
// CHECK-NEXT: #pragma omp target parallel allocate(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])
// CHECK-NEXT: foo()
// 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)
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel if(target: argc > 0)
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel if(parallel: argc > 0)
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel if(C)
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel map(tofrom: i)
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel map(tofrom: a[0:10],i)
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel map(to: i) map(from: j)
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel map(always,alloc: i)
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel nowait
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel depend(in : argc,argv[i:argc],a[:])
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel defaultmap(tofrom: scalar)
// CHECK-NEXT: foo()
// CHECK: template<> int tmain<int, 5>(int argc, int *argv) {
// CHECK-NEXT: int b = argc, c, d, e, f, g;
// CHECK-NEXT: static int h;
// CHECK-NEXT: S<int> s;
// CHECK-NEXT: int arr[5][10], arr1[5];
// CHECK-NEXT: int i, j, a[20]
// CHECK-NEXT: #pragma omp target parallel
// CHECK-NEXT: h = 2;
// CHECK-NEXT: #pragma omp target parallel allocate(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])
// CHECK-NEXT: foo()
// 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)
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel if(target: argc > 0)
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel if(parallel: argc > 0)
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel if(5)
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel map(tofrom: i)
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel map(tofrom: a[0:10],i)
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel map(to: i) map(from: j)
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel map(always,alloc: i)
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel nowait
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel depend(in : argc,argv[i:argc],a[:])
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel defaultmap(tofrom: scalar)
// CHECK-NEXT: foo()
// CHECK: template<> char tmain<char, 1>(char argc, char *argv) {
// CHECK-NEXT: char b = argc, c, d, e, f, g;
// CHECK-NEXT: static char h;
// CHECK-NEXT: S<char> s;
// CHECK-NEXT: char arr[1][10], arr1[1];
// CHECK-NEXT: char i, j, a[20]
// CHECK-NEXT: #pragma omp target parallel
// CHECK-NEXT: h = 2;
// CHECK-NEXT: #pragma omp target parallel allocate(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])
// CHECK-NEXT: foo()
// 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)
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel if(target: argc > 0)
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel if(parallel: argc > 0)
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel if(1)
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel map(tofrom: i)
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel map(tofrom: a[0:10],i)
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel map(to: i) map(from: j)
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel map(always,alloc: i)
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel nowait
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel depend(in : argc,argv[i:argc],a[:])
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target parallel defaultmap(tofrom: scalar)
// CHECK-NEXT: foo()
// CHECK-LABEL: int main(int argc, char **argv) {
int main (int argc, char **argv) {
int i, j, a[20];
// CHECK-NEXT: int i, j, a[20]
#pragma omp target parallel
// CHECK-NEXT: #pragma omp target parallel
foo();
// CHECK-NEXT: foo();
#pragma omp target parallel if (argc > 0)
// CHECK-NEXT: #pragma omp target parallel if(argc > 0)
foo();
// CHECK-NEXT: foo();
#pragma omp target parallel if (target: argc > 0)
// CHECK-NEXT: #pragma omp target parallel if(target: argc > 0)
foo();
// CHECK-NEXT: foo();
#pragma omp target parallel if (parallel: argc > 0)
// CHECK-NEXT: #pragma omp target parallel if(parallel: argc > 0)
foo();
// CHECK-NEXT: foo();
#pragma omp target parallel map(i) if(argc>0)
// CHECK-NEXT: #pragma omp target parallel map(tofrom: i) if(argc > 0)
foo();
// CHECK-NEXT: foo();
#pragma omp target parallel map(i)
// CHECK-NEXT: #pragma omp target parallel map(tofrom: i)
foo();
// CHECK-NEXT: foo();
#pragma omp target parallel map(a[0:10], i)
// CHECK-NEXT: #pragma omp target parallel map(tofrom: a[0:10],i)
foo();
// CHECK-NEXT: foo();
#pragma omp target parallel map(to: i) map(from: j)
// CHECK-NEXT: #pragma omp target parallel map(to: i) map(from: j)
foo();
// CHECK-NEXT: foo();
#pragma omp target parallel map(always,alloc: i)
// CHECK-NEXT: #pragma omp target parallel map(always,alloc: i)
foo();
// CHECK-NEXT: foo();
#pragma omp target parallel nowait
// CHECK-NEXT: #pragma omp target parallel nowait
foo();
// CHECK-NEXT: foo();
#pragma omp target parallel depend(in : argc, argv[i:argc], a[:])
// CHECK-NEXT: #pragma omp target parallel depend(in : argc,argv[i:argc],a[:])
foo();
// CHECK-NEXT: foo();
#pragma omp target parallel defaultmap(tofrom: scalar)
// CHECK-NEXT: #pragma omp target parallel defaultmap(tofrom: scalar)
foo();
// CHECK-NEXT: foo();
return tmain<int, 5>(argc, &argc) + tmain<char, 1>(argv[0][0], argv[0]);
}
extern template int S<int>::TS;
extern template char S<char>::TS;
#endif