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 -ast-print %s -DOMP5 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
5 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s -DOMP5
6 // RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -verify %s -ast-print -DOMP5 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
7 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -ast-print %s -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
8 // RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -x c++ -std=c++11 -emit-pch -o %t %s -DOMP51
9 // RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -std=c++11 -include-pch %t -verify %s -ast-print -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP52
10 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=52 -ast-print %s -DOMP52 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP52
11 // RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -x c++ -std=c++11 -emit-pch -o %t %s -DOMP52
12 // RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -std=c++11 -include-pch %t -verify %s -ast-print -DOMP52 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP52
14 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -ast-print %s | FileCheck %s --check-prefix=CHECK --check-prefix=OMP45
15 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -emit-pch -o %t %s
16 // 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
17 // RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s -DOMP5 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
18 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s -DOMP5
19 // RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -verify %s -ast-print -DOMP5 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
20 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=51 -ast-print %s -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
21 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=51 -x c++ -std=c++11 -emit-pch -o %t %s -DOMP51
22 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=51 -std=c++11 -include-pch %t -verify %s -ast-print -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
23 // expected-no-diagnostics
24 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=52 -ast-print %s -DOMP52 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP52
25 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=52 -x c++ -std=c++11 -emit-pch -o %t %s -DOMP52
26 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=52 -std=c++11 -include-pch %t -verify %s -ast-print -DOMP52 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP52
27 // expected-no-diagnostics
46 S7(typename
T::type v
) : a(v
) {
47 #pragma omp for simd private(a) private(this->a) private(T::a)
48 for (int k
= 0; k
< a
.a
; ++k
)
51 S7
&operator=(S7
&s
) {
52 #pragma omp for simd private(a) private(this->a)
53 for (int k
= 0; k
< s
.a
.a
; ++k
)
59 // CHECK: #pragma omp for simd private(this->a) private(this->a) private(T::a){{$}}
60 // CHECK: #pragma omp for simd private(this->a) private(this->a)
61 // CHECK: #pragma omp for simd private(this->a) private(this->a) private(this->S1::a)
63 class S8
: public S7
<S1
> {
67 S8(int v
) : S7
<S1
>(v
){
68 #pragma omp for simd private(a) private(this->a) private(S7<S1>::a)
69 for (int k
= 0; k
< a
.a
; ++k
)
72 S8
&operator=(S8
&s
) {
73 #pragma omp for simd private(a) private(this->a)
74 for (int k
= 0; k
< s
.a
.a
; ++k
)
80 // CHECK: #pragma omp for simd private(this->a) private(this->a) private(this->S7<S1>::a)
81 // CHECK: #pragma omp for simd private(this->a) private(this->a)
85 template<class T
, class N
> T
reduct(T
* arr
, N num
) {
90 // CHECK: T sum = (T)0;
91 #pragma omp for simd private(myind, g_ind), linear(ind), aligned(arr) ordered
92 // CHECK-NEXT: #pragma omp for simd private(myind,g_ind) linear(ind) aligned(arr) ordered
93 for (i
= 0; i
< num
; ++i
) {
101 template<class T
> struct S
{
105 T
result(T
*v
) const {
113 #pragma omp for simd private(val) safelen(7) linear(lin : step(-5)) lastprivate(res) simdlen(5) allocate(res) if(res) nontemporal(res, val, lin) order(reproducible:concurrent)
115 #pragma omp for simd private(val) safelen(7) linear(lin : -5) lastprivate(res) simdlen(5) allocate(res) if(res) nontemporal(res, val, lin) order(reproducible:concurrent)
117 #pragma omp for simd private(val) safelen(7) linear(lin : -5) lastprivate(res) simdlen(5) allocate(res) if(res) nontemporal(res, val, lin) order(concurrent)
119 #pragma omp for simd private(val) safelen(7) linear(lin : -5) lastprivate(res) simdlen(5) allocate(res)
121 // OMP52-NEXT: #pragma omp for simd private(val) safelen(7) linear(lin: step(-5)) lastprivate(res) simdlen(5) allocate(res) if(res) nontemporal(res,val,lin) order(reproducible: concurrent)
122 // OMP51-NEXT: #pragma omp for simd private(val) safelen(7) linear(lin: step(-5)) lastprivate(res) simdlen(5) allocate(res) if(res) nontemporal(res,val,lin) order(reproducible: concurrent)
123 // OMP50-NEXT: #pragma omp for simd private(val) safelen(7) linear(lin: step(-5)) lastprivate(res) simdlen(5) allocate(res) if(res) nontemporal(res,val,lin) order(concurrent)
124 // OMP45-NEXT: #pragma omp for simd private(val) safelen(7) linear(lin: step(-5)) lastprivate(res) simdlen(5) allocate(res)
125 for (T i
= 7; i
< m_a
; ++i
) {
131 // CHECK: T clen = 3;
132 #pragma omp for simd safelen(clen-1) simdlen(clen-1)
133 // CHECK-NEXT: #pragma omp for simd safelen(clen - 1) simdlen(clen - 1)
134 for(T i
= clen
+2; i
< 20; ++i
) {
135 // CHECK-NEXT: for (T i = clen + 2; i < 20; ++i) {
136 v
[i
] = v
[v
-clen
] + 1;
137 // CHECK-NEXT: v[i] = v[v - clen] + 1;
147 template<int LEN
> struct S2
{
148 static void func(int n
, float *a
, float *b
, float *c
) {
150 #pragma omp for simd allocate(k1) safelen(LEN) linear(k1,k2:LEN) aligned(a:LEN) simdlen(LEN)
151 for(int i
= 0; i
< n
; i
++) {
153 c
[k1
] = a
[k1
] + b
[k1
];
154 c
[k2
] = a
[k2
] + b
[k2
];
161 // S2<4>::func is called below in main.
162 // CHECK: template<> struct S2<4> {
163 // CHECK-NEXT: static void func(int n, float *a, float *b, float *c) {
164 // CHECK-NEXT: int k1 = 0, k2 = 0;
165 // CHECK-NEXT: #pragma omp for simd allocate(k1) safelen(4) linear(k1,k2: step(4)) aligned(a: 4) simdlen(4)
166 // CHECK-NEXT: for (int i = 0; i < n; i++) {
167 // CHECK-NEXT: c[i] = a[i] + b[i];
168 // CHECK-NEXT: c[k1] = a[k1] + b[k1];
169 // CHECK-NEXT: c[k2] = a[k2] + b[k2];
170 // CHECK-NEXT: k1 = k1 + 4;
171 // CHECK-NEXT: k2 = k2 + 4;
175 int main (int argc
, char **argv
) {
176 int b
= argc
, c
, d
, e
, f
, g
;
179 // CHECK: static int *a;
180 #pragma omp for simd ordered
181 // CHECK-NEXT: #pragma omp for simd ordered
182 for (int i
=0; i
< 2; ++i
)*a
=2;
183 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
184 // CHECK-NEXT: *a = 2;
186 #pragma omp for simd private(argc, b),lastprivate(d,f) collapse(2) aligned(a : 4) ,firstprivate( g )
187 for (int i
= 0; i
< 10; ++i
)
188 for (int j
= 0; j
< 10; ++j
) {foo(); k1
+= 8; k2
+= 8;}
189 // CHECK-NEXT: #pragma omp parallel
190 // CHECK-NEXT: #pragma omp for simd private(argc,b) lastprivate(d,f) collapse(2) aligned(a: 4) firstprivate(g)
191 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
192 // CHECK-NEXT: for (int j = 0; j < 10; ++j) {
193 // CHECK-NEXT: foo();
194 // CHECK-NEXT: k1 += 8;
195 // CHECK-NEXT: k2 += 8;
197 for (int i
= 0; i
< 10; ++i
)foo();
198 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
199 // CHECK-NEXT: foo();
201 // CHECK-NEXT: const int CLEN = 4;
203 #pragma omp for simd aligned(a:CLEN) linear(a:CLEN) safelen(CLEN) collapse( 1 ) simdlen(CLEN) if(simd:a)
205 #pragma omp for simd aligned(a:CLEN) linear(a:CLEN) safelen(CLEN) collapse( 1 ) simdlen(CLEN)
207 // OMP52-NEXT: #pragma omp for simd aligned(a: CLEN) linear(a: step(CLEN)) safelen(CLEN) collapse(1) simdlen(CLEN)
208 // OMP51-NEXT: #pragma omp for simd aligned(a: CLEN) linear(a: step(CLEN)) safelen(CLEN) collapse(1) simdlen(CLEN)
209 // OMP50-NEXT: #pragma omp for simd aligned(a: CLEN) linear(a: step(CLEN)) safelen(CLEN) collapse(1) simdlen(CLEN) if(simd: a)
210 // OMP45-NEXT: #pragma omp for simd aligned(a: CLEN) linear(a: step(CLEN)) safelen(CLEN) collapse(1) simdlen(CLEN)
211 for (int i
= 0; i
< 10; ++i
)foo();
212 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
213 // CHECK-NEXT: foo();
216 S2
<4>::func(0,arr
,arr
,arr
);