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