22
22
#include " common.hpp"
23
23
24
24
constexpr sycl::specialization_id<int > int_id;
25
+ constexpr sycl::specialization_id<int > int_id2 (2 );
25
26
constexpr sycl::specialization_id<double > double_id (3.14 );
26
27
constexpr sycl::specialization_id<custom_type> custom_type_id;
27
28
@@ -69,16 +70,19 @@ int main() {
69
70
70
71
bool test_default_values (sycl::queue q) {
71
72
sycl::buffer<int > int_buffer (1 );
73
+ sycl::buffer<int > int_buffer2 (1 );
72
74
sycl::buffer<double > double_buffer (1 );
73
75
sycl::buffer<custom_type> custom_type_buffer (1 );
74
76
75
77
q.submit ([&](sycl::handler &cgh) {
76
78
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);
77
80
auto double_acc = double_buffer.get_access <sycl::access::mode::write>(cgh);
78
81
auto custom_type_acc =
79
82
custom_type_buffer.get_access <sycl::access::mode::write>(cgh);
80
83
cgh.single_task <TestDefaultValuesKernel>([=](sycl::kernel_handler kh) {
81
84
int_acc[0 ] = kh.get_specialization_constant <int_id>();
85
+ int_acc2[0 ] = kh.get_specialization_constant <int_id2>();
82
86
double_acc[0 ] = kh.get_specialization_constant <double_id>();
83
87
custom_type_acc[0 ] = kh.get_specialization_constant <custom_type_id>();
84
88
});
@@ -90,6 +94,10 @@ bool test_default_values(sycl::queue q) {
90
94
" integer specialization constant (defined without default value)" ))
91
95
return false ;
92
96
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
+
93
101
auto double_acc = double_buffer.get_access <sycl::access::mode::read>();
94
102
if (!check_value (3.14 , double_acc[0 ], " double specialization constant" ))
95
103
return false ;
@@ -153,25 +161,30 @@ bool test_set_and_get_on_host(sycl::queue q) {
153
161
154
162
bool test_set_and_get_on_device (sycl::queue q) {
155
163
sycl::buffer<int > int_buffer (1 );
164
+ sycl::buffer<int > int_buffer2 (1 );
156
165
sycl::buffer<double > double_buffer (1 );
157
166
sycl::buffer<custom_type> custom_type_buffer (1 );
158
167
159
168
int new_int_value = 8 ;
169
+ int new_int_value2 = 0 ;
160
170
double new_double_value = 3.0 ;
161
171
custom_type new_custom_type_value (' b' , 1.0 , 12 );
162
172
163
173
q.submit ([&](sycl::handler &cgh) {
164
174
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);
165
176
auto double_acc = double_buffer.get_access <sycl::access::mode::write>(cgh);
166
177
auto custom_type_acc =
167
178
custom_type_buffer.get_access <sycl::access::mode::write>(cgh);
168
179
169
180
cgh.set_specialization_constant <int_id>(new_int_value);
181
+ cgh.set_specialization_constant <int_id2>(new_int_value2);
170
182
cgh.set_specialization_constant <double_id>(new_double_value);
171
183
cgh.set_specialization_constant <custom_type_id>(new_custom_type_value);
172
184
173
185
cgh.single_task <TestSetAndGetOnDevice>([=](sycl::kernel_handler kh) {
174
186
int_acc[0 ] = kh.get_specialization_constant <int_id>();
187
+ int_acc2[0 ] = kh.get_specialization_constant <int_id2>();
175
188
double_acc[0 ] = kh.get_specialization_constant <double_id>();
176
189
custom_type_acc[0 ] = kh.get_specialization_constant <custom_type_id>();
177
190
});
@@ -182,6 +195,11 @@ bool test_set_and_get_on_device(sycl::queue q) {
182
195
" integer specialization constant" ))
183
196
return false ;
184
197
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
+
185
203
auto double_acc = double_buffer.get_access <sycl::access::mode::read>();
186
204
if (!check_value (new_double_value, double_acc[0 ],
187
205
" double specialization constant" ))
0 commit comments