1 // RUN: %clang_cc1 -verify -fopenmp -ast-print %s | 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 | FileCheck %s
4 // expected-no-diagnostics
23 S7(typename T::type v) : a(v) {
24 #pragma omp for simd private(a) private(this->a) private(T::a)
25 for (int k = 0; k < a.a; ++k)
28 S7 &operator=(S7 &s) {
29 #pragma omp for simd private(a) private(this->a)
30 for (int k = 0; k < s.a.a; ++k)
36 // CHECK: #pragma omp for simd private(this->a) private(this->a) private(this->S1::a)
37 // CHECK: #pragma omp for simd private(this->a) private(this->a) private(T::a)
38 // CHECK: #pragma omp for simd private(this->a) private(this->a)
40 class S8 : public S7<S1> {
44 S8(int v) : S7<S1>(v){
45 #pragma omp for simd private(a) private(this->a) private(S7<S1>::a)
46 for (int k = 0; k < a.a; ++k)
49 S8 &operator=(S8 &s) {
50 #pragma omp for simd private(a) private(this->a)
51 for (int k = 0; k < s.a.a; ++k)
57 // CHECK: #pragma omp for simd private(this->a) private(this->a) private(this->S7<S1>::a)
58 // CHECK: #pragma omp for simd private(this->a) private(this->a)
62 template<class T, class N> T reduct(T* arr, N num) {
67 // CHECK: T sum = (T)0;
68 #pragma omp for simd private(myind, g_ind), linear(ind), aligned(arr) ordered
69 // CHECK-NEXT: #pragma omp for simd private(myind,g_ind) linear(ind) aligned(arr) ordered
70 for (i = 0; i < num; ++i) {
78 template<class T> struct S {
82 T result(T *v) const {
89 #pragma omp for simd private(val) safelen(7) linear(lin : -5) lastprivate(res) simdlen(5)
90 // CHECK-NEXT: #pragma omp for simd private(val) safelen(7) linear(lin: -5) lastprivate(res) simdlen(5)
91 for (T i = 7; i < m_a; ++i) {
98 #pragma omp for simd safelen(clen-1) simdlen(clen-1)
99 // CHECK-NEXT: #pragma omp for simd safelen(clen - 1) simdlen(clen - 1)
100 for(T i = clen+2; i < 20; ++i) {
101 // CHECK-NEXT: for (T i = clen + 2; i < 20; ++i) {
102 v[i] = v[v-clen] + 1;
103 // CHECK-NEXT: v[i] = v[v - clen] + 1;
113 template<int LEN> struct S2 {
114 static void func(int n, float *a, float *b, float *c) {
116 #pragma omp for simd safelen(LEN) linear(k1,k2:LEN) aligned(a:LEN) simdlen(LEN)
117 for(int i = 0; i < n; i++) {
119 c[k1] = a[k1] + b[k1];
120 c[k2] = a[k2] + b[k2];
127 // S2<4>::func is called below in main.
128 // CHECK: template <int LEN = 4> struct S2 {
129 // CHECK-NEXT: static void func(int n, float *a, float *b, float *c) {
130 // CHECK-NEXT: int k1 = 0, k2 = 0;
131 // CHECK-NEXT: #pragma omp for simd safelen(4) linear(k1,k2: 4) aligned(a: 4) simdlen(4)
132 // CHECK-NEXT: for (int i = 0; i < n; i++) {
133 // CHECK-NEXT: c[i] = a[i] + b[i];
134 // CHECK-NEXT: c[k1] = a[k1] + b[k1];
135 // CHECK-NEXT: c[k2] = a[k2] + b[k2];
136 // CHECK-NEXT: k1 = k1 + 4;
137 // CHECK-NEXT: k2 = k2 + 4;
141 int main (int argc, char **argv) {
142 int b = argc, c, d, e, f, g;
145 // CHECK: static int *a;
146 #pragma omp for simd ordered
147 // CHECK-NEXT: #pragma omp for simd ordered
148 for (int i=0; i < 2; ++i)*a=2;
149 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
150 // CHECK-NEXT: *a = 2;
152 #pragma omp for simd private(argc, b),lastprivate(d,f) collapse(2) aligned(a : 4) ,firstprivate( g )
153 for (int i = 0; i < 10; ++i)
154 for (int j = 0; j < 10; ++j) {foo(); k1 += 8; k2 += 8;}
155 // CHECK-NEXT: #pragma omp parallel
156 // CHECK-NEXT: #pragma omp for simd private(argc,b) lastprivate(d,f) collapse(2) aligned(a: 4) firstprivate(g)
157 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
158 // CHECK-NEXT: for (int j = 0; j < 10; ++j) {
159 // CHECK-NEXT: foo();
160 // CHECK-NEXT: k1 += 8;
161 // CHECK-NEXT: k2 += 8;
163 for (int i = 0; i < 10; ++i)foo();
164 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
165 // CHECK-NEXT: foo();
167 // CHECK-NEXT: const int CLEN = 4;
168 #pragma omp for simd aligned(a:CLEN) linear(a:CLEN) safelen(CLEN) collapse( 1 ) simdlen(CLEN)
169 // CHECK-NEXT: #pragma omp for simd aligned(a: CLEN) linear(a: CLEN) safelen(CLEN) collapse(1) simdlen(CLEN)
170 for (int i = 0; i < 10; ++i)foo();
171 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
172 // CHECK-NEXT: foo();
175 S2<4>::func(0,arr,arr,arr);