diff --git a/CMakeLists.txt b/CMakeLists.txt index ae3a81414..319ab809a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,15 @@ else() endif() # ------------------ +# ------------------ +# Extensive mode for running extension oneAPI compile-time property list tests +option(SYCL_ENABLE_EXT_ONEAPI_PROPERTY_LIST_TESTS + "Enable extension oneAPI compile-time property list tests" OFF) +if(SYCL_ENABLE_EXT_ONEAPI_PROPERTY_LIST_TESTS) + message(STATUS "oneAPI extension compile-time property list tests mode: ON") +endif() +# ------------------ + # ------------------ # Extensive mode for running legacy tests option(SYCL_CTS_TEST_DEPRECATED_FEATURES diff --git a/tests/extension/oneapi_property_list/CMakeLists.txt b/tests/extension/oneapi_property_list/CMakeLists.txt new file mode 100644 index 000000000..9db354b7f --- /dev/null +++ b/tests/extension/oneapi_property_list/CMakeLists.txt @@ -0,0 +1,5 @@ +if(SYCL_ENABLE_EXT_ONEAPI_PROPERTY_LIST_TESTS) + file(GLOB test_cases_list *.cpp) + + add_cts_test(${test_cases_list}) +endif() diff --git a/tests/extension/oneapi_property_list/property_list_prop_eq_op.cpp b/tests/extension/oneapi_property_list/property_list_prop_eq_op.cpp new file mode 100644 index 000000000..43d8459ef --- /dev/null +++ b/tests/extension/oneapi_property_list/property_list_prop_eq_op.cpp @@ -0,0 +1,75 @@ +/******************************************************************************* +// +// SYCL 2020 Extension Conformance Test +// +// Provides test for equality and inequality operators for properties +// +*******************************************************************************/ + +#include "../../common/common.h" + +#define TEST_NAME property_list_prop_eq_op + +namespace TEST_NAMESPACE { + +using namespace sycl_cts; + +template +constexpr void check_equal(util::logger &log, T prop1, U prop2, + bool expected_equal) { + if ((prop1 == prop2) != expected_equal) { + FAIL(log, "wrong result for equality operator"); + } + + if ((prop1 != prop2) == expected_equal) { + FAIL(log, "wrong result for inequality operator"); + } +} + +/** test sycl::ext::oneapi::property_value equality operators + */ +class TEST_NAME : public util::test_base { + public: + /** return information about this test + */ + void get_info(test_base::info &out) const override { + set_test_info(out, TOSTRING(TEST_NAME), TEST_FILE); + } + + /** execute the test + */ + void run(util::logger &log) override { +#if !defined(SYCL_EXT_ONEAPI_PROPERTY_LIST) + log.skip("SYCL_EXT_ONEAPI_PROPERTY_LIST is not defined, test is skipped"); +#elif !defined(SYCL_EXT_ONEAPI_DEVICE_GLOBAL) + log.skip("SYCL_EXT_ONEAPI_DEVICE_GLOBAL is not defined, test is skipped"); +#else + { + using namespace sycl::ext::oneapi; + property_list props{device_image_scope_v}; + constexpr auto prop_value_device_image_scope = + props.get_property(); + + property_list props2{implement_in_csr_v}; + constexpr auto prop_value_implement_in_csr_true = + props2.get_property(); + + property_list props3{implement_in_csr_v}; + constexpr auto prop_value_implement_in_csr_false = + props3.get_property(); + + check_equal(log, prop_value_device_image_scope, + prop_value_device_image_scope, true); + check_equal(log, prop_value_implement_in_csr_true, + prop_value_implement_in_csr_true, true); + check_equal(log, prop_value_implement_in_csr_true, + prop_value_implement_in_csr_false, false); + } +#endif + } +}; + +// register this test with the test_collection. +util::test_proxy proxy; + +} /* namespace TEST_NAMESPACE */ diff --git a/tests/extension/oneapi_property_list/property_list_property_value.cpp b/tests/extension/oneapi_property_list/property_list_property_value.cpp new file mode 100644 index 000000000..da0f6940f --- /dev/null +++ b/tests/extension/oneapi_property_list/property_list_property_value.cpp @@ -0,0 +1,113 @@ +/******************************************************************************* +// +// SYCL 2020 Extension Conformance Test +// +// Provides test for sycl::ext::oneapi::property_value +// +*******************************************************************************/ + +#include "../../common/common.h" +#include + +#define TEST_NAME property_list_property_value + +namespace TEST_NAMESPACE { + +using namespace sycl_cts; + +// to check if class has member value +template +struct member_value : std::false_type {}; + +template +struct member_value : std::true_type {}; + +// to check if class has member value_t +template +struct member_type_value_t : std::false_type {}; + +template +struct member_type_value_t + : std::true_type {}; + +#if defined(SYCL_EXT_ONEAPI_PROPERTY_LIST) && \ + defined(SYCL_EXT_ONEAPI_DEVICE_GLOBAL) + +using namespace sycl::ext::oneapi; + +template +void check(util::logger &log, T prop_value, host_access::access access, + std::string access_string) { + if (prop_value.value != access) { + FAIL(log, "member value for " + access_string + " is incorrect"); + } + + if (!std::is_same_v) { + FAIL(log, "member type value_t for " + access_string + " is incorrect"); + } +} +#endif +/** test sycl::ext::oneapi::property_value interface + */ +class TEST_NAME : public util::test_base { + public: + /** return information about this test + */ + void get_info(test_base::info &out) const override { + set_test_info(out, TOSTRING(TEST_NAME), TEST_FILE); + } + + /** execute the test + */ + void run(util::logger &log) override { +#if !defined(SYCL_EXT_ONEAPI_PROPERTY_LIST) + log.skip("SYCL_EXT_ONEAPI_PROPERTY_LIST is not defined, test is skipped"); +#elif !defined(SYCL_EXT_ONEAPI_DEVICE_GLOBAL) + log.skip("SYCL_EXT_ONEAPI_DEVICE_GLOBAL is not defined, test is skipped"); +#else + { + property_list props{device_image_scope_v}; + auto prop_value = props.get_property(); + + property_list props_read{host_access_v}; + auto prop_value_read = props_read.get_property(); + + property_list props_write{host_access_v}; + auto prop_value_write = props_write.get_property(); + + property_list props_read_write{ + host_access_v}; + auto prop_value_read_write = props_read_write.get_property(); + + property_list props_none{host_access_v}; + auto prop_value_none = props_none.get_property(); + + if (member_value::value) { + FAIL(log, + "member value is available for property value without parameter"); + } + + if (member_type_value_t::value) { + FAIL(log, + "member type value_t is available for property value without " + "parameter"); + } + + check(log, prop_value_read, host_access::access::read, + "host_access::access::read"); + check(log, prop_value_write, host_access::access::write, + "host_access::access::write"); + check(log, prop_value_read_write, host_access::access::read_write, + "host_access::access::read_write"); + check(log, prop_value_none, host_access::access::none, + "host_access::access::none"); + } +#endif + } +}; + +// register this test with the test_collection. +util::test_proxy proxy; + +} /* namespace TEST_NAMESPACE */