diff --git a/tests/accessor/generic_accessor_api_common.h b/tests/accessor/generic_accessor_api_common.h index 1c6abe969..ed563c598 100644 --- a/tests/accessor/generic_accessor_api_common.h +++ b/tests/accessor/generic_accessor_api_common.h @@ -58,9 +58,29 @@ 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 = 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 878fad825..422d377e0 100644 --- a/tests/accessor_legacy/accessor_api_buffer_common.h +++ b/tests/accessor_legacy/accessor_api_buffer_common.h @@ -108,7 +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 */ 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 9f7e00b5b..bd4bf52f7 100644 --- a/tests/accessor_legacy/accessor_api_local_common.h +++ b/tests/accessor_legacy/accessor_api_local_common.h @@ -67,19 +67,8 @@ 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 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 */ diff --git a/tests/atomic_ref/atomic_ref_common.h b/tests/atomic_ref/atomic_ref_common.h index fd296e88e..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_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 +267,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, 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); }); }); diff --git a/tests/device/device_info.cpp b/tests/device/device_info.cpp index b4000191d..9f3853d7b 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( @@ -223,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>(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; } 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); diff --git a/tests/marray/marray_operators.h b/tests/marray/marray_operators.h index f18fa6edf..1885a28f3 100644 --- a/tests/marray/marray_operators.h +++ b/tests/marray/marray_operators.h @@ -822,11 +822,18 @@ 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 = [] { + 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); } }; @@ -839,11 +846,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 constexpr (!std::is_same_v) { + static const auto unary_post_operators = + named_type_pack::generate("post ++", + "post --"); + for_all_combinations(num_elements, + unary_post_operators); + } } }; 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() { 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}) 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) { 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}); }); 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, 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) {