@@ -36,7 +36,7 @@ struct initializer {
36
36
37
37
// Descriptor class for the case of calling constructor in variable declaration
38
38
// context.
39
- struct var_dec {
39
+ struct var_decl {
40
40
static std::string get_description () { return " variable declaration" ; }
41
41
42
42
template <typename DataT, int NumElems>
@@ -48,7 +48,7 @@ struct var_dec {
48
48
49
49
// Descriptor class for the case of calling constructor in rvalue in an
50
50
// expression context.
51
- struct rval_in_express {
51
+ struct rval_in_expr {
52
52
static std::string get_description () { return " rvalue in an expression" ; }
53
53
54
54
template <typename DataT, int NumElems>
@@ -191,30 +191,32 @@ class FillCtorTestDescription
191
191
}
192
192
};
193
193
194
- template <typename DataT, int NumElems, typename TestCaseT, typename BaseVal,
195
- typename Step>
194
+ template <init_val... Values> auto get_init_values_pack () {
195
+ return value_pack<init_val, Values...>::generate_unnamed ();
196
+ }
197
+
198
+ template <typename DataT, typename DimT, typename TestCaseT, typename BaseValT,
199
+ typename StepT>
196
200
class run_test {
201
+ static constexpr int NumElems = DimT::value;
202
+ static constexpr init_val BaseVal = BaseValT::value;
203
+ static constexpr init_val Step = StepT::value;
204
+ using KernelT = kernel_for_fill<DataT, NumElems, TestCaseT, BaseVal, Step>;
205
+
197
206
public:
198
207
bool operator ()(sycl::queue &queue, const std::string &data_type) {
199
- static_assert (std::is_same_v<typename BaseVal::value_type, init_val>,
200
- " BaseVal template parameter should be init_val type." );
201
- static_assert (std::is_same_v<typename Step::value_type, init_val>,
202
- " Step template parameter should be init_val type." );
203
-
204
208
shared_vector<DataT> result (NumElems, shared_allocator<DataT>(queue));
205
209
206
- const auto base_value = get_value<DataT, BaseVal::value >();
207
- const auto step_value = get_value<DataT, Step::value >(base_value);
210
+ const auto base_value = get_value<DataT, BaseVal>();
211
+ const auto step_value = get_value<DataT, Step>(base_value);
208
212
209
213
queue.submit ([&](sycl::handler &cgh) {
210
214
DataT *const out = result.data ();
211
215
212
- cgh.single_task <kernel_for_fill<DataT, NumElems, TestCaseT,
213
- BaseVal::value, Step::value>>(
214
- [=]() SYCL_ESIMD_KERNEL {
215
- TestCaseT::template call_simd_ctor<DataT, NumElems>(
216
- base_value, step_value, out);
217
- });
216
+ cgh.single_task <KernelT>([=]() SYCL_ESIMD_KERNEL {
217
+ TestCaseT::template call_simd_ctor<DataT, NumElems>(base_value,
218
+ step_value, out);
219
+ });
218
220
});
219
221
queue.wait_and_throw ();
220
222
bool passed = true ;
@@ -228,8 +230,7 @@ class run_test {
228
230
// constructor.
229
231
DataT expected_value = base_value;
230
232
for (size_t i = 1 ; i < result.size (); ++i) {
231
- if constexpr (BaseVal::value == init_val::nan ||
232
- Step::value == init_val::nan) {
233
+ if constexpr (BaseVal == init_val::nan || Step == init_val::nan) {
233
234
234
235
if (!std::isnan (result[i])) {
235
236
passed = false ;
@@ -241,9 +242,8 @@ class run_test {
241
242
log_msg += " , with context: " + TestCaseT::get_description ();
242
243
log_msg += " . The element at index: " + std::to_string (i) +
243
244
" , is not nan, but it should." ;
244
- log_msg +=
245
- " , with base value: " + init_val_to_string<BaseVal::value>();
246
- log_msg += " , with step value: " + init_val_to_string<Step::value>();
245
+ log_msg += " , with base value: " + init_val_to_string<BaseVal>();
246
+ log_msg += " , with step value: " + init_val_to_string<Step>();
247
247
248
248
log::note (log_msg);
249
249
}
@@ -262,33 +262,12 @@ class run_test {
262
262
bool fail_test (size_t index, DataT retrieved, DataT expected,
263
263
const std::string &data_type) {
264
264
const auto description =
265
- FillCtorTestDescription<DataT, NumElems, TestCaseT, BaseVal::value,
266
- Step::value>(index, retrieved, expected,
267
- data_type);
265
+ FillCtorTestDescription<DataT, NumElems, TestCaseT, BaseVal, Step>(
266
+ index, retrieved, expected, data_type);
268
267
log::fail (description);
269
268
270
269
return false ;
271
270
}
272
271
};
273
272
274
- // Iterating over provided types and dimensions, running test for each of
275
- // them.
276
- template <typename TestT, init_val BaseVal, init_val Step, typename ... Types,
277
- int ... Dims>
278
- bool run_verification (
279
- sycl::queue &queue,
280
- const esimd_functional::values_pack<Dims...> &dimensions,
281
- const esimd_functional::named_type_pack<Types...> &types) {
282
-
283
- typedef std::integral_constant<init_val, BaseVal> base_value;
284
- typedef std::integral_constant<init_val, Step> step_value;
285
-
286
- bool passed = true ;
287
- passed &= esimd_functional::for_all_types_and_dims<run_test, TestT,
288
- base_value, step_value>(
289
- types, dimensions, queue);
290
-
291
- return passed;
292
- }
293
-
294
273
} // namespace esimd_test::api::functional::ctors
0 commit comments