Skip to content

Commit 94c5198

Browse files
Pavel Samolysovbb-sycl
authored andcommitted
[SYCL] Extend the SpecConstants/vector-convolution-demo.cpp test (intel#830)
The test is extended with a specialization constant built upon an aligned structure. The CFE generates a padding represented as '[size x i8] undef' for such structures and the sycl-post-link tool crashed during property set generation for the specialization constant. The bug has been fixed in intel/llvm#5538, this extension is the E2E test for the fix to ensure that the default values and offsets given to the runtime are correct. Signed-off-by: Pavel Samolysov <[email protected]>
1 parent 52cee6c commit 94c5198

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

SYCL/SpecConstants/2020/vector-convolution-demo.cpp

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ struct coeff_struct_t {
2525
};
2626

2727
<<<<<<< HEAD
28+
<<<<<<< HEAD
29+
=======
30+
>>>>>>> a621ef9b0 ([SYCL] Extend the SpecConstants/vector-convolution-demo.cpp test (#830))
2831
struct alignas(64) coeff_struct_aligned_t {
2932
std::array<std::array<float, 3>, 3> c;
3033
};
@@ -33,6 +36,7 @@ struct alignas(64) coeff_struct_aligned2_t {
3336
std::array<std::array<float, 3>, 3> c;
3437
int number;
3538
};
39+
<<<<<<< HEAD
3640

3741
template <typename T> constexpr T get_coefficients() {
3842
return {{{{1.0, 2.0, 3.0}, {1.1, 2.1, 3.1}, {1.2, 2.2, 3.2}}}};
@@ -44,17 +48,26 @@ template <> constexpr coeff_t get_coefficients<coeff_t>() {
4448
coeff_t get_coefficients() {
4549
return {{{1.0, 2.0, 3.0}, {1.1, 2.1, 3.1}, {1.2, 2.2, 3.2}}};
4650
}
51+
=======
52+
>>>>>>> a621ef9b0 ([SYCL] Extend the SpecConstants/vector-convolution-demo.cpp test (#830))
4753

48-
coeff_struct_t get_coefficient_struct() {
54+
template <typename T> constexpr T get_coefficients() {
4955
return {{{{1.0, 2.0, 3.0}, {1.1, 2.1, 3.1}, {1.2, 2.2, 3.2}}}};
5056
>>>>>>> 6c7a8e6f7 ([SYCL] Add a vector convolution demo of using specialization constants (#747))
5157
}
5258

59+
template <> constexpr coeff_t get_coefficients<coeff_t>() {
60+
return {{{1.0, 2.0, 3.0}, {1.1, 2.1, 3.1}, {1.2, 2.2, 3.2}}};
61+
}
62+
5363
constexpr specialization_id<coeff_t> coeff_id;
5464

5565
constexpr specialization_id<coeff_struct_t> coeff_struct_id;
5666

5767
<<<<<<< HEAD
68+
<<<<<<< HEAD
69+
=======
70+
>>>>>>> a621ef9b0 ([SYCL] Extend the SpecConstants/vector-convolution-demo.cpp test (#830))
5871
// Represented in the IR as
5972
// clang-format off
6073
// { %struct.coeff_struct_aligned_t { %"class.std::array.0" zeroinitializer, [28 x i8] undef } }
@@ -72,8 +85,11 @@ constexpr specialization_id<coeff_struct_aligned_t> coeff_struct_aligned_id;
7285
// clang-format on
7386
constexpr specialization_id<coeff_struct_aligned2_t> coeff_struct_aligned_id2;
7487

88+
<<<<<<< HEAD
7589
=======
7690
>>>>>>> 6c7a8e6f7 ([SYCL] Add a vector convolution demo of using specialization constants (#747))
91+
=======
92+
>>>>>>> a621ef9b0 ([SYCL] Extend the SpecConstants/vector-convolution-demo.cpp test (#830))
7793
template <typename IN>
7894
float calc_conv(const coeff_t &coeff, const IN &in, item<2> item_id) {
7995
float acc = 0;
@@ -103,17 +119,23 @@ void do_conv(buffer<float, 2> in, buffer<float, 2> out, CP coeff_provider) {
103119
// Set the coefficient of the convolution as constant.
104120
// This will build a specific kernel the coefficient available as literals.
105121
<<<<<<< HEAD
122+
<<<<<<< HEAD
123+
=======
124+
>>>>>>> a621ef9b0 ([SYCL] Extend the SpecConstants/vector-convolution-demo.cpp test (#830))
106125
cgh.set_specialization_constant<coeff_id>(get_coefficients<coeff_t>());
107126
cgh.set_specialization_constant<coeff_struct_id>(
108127
get_coefficients<coeff_struct_t>());
109128
cgh.set_specialization_constant<coeff_struct_aligned_id>(
110129
get_coefficients<coeff_struct_aligned_t>());
111130
cgh.set_specialization_constant<coeff_struct_aligned_id2>(
112131
get_coefficients<coeff_struct_aligned2_t>());
132+
<<<<<<< HEAD
113133
=======
114134
cgh.set_specialization_constant<coeff_id>(get_coefficients());
115135
cgh.set_specialization_constant<coeff_struct_id>(get_coefficient_struct());
116136
>>>>>>> 6c7a8e6f7 ([SYCL] Add a vector convolution demo of using specialization constants (#747))
137+
=======
138+
>>>>>>> a621ef9b0 ([SYCL] Extend the SpecConstants/vector-convolution-demo.cpp test (#830))
117139
cgh.parallel_for<KernelName>(
118140
in.get_range(), [=](item<2> item_id, kernel_handler h) {
119141
auto coeff = coeff_provider(h);
@@ -175,6 +197,9 @@ int main() {
175197
compare_result(host_accessor{output, read_only}, expected);
176198

177199
<<<<<<< HEAD
200+
<<<<<<< HEAD
201+
=======
202+
>>>>>>> a621ef9b0 ([SYCL] Extend the SpecConstants/vector-convolution-demo.cpp test (#830))
178203
do_conv<class Convolution3>(input, output, [](kernel_handler &h) {
179204
return h.get_specialization_constant<coeff_struct_aligned_id>().c;
180205
});
@@ -187,8 +212,11 @@ int main() {
187212

188213
compare_result(host_accessor{output, read_only}, expected);
189214

215+
<<<<<<< HEAD
190216
=======
191217
>>>>>>> 6c7a8e6f7 ([SYCL] Add a vector convolution demo of using specialization constants (#747))
218+
=======
219+
>>>>>>> a621ef9b0 ([SYCL] Extend the SpecConstants/vector-convolution-demo.cpp test (#830))
192220
std::cout << "Good computation!" << std::endl;
193221
return 0;
194222
}

0 commit comments

Comments
 (0)