Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit de6fcf8

Browse files
authored
[SYCL ] Test for redefining int specialization const to zero (#541)
Signed-off-by: mdimakov <[email protected]>
1 parent 3ec7e22 commit de6fcf8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

SYCL/SpecConstants/2020/handler-api.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "common.hpp"
2323

2424
constexpr sycl::specialization_id<int> int_id;
25+
constexpr sycl::specialization_id<int> int_id2(2);
2526
constexpr sycl::specialization_id<double> double_id(3.14);
2627
constexpr sycl::specialization_id<custom_type> custom_type_id;
2728

@@ -69,16 +70,19 @@ int main() {
6970

7071
bool test_default_values(sycl::queue q) {
7172
sycl::buffer<int> int_buffer(1);
73+
sycl::buffer<int> int_buffer2(1);
7274
sycl::buffer<double> double_buffer(1);
7375
sycl::buffer<custom_type> custom_type_buffer(1);
7476

7577
q.submit([&](sycl::handler &cgh) {
7678
auto int_acc = int_buffer.get_access<sycl::access::mode::write>(cgh);
79+
auto int_acc2 = int_buffer2.get_access<sycl::access::mode::write>(cgh);
7780
auto double_acc = double_buffer.get_access<sycl::access::mode::write>(cgh);
7881
auto custom_type_acc =
7982
custom_type_buffer.get_access<sycl::access::mode::write>(cgh);
8083
cgh.single_task<TestDefaultValuesKernel>([=](sycl::kernel_handler kh) {
8184
int_acc[0] = kh.get_specialization_constant<int_id>();
85+
int_acc2[0] = kh.get_specialization_constant<int_id2>();
8286
double_acc[0] = kh.get_specialization_constant<double_id>();
8387
custom_type_acc[0] = kh.get_specialization_constant<custom_type_id>();
8488
});
@@ -90,6 +94,10 @@ bool test_default_values(sycl::queue q) {
9094
"integer specialization constant (defined without default value)"))
9195
return false;
9296

97+
auto int_acc2 = int_buffer2.get_access<sycl::access::mode::read>();
98+
if (!check_value(2, int_acc2[0], "integer specialization constant"))
99+
return false;
100+
93101
auto double_acc = double_buffer.get_access<sycl::access::mode::read>();
94102
if (!check_value(3.14, double_acc[0], "double specialization constant"))
95103
return false;
@@ -153,25 +161,30 @@ bool test_set_and_get_on_host(sycl::queue q) {
153161

154162
bool test_set_and_get_on_device(sycl::queue q) {
155163
sycl::buffer<int> int_buffer(1);
164+
sycl::buffer<int> int_buffer2(1);
156165
sycl::buffer<double> double_buffer(1);
157166
sycl::buffer<custom_type> custom_type_buffer(1);
158167

159168
int new_int_value = 8;
169+
int new_int_value2 = 0;
160170
double new_double_value = 3.0;
161171
custom_type new_custom_type_value('b', 1.0, 12);
162172

163173
q.submit([&](sycl::handler &cgh) {
164174
auto int_acc = int_buffer.get_access<sycl::access::mode::write>(cgh);
175+
auto int_acc2 = int_buffer2.get_access<sycl::access::mode::write>(cgh);
165176
auto double_acc = double_buffer.get_access<sycl::access::mode::write>(cgh);
166177
auto custom_type_acc =
167178
custom_type_buffer.get_access<sycl::access::mode::write>(cgh);
168179

169180
cgh.set_specialization_constant<int_id>(new_int_value);
181+
cgh.set_specialization_constant<int_id2>(new_int_value2);
170182
cgh.set_specialization_constant<double_id>(new_double_value);
171183
cgh.set_specialization_constant<custom_type_id>(new_custom_type_value);
172184

173185
cgh.single_task<TestSetAndGetOnDevice>([=](sycl::kernel_handler kh) {
174186
int_acc[0] = kh.get_specialization_constant<int_id>();
187+
int_acc2[0] = kh.get_specialization_constant<int_id2>();
175188
double_acc[0] = kh.get_specialization_constant<double_id>();
176189
custom_type_acc[0] = kh.get_specialization_constant<custom_type_id>();
177190
});
@@ -182,6 +195,11 @@ bool test_set_and_get_on_device(sycl::queue q) {
182195
"integer specialization constant"))
183196
return false;
184197

198+
auto int_acc2 = int_buffer2.get_access<sycl::access::mode::read>();
199+
if (!check_value(new_int_value2, int_acc2[0],
200+
"integer specialization constant"))
201+
return false;
202+
185203
auto double_acc = double_buffer.get_access<sycl::access::mode::read>();
186204
if (!check_value(new_double_value, double_acc[0],
187205
"double specialization constant"))

0 commit comments

Comments
 (0)