1 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -ast-print %s | 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
3 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -std=c++11 -include-pch %t -verify %s -ast-print | FileCheck %s --check-prefix=CHECK --check-prefix=OMP45
4 // RUN: %clang_cc1 -verify -fopenmp -DOMP5 -ast-print %s | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
5 // RUN: %clang_cc1 -fopenmp -DOMP5 -x c++ -std=c++11 -emit-pch -o %t %s
6 // RUN: %clang_cc1 -fopenmp -DOMP5 -std=c++11 -include-pch %t -verify %s -ast-print | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
7 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -DOMP51 -ast-print %s | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
8 // RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -DOMP51 -x c++ -std=c++11 -emit-pch -o %t %s
9 // RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -DOMP51 -std=c++11 -include-pch %t -verify %s -ast-print | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
11 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -ast-print %s | 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
13 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -std=c++11 -include-pch %t -verify %s -ast-print | FileCheck %s --check-prefix=CHECK --check-prefix=OMP45
14 // RUN: %clang_cc1 -verify -fopenmp-simd -DOMP5 -ast-print %s | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
15 // RUN: %clang_cc1 -fopenmp-simd -DOMP5 -x c++ -std=c++11 -emit-pch -o %t %s
16 // RUN: %clang_cc1 -fopenmp-simd -DOMP5 -std=c++11 -include-pch %t -verify %s -ast-print | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
17 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=51 -DOMP51 -ast-print %s | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
18 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=51 -DOMP51 -x c++ -std=c++11 -emit-pch -o %t %s
19 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=51 -DOMP51 -std=c++11 -include-pch %t -verify %s -ast-print | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
20 // expected-no-diagnostics
41 S7(typename
T::type v
) : a(v
) {
42 #pragma omp parallel for simd private(a) private(this->a) private(T::a)
43 for (int k
= 0; k
< a
.a
; ++k
)
46 S7
&operator=(S7
&s
) {
47 #pragma omp parallel for simd private(a) private(this->a)
48 for (int k
= 0; k
< s
.a
.a
; ++k
)
54 // CHECK: #pragma omp parallel for simd private(this->a) private(this->a) private(T::a){{$}}
55 // CHECK: #pragma omp parallel for simd private(this->a) private(this->a)
56 // CHECK: #pragma omp parallel for simd private(this->a) private(this->a) private(this->S1::a)
58 class S8
: public S7
<S1
> {
62 S8(int v
) : S7
<S1
>(v
){
63 #pragma omp parallel for simd private(a) private(this->a) private(S7 <S1>::a)
64 for (int k
= 0; k
< a
.a
; ++k
)
67 S8
&operator=(S8
&s
) {
68 #pragma omp parallel for simd private(a) private(this->a)
69 for (int k
= 0; k
< s
.a
.a
; ++k
)
75 // CHECK: #pragma omp parallel for simd private(this->a) private(this->a) private(this->S7<S1>::a)
76 // CHECK: #pragma omp parallel for simd private(this->a) private(this->a)
79 template<class T
, class N
> T
reduct(T
* arr
, N num
) {
84 // CHECK: T sum = (T)0;
85 #pragma omp parallel for simd private(myind, g_ind), linear(ind), aligned(arr) if (parallel :num)
86 // CHECK-NEXT: #pragma omp parallel for simd private(myind,g_ind) linear(ind) aligned(arr) if(parallel: num)
87 for (i
= 0; i
< num
; ++i
) {
95 template<class T
> struct S
{
99 T
result(T
*v
) const {
106 #pragma omp parallel for simd private(val) safelen(7) linear(lin : -5) lastprivate(res) simdlen(5) if(7) allocate(lin)
107 // CHECK-NEXT: #pragma omp parallel for simd private(val) safelen(7) linear(lin: step(-5)) lastprivate(res) simdlen(5) if(7) allocate(lin)
108 for (T i
= 7; i
< m_a
; ++i
) {
114 // CHECK: T clen = 3;
115 #pragma omp parallel for simd safelen(clen-1) simdlen(clen-1) ordered
116 // CHECK-NEXT: #pragma omp parallel for simd safelen(clen - 1) simdlen(clen - 1) ordered
117 for(T i
= clen
+2; i
< 20; ++i
) {
118 // CHECK-NEXT: for (T i = clen + 2; i < 20; ++i) {
119 v
[i
] = v
[v
-clen
] + 1;
120 // CHECK-NEXT: v[i] = v[v - clen] + 1;
130 template<int LEN
> struct S2
{
131 static void func(int n
, float *a
, float *b
, float *c
) {
133 #pragma omp parallel for simd allocate(k1) safelen(LEN) linear(k1,k2:LEN) aligned(a:LEN) simdlen(LEN)
134 for(int i
= 0; i
< n
; i
++) {
136 c
[k1
] = a
[k1
] + b
[k1
];
137 c
[k2
] = a
[k2
] + b
[k2
];
144 // S2<4>::func is called below in main.
145 // CHECK: template<> struct S2<4> {
146 // CHECK-NEXT: static void func(int n, float *a, float *b, float *c) {
147 // CHECK-NEXT: int k1 = 0, k2 = 0;
148 // CHECK-NEXT: #pragma omp parallel for simd allocate(k1) safelen(4) linear(k1,k2: step(4)) aligned(a: 4) simdlen(4)
149 // CHECK-NEXT: for (int i = 0; i < n; i++) {
150 // CHECK-NEXT: c[i] = a[i] + b[i];
151 // CHECK-NEXT: c[k1] = a[k1] + b[k1];
152 // CHECK-NEXT: c[k2] = a[k2] + b[k2];
153 // CHECK-NEXT: k1 = k1 + 4;
154 // CHECK-NEXT: k2 = k2 + 4;
158 int main (int argc
, char **argv
) {
159 int b
= argc
, c
, d
, e
, f
, g
;
162 // CHECK: static int *a;
164 #pragma omp parallel for simd if(parallel :b) if(simd: b) nontemporal(argc, c) lastprivate(conditional:d,f) order(unconstrained:concurrent)
166 #pragma omp parallel for simd if(parallel :b) if(simd: b) nontemporal(argc, c) lastprivate(conditional:d,f) order(concurrent)
168 #pragma omp parallel for simd if(parallel :b) ordered
170 // OMP51-NEXT: #pragma omp parallel for simd if(parallel: b) if(simd: b) nontemporal(argc,c) lastprivate(conditional: d,f) order(unconstrained: concurrent)
171 // OMP50-NEXT: #pragma omp parallel for simd if(parallel: b) if(simd: b) nontemporal(argc,c) lastprivate(conditional: d,f) order(concurrent)
172 // OMP45-NEXT: #pragma omp parallel for simd if(parallel: b) ordered
173 for (int i
=0; i
< 2; ++i
)*a
=2;
174 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
175 // CHECK-NEXT: *a = 2;
177 #pragma omp parallel for simd private(argc, b),lastprivate(d,f) collapse(2) aligned(a : 4) ,firstprivate( g ) if(g)
178 for (int i
= 0; i
< 10; ++i
)
179 for (int j
= 0; j
< 10; ++j
) {foo(); k1
+= 8; k2
+= 8;}
180 // CHECK-NEXT: #pragma omp parallel
181 // CHECK-NEXT: #pragma omp parallel for simd private(argc,b) lastprivate(d,f) collapse(2) aligned(a: 4) firstprivate(g) if(g)
182 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
183 // CHECK-NEXT: for (int j = 0; j < 10; ++j) {
184 // CHECK-NEXT: foo();
185 // CHECK-NEXT: k1 += 8;
186 // CHECK-NEXT: k2 += 8;
188 for (int i
= 0; i
< 10; ++i
)foo();
189 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
190 // CHECK-NEXT: foo();
192 // CHECK-NEXT: const int CLEN = 4;
193 #pragma omp parallel for simd aligned(a:CLEN) linear(a:CLEN) safelen(CLEN) collapse( 1 ) simdlen(CLEN)
194 // CHECK-NEXT: #pragma omp parallel for simd aligned(a: CLEN) linear(a: step(CLEN)) safelen(CLEN) collapse(1) simdlen(CLEN)
195 for (int i
= 0; i
< 10; ++i
)foo();
196 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
197 // CHECK-NEXT: foo();
200 S2
<4>::func(0,arr
,arr
,arr
);