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 -DOMP5 -ast-print %s -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
5 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 -x c++ -std=c++11 -emit-pch -o %t %s -Wno-openmp-mapping
6 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
7 // RUN: %clang_cc1 -verify -fopenmp -DOMP51 -ast-print %s -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
8 // RUN: %clang_cc1 -fopenmp -DOMP51 -x c++ -std=c++11 -emit-pch -o %t %s -Wno-openmp-mapping
9 // RUN: %clang_cc1 -fopenmp -DOMP51 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
11 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -ast-print %s -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP45
12 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -emit-pch -o %t %s -Wno-openmp-mapping
13 // 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
14 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 -DOMP5 -ast-print %s -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
15 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -DOMP5 -x c++ -std=c++11 -emit-pch -o %t %s -Wno-openmp-mapping
16 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -DOMP5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
17 // RUN: %clang_cc1 -verify -fopenmp-simd -DOMP51 -ast-print %s -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
18 // RUN: %clang_cc1 -fopenmp-simd -DOMP51 -x c++ -std=c++11 -emit-pch -o %t %s -Wno-openmp-mapping
19 // RUN: %clang_cc1 -fopenmp-simd -DOMP51 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
20 // expected-no-diagnostics
25 typedef void **omp_allocator_handle_t
;
26 extern const omp_allocator_handle_t omp_null_allocator
;
27 extern const omp_allocator_handle_t omp_default_mem_alloc
;
28 extern const omp_allocator_handle_t omp_large_cap_mem_alloc
;
29 extern const omp_allocator_handle_t omp_const_mem_alloc
;
30 extern const omp_allocator_handle_t omp_high_bw_mem_alloc
;
31 extern const omp_allocator_handle_t omp_low_lat_mem_alloc
;
32 extern const omp_allocator_handle_t omp_cgroup_mem_alloc
;
33 extern const omp_allocator_handle_t omp_pteam_mem_alloc
;
34 extern const omp_allocator_handle_t omp_thread_mem_alloc
;
52 S7(typename
T::type v
) : a(v
) {
53 #pragma omp target teams distribute simd private(a) private(this->a) private(T::a)
54 for (int k
= 0; k
< a
.a
; ++k
)
57 S7
&operator=(S7
&s
) {
59 #pragma omp target teams distribute simd allocate(a) private(a) private(this->a) linear(k) allocate(k)
60 for (k
= 0; k
< s
.a
.a
; ++k
)
65 int b
, argv
, d
, c
, e
, f
;
66 #pragma omp target teams distribute simd private(b), firstprivate(argv) shared(d) reduction(+:c) reduction(max:e) num_teams(f) thread_limit(d)
67 for (int k
= 0; k
< a
.a
; ++k
)
75 #pragma omp target teams distribute simd simdlen(slen1) safelen(slen2) aligned(arr:alen)
76 for (int k
= 0; k
< a
.a
; ++k
)
80 // CHECK: #pragma omp target teams distribute simd private(this->a) private(this->a) private(T::a)
81 // CHECK: #pragma omp target teams distribute simd allocate(this->a) private(this->a) private(this->a) linear(k) allocate(k)
82 // CHECK: #pragma omp target teams distribute simd private(b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d)
83 // CHECK: #pragma omp target teams distribute simd simdlen(slen1) safelen(slen2) aligned(arr: alen)
84 // CHECK: #pragma omp target teams distribute simd private(this->a) private(this->a) private(this->S::a)
86 class S8
: public S7
<S
> {
91 #pragma omp target teams distribute simd private(a) private(this->a) private(S7<S>::a)
92 for (int k
= 0; k
< a
.a
; ++k
)
95 S8
&operator=(S8
&s
) {
96 #pragma omp target teams distribute simd private(a) private(this->a)
97 for (int k
= 0; k
< s
.a
.a
; ++k
)
102 int b
, argv
, d
, c
, e
, f
;
103 #pragma omp target teams distribute simd private(b), firstprivate(argv) shared(d) reduction(+:c) reduction(max:e) num_teams(f) thread_limit(d)
104 for (int k
= 0; k
< a
.a
; ++k
)
112 #pragma omp target teams distribute simd simdlen(slen1) safelen(slen2) aligned(arr:alen)
113 for (int k
= 0; k
< a
.a
; ++k
)
117 // CHECK: #pragma omp target teams distribute simd private(this->a) private(this->a) private(this->S7<S>::a)
118 // CHECK: #pragma omp target teams distribute simd private(this->a) private(this->a)
119 // CHECK: #pragma omp target teams distribute simd private(b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d)
120 // CHECK: #pragma omp target teams distribute simd simdlen(slen1) safelen(slen2) aligned(arr: alen)
122 template <class T
, int N
>
124 T b
= argc
, c
, d
, e
, f
, g
;
126 // CHECK: static T a;
130 #pragma omp target teams distribute simd
131 for (int i
=0; i
< 2; ++i
)
133 // CHECK: #pragma omp target teams distribute simd{{$}}
134 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
135 // CHECK-NEXT: a = 2;
136 #pragma omp target teams distribute simd private(argc, b), firstprivate(c, d), collapse(2)
137 for (int i
= 0; i
< 10; ++i
)
138 for (int j
= 0; j
< 10; ++j
)
140 // CHECK: #pragma omp target teams distribute simd private(argc,b) firstprivate(c,d) collapse(2)
141 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
142 // CHECK-NEXT: for (int j = 0; j < 10; ++j)
143 // CHECK-NEXT: foo();
144 for (int i
= 0; i
< 10; ++i
)
146 // CHECK: for (int i = 0; i < 10; ++i)
147 // CHECK-NEXT: foo();
148 #pragma omp target teams distribute simd
149 for (int i
= 0; i
< 10; ++i
)
151 // CHECK: #pragma omp target teams distribute simd
152 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
153 // CHECK-NEXT: foo();
154 #pragma omp target teams distribute simd private(b), firstprivate(argc) shared(d) reduction(+:c) reduction(max:e) num_teams(f) thread_limit(d)
155 for (int k
= 0; k
< 10; ++k
)
157 // CHECK: #pragma omp target teams distribute simd private(b) firstprivate(argc) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d)
158 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
159 // CHECK-NEXT: e += d + argc;
160 #pragma omp target teams distribute simd simdlen(clen-1)
161 for (int k
= 0; k
< 10; ++k
)
163 // CHECK: #pragma omp target teams distribute simd simdlen(clen - 1)
164 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
165 // CHECK-NEXT: e += d + argc;
166 #pragma omp target teams distribute simd safelen(clen-1) aligned(arr:alen)
167 for (int k
= 0; k
< 10; ++k
)
168 e
+= d
+ argc
+ arr
[k
];
169 // CHECK: #pragma omp target teams distribute simd safelen(clen - 1) aligned(arr: alen)
170 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
171 // CHECK-NEXT: e += d + argc + arr[k];
175 int main (int argc
, char **argv
) {
176 int b
= argc
, c
, d
, e
, f
, g
;
178 // CHECK: static int a;
182 #pragma omp target teams distribute simd
183 for (int i
=0; i
< 2; ++i
)
185 // CHECK: #pragma omp target teams distribute simd
186 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
187 // CHECK-NEXT: a = 2;
188 #pragma omp target teams distribute simd private(argc,b),firstprivate(argv, c), collapse(2)
189 for (int i
= 0; i
< 10; ++i
)
190 for (int j
= 0; j
< 10; ++j
)
192 // CHECK: #pragma omp target teams distribute simd private(argc,b) firstprivate(argv,c) collapse(2)
193 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
194 // CHECK-NEXT: for (int j = 0; j < 10; ++j)
195 // CHECK-NEXT: foo();
196 for (int i
= 0; i
< 10; ++i
)
198 // CHECK: for (int i = 0; i < 10; ++i)
199 // CHECK-NEXT: foo();
200 #pragma omp target teams distribute simd
201 for (int i
= 0; i
< 10; ++i
)foo();
202 // CHECK: #pragma omp target teams distribute simd
203 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
204 // CHECK-NEXT: foo();
205 #pragma omp target teams distribute simd private(b), firstprivate(argc) shared(d) reduction(+:c) reduction(max:e) num_teams(f) thread_limit(d)
206 for (int k
= 0; k
< 10; ++k
)
208 // CHECK: #pragma omp target teams distribute simd private(b) firstprivate(argc) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d)
209 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
210 // CHECK-NEXT: e += d + argc;
211 #pragma omp target teams distribute simd simdlen(clen-1)
212 for (int k
= 0; k
< 10; ++k
)
214 // CHECK: #pragma omp target teams distribute simd simdlen(clen - 1)
215 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
216 // CHECK-NEXT: e += d + argc;
218 #pragma omp target teams distribute simd safelen(clen-1) aligned(arr:N+6) if(simd:argc) nontemporal(argc, c, d) order(unconstrained:concurrent) allocate(omp_low_lat_mem_alloc:e) firstprivate(e) uses_allocators(omp_low_lat_mem_alloc)
220 #pragma omp target teams distribute simd safelen(clen-1) aligned(arr:N+6) if(simd:argc) nontemporal(argc, c, d) order(concurrent) allocate(omp_low_lat_mem_alloc:e) firstprivate(e) uses_allocators(omp_low_lat_mem_alloc)
222 #pragma omp target teams distribute simd safelen(clen-1) aligned(arr:N+6)
224 for (int k
= 0; k
< 10; ++k
)
225 e
+= d
+ argc
+ arr
[k
];
226 // OMP45: #pragma omp target teams distribute simd safelen(clen - 1) aligned(arr: N + 6)
227 // OMP50: #pragma omp target teams distribute simd safelen(clen - 1) aligned(arr: N + 6) if(simd: argc) nontemporal(argc,c,d) order(concurrent) allocate(omp_low_lat_mem_alloc: e) firstprivate(e) uses_allocators(omp_low_lat_mem_alloc)
228 // OMP51: #pragma omp target teams distribute simd safelen(clen - 1) aligned(arr: N + 6) if(simd: argc) nontemporal(argc,c,d) order(unconstrained: concurrent) allocate(omp_low_lat_mem_alloc: e) firstprivate(e) uses_allocators(omp_low_lat_mem_alloc)
229 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
230 // CHECK-NEXT: e += d + argc + arr[k];