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 teams distribute simd |
32 | for(int i = 0; i < X; i++) { |
33 | a[i] = (T)0; |
34 | } |
35 | // CK1: call i32 @__tgt_target_teams( |
36 | // CK1: call void @[[OFFL2:.+]]( |
37 | #pragma omp target teams distribute simd dist_schedule(static) |
38 | for(int i = 0; i < X; i++) { |
39 | a[i] = (T)0; |
40 | } |
41 | // CK1: call i32 @__tgt_target_teams( |
42 | // CK1: call void @[[OFFL3:.+]]( |
43 | #pragma omp target teams distribute simd dist_schedule(static, X/2) |
44 | for(int i = 0; i < X; i++) { |
45 | a[i] = (T)0; |
46 | } |
47 | // CK1: define internal void @[[OFFL1]]( |
48 | // CK1: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}} @[[OUTL1:.+]] to {{.+}}, |
49 | // CK1: ret void |
50 | |
51 | // CK1: define internal void @[[OUTL1]]({{.+}}) |
52 | // CK1: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 92 |
53 | // CK1: call void @__kmpc_for_static_fini( |
54 | // CK1: ret void |
55 | |
56 | // CK1: define internal void @[[OFFL2]]( |
57 | // CK1: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}} @[[OUTL2:.+]] to {{.+}}, |
58 | // CK1: ret void |
59 | |
60 | // CK1: define internal void @[[OUTL2]]({{.+}}) |
61 | // CK1: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 92 |
62 | // CK1: call void @__kmpc_for_static_fini( |
63 | // CK1: ret void |
64 | |
65 | // CK1: define internal void @[[OFFL3]]( |
66 | // CK1: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}} @[[OUTL3:.+]] to {{.+}}, |
67 | // CK1: ret void |
68 | |
69 | // CK1: define internal void @[[OUTL3]]({{.+}}) |
70 | // CK1: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 91 |
71 | // CK1: call void @__kmpc_for_static_fini( |
72 | // CK1: ret void |
73 | |
74 | return a[0]; |
75 | } |
76 | }; |
77 | |
78 | int teams_template_struct(void) { |
79 | SS<int, 123, 456> V; |
80 | return V.foo(); |
81 | |
82 | } |
83 | #endif // CK1 |
84 | |
85 | // Test host codegen. |
86 | // 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 |
87 | // 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 |
88 | // 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 |
89 | // 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 |
90 | // 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 |
91 | // 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 |
92 | |
93 | // 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 |
94 | // 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 |
95 | // 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 |
96 | // 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 |
97 | // 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 |
98 | // 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 |
99 | // SIMD-ONLY1-NOT: {{__kmpc|__tgt}} |
100 | #ifdef CK2 |
101 | |
102 | template <typename T, int n> |
103 | int tmain(T argc) { |
104 | T a[n]; |
105 | #pragma omp target teams distribute simd |
106 | for(int i = 0; i < n; i++) { |
107 | a[i] = (T)0; |
108 | } |
109 | #pragma omp target teams distribute simd dist_schedule(static) |
110 | for(int i = 0; i < n; i++) { |
111 | a[i] = (T)0; |
112 | } |
113 | #pragma omp target teams distribute simd dist_schedule(static, n) |
114 | for(int i = 0; i < n; i++) { |
115 | a[i] = (T)0; |
116 | } |
117 | return 0; |
118 | } |
119 | |
120 | int main (int argc, char **argv) { |
121 | int n = 100; |
122 | int a[n]; |
123 | #pragma omp target teams distribute simd |
124 | for(int i = 0; i < n; i++) { |
125 | a[i] = 0; |
126 | } |
127 | #pragma omp target teams distribute simd dist_schedule(static) |
128 | for(int i = 0; i < n; i++) { |
129 | a[i] = 0; |
130 | } |
131 | #pragma omp target teams distribute simd dist_schedule(static, n) |
132 | for(int i = 0; i < n; i++) { |
133 | a[i] = 0; |
134 | } |
135 | return tmain<int, 10>(argc); |
136 | } |
137 | |
138 | // CK2: define {{.*}}i32 @{{[^,]+}}(i{{.+}}{{.+}} %[[ARGC:.+]], {{.+}}) |
139 | // CK2: call i32 @__tgt_target_teams( |
140 | // CK2: call void @[[OFFL1:.+]]({{.+}}) |
141 | // CK2: call i32 @__tgt_target_teams( |
142 | // CK2: call void @[[OFFL2:.+]]({{.+}}) |
143 | // CK2: call i32 @__tgt_target_teams( |
144 | // CK2: call void @[[OFFL3:.+]]({{.+}}) |
145 | // CK2: {{%.+}} = call{{.*}} i32 @[[TMAIN:.+]]({{.+}}) |
146 | // CK2: ret |
147 | |
148 | // CK2: define {{.*}}void @[[OFFL1]]({{.+}}) |
149 | // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 3, {{.+}} @[[OUTL1:.+]] to {{.+}}, |
150 | // CK2: ret void |
151 | |
152 | // CK2: define internal void @[[OUTL1]]({{.+}}) |
153 | // CK2: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 92 |
154 | // CK2: call void @__kmpc_for_static_fini( |
155 | // CK2: ret void |
156 | |
157 | // CK2: define {{.*}}void @[[OFFL2]]({{.+}}) |
158 | // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 3, {{.+}} @[[OUTL2:.+]] to {{.+}}, |
159 | // CK2: ret void |
160 | |
161 | // CK2: define internal void @[[OUTL2]]({{.+}}) |
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 @[[OFFL3]]({{.+}}) |
167 | // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 4, {{.+}} @[[OUTL3:.+]] to {{.+}}, |
168 | // CK2: ret void |
169 | |
170 | // CK2: define internal void @[[OUTL3]]({{.+}}) |
171 | // CK2: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 91 |
172 | // CK2: call void @__kmpc_for_static_fini( |
173 | // CK2: ret void |
174 | |
175 | // CK2: define {{.*}}i32 @[[TMAIN]]({{.+}}) |
176 | // CK2: call i32 @__tgt_target_teams( |
177 | // CK2: call void @[[OFFLT1:.+]]({{.+}}) |
178 | // CK2: call i32 @__tgt_target_teams( |
179 | // CK2: call void @[[OFFLT2:.+]]({{.+}}) |
180 | // CK2: call i32 @__tgt_target_teams( |
181 | // CK2: call void @[[OFFLT3:.+]]({{.+}}) |
182 | // CK2: ret |
183 | // CK2-NEXT: } |
184 | |
185 | // CK2: define {{.*}}void @[[OFFLT1]]({{.+}}) |
186 | // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}} @[[OUTLT1:.+]] to {{.+}}, |
187 | // CK2: ret void |
188 | |
189 | // CK2: define internal void @[[OUTLT1]]({{.+}}) |
190 | // CK2: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 92 |
191 | // CK2: call void @__kmpc_for_static_fini( |
192 | // CK2: ret void |
193 | |
194 | // CK2: define {{.*}}void @[[OFFLT2]]({{.+}}) |
195 | // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}} @[[OUTLT2:.+]] to {{.+}}, |
196 | // CK2: ret void |
197 | |
198 | // CK2: define internal void @[[OUTLT2]]({{.+}}) |
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 @[[OFFLT3]]({{.+}}) |
204 | // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}} @[[OUTLT3:.+]] to {{.+}}, |
205 | // CK2: ret void |
206 | |
207 | // CK2: define internal void @[[OUTLT3]]({{.+}}) |
208 | // CK2: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 91 |
209 | // CK2: call void @__kmpc_for_static_fini( |
210 | // CK2: ret void |
211 | |
212 | #endif // CK2 |
213 | #endif // #ifndef HEADER |
214 | |