1 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -ast-print %s -Wno-openmp-mapping -Wsign-conversion | 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 -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 -Wsign-conversion -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 -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 -Wsign-conversion | 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 -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 -Wsign-conversion -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 -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 teams distribute parallel for private(a) private(this->a) private(T::a) allocate(omp_cgroup_mem_alloc:a) uses_allocators(omp_cgroup_mem_alloc)
48 for (int k
= 0; k
< a
.a
; ++k
) {
50 #pragma omp cancel for
53 S7
&operator=(S7
&s
) {
54 #pragma omp target teams distribute parallel for private(a) private(this->a)
55 for (int k
= 0; k
< s
.a
.a
; ++k
)
62 int b
, argv
, d
, c
, e
, f
;
63 #pragma omp target teams distribute parallel for default(none), private(b) firstprivate(argv) shared(d) reduction(+:c) reduction(max:e) num_teams(f) thread_limit(d)
64 for (int k
= 0; k
< a
.a
; ++k
)
68 // CHECK: #pragma omp target teams distribute parallel for private(this->a) private(this->a) private(T::a) allocate(omp_cgroup_mem_alloc: this->a) uses_allocators(omp_cgroup_mem_alloc)
69 // CHECK: #pragma omp cancel for
70 // CHECK: #pragma omp target teams distribute parallel for private(this->a) private(this->a)
71 // CHECK: #pragma omp target teams distribute parallel for default(none) private(b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d)
73 class S8
: public S7
<S
> {
78 #pragma omp target teams distribute parallel for private(a) private(this->a) private(S7<S>::a)
79 for (int k
= 0; k
< a
.a
; ++k
)
82 S8
&operator=(S8
&s
) {
83 #pragma omp target teams distribute parallel for private(a) private(this->a)
84 for (int k
= 0; k
< s
.a
.a
; ++k
)
91 int b
, argv
, d
, c
, e
, f8
;
92 #pragma omp target teams distribute parallel for allocate(b) default(none), private(b) firstprivate(argv) shared(d) reduction(+:c) reduction(max:e) num_teams(f8) thread_limit(d) allocate(e)
93 for (int k
= 0; k
< a
.a
; ++k
)
97 // CHECK: #pragma omp target teams distribute parallel for private(this->a) private(this->a) private(this->S::a)
98 // CHECK: #pragma omp target teams distribute parallel for private(this->a) private(this->a) private(this->S7<S>::a)
99 // CHECK: #pragma omp target teams distribute parallel for private(this->a) private(this->a)
100 // CHECK: #pragma omp target teams distribute parallel for allocate(b) default(none) private(b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(f8) thread_limit(d) allocate(e)
102 template <class T
, int N
>
104 T b
= argc
, c
, d
, e
, f
, g
;
106 // CHECK: static T a;
110 #pragma omp target teams distribute parallel for
111 for (int i
=0; i
< 2; ++i
)
113 // CHECK: #pragma omp target teams distribute parallel for{{$}}
114 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
115 // CHECK-NEXT: a = 2;
117 #pragma omp target teams distribute parallel for private(argc, b), firstprivate(c, d), collapse(2) order(unconstrained:concurrent)
119 #pragma omp target teams distribute parallel for private(argc, b), firstprivate(c, d), collapse(2) order(concurrent)
121 for (int i
= 0; i
< 10; ++i
)
122 for (int j
= 0; j
< 10; ++j
)
124 // OMP51: #pragma omp target teams distribute parallel for private(argc,b) firstprivate(c,d) collapse(2) order(unconstrained: concurrent)
125 // OMP50: #pragma omp target teams distribute parallel for private(argc,b) firstprivate(c,d) collapse(2) order(concurrent)
126 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
127 // CHECK-NEXT: for (int j = 0; j < 10; ++j)
128 // CHECK-NEXT: foo();
129 for (int i
= 0; i
< 10; ++i
)
131 // CHECK: for (int i = 0; i < 10; ++i)
132 // CHECK-NEXT: foo();
133 #pragma omp target teams distribute parallel for
134 for (int i
= 0; i
< 10; ++i
)
136 // CHECK: #pragma omp target teams distribute parallel for
137 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
138 // CHECK-NEXT: foo();
139 #pragma omp target teams distribute parallel for default(none), private(b) firstprivate(argc) shared(d) reduction(+:c) reduction(max:e) num_teams(f) thread_limit(d)
140 for (int k
= 0; k
< 10; ++k
)
142 // CHECK: #pragma omp target teams distribute parallel for default(none) private(b) firstprivate(argc) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d)
143 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
144 // CHECK-NEXT: e += d + argc;
145 #pragma omp target teams distribute parallel for
146 for (int k
= 0; k
< 10; ++k
)
148 // CHECK: #pragma omp target teams distribute parallel for
149 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
150 // CHECK-NEXT: e += d + argc;
154 int main (int argc
, char **argv
) {
155 int b
= argc
, c
, d
, e
, f
, g
;
157 // CHECK: static int a;
161 #pragma omp target teams distribute parallel for
162 for (int i
=0; i
< 2; ++i
)
164 // CHECK: #pragma omp target teams distribute parallel for
165 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
166 // CHECK-NEXT: a = 2;
167 #pragma omp target teams distribute parallel for private(argc,b),firstprivate(argv, c), collapse(2)
168 for (int i
= 0; i
< 10; ++i
)
169 for (int j
= 0; j
< 10; ++j
)
171 // CHECK: #pragma omp target teams distribute parallel for private(argc,b) firstprivate(argv,c) collapse(2)
172 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
173 // CHECK-NEXT: for (int j = 0; j < 10; ++j)
174 // CHECK-NEXT: foo();
175 for (int i
= 0; i
< 10; ++i
)
177 // CHECK: for (int i = 0; i < 10; ++i)
178 // CHECK-NEXT: foo();
179 #pragma omp target teams distribute parallel for
180 for (int i
= 0; i
< 10; ++i
)foo();
181 // CHECK: #pragma omp target teams distribute parallel for
182 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
183 // CHECK-NEXT: foo();
184 #pragma omp target teams distribute parallel for default(none), private(b) firstprivate(argc) shared(d) reduction(+:c) reduction(max:e) num_teams(f) thread_limit(d)
185 for (int k
= 0; k
< 10; ++k
)
187 // CHECK: #pragma omp target teams distribute parallel for default(none) private(b) firstprivate(argc) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d)
188 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
189 // CHECK-NEXT: e += d + argc;
190 #pragma omp target teams distribute parallel for reduction(task,+:argc)
191 for (int k
= 0; k
< 10; ++k
)
193 // CHECK: #pragma omp target teams distribute parallel for reduction(task, +: argc)
194 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
195 // CHECK-NEXT: e += d + argc;