1 | // RUN: %clang_cc1 -verify -fopenmp -ast-print %s -Wno-openmp-target | 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 -Wno-openmp-target | FileCheck %s |
4 | |
5 | // RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s -Wno-openmp-target | FileCheck %s |
6 | // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s |
7 | // RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -Wno-openmp-target | FileCheck %s |
8 | // expected-no-diagnostics |
9 | |
10 | #ifndef HEADER |
11 | #define HEADER |
12 | |
13 | struct S { |
14 | S(): a(0) {} |
15 | S(int v) : a(v) {} |
16 | int a; |
17 | typedef int type; |
18 | }; |
19 | |
20 | template <typename T> |
21 | class S7 : public T { |
22 | protected: |
23 | T a; |
24 | S7() : a(0) {} |
25 | |
26 | public: |
27 | S7(typename T::type v) : a(v) { |
28 | #pragma omp target |
29 | #pragma omp teams |
30 | #pragma omp distribute simd private(a) private(this->a) private(T::a) allocate(T::a) |
31 | for (int k = 0; k < a.a; ++k) |
32 | ++this->a.a; |
33 | } |
34 | S7 &operator=(S7 &s) { |
35 | #pragma omp target |
36 | #pragma omp teams |
37 | #pragma omp distribute simd allocate(a) private(a) private(this->a) |
38 | for (int k = 0; k < s.a.a; ++k) |
39 | ++s.a.a; |
40 | return *this; |
41 | } |
42 | }; |
43 | |
44 | // CHECK: #pragma omp distribute simd private(this->a) private(this->a) private(T::a) allocate(T::a){{$}} |
45 | // CHECK: #pragma omp distribute simd allocate(this->a) private(this->a) private(this->a) |
46 | // CHECK: #pragma omp distribute simd private(this->a) private(this->a) private(this->S::a) allocate(this->S::a) |
47 | |
48 | class S8 : public S7<S> { |
49 | S8() {} |
50 | |
51 | public: |
52 | S8(int v) : S7<S>(v){ |
53 | #pragma omp target |
54 | #pragma omp teams |
55 | #pragma omp distribute simd private(a) private(this->a) private(S7<S>::a) |
56 | for (int k = 0; k < a.a; ++k) |
57 | ++this->a.a; |
58 | } |
59 | S8 &operator=(S8 &s) { |
60 | #pragma omp target |
61 | #pragma omp teams |
62 | #pragma omp distribute simd private(a) private(this->a) |
63 | for (int k = 0; k < s.a.a; ++k) |
64 | ++s.a.a; |
65 | return *this; |
66 | } |
67 | }; |
68 | |
69 | // CHECK: #pragma omp distribute simd private(this->a) private(this->a) private(this->S7<S>::a) |
70 | // CHECK: #pragma omp distribute simd private(this->a) private(this->a) |
71 | |
72 | template <class T, int N> |
73 | T tmain(T argc) { |
74 | T b = argc, c, d, e, f, h; |
75 | static T a; |
76 | // CHECK: static T a; |
77 | static T g; |
78 | #pragma omp threadprivate(g) |
79 | |
80 | #pragma omp target |
81 | #pragma omp teams |
82 | #pragma omp distribute simd dist_schedule(static, a) firstprivate(a) |
83 | for (int i = 0; i < 2; ++i) |
84 | a = 2; |
85 | // CHECK: #pragma omp distribute simd dist_schedule(static, a) firstprivate(a) |
86 | // CHECK-NEXT: for (int i = 0; i < 2; ++i) |
87 | // CHECK-NEXT: a = 2; |
88 | |
89 | #pragma omp target |
90 | #pragma omp teams |
91 | #pragma omp distribute simd private(argc, b), firstprivate(c, d), lastprivate(f) collapse(N) reduction(+ : h) dist_schedule(static,N) |
92 | for (int i = 0; i < 2; ++i) |
93 | for (int j = 0; j < 2; ++j) |
94 | for (int k = 0; k < 10; ++k) |
95 | for (int m = 0; m < 10; ++m) |
96 | for (int n = 0; n < 10; ++n) |
97 | a++; |
98 | // CHECK: #pragma omp distribute simd private(argc,b) firstprivate(c,d) lastprivate(f) collapse(N) reduction(+: h) dist_schedule(static, N) |
99 | // CHECK-NEXT: for (int i = 0; i < 2; ++i) |
100 | // CHECK-NEXT: for (int j = 0; j < 2; ++j) |
101 | // CHECK-NEXT: for (int k = 0; k < 10; ++k) |
102 | // CHECK-NEXT: for (int m = 0; m < 10; ++m) |
103 | // CHECK-NEXT: for (int n = 0; n < 10; ++n) |
104 | // CHECK-NEXT: a++; |
105 | return T(); |
106 | } |
107 | |
108 | int main(int argc, char **argv) { |
109 | int b = argc, c, d, e, f, h; |
110 | int x[200]; |
111 | static int a; |
112 | // CHECK: static int a; |
113 | static float g; |
114 | #pragma omp threadprivate(g) |
115 | |
116 | #pragma omp target |
117 | #pragma omp teams |
118 | #pragma omp distribute simd dist_schedule(static, a) private(a) |
119 | for (int i = 0; i < 2; ++i) |
120 | a = 2; |
121 | // CHECK: #pragma omp distribute simd dist_schedule(static, a) private(a) |
122 | // CHECK-NEXT: for (int i = 0; i < 2; ++i) |
123 | // CHECK-NEXT: a = 2; |
124 | |
125 | #pragma omp target |
126 | #pragma omp teams |
127 | #pragma omp distribute simd private(argc, b), firstprivate(argv, c), lastprivate(d, f) collapse(2) reduction(+ : h) dist_schedule(static, b) |
128 | for (int i = 0; i < 10; ++i) |
129 | for (int j = 0; j < 10; ++j) |
130 | a++; |
131 | // CHECK: #pragma omp distribute simd private(argc,b) firstprivate(argv,c) lastprivate(d,f) collapse(2) reduction(+: h) dist_schedule(static, b) |
132 | // CHECK-NEXT: for (int i = 0; i < 10; ++i) |
133 | // CHECK-NEXT: for (int j = 0; j < 10; ++j) |
134 | // CHECK-NEXT: a++; |
135 | |
136 | int i; |
137 | #pragma omp target |
138 | #pragma omp teams |
139 | #pragma omp distribute simd aligned(x:8) linear(i:2) safelen(8) simdlen(8) |
140 | for (i = 0; i < 100; i++) |
141 | for (int j = 0; j < 200; j++) |
142 | a += h + x[j]; |
143 | // CHECK: #pragma omp distribute simd aligned(x: 8) linear(i: 2) safelen(8) simdlen(8) |
144 | // CHECK-NEXT: for (i = 0; i < 100; i++) |
145 | // CHECK-NEXT: for (int j = 0; j < 200; j++) |
146 | // CHECK-NEXT: a += h + x[j]; |
147 | |
148 | return (tmain<int, 5>(argc) + tmain<char, 1>(argv[0][0])); |
149 | } |
150 | |
151 | #endif |
152 | |