From 0f2a228c1fb8cd644ee5d94ae35fddc6ece130a3 Mon Sep 17 00:00:00 2001 From: Fabian Knorr Date: Sat, 17 Feb 2024 16:22:59 +0100 Subject: [PATCH 01/19] Fix: get_multi_ptr() is only defined for device- and local accessors --- tests/accessor/generic_accessor_api_common.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/accessor/generic_accessor_api_common.h b/tests/accessor/generic_accessor_api_common.h index 1c6abe969..ded932e5d 100644 --- a/tests/accessor/generic_accessor_api_common.h +++ b/tests/accessor/generic_accessor_api_common.h @@ -58,8 +58,23 @@ void test_accessor_methods(const AccT &accessor, #endif } +template +extern const sycl::target accessor_target_v; + +template +inline constexpr sycl::target accessor_target_v> = Target; + +template +inline constexpr sycl::target accessor_target_v> = sycl::target::device; + +template +inline constexpr sycl::target accessor_target_v> = sycl::target::host_buffer; + + template void test_accessor_ptr_host(AccT &accessor, T expected_data) { + // get_multi_ptr is only defined for device accessors and local accessors + if constexpr (accessor_target_v> == sycl::target::device) { INFO("check get_multi_ptr() method"); auto acc_multi_ptr_no = From 363c209ee9d2381c69df067a92b194047b60935e Mon Sep 17 00:00:00 2001 From: Fabian Knorr Date: Sat, 17 Feb 2024 16:24:13 +0100 Subject: [PATCH 02/19] Fix: legacy accessors do not have member function size() --- tests/accessor_legacy/accessor_api_buffer_common.h | 4 ++++ tests/accessor_legacy/accessor_api_local_common.h | 11 ----------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/tests/accessor_legacy/accessor_api_buffer_common.h b/tests/accessor_legacy/accessor_api_buffer_common.h index 878fad825..f6438fd60 100644 --- a/tests/accessor_legacy/accessor_api_buffer_common.h +++ b/tests/accessor_legacy/accessor_api_buffer_common.h @@ -108,6 +108,10 @@ class check_buffer_accessor_api_methods { "accessor does not properly report placeholder status"); } } + // legacy accessors do not have the size() member function + if constexpr (target != sycl::access::target::constant_buffer && + target != sycl::access::target::local && + target != sycl::access::target::host_buffer) { /** check size() method */ diff --git a/tests/accessor_legacy/accessor_api_local_common.h b/tests/accessor_legacy/accessor_api_local_common.h index 9f7e00b5b..77d7a7a7a 100644 --- a/tests/accessor_legacy/accessor_api_local_common.h +++ b/tests/accessor_legacy/accessor_api_local_common.h @@ -69,17 +69,6 @@ class check_local_accessor_api_methods { queue.submit([&](sycl::handler &h) { auto acc = make_local_accessor_generic(range, h); - { - /** check size() method - */ - auto accessorCount = acc.size(); - check_return_type(log, accessorCount, "size()"); - const auto expectedCount = ((dims == 0) ? 1 : count); - if (accessorCount != expectedCount) { - fail_for_accessor(log, typeName, - "accessor does not return the correct count"); - } - } { /** check get_count() method */ From e6aed1267ca115e539102796fd7a602a1a9f15b5 Mon Sep 17 00:00:00 2001 From: Fabian Knorr Date: Sat, 17 Feb 2024 16:24:43 +0100 Subject: [PATCH 03/19] Fix: Typo in function name --- tests/atomic_ref/atomic_ref_common.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/atomic_ref/atomic_ref_common.h b/tests/atomic_ref/atomic_ref_common.h index fd296e88e..953f19c82 100644 --- a/tests/atomic_ref/atomic_ref_common.h +++ b/tests/atomic_ref/atomic_ref_common.h @@ -253,7 +253,7 @@ inline bool memory_order_is_supported(sycl::queue& q, return it != memory_orders_supported.end(); } -inline bool memory_scope_is_suppoted(sycl::queue& q, sycl::memory_scope scope) { +inline bool memory_scope_is_supported(sycl::queue& q, sycl::memory_scope scope) { std::vector memory_scopes_supported = q.get_device() .get_info(); @@ -266,7 +266,7 @@ inline bool memory_order_and_scope_are_supported(sycl::queue& q, sycl::memory_order order, sycl::memory_scope scope) { return memory_order_is_supported(q, order) && - memory_scope_is_suppoted(q, scope); + memory_scope_is_supported(q, scope); } inline bool memory_order_and_scope_are_not_supported(sycl::queue& q, From 13b22779006fb05a9748ac4cf10487dccdf2f7d1 Mon Sep 17 00:00:00 2001 From: Fabian Knorr Date: Sat, 17 Feb 2024 16:25:37 +0100 Subject: [PATCH 04/19] Fix: `id<1> == int` is ambiguous --- tests/atomic_ref_stress/atomic_ref_stress_common.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/atomic_ref_stress/atomic_ref_stress_common.h b/tests/atomic_ref_stress/atomic_ref_stress_common.h index f927d02ae..a5601f945 100644 --- a/tests/atomic_ref_stress/atomic_ref_stress_common.h +++ b/tests/atomic_ref_stress/atomic_ref_stress_common.h @@ -172,7 +172,7 @@ class aquire_release { refA.store(0); refB.store(0); sycl::group_barrier(item.get_group()); - if (item.get_local_id() == 0) { + if (item.get_local_id() == sycl::id(0)) { x = refA.load(); refB.store(1); } else { @@ -180,7 +180,7 @@ class aquire_release { refA.store(1); } sycl::group_barrier(item.get_group()); - if (item.get_local_id() == 0) + if (item.get_local_id() == sycl::id(0)) res_acc[item.get_group_linear_id()] = !(x == 1 && y == 1); }); }); From ad599db452a2d5d65e986ade2ece5d586a6b8572 Mon Sep 17 00:00:00 2001 From: Fabian Knorr Date: Sat, 17 Feb 2024 16:27:01 +0100 Subject: [PATCH 05/19] Fix: info::device::image_max_array_size is not part of the Spec --- tests/device/device_info.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/device/device_info.cpp b/tests/device/device_info.cpp index b4000191d..92ebabe62 100644 --- a/tests/device/device_info.cpp +++ b/tests/device/device_info.cpp @@ -146,7 +146,6 @@ TEST_CASE("device info", "[device]") { check_get_info_param(dev); check_get_info_param( dev); - check_get_info_param(dev); check_get_info_param(dev); check_get_info_param(dev); check_get_info_param( From 53fd92f2e4d6ade9db7ace62d3f03e7d158b9421 Mon Sep 17 00:00:00 2001 From: Fabian Knorr Date: Sat, 17 Feb 2024 18:52:27 +0100 Subject: [PATCH 06/19] Fix: info::device::opencl_c_version is not part of the Spec --- tests/device/device_info.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/device/device_info.cpp b/tests/device/device_info.cpp index 92ebabe62..9f3853d7b 100644 --- a/tests/device/device_info.cpp +++ b/tests/device/device_info.cpp @@ -222,8 +222,6 @@ TEST_CASE("device info", "[device]") { check_get_info_param(dev); check_get_info_param(dev); check_get_info_param(dev); - check_get_info_param( - dev); check_get_info_param(dev); check_get_info_param Date: Sat, 17 Feb 2024 16:27:34 +0100 Subject: [PATCH 07/19] Fix: sycl::runtime_error is not part of the Spec --- tests/device_selector/device_selector_predefined.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/device_selector/device_selector_predefined.cpp b/tests/device_selector/device_selector_predefined.cpp index cd50e51ad..526a9ab7d 100644 --- a/tests/device_selector/device_selector_predefined.cpp +++ b/tests/device_selector/device_selector_predefined.cpp @@ -74,8 +74,8 @@ TEST_CASE("predefined selectors", "[device_selector]") { try { auto cpuDevice = util::get_cts_object::device(cpuSelector); FAIL("selected a CPU device when none are available"); - } catch (const sycl::runtime_error &e) { - // sycl::runtime_error is expected + } catch (const sycl::exception &e) { + // sycl::exception is expected } catch (...) { FAIL("wrong error thrown when no CPU devices are available"); } @@ -90,8 +90,8 @@ TEST_CASE("predefined selectors", "[device_selector]") { try { auto gpuDevice = util::get_cts_object::device(gpuSelector); FAIL("selected a GPU device when none are available"); - } catch (const sycl::runtime_error &e) { - // sycl::runtime_error is expected + } catch (const sycl::exception &e) { + // sycl::exception is expected } catch (...) { FAIL("wrong error thrown when no GPU devices are available"); } @@ -108,8 +108,8 @@ TEST_CASE("predefined selectors", "[device_selector]") { auto acceleratorDevice = util::get_cts_object::device(acceleratorSelector); FAIL("selected an accelerator device when none are available"); - } catch (const sycl::runtime_error &e) { - // sycl::runtime_error is expected + } catch (const sycl::exception &e) { + // sycl::exception is expected } catch (...) { FAIL("wrong error thrown when no accelerator devices are available"); } From cb520fdb0dad39361bad3db616f896e053e292c0 Mon Sep 17 00:00:00 2001 From: Fabian Knorr Date: Sat, 17 Feb 2024 16:28:03 +0100 Subject: [PATCH 08/19] Fix: sycl::exception is not default-constructible --- tests/exceptions/exceptions_constructors.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/exceptions/exceptions_constructors.cpp b/tests/exceptions/exceptions_constructors.cpp index 04a187bd4..e4691697d 100644 --- a/tests/exceptions/exceptions_constructors.cpp +++ b/tests/exceptions/exceptions_constructors.cpp @@ -194,8 +194,14 @@ TEST_CASE("Constructors for sycl::exception with sycl::errc error codes", check_exception(copy, errcode, sycl::sycl_category()); } SECTION("operator=(const exception& other)") { + // sycl::exception is not default-constructible, so explicitly construct + // `copy` with an error code that is different from `errcode` + std::error_code other_errc(errcode == sycl::errc::success + ? sycl::errc::runtime + : sycl::errc::success); + sycl::exception e(std_errc); - sycl::exception copy; + sycl::exception copy(other_errc); CHECK_NOTHROW((copy = e)); check_exception(copy, errcode, sycl::sycl_category()); } From 9fe6b29000c91d784ad46cc5f1378807573432f0 Mon Sep 17 00:00:00 2001 From: Fabian Knorr Date: Sat, 17 Feb 2024 16:30:54 +0100 Subject: [PATCH 09/19] Fix: `sycl::id<1> - 1` is ambiguous --- tests/id/id.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/id/id.cpp b/tests/id/id.cpp index 5e6a573ba..13a46adf9 100644 --- a/tests/id/id.cpp +++ b/tests/id/id.cpp @@ -239,7 +239,8 @@ TEMPLATE_TEST_CASE_SIG("id can be implicitly conversion-constructed from item", q.submit([r, &result_buf](sycl::handler& cgh) { sycl::accessor result{result_buf, cgh, sycl::write_only}; cgh.parallel_for>(r, [=](sycl::item itm) { - if (itm.get_id() == id{r} - 1) { + // `ul` suffix is necessary to resolve ambiguity for id<1> + if (itm.get_id() == id{r} - 1ul) { // Use assignment operator to trigger implicit conversion result[0] = itm; } From 52f993ba026f8187e4ec452300f4aa8af37737c3 Mon Sep 17 00:00:00 2001 From: Fabian Knorr Date: Sat, 17 Feb 2024 16:32:59 +0100 Subject: [PATCH 10/19] Fix: remove `template` from non-dependent expression --- tests/kernel/kernel_semantics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/kernel/kernel_semantics.cpp b/tests/kernel/kernel_semantics.cpp index 5f3bac7fc..31428198d 100644 --- a/tests/kernel/kernel_semantics.cpp +++ b/tests/kernel/kernel_semantics.cpp @@ -44,10 +44,10 @@ TEST_CASE("kernel common reference semantics", "[kernel]") { sycl::kernel kernel_0 = sycl::get_kernel_bundle(context_0) - .template get_kernel(sycl::get_kernel_id()); + .get_kernel(sycl::get_kernel_id()); sycl::kernel kernel_1 = sycl::get_kernel_bundle(context_1) - .template get_kernel(sycl::get_kernel_id()); + .get_kernel(sycl::get_kernel_id()); common_reference_semantics::check_host(kernel_0, kernel_1, "kernel"); sycl_cts::tests::kernel_bundle::define_kernel(queue_0); sycl_cts::tests::kernel_bundle::define_kernel(queue_1); From f9f2894744a444555056bfb20101f5ac9ff4ca0e Mon Sep 17 00:00:00 2001 From: Fabian Knorr Date: Sat, 17 Feb 2024 16:34:07 +0100 Subject: [PATCH 11/19] Fix: marray does not have operator++/-- --- tests/marray/marray_operators.h | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/tests/marray/marray_operators.h b/tests/marray/marray_operators.h index f18fa6edf..219068ea2 100644 --- a/tests/marray/marray_operators.h +++ b/tests/marray/marray_operators.h @@ -822,13 +822,22 @@ class check_marray_pre_unary_operators_for_type { INFO("prefix unary operators for type \"" << type_name << "\": "); const auto num_elements = marray_common::get_num_elements(); - - static const auto unary_operators = - named_type_pack::generate("unary +", "unary -", "pre ++", - "pre --", "!", "~"); + static const auto unary_operators = make_unary_operators(); for_all_combinations(num_elements, unary_operators); } + + private: + static auto make_unary_operators() { + if constexpr (std::is_same_v) { + // marray does not have operator++/-- + return named_type_pack::generate( + "unary +", "unary -", "!", "~"); + } else { + return named_type_pack::generate("unary +", "unary -", "pre ++", + "pre --", "!", "~"); + } + } }; template @@ -839,11 +848,14 @@ class check_marray_post_unary_operators_for_type { const auto num_elements = marray_common::get_num_elements(); - static const auto unary_post_operators = - named_type_pack::generate("post ++", - "post --"); - for_all_combinations(num_elements, - unary_post_operators); + // marray does not have operator++/-- + if (!std::is_same_v) { + static const auto unary_post_operators = + named_type_pack::generate("post ++", + "post --"); + for_all_combinations(num_elements, + unary_post_operators); + } } }; From 54d8b794df828602416c958c3136107b844d3a3b Mon Sep 17 00:00:00 2001 From: Fabian Knorr Date: Sat, 17 Feb 2024 16:34:48 +0100 Subject: [PATCH 12/19] Fix: Avoid multiple definitions of kernel names --- tests/namespace/namespace.cpp.in | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/namespace/namespace.cpp.in b/tests/namespace/namespace.cpp.in index 72a9840d4..75cbcbd79 100644 --- a/tests/namespace/namespace.cpp.in +++ b/tests/namespace/namespace.cpp.in @@ -29,9 +29,14 @@ #include -struct kernel_1; -struct kernel_2; -struct kernel_3; +// Multiple translation units are instantiated from this .in file and linked together, so we must +// ensure that kernel names are namespaced to disambiguate their definitions +namespace kernels CTS_NAMESPACE { + struct kernel_1; + struct kernel_2; + struct kernel_3; +} +using namespace kernels CTS_NAMESPACE; /** Example program, adapted to use the CTS queue. */ static int test_namespace() { From 502a9bf115092bc5f22d083699cb4ebcdc4461c8 Mon Sep 17 00:00:00 2001 From: Fabian Knorr Date: Sat, 17 Feb 2024 16:36:30 +0100 Subject: [PATCH 13/19] Fix: Regex typo in scalars/CMakeLists --- tests/scalars/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scalars/CMakeLists.txt b/tests/scalars/CMakeLists.txt index c24e4e87e..c8b65be26 100644 --- a/tests/scalars/CMakeLists.txt +++ b/tests/scalars/CMakeLists.txt @@ -2,7 +2,7 @@ file(GLOB test_cases_list *.cpp) if(NOT SYCL_CTS_ENABLE_OPENCL_INTEROP_TESTS) - list(FILTER test_cases_list EXCLUDE REGEX scalars_interopability_types.cpp) + list(FILTER test_cases_list EXCLUDE REGEX scalars_interoperability_types.cpp) endif() add_cts_test(${test_cases_list}) From 9008312be44b750b92ad01b72217f6b76a0c7a47 Mon Sep 17 00:00:00 2001 From: Fabian Knorr Date: Sat, 17 Feb 2024 16:39:11 +0100 Subject: [PATCH 14/19] Fix: sycl::vec cannot load/store from accessor or load from non-const multi_ptr --- tests/vector_load_store/generate_vector_load_store.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/vector_load_store/generate_vector_load_store.py b/tests/vector_load_store/generate_vector_load_store.py index dad739261..411a8571b 100755 --- a/tests/vector_load_store/generate_vector_load_store.py +++ b/tests/vector_load_store/generate_vector_load_store.py @@ -54,25 +54,19 @@ cgh.single_task([=]() { auto testVec${type_as_str}${size} = sycl::vec<${type}, ${size}>(${val}); - testVec${type_as_str}${size}.load(0, inPtr${type_as_str}${size}); - testVec${type_as_str}${size}.store(0, outPtr${type_as_str}${size}); auto multiPtrIn${type_as_str}${size} = inPtr${type_as_str}${size}.get_multi_ptr<${decorated}>(); sycl::global_ptr constMultiPtrIn${type_as_str}${size} = multiPtrIn${type_as_str}${size}; auto multiPtrOut${type_as_str}${size} = outPtr${type_as_str}${size}.get_multi_ptr<${decorated}>(); - testVec${type_as_str}${size}.load(0, multiPtrIn${type_as_str}${size}); testVec${type_as_str}${size}.load(0, constMultiPtrIn${type_as_str}${size}); testVec${type_as_str}${size}.store(0, multiPtrOut${type_as_str}${size}); auto cleanVec${type_as_str}${size} = sycl::vec<${type}, ${size}>(${val}); sycl::vec<${type}, ${size}> swizzledVec {cleanVec${type_as_str}${size}.template swizzle<${swizVals}>()}; - swizzledVec.load(0, swizzleInPtr${type_as_str}${size}); - swizzledVec.store(0, swizzleOutPtr${type_as_str}${size}); auto multiPtrInSwizzle${type_as_str}${size} = swizzleInPtr${type_as_str}${size}.get_multi_ptr<${decorated}>(); sycl::global_ptr constMultiPtrInSwizzle${type_as_str}${size} = multiPtrInSwizzle${type_as_str}${size}; auto multiPtrOutSwizzle${type_as_str}${size} = swizzleOutPtr${type_as_str}${size}.get_multi_ptr<${decorated}>(); - swizzledVec.load(0, multiPtrInSwizzle${type_as_str}${size}); swizzledVec.load(0, constMultiPtrInSwizzle${type_as_str}${size}); swizzledVec.store(0, multiPtrOutSwizzle${type_as_str}${size}); }); From 0fbac0d1eb9d8f14cf9f07ef2dca833f5c40ba56 Mon Sep 17 00:00:00 2001 From: Fabian Knorr Date: Sat, 17 Feb 2024 16:40:18 +0100 Subject: [PATCH 15/19] Fix: vec does not provide operator++/-- --- .../generate_vector_operators.py | 172 +++++++++--------- 1 file changed, 87 insertions(+), 85 deletions(-) diff --git a/tests/vector_operators/generate_vector_operators.py b/tests/vector_operators/generate_vector_operators.py index e7de5c4ee..c6de167f1 100755 --- a/tests/vector_operators/generate_vector_operators.py +++ b/tests/vector_operators/generate_vector_operators.py @@ -207,92 +207,93 @@ } // Post and pre increment and decrement - // C++17 does not allow ++ or -- (either prefix or postfix) for the bool type - // So skip tests for these operators if DataT is bool - if constexpr (!std::is_same_v<${type}, bool>) { - for (int i = 0; i < ${size}; ++i) { - resArr[i] = static_cast<${type}>(${test_value_1}); - } - for (int i = 0; i < ${size}; ++i) { - resArr2[i] = static_cast<${type}>(${test_value_1}) + static_cast<${type}>(1); - } - testVec1Copy = testVec1; - resVec = testVec1Copy++; - if (!check_vector_values(resVec, resArr)) { - resAcc[0] = false; - } - if (!check_vector_values(testVec1Copy, resArr2)) { - resAcc[0] = false; - } - testVec1Copy = testVec1; - resVec = testVec1Copy.${swizzle}++; - if (!check_vector_values(resVec, resArr)) { - resAcc[0] = false; - } - if (!check_vector_values(testVec1Copy, resArr2)) { - resAcc[0] = false; - } - for (int i = 0; i < ${size}; ++i) { - resArr[i] = static_cast<${type}>(${test_value_1}) + static_cast<${type}>(1); - } - testVec1Copy = testVec1; - resVec = ++testVec1Copy; - if (!check_vector_values(resVec, resArr)) { - resAcc[0] = false; - } - if (!check_vector_values(testVec1Copy, resArr)) { - resAcc[0] = false; - } - testVec1Copy = testVec1; - resVec = ++testVec1Copy.${swizzle}; - if (!check_vector_values(resVec, resArr)) { - resAcc[0] = false; - } - if (!check_vector_values(testVec1Copy, resArr)) { - resAcc[0] = false; - } - for (int i = 0; i < ${size}; ++i) { - resArr[i] = static_cast<${type}>(${test_value_1}); - } - for (int i = 0; i < ${size}; ++i) { - resArr2[i] = static_cast<${type}>(${test_value_1}) - static_cast<${type}>(1); - } - testVec1Copy = testVec1; - resVec = testVec1Copy--; - if (!check_vector_values(resVec, resArr)) { - resAcc[0] = false; - } - if (!check_vector_values(testVec1Copy, resArr2)) { - resAcc[0] = false; - } - testVec1Copy = testVec1; - resVec = testVec1Copy.${swizzle}--; - if (!check_vector_values(resVec, resArr)) { - resAcc[0] = false; - } - if (!check_vector_values(testVec1Copy, resArr2)) { - resAcc[0] = false; - } - for (int i = 0; i < ${size}; ++i) { - resArr[i] = static_cast<${type}>(${test_value_1}) - static_cast<${type}>(1); - } - testVec1Copy = testVec1; - resVec = --testVec1Copy; - if (!check_vector_values(resVec, resArr)) { - resAcc[0] = false; - } - if (!check_vector_values(testVec1Copy, resArr)) { - resAcc[0] = false; - } - testVec1Copy = testVec1; - resVec = --testVec1Copy.${swizzle}; - if (!check_vector_values(resVec, resArr)) { - resAcc[0] = false; - } - if (!check_vector_values(testVec1Copy, resArr)) { - resAcc[0] = false; - } + // The standard does not require ++ and -- (either prefix or postfix) for the + // bool type, so we skip tests for these operators if DataT is bool. This cannot + // be done via `if constexpr` because the type is not a dependent type. +#if !${type_is_bool} + for (int i = 0; i < ${size}; ++i) { + resArr[i] = static_cast<${type}>(${test_value_1}); + } + for (int i = 0; i < ${size}; ++i) { + resArr2[i] = static_cast<${type}>(${test_value_1}) + static_cast<${type}>(1); + } + testVec1Copy = testVec1; + resVec = testVec1Copy++; + if (!check_vector_values(resVec, resArr)) { + resAcc[0] = false; + } + if (!check_vector_values(testVec1Copy, resArr2)) { + resAcc[0] = false; + } + testVec1Copy = testVec1; + resVec = testVec1Copy.${swizzle}++; + if (!check_vector_values(resVec, resArr)) { + resAcc[0] = false; + } + if (!check_vector_values(testVec1Copy, resArr2)) { + resAcc[0] = false; + } + for (int i = 0; i < ${size}; ++i) { + resArr[i] = static_cast<${type}>(${test_value_1}) + static_cast<${type}>(1); + } + testVec1Copy = testVec1; + resVec = ++testVec1Copy; + if (!check_vector_values(resVec, resArr)) { + resAcc[0] = false; + } + if (!check_vector_values(testVec1Copy, resArr)) { + resAcc[0] = false; + } + testVec1Copy = testVec1; + resVec = ++testVec1Copy.${swizzle}; + if (!check_vector_values(resVec, resArr)) { + resAcc[0] = false; + } + if (!check_vector_values(testVec1Copy, resArr)) { + resAcc[0] = false; + } + for (int i = 0; i < ${size}; ++i) { + resArr[i] = static_cast<${type}>(${test_value_1}); + } + for (int i = 0; i < ${size}; ++i) { + resArr2[i] = static_cast<${type}>(${test_value_1}) - static_cast<${type}>(1); + } + testVec1Copy = testVec1; + resVec = testVec1Copy--; + if (!check_vector_values(resVec, resArr)) { + resAcc[0] = false; + } + if (!check_vector_values(testVec1Copy, resArr2)) { + resAcc[0] = false; + } + testVec1Copy = testVec1; + resVec = testVec1Copy.${swizzle}--; + if (!check_vector_values(resVec, resArr)) { + resAcc[0] = false; + } + if (!check_vector_values(testVec1Copy, resArr2)) { + resAcc[0] = false; + } + for (int i = 0; i < ${size}; ++i) { + resArr[i] = static_cast<${type}>(${test_value_1}) - static_cast<${type}>(1); + } + testVec1Copy = testVec1; + resVec = --testVec1Copy; + if (!check_vector_values(resVec, resArr)) { + resAcc[0] = false; + } + if (!check_vector_values(testVec1Copy, resArr)) { + resAcc[0] = false; + } + testVec1Copy = testVec1; + resVec = --testVec1Copy.${swizzle}; + if (!check_vector_values(resVec, resArr)) { + resAcc[0] = false; + } + if (!check_vector_values(testVec1Copy, resArr)) { + resAcc[0] = false; } +#endif // Assignment operators for (int i = 0; i < ${size}; ++i) { @@ -1338,6 +1339,7 @@ def generate_all_type_test(type_str, size): val=Data.value_default_dict[type_str]) test_string += all_type_test_template.substitute( type=type_str, + type_is_bool=int(type_str == 'bool'), size=str(size), swizzle=get_swizzle(size), test_value_1=1, From e931257b2e7a8d898c22b63d00494cbb5f7c90f7 Mon Sep 17 00:00:00 2001 From: Fabian Knorr Date: Sat, 17 Feb 2024 16:40:39 +0100 Subject: [PATCH 16/19] Fix: Call to erase_if is ambiguous with C++20 --- util/device_set.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/util/device_set.cpp b/util/device_set.cpp index 3c6fcf23c..f6806d15e 100644 --- a/util/device_set.cpp +++ b/util/device_set.cpp @@ -48,7 +48,9 @@ void device_set::intersect(const device_set& other) { const auto& device = *it; return other.m_devices.find(device) == other.m_devices.end(); }; - erase_if(m_devices, condition); + // must explicitly specify namespace `util` to avoid ambiguity with + // std::erase_if when compiling for C++20 + util::erase_if(m_devices, condition); } void device_set::removeDevsWith(sycl::aspect aspect) { @@ -56,7 +58,7 @@ void device_set::removeDevsWith(sycl::aspect aspect) { const auto& device = *it; return device.has(aspect); }; - erase_if(m_devices, condition); + util::erase_if(m_devices, condition); } void device_set::removeDevsWith(std::initializer_list aspects) { @@ -70,7 +72,7 @@ void device_set::removeDevsWithout(sycl::aspect aspect) { const auto& device = *it; return !device.has(aspect); }; - erase_if(m_devices, condition); + util::erase_if(m_devices, condition); } void device_set::removeDevsWithout(const kernel_restrictions& restriction) { @@ -78,7 +80,7 @@ void device_set::removeDevsWithout(const kernel_restrictions& restriction) { const auto& device = *it; return !restriction.is_compatible(device); }; - erase_if(m_devices, condition); + util::erase_if(m_devices, condition); } device_set device_set::filtered(const device_set& other, sycl::aspect aspect) { From 87644594deea66d0232ae4f5017879864e924f0c Mon Sep 17 00:00:00 2001 From: Fabian Knorr Date: Sat, 17 Feb 2024 20:20:41 +0100 Subject: [PATCH 17/19] Fix: correctly reset array in test_scalars --- tests/scalars/scalars_fixed_width_types.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/scalars/scalars_fixed_width_types.cpp b/tests/scalars/scalars_fixed_width_types.cpp index 738bf8f2a..8bcb435fd 100644 --- a/tests/scalars/scalars_fixed_width_types.cpp +++ b/tests/scalars/scalars_fixed_width_types.cpp @@ -49,7 +49,8 @@ TEST_CASE("Fixed width types size equality", "[scalars]") { CHECK(results[i]); } - std::iota(results.begin(), results.end(), false); + std::fill(results.begin(), results.end(), false); + { sycl::buffer res_buf(results.data(), {types_count}); queue.submit([&](sycl::handler& cgh) { From 8a685323b4793b6eb3e44ccbbd16980e48b033b9 Mon Sep 17 00:00:00 2001 From: Fabian Knorr Date: Thu, 13 Jun 2024 12:29:13 +0200 Subject: [PATCH 18/19] Address reviewer comments on fixes --- tests/marray/marray_operators.h | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/tests/marray/marray_operators.h b/tests/marray/marray_operators.h index 219068ea2..1885a28f3 100644 --- a/tests/marray/marray_operators.h +++ b/tests/marray/marray_operators.h @@ -822,22 +822,20 @@ class check_marray_pre_unary_operators_for_type { INFO("prefix unary operators for type \"" << type_name << "\": "); const auto num_elements = marray_common::get_num_elements(); - static const auto unary_operators = make_unary_operators(); + static const auto unary_operators = [] { + if constexpr (std::is_same_v) { + // marray does not have operator++/-- + return named_type_pack::generate( + "unary +", "unary -", "!", "~"); + } else { + return named_type_pack::generate("unary +", "unary -", + "pre ++", "pre --", + "!", "~"); + } + }(); for_all_combinations(num_elements, unary_operators); } - - private: - static auto make_unary_operators() { - if constexpr (std::is_same_v) { - // marray does not have operator++/-- - return named_type_pack::generate( - "unary +", "unary -", "!", "~"); - } else { - return named_type_pack::generate("unary +", "unary -", "pre ++", - "pre --", "!", "~"); - } - } }; template @@ -849,7 +847,7 @@ class check_marray_post_unary_operators_for_type { const auto num_elements = marray_common::get_num_elements(); // marray does not have operator++/-- - if (!std::is_same_v) { + if constexpr (!std::is_same_v) { static const auto unary_post_operators = named_type_pack::generate("post ++", "post --"); From 004bcbf5ea7e947e9e6efaabdd33558b15fa7460 Mon Sep 17 00:00:00 2001 From: Fabian Knorr Date: Wed, 19 Jun 2024 11:50:34 +0200 Subject: [PATCH 19/19] Fix formatting in updated tests --- tests/accessor/generic_accessor_api_common.h | 25 +++++++++++-------- .../accessor_api_buffer_common.h | 3 +-- .../accessor_api_local_common.h | 2 +- tests/atomic_ref/atomic_ref_common.h | 3 ++- .../device_selector_predefined.cpp | 6 ++--- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/tests/accessor/generic_accessor_api_common.h b/tests/accessor/generic_accessor_api_common.h index ded932e5d..ed563c598 100644 --- a/tests/accessor/generic_accessor_api_common.h +++ b/tests/accessor/generic_accessor_api_common.h @@ -58,24 +58,29 @@ void test_accessor_methods(const AccT &accessor, #endif } -template +template extern const sycl::target accessor_target_v; -template -inline constexpr sycl::target accessor_target_v> = Target; +template +inline constexpr sycl::target + accessor_target_v> = + Target; -template -inline constexpr sycl::target accessor_target_v> = sycl::target::device; - -template -inline constexpr sycl::target accessor_target_v> = sycl::target::host_buffer; +template +inline constexpr sycl::target accessor_target_v> = + sycl::target::device; +template +inline constexpr sycl::target + accessor_target_v> = + sycl::target::host_buffer; template void test_accessor_ptr_host(AccT &accessor, T expected_data) { // get_multi_ptr is only defined for device accessors and local accessors - if constexpr (accessor_target_v> == sycl::target::device) - { + if constexpr (accessor_target_v> == + sycl::target::device) { INFO("check get_multi_ptr() method"); auto acc_multi_ptr_no = accessor.template get_multi_ptr(); diff --git a/tests/accessor_legacy/accessor_api_buffer_common.h b/tests/accessor_legacy/accessor_api_buffer_common.h index f6438fd60..422d377e0 100644 --- a/tests/accessor_legacy/accessor_api_buffer_common.h +++ b/tests/accessor_legacy/accessor_api_buffer_common.h @@ -111,8 +111,7 @@ class check_buffer_accessor_api_methods { // legacy accessors do not have the size() member function if constexpr (target != sycl::access::target::constant_buffer && target != sycl::access::target::local && - target != sycl::access::target::host_buffer) - { + target != sycl::access::target::host_buffer) { /** check size() method */ auto accessorCount = accessor.size(); diff --git a/tests/accessor_legacy/accessor_api_local_common.h b/tests/accessor_legacy/accessor_api_local_common.h index 77d7a7a7a..bd4bf52f7 100644 --- a/tests/accessor_legacy/accessor_api_local_common.h +++ b/tests/accessor_legacy/accessor_api_local_common.h @@ -67,7 +67,7 @@ class check_local_accessor_api_methods { util::get_cts_object::range::value>::get(1, 1, 1); error_buffer_t errorBuffer(errors.get(), sycl::range<1>(2)); - queue.submit([&](sycl::handler &h) { + queue.submit([&](sycl::handler& h) { auto acc = make_local_accessor_generic(range, h); { /** check get_count() method diff --git a/tests/atomic_ref/atomic_ref_common.h b/tests/atomic_ref/atomic_ref_common.h index 953f19c82..98475ef12 100644 --- a/tests/atomic_ref/atomic_ref_common.h +++ b/tests/atomic_ref/atomic_ref_common.h @@ -253,7 +253,8 @@ inline bool memory_order_is_supported(sycl::queue& q, return it != memory_orders_supported.end(); } -inline bool memory_scope_is_supported(sycl::queue& q, sycl::memory_scope scope) { +inline bool memory_scope_is_supported(sycl::queue& q, + sycl::memory_scope scope) { std::vector memory_scopes_supported = q.get_device() .get_info(); diff --git a/tests/device_selector/device_selector_predefined.cpp b/tests/device_selector/device_selector_predefined.cpp index 526a9ab7d..78f825ee3 100644 --- a/tests/device_selector/device_selector_predefined.cpp +++ b/tests/device_selector/device_selector_predefined.cpp @@ -74,7 +74,7 @@ TEST_CASE("predefined selectors", "[device_selector]") { try { auto cpuDevice = util::get_cts_object::device(cpuSelector); FAIL("selected a CPU device when none are available"); - } catch (const sycl::exception &e) { + } catch (const sycl::exception& e) { // sycl::exception is expected } catch (...) { FAIL("wrong error thrown when no CPU devices are available"); @@ -90,7 +90,7 @@ TEST_CASE("predefined selectors", "[device_selector]") { try { auto gpuDevice = util::get_cts_object::device(gpuSelector); FAIL("selected a GPU device when none are available"); - } catch (const sycl::exception &e) { + } catch (const sycl::exception& e) { // sycl::exception is expected } catch (...) { FAIL("wrong error thrown when no GPU devices are available"); @@ -108,7 +108,7 @@ TEST_CASE("predefined selectors", "[device_selector]") { auto acceleratorDevice = util::get_cts_object::device(acceleratorSelector); FAIL("selected an accelerator device when none are available"); - } catch (const sycl::exception &e) { + } catch (const sycl::exception& e) { // sycl::exception is expected } catch (...) { FAIL("wrong error thrown when no accelerator devices are available");