Debian Codegraph @

clang/test/OpenMP/distribute_parallel_for_simd_ast_print.cpp

raw
1 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -ast-print %s -Wno-openmp-mapping | 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 -Wno-openmp-mapping | FileCheck %s --check-prefix CHECK --check-prefix OMP45
4 // RUN: %clang_cc1 -verify -fopenmp -ast-print %s -Wno-openmp-mapping -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 -Wno-openmp-mapping -DOMP5 | FileCheck %s --check-prefix CHECK --check-prefix OMP50
7 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -ast-print %s -Wno-openmp-mapping -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 -Wno-openmp-mapping -DOMP51 | FileCheck %s --check-prefix CHECK --check-prefix OMP51
10 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=60 -ast-print %s -Wno-openmp-mapping -DOMP51 | FileCheck %s --check-prefix CHECK --check-prefix OMP51
11 // RUN: %clang_cc1 -fopenmp -fopenmp-version=60 -x c++ -std=c++11 -emit-pch -o %t %s -DOMP51
12 // RUN: %clang_cc1 -fopenmp -fopenmp-version=60 -std=c++11 -include-pch %t -verify %s -ast-print -Wno-openmp-mapping -DOMP51 | FileCheck %s --check-prefix CHECK --check-prefix OMP51
13
14 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -ast-print %s -Wno-openmp-mapping | 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 -Wno-openmp-mapping | FileCheck %s --check-prefix CHECK --check-prefix OMP45
17 // RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s -Wno-openmp-mapping -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 -Wno-openmp-mapping -DOMP5 | FileCheck %s --check-prefix CHECK --check-prefix OMP50
20 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=51 -ast-print %s -Wno-openmp-mapping -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 -Wno-openmp-mapping -DOMP51 | FileCheck %s --check-prefix CHECK --check-prefix OMP51
23 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=60 -ast-print %s -Wno-openmp-mapping -DOMP51 | FileCheck %s --check-prefix CHECK --check-prefix OMP51
24 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=60 -x c++ -std=c++11 -emit-pch -o %t %s -DOMP51
25 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=60 -std=c++11 -include-pch %t -verify %s -ast-print -Wno-openmp-mapping -DOMP51 | FileCheck %s --check-prefix CHECK --check-prefix OMP51
26 // expected-no-diagnostics
27
28 #ifndef HEADER
29 #define HEADER
30
31 struct S {
32 S(): a(0) {}
33 S(int v) : a(v) {}
34 int a;
35 typedef int type;
36 };
37
38 template <typename T>
39 class S7 : public T {
40 protected:
41 T a;
42 S7() : a(0) {}
43
44 public:
45 S7(typename T::type v) : a(v) {
46 #pragma omp target
47 #pragma omp teams
48 #pragma omp distribute parallel for simd private(a) private(this->a) private(T::a)
49 for (int k = 0; k < a.a; ++k)
50 ++this->a.a;
51 }
52 S7 &operator=(S7 &s) {
53 int k;
54 #pragma omp target
55 #pragma omp teams
56 #pragma omp distribute parallel for simd private(a) private(this->a) linear(k)
57 for (k = 0; k < s.a.a; ++k)
58 ++s.a.a;
59 return *this;
60 }
61 };
62
63 // CHECK: #pragma omp distribute parallel for simd private(this->a) private(this->a) private(T::a){{$}}
64 // CHECK: #pragma omp distribute parallel for simd private(this->a) private(this->a) linear(k)
65 // CHECK: #pragma omp distribute parallel for simd private(this->a) private(this->a) private(this->S::a)
66
67 class S8 : public S7<S> {
68 S8() {}
69
70 public:
71 S8(int v) : S7<S>(v){
72 #pragma omp target
73 #pragma omp teams
74 #pragma omp distribute parallel for simd private(a) private(this->a) private(S7<S>::a)
75 for (int k = 0; k < a.a; ++k)
76 ++this->a.a;
77 }
78 S8 &operator=(S8 &s) {
79 #pragma omp target
80 #pragma omp teams
81 #pragma omp distribute parallel for simd private(a) private(this->a)
82 for (int k = 0; k < s.a.a; ++k)
83 ++s.a.a;
84 return *this;
85 }
86 };
87
88 // CHECK: #pragma omp distribute parallel for simd private(this->a) private(this->a) private(this->S7<S>::a)
89 // CHECK: #pragma omp distribute parallel for simd private(this->a) private(this->a)
90
91 template <class T, int N>
92 T tmain(T argc) {
93 T b = argc, c, d, e, f, h;
94 static T a;
95 // CHECK: static T a;
96 static T g;
97 #pragma omp threadprivate(g)
98 #pragma omp target
99 #pragma omp teams
100 #pragma omp distribute parallel for simd dist_schedule(static, a) schedule(dynamic) default(none) copyin(g) firstprivate(a) allocate(a)
101 // CHECK: #pragma omp distribute parallel for simd dist_schedule(static, a) schedule(dynamic) default(none) copyin(g) firstprivate(a) allocate(a)
102 for (int i = 0; i < 2; ++i)
103 a = 2;
104 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
105 // CHECK-NEXT: a = 2;
106 #pragma omp target
107 #pragma omp teams
108 #pragma omp distribute parallel for simd allocate(argc) private(argc, b), firstprivate(c, d), lastprivate(f) collapse(N) schedule(static, N) if (parallel :argc) num_threads(N) default(shared) shared(e) reduction(+ : h) dist_schedule(static,N)
109 for (int i = 0; i < 2; ++i)
110 for (int j = 0; j < 2; ++j)
111 for (int j = 0; j < 2; ++j)
112 for (int j = 0; j < 2; ++j)
113 for (int j = 0; j < 2; ++j)
114 for (int i = 0; i < 2; ++i)
115 for (int j = 0; j < 2; ++j)
116 for (int j = 0; j < 2; ++j)
117 for (int j = 0; j < 2; ++j)
118 for (int j = 0; j < 2; ++j)
119 a++;
120 // CHECK: #pragma omp distribute parallel for simd allocate(argc) private(argc,b) firstprivate(c,d) lastprivate(f) collapse(N) schedule(static, N) if(parallel: argc) num_threads(N) default(shared) shared(e) reduction(+: h) dist_schedule(static, N)
121 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
122 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
123 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
124 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
125 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
126 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
127 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
128 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
129 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
130 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
131 // CHECK-NEXT: a++;
132 return T();
133 }
134
135 int main(int argc, char **argv) {
136 int b = argc, c, d, e, f, h;
137 int x[200];
138 static int a;
139 // CHECK: static int a;
140 static float g;
141 #pragma omp threadprivate(g)
142 #pragma omp target
143 #pragma omp teams
144 #pragma omp distribute parallel for simd schedule(guided, argc) default(none) copyin(g) dist_schedule(static, a) private(a) shared(argc)
145 // CHECK: #pragma omp distribute parallel for simd schedule(guided, argc) default(none) copyin(g) dist_schedule(static, a) private(a) shared(argc)
146 for (int i = 0; i < 2; ++i)
147 a = 2;
148 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
149 // CHECK-NEXT: a = 2;
150 #pragma omp target
151 #pragma omp teams
152 #pragma omp distribute parallel for simd private(argc, b), firstprivate(argv, c), lastprivate(d, f) collapse(2) schedule(auto) if (argc) num_threads(a) default(shared) shared(e) reduction(+ : h) dist_schedule(static, b)
153 for (int i = 0; i < 10; ++i)
154 for (int j = 0; j < 10; ++j)
155 a++;
156 // CHECK: #pragma omp distribute parallel for simd private(argc,b) firstprivate(argv,c) lastprivate(d,f) collapse(2) schedule(auto) if(argc) num_threads(a) default(shared) shared(e) reduction(+: h) dist_schedule(static, b)
157 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
158 // CHECK-NEXT: for (int j = 0; j < 10; ++j)
159 // CHECK-NEXT: a++;
160
161 int i;
162 #pragma omp target
163 #pragma omp teams
164 #ifdef OMP51
165 #pragma omp distribute parallel for simd aligned(x:8) linear(i:2) safelen(8) simdlen(8) if(simd: argc) nontemporal(argc, c, d) order(unconstrained:concurrent)
166 #elif OMP5
167 #pragma omp distribute parallel for simd aligned(x:8) linear(i:2) safelen(8) simdlen(8) if(simd: argc) nontemporal(argc, c, d) order(concurrent)
168 #else
169 #pragma omp distribute parallel for simd aligned(x:8) linear(i:2) safelen(8) simdlen(8)
170 #endif // OMP51
171 for (i = 0; i < 100; i++)
172 for (int j = 0; j < 200; j++)
173 a += h + x[j];
174 // OMP45: #pragma omp distribute parallel for simd aligned(x: 8) linear(i: step(2)) safelen(8) simdlen(8)
175 // OMP50: #pragma omp distribute parallel for simd aligned(x: 8) linear(i: step(2)) safelen(8) simdlen(8) if(simd: argc) nontemporal(argc,c,d) order(concurrent)
176 // OMP51: #pragma omp distribute parallel for simd aligned(x: 8) linear(i: step(2)) safelen(8) simdlen(8) if(simd: argc) nontemporal(argc,c,d) order(unconstrained: concurrent)
177 // CHECK-NEXT: for (i = 0; i < 100; i++)
178 // CHECK-NEXT: for (int j = 0; j < 200; j++)
179 // CHECK-NEXT: a += h + x[j];
180
181 return (tmain<int, 5>(argc) + tmain<char, 1>(argv[0][0]));
182 }
183
184 #endif