1 // RUN: %clang_cc1 -verify -fopenmp -ast-print %s -Wno-openmp-mapping | 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 -Wno-openmp-mapping | FileCheck %s
5 // RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s -Wno-openmp-mapping | 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 -Wno-openmp-mapping | 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
;
40 S7(typename
T::type v
) : a(v
) {
42 #pragma omp teams distribute private(a) private(this->a) private(T::a)
43 for (int k
= 0; k
< a
.a
; ++k
)
46 S7
&operator=(S7
&s
) {
48 #pragma omp teams distribute private(a) private(this->a)
49 for (int k
= 0; k
< s
.a
.a
; ++k
)
55 int b
, argv
, d
, c
, e
, f
;
57 #pragma omp teams distribute default(none), private(b) firstprivate(argv) shared(d) reduction(+:c) reduction(max:e) num_teams(f) thread_limit(d)
58 for (int k
= 0; k
< a
.a
; ++k
)
62 // CHECK: #pragma omp target
63 // CHECK-NEXT: #pragma omp teams distribute private(this->a) private(this->a) private(T::a)
64 // CHECK: #pragma omp target
65 // CHECK-NEXT: #pragma omp teams distribute private(this->a) private(this->a)
66 // CHECK: #pragma omp target
67 // CHECK-NEXT: #pragma omp teams distribute default(none) private(b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d)
68 // CHECK: #pragma omp target
69 // CHECK-NEXT: #pragma omp teams distribute private(this->a) private(this->a) private(this->S::a)
71 class S8
: public S7
<S
> {
77 #pragma omp teams distribute private(a) private(this->a) private(S7<S>::a)
78 for (int k
= 0; k
< a
.a
; ++k
)
81 S8
&operator=(S8
&s
) {
83 #pragma omp teams distribute private(a) private(this->a)
84 for (int k
= 0; k
< s
.a
.a
; ++k
)
90 int b
, argv
, d
, c
, e
, f
;
92 #pragma omp teams distribute allocate(omp_thread_mem_alloc:argv) default(none), private(b) firstprivate(argv) shared(d) reduction(+:c) reduction(max:e) num_teams(f) thread_limit(d) allocate(omp_default_mem_alloc:c) shared(omp_default_mem_alloc, omp_thread_mem_alloc)
93 for (int k
= 0; k
< a
.a
; ++k
)
97 // CHECK: #pragma omp target
98 // CHECK-NEXT: #pragma omp teams distribute private(this->a) private(this->a) private(this->S7<S>::a)
99 // CHECK: #pragma omp target
100 // CHECK-NEXT: #pragma omp teams distribute private(this->a) private(this->a)
101 // CHECK: #pragma omp target
102 // CHECK-NEXT: #pragma omp teams distribute allocate(omp_thread_mem_alloc: argv) default(none) private(b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d) allocate(omp_default_mem_alloc: c) shared(omp_default_mem_alloc,omp_thread_mem_alloc)
104 template <class T
, int N
>
106 T b
= argc
, c
, d
, e
, f
, g
;
108 // CHECK: static T a;
110 #pragma omp teams distribute
111 for (int i
=0; i
< 2; ++i
)
113 // CHECK: #pragma omp target
114 // CHECK-NEXT: #pragma omp teams distribute{{$}}
115 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
116 // CHECK-NEXT: a = 2;
118 #pragma omp teams distribute private(argc, b), firstprivate(c, d), collapse(2)
119 for (int i
= 0; i
< 10; ++i
)
120 for (int j
= 0; j
< 10; ++j
)
122 // CHECK: #pragma omp target
123 // CHECK-NEXT: #pragma omp teams distribute private(argc,b) firstprivate(c,d) collapse(2)
124 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
125 // CHECK-NEXT: for (int j = 0; j < 10; ++j)
126 // CHECK-NEXT: foo();
127 for (int i
= 0; i
< 10; ++i
)
129 // CHECK: for (int i = 0; i < 10; ++i)
130 // CHECK-NEXT: foo();
132 #pragma omp teams distribute
133 for (int i
= 0; i
< 10; ++i
)
135 // CHECK: #pragma omp target
136 // CHECK-NEXT: #pragma omp teams distribute
137 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
138 // CHECK-NEXT: foo();
140 #pragma omp teams distribute default(none), private(b) firstprivate(argc) shared(d) reduction(+:c) reduction(max:e) num_teams(f) thread_limit(d)
141 for (int k
= 0; k
< 10; ++k
)
143 // CHECK: #pragma omp target
144 // CHECK-NEXT: #pragma omp teams distribute default(none) private(b) firstprivate(argc) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d)
145 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
146 // CHECK-NEXT: e += d + argc;
150 int main (int argc
, char **argv
) {
151 int b
= argc
, c
, d
, e
, f
, g
;
153 // CHECK: static int a;
155 #pragma omp teams distribute
156 for (int i
=0; i
< 2; ++i
)
158 // CHECK: #pragma omp target
159 // CHECK-NEXT: #pragma omp teams distribute
160 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
161 // CHECK-NEXT: a = 2;
163 #pragma omp teams distribute private(argc,b),firstprivate(argv, c), collapse(2)
164 for (int i
= 0; i
< 10; ++i
)
165 for (int j
= 0; j
< 10; ++j
)
167 // CHECK: #pragma omp target
168 // CHECK-NEXT: #pragma omp teams distribute private(argc,b) firstprivate(argv,c) collapse(2)
169 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
170 // CHECK-NEXT: for (int j = 0; j < 10; ++j)
171 // CHECK-NEXT: foo();
172 for (int i
= 0; i
< 10; ++i
)
174 // CHECK: for (int i = 0; i < 10; ++i)
175 // CHECK-NEXT: foo();
177 #pragma omp teams distribute
178 for (int i
= 0; i
< 10; ++i
)foo();
179 // CHECK: #pragma omp target
180 // CHECK-NEXT: #pragma omp teams distribute
181 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
182 // CHECK-NEXT: foo();
184 #pragma omp teams distribute 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
188 // CHECK-NEXT: #pragma omp teams distribute default(none) private(b) firstprivate(argc) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d)
189 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
190 // CHECK-NEXT: e += d + argc;