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 -Wno-openmp-mapping
3 // RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -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 -Wno-openmp-mapping
7 // RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -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
) {
41 #pragma omp target teams distribute private(a) private(this->a) private(T::a)
42 for (int k
= 0; k
< a
.a
; ++k
)
45 S7
&operator=(S7
&s
) {
46 #pragma omp target teams distribute private(a) private(this->a)
47 for (int k
= 0; k
< s
.a
.a
; ++k
)
53 int b
, argv
, d
, c
, e
, f
;
54 #pragma omp target teams distribute default(none), private(b) firstprivate(argv) shared(d) reduction(+:c) reduction(max:e) num_teams(f) thread_limit(d) allocate(omp_low_lat_mem_alloc:b) uses_allocators(omp_low_lat_mem_alloc)
55 for (int k
= 0; k
< a
.a
; ++k
)
59 // CHECK: #pragma omp target teams distribute private(this->a) private(this->a) private(T::a)
60 // CHECK: #pragma omp target teams distribute private(this->a) private(this->a)
61 // CHECK: #pragma omp target teams distribute default(none) private(b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d) allocate(omp_low_lat_mem_alloc: b) uses_allocators(omp_low_lat_mem_alloc)
62 // CHECK: #pragma omp target teams distribute private(this->a) private(this->a) private(this->S::a)
64 class S8
: public S7
<S
> {
69 #pragma omp target teams distribute private(a) private(this->a) private(S7<S>::a)
70 for (int k
= 0; k
< a
.a
; ++k
)
73 S8
&operator=(S8
&s
) {
74 #pragma omp target teams distribute private(a) private(this->a)
75 for (int k
= 0; k
< s
.a
.a
; ++k
)
81 int b
, argv
, d
, c
, e
, f
;
82 #pragma omp target teams distribute allocate(argv) default(none), private(b) firstprivate(argv) shared(d) reduction(+:c) reduction(max:e) num_teams(f) thread_limit(d) allocate(e)
83 for (int k
= 0; k
< a
.a
; ++k
)
87 // CHECK: #pragma omp target teams distribute private(this->a) private(this->a) private(this->S7<S>::a)
88 // CHECK: #pragma omp target teams distribute private(this->a) private(this->a)
89 // CHECK: #pragma omp target teams distribute allocate(argv) default(none) private(b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d) allocate(e)
91 template <class T
, int N
>
93 T b
= argc
, c
, d
, e
, f
, g
;
96 #pragma omp target teams distribute
97 for (int i
=0; i
< 2; ++i
)
99 // CHECK: #pragma omp target teams distribute{{$}}
100 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
101 // CHECK-NEXT: a = 2;
102 #pragma omp target teams distribute private(argc, b), firstprivate(c, d), collapse(2)
103 for (int i
= 0; i
< 10; ++i
)
104 for (int j
= 0; j
< 10; ++j
)
106 // CHECK: #pragma omp target teams distribute private(argc,b) firstprivate(c,d) collapse(2)
107 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
108 // CHECK-NEXT: for (int j = 0; j < 10; ++j)
109 // CHECK-NEXT: foo();
110 for (int i
= 0; i
< 10; ++i
)
112 // CHECK: for (int i = 0; i < 10; ++i)
113 // CHECK-NEXT: foo();
114 #pragma omp target teams distribute
115 for (int i
= 0; i
< 10; ++i
)
117 // CHECK: #pragma omp target teams distribute
118 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
119 // CHECK-NEXT: foo();
120 #pragma omp target teams distribute default(none), private(b) firstprivate(argc) shared(d) reduction(+:c) reduction(max:e) num_teams(f) thread_limit(d)
121 for (int k
= 0; k
< 10; ++k
)
123 // CHECK: #pragma omp target teams distribute default(none) private(b) firstprivate(argc) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d)
124 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
125 // CHECK-NEXT: e += d + argc;
129 int main (int argc
, char **argv
) {
130 int b
= argc
, c
, d
, e
, f
, g
;
132 // CHECK: static int a;
133 #pragma omp target teams distribute
134 for (int i
=0; i
< 2; ++i
)
136 // CHECK: #pragma omp target teams distribute
137 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
138 // CHECK-NEXT: a = 2;
139 #pragma omp target teams distribute private(argc,b),firstprivate(argv, c), collapse(2)
140 for (int i
= 0; i
< 10; ++i
)
141 for (int j
= 0; j
< 10; ++j
)
143 // CHECK: #pragma omp target teams distribute private(argc,b) firstprivate(argv,c) collapse(2)
144 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
145 // CHECK-NEXT: for (int j = 0; j < 10; ++j)
146 // CHECK-NEXT: foo();
147 for (int i
= 0; i
< 10; ++i
)
149 // CHECK: for (int i = 0; i < 10; ++i)
150 // CHECK-NEXT: foo();
151 #pragma omp target teams distribute
152 for (int i
= 0; i
< 10; ++i
)foo();
153 // CHECK: #pragma omp target teams distribute
154 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
155 // CHECK-NEXT: foo();
156 #pragma omp target teams distribute default(none), private(b) firstprivate(argc) shared(d) reduction(+:c) reduction(max:e) num_teams(f) thread_limit(d)
157 for (int k
= 0; k
< 10; ++k
)
159 // CHECK: #pragma omp target teams distribute default(none) private(b) firstprivate(argc) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d)
160 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
161 // CHECK-NEXT: e += d + argc;