1 | // expected-no-diagnostics |
2 | #ifndef HEADER |
3 | #define HEADER |
4 | |
5 | // Test host codegen. |
6 | // RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64 |
7 | // RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s |
8 | // RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64 |
9 | // RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-32 |
10 | // RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s |
11 | // RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-32 |
12 | |
13 | // RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s |
14 | // RUN: %clang_cc1 -DCK1 -fopenmp-simd -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s |
15 | // RUN: %clang_cc1 -DCK1 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s |
16 | // RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s |
17 | // RUN: %clang_cc1 -DCK1 -fopenmp-simd -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s |
18 | // RUN: %clang_cc1 -DCK1 -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s |
19 | // SIMD-ONLY0-NOT: {{__kmpc|__tgt}} |
20 | #ifdef CK1 |
21 | |
22 | template <typename T, int X, long long Y> |
23 | struct SS{ |
24 | T a[X]; |
25 | float b; |
26 | // CK1: define {{.*}}i32 @{{.+}}foo{{.+}}( |
27 | int foo(void) { |
28 | |
29 | // CK1: call i32 @__tgt_target_teams( |
30 | // CK1: call void @[[OFFL1:.+]]( |
31 | #pragma omp target |
32 | #pragma omp teams distribute |
33 | for(int i = 0; i < X; i++) { |
34 | a[i] = (T)0; |
35 | } |
36 | // CK1: call i32 @__tgt_target_teams( |
37 | // CK1: call void @[[OFFL2:.+]]( |
38 | #pragma omp target |
39 | #pragma omp teams distribute dist_schedule(static) |
40 | for(int i = 0; i < X; i++) { |
41 | a[i] = (T)0; |
42 | } |
43 | // CK1: call i32 @__tgt_target_teams( |
44 | // CK1: call void @[[OFFL3:.+]]( |
45 | #pragma omp target |
46 | #pragma omp teams distribute dist_schedule(static, X/2) |
47 | for(int i = 0; i < X; i++) { |
48 | a[i] = (T)0; |
49 | } |
50 | // CK1: define internal void @[[OFFL1]]( |
51 | // CK1: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}} @[[OUTL1:.+]] to {{.+}}, |
52 | // CK1: ret void |
53 | |
54 | // CK1: define internal void @[[OUTL1]]({{.+}}) |
55 | // CK1: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 92 |
56 | // CK1: call void @__kmpc_for_static_fini( |
57 | // CK1: ret void |
58 | |
59 | // CK1: define internal void @[[OFFL2]]( |
60 | // CK1: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}} @[[OUTL2:.+]] to {{.+}}, |
61 | // CK1: ret void |
62 | |
63 | // CK1: define internal void @[[OUTL2]]({{.+}}) |
64 | // CK1: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 92 |
65 | // CK1: call void @__kmpc_for_static_fini( |
66 | // CK1: ret void |
67 | |
68 | // CK1: define internal void @[[OFFL3]]( |
69 | // CK1: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}} @[[OUTL3:.+]] to {{.+}}, |
70 | // CK1: ret void |
71 | |
72 | // CK1: define internal void @[[OUTL3]]({{.+}}) |
73 | // CK1: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 91 |
74 | // CK1: call void @__kmpc_for_static_fini( |
75 | // CK1: ret void |
76 | |
77 | return a[0]; |
78 | } |
79 | }; |
80 | |
81 | int teams_template_struct(void) { |
82 | SS<int, 123, 456> V; |
83 | return V.foo(); |
84 | |
85 | } |
86 | #endif // CK1 |
87 | |
88 | // Test host codegen. |
89 | // RUN: %clang_cc1 -DCK2 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CK2 --check-prefix CK2-64 |
90 | // RUN: %clang_cc1 -DCK2 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s |
91 | // RUN: %clang_cc1 -DCK2 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK2 --check-prefix CK2-64 |
92 | // RUN: %clang_cc1 -DCK2 -verify -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CK2 --check-prefix CK2-32 |
93 | // RUN: %clang_cc1 -DCK2 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s |
94 | // RUN: %clang_cc1 -DCK2 -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK2 --check-prefix CK2-32 |
95 | |
96 | // RUN: %clang_cc1 -DCK2 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s |
97 | // RUN: %clang_cc1 -DCK2 -fopenmp-simd -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s |
98 | // RUN: %clang_cc1 -DCK2 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s |
99 | // RUN: %clang_cc1 -DCK2 -verify -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s |
100 | // RUN: %clang_cc1 -DCK2 -fopenmp-simd -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s |
101 | // RUN: %clang_cc1 -DCK2 -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s |
102 | // SIMD-ONLY1-NOT: {{__kmpc|__tgt}} |
103 | #ifdef CK2 |
104 | |
105 | template <typename T, int n> |
106 | int tmain(T argc) { |
107 | T a[n]; |
108 | #pragma omp target |
109 | #pragma omp teams distribute |
110 | for(int i = 0; i < n; i++) { |
111 | a[i] = (T)0; |
112 | } |
113 | #pragma omp target |
114 | #pragma omp teams distribute dist_schedule(static) |
115 | for(int i = 0; i < n; i++) { |
116 | a[i] = (T)0; |
117 | } |
118 | #pragma omp target |
119 | #pragma omp teams distribute dist_schedule(static, n) |
120 | for(int i = 0; i < n; i++) { |
121 | a[i] = (T)0; |
122 | } |
123 | return 0; |
124 | } |
125 | |
126 | int main (int argc, char **argv) { |
127 | int n = 100; |
128 | int a[n]; |
129 | #pragma omp target |
130 | #pragma omp teams distribute |
131 | for(int i = 0; i < n; i++) { |
132 | a[i] = 0; |
133 | } |
134 | #pragma omp target |
135 | #pragma omp teams distribute dist_schedule(static) |
136 | for(int i = 0; i < n; i++) { |
137 | a[i] = 0; |
138 | } |
139 | #pragma omp target |
140 | #pragma omp teams distribute dist_schedule(static, n) |
141 | for(int i = 0; i < n; i++) { |
142 | a[i] = 0; |
143 | } |
144 | return tmain<int, 10>(argc); |
145 | } |
146 | |
147 | // CK2: define {{.*}}i32 @{{[^,]+}}(i{{.+}}{{.+}} %[[ARGC:.+]], {{.+}}) |
148 | // CK2: call i32 @__tgt_target_teams( |
149 | // CK2: call void @[[OFFL1:.+]]({{.+}}) |
150 | // CK2: call i32 @__tgt_target_teams( |
151 | // CK2: call void @[[OFFL2:.+]]({{.+}}) |
152 | // CK2: call i32 @__tgt_target_teams( |
153 | // CK2: call void @[[OFFL3:.+]]({{.+}}) |
154 | // CK2: {{%.+}} = call{{.*}} i32 @[[TMAIN:.+]]({{.+}}) |
155 | // CK2: ret |
156 | |
157 | // CK2: define {{.*}}void @[[OFFL1]]({{.+}}) |
158 | // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 3, {{.+}} @[[OUTL1:.+]] to {{.+}}, |
159 | // CK2: ret void |
160 | |
161 | // CK2: define internal void @[[OUTL1]]({{.+}}) |
162 | // CK2: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 92 |
163 | // CK2: call void @__kmpc_for_static_fini( |
164 | // CK2: ret void |
165 | |
166 | // CK2: define {{.*}}void @[[OFFL2]]({{.+}}) |
167 | // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 3, {{.+}} @[[OUTL2:.+]] to {{.+}}, |
168 | // CK2: ret void |
169 | |
170 | // CK2: define internal void @[[OUTL2]]({{.+}}) |
171 | // CK2: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 92 |
172 | // CK2: call void @__kmpc_for_static_fini( |
173 | // CK2: ret void |
174 | |
175 | // CK2: define {{.*}}void @[[OFFL3]]({{.+}}) |
176 | // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 4, {{.+}} @[[OUTL3:.+]] to {{.+}}, |
177 | // CK2: ret void |
178 | |
179 | // CK2: define internal void @[[OUTL3]]({{.+}}) |
180 | // CK2: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 91 |
181 | // CK2: call void @__kmpc_for_static_fini( |
182 | // CK2: ret void |
183 | |
184 | // CK2: define {{.*}}i32 @[[TMAIN]]({{.+}}) |
185 | // CK2: call i32 @__tgt_target_teams( |
186 | // CK2: call void @[[OFFLT1:.+]]({{.+}}) |
187 | // CK2: call i32 @__tgt_target_teams( |
188 | // CK2: call void @[[OFFLT2:.+]]({{.+}}) |
189 | // CK2: call i32 @__tgt_target_teams( |
190 | // CK2: call void @[[OFFLT3:.+]]({{.+}}) |
191 | // CK2: ret |
192 | // CK2-NEXT: } |
193 | |
194 | // CK2: define {{.*}}void @[[OFFLT1]]({{.+}}) |
195 | // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}} @[[OUTLT1:.+]] to {{.+}}, |
196 | // CK2: ret void |
197 | |
198 | // CK2: define internal void @[[OUTLT1]]({{.+}}) |
199 | // CK2: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 92 |
200 | // CK2: call void @__kmpc_for_static_fini( |
201 | // CK2: ret void |
202 | |
203 | // CK2: define {{.*}}void @[[OFFLT2]]({{.+}}) |
204 | // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}} @[[OUTLT2:.+]] to {{.+}}, |
205 | // CK2: ret void |
206 | |
207 | // CK2: define internal void @[[OUTLT2]]({{.+}}) |
208 | // CK2: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 92 |
209 | // CK2: call void @__kmpc_for_static_fini( |
210 | // CK2: ret void |
211 | |
212 | // CK2: define {{.*}}void @[[OFFLT3]]({{.+}}) |
213 | // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}} @[[OUTLT3:.+]] to {{.+}}, |
214 | // CK2: ret void |
215 | |
216 | // CK2: define internal void @[[OUTLT3]]({{.+}}) |
217 | // CK2: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 91 |
218 | // CK2: call void @__kmpc_for_static_fini( |
219 | // CK2: ret void |
220 | |
221 | #endif // CK2 |
222 | #endif // #ifndef HEADER |
223 | |