From 91f0ce64779cca20ecbd97d7c355ee7d805df8b4 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Mon, 2 Sep 2024 07:08:50 -0700 Subject: [PATCH 01/27] Add def based check for queue Signed-off-by: Tikhomirova, Kseniya --- sycl/include/sycl/detail/property_helper.hpp | 3 ++- .../sycl/detail/property_list_base.hpp | 19 ++++++++++++++ sycl/include/sycl/property_list.hpp | 2 ++ sycl/source/detail/queue_impl.cpp | 26 +++++++++++++++++++ sycl/source/detail/queue_impl.hpp | 4 +++ 5 files changed, 53 insertions(+), 1 deletion(-) diff --git a/sycl/include/sycl/detail/property_helper.hpp b/sycl/include/sycl/detail/property_helper.hpp index 544e776a21e1e..418380a36c825 100644 --- a/sycl/include/sycl/detail/property_helper.hpp +++ b/sycl/include/sycl/detail/property_helper.hpp @@ -88,6 +88,7 @@ class PropertyWithDataBase { PropertyWithDataBase(int ID) : MID(ID) {} bool isSame(int ID) const { return ID == MID; } virtual ~PropertyWithDataBase() = default; + int getKind() const { return MID; } private: int MID = -1; @@ -99,7 +100,7 @@ class PropertyWithDataBase { template class PropertyWithData : public PropertyWithDataBase { public: PropertyWithData() : PropertyWithDataBase(ID) {} - static int getKind() { return ID; } + static constexpr int getKind() { return ID; } }; } // namespace detail diff --git a/sycl/include/sycl/detail/property_list_base.hpp b/sycl/include/sycl/detail/property_list_base.hpp index 9b1447492d902..6d4ea3f08b9f9 100644 --- a/sycl/include/sycl/detail/property_list_base.hpp +++ b/sycl/include/sycl/detail/property_list_base.hpp @@ -126,6 +126,25 @@ class PropertyListBase { } } + void checkPropsAndThrow(std::function FunctionForDataless, + std::function FunctionForData) const { + static const auto ErrorCode = sycl::make_error_code(errc::invalid); + static const auto ErrorMessage = "The property list contains property " + "unsupported for the current object"; + + for (int PropertyKind = 0; + PropertyKind < static_cast(MDataLessProps.size()); + PropertyKind++) { + if (MDataLessProps[PropertyKind] && !FunctionForDataless(PropertyKind)) + throw sycl::exception(ErrorCode, ErrorMessage); + } + + for (const auto &PropertyItem : MPropsWithData) { + if (!FunctionForData(PropertyItem->getKind())) + throw sycl::exception(ErrorCode, ErrorMessage); + } + } + // Stores enabled/disabled for simple properties std::bitset MDataLessProps; // Stores shared_ptrs to complex properties diff --git a/sycl/include/sycl/property_list.hpp b/sycl/include/sycl/property_list.hpp index 714aed9b9b049..a58cb26995c91 100644 --- a/sycl/include/sycl/property_list.hpp +++ b/sycl/include/sycl/property_list.hpp @@ -64,6 +64,8 @@ class property_list : protected detail::PropertyListBase { template operator ext::oneapi::accessor_property_list(); + using PropertyListBase::checkPropsAndThrow; + private: property_list( std::bitset DataLessProps, diff --git a/sycl/source/detail/queue_impl.cpp b/sycl/source/detail/queue_impl.cpp index 8b4e51f340aed..ffbec780b25e6 100644 --- a/sycl/source/detail/queue_impl.cpp +++ b/sycl/source/detail/queue_impl.cpp @@ -807,6 +807,32 @@ void queue_impl::doUnenqueuedCommandCleanup( tryToCleanup(MDefaultGraphDeps); } +void queue_impl::verifyProps(const property_list &Props) const { + auto CheckDataLessProperties = [](int PropertyKind) { +#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \ + case NS_QUALIFIER::PROP_NAME::getKind(): \ + return true; +#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) + switch (PropertyKind) { +#include + default: + return false; + } + }; + auto CheckPropertiesWithData = [](int PropertyKind) { +#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) +#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) \ + case NS_QUALIFIER::PROP_NAME::getKind(): \ + return true; + switch (PropertyKind) { +#include + default: + return false; + } + }; + Props.checkPropsAndThrow(CheckDataLessProperties, CheckPropertiesWithData); +} + } // namespace detail } // namespace _V1 } // namespace sycl diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index c5777c368145d..1913ec88d8d1f 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -114,6 +114,7 @@ class queue_impl { MIsProfilingEnabled(has_property()), MQueueID{ MNextAvailableQueueID.fetch_add(1, std::memory_order_relaxed)} { + verifyProps(PropList); if (has_property()) { if (has_property()) throw sycl::exception(make_error_code(errc::invalid), @@ -249,6 +250,7 @@ class queue_impl { MDiscardEvents( has_property()), MIsProfilingEnabled(has_property()) { + verifyProps(PropList); queue_impl_interop(UrQueue); } @@ -984,6 +986,8 @@ class queue_impl { std::mutex MMissedCleanupRequestsMtx; friend class sycl::ext::oneapi::experimental::detail::node_impl; + + void verifyProps(const property_list &Props) const; }; } // namespace detail From ae0b1d46a454a57803b4652444a7f3d85dc0789d Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Thu, 29 Aug 2024 10:06:09 -0700 Subject: [PATCH 02/27] add test for queue Signed-off-by: Tikhomirova, Kseniya --- sycl/unittests/queue/CMakeLists.txt | 1 + sycl/unittests/queue/Properties.cpp | 90 +++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 sycl/unittests/queue/Properties.cpp diff --git a/sycl/unittests/queue/CMakeLists.txt b/sycl/unittests/queue/CMakeLists.txt index 5317d82354f77..07a5601c359c6 100644 --- a/sycl/unittests/queue/CMakeLists.txt +++ b/sycl/unittests/queue/CMakeLists.txt @@ -8,4 +8,5 @@ add_sycl_unittest(QueueTests OBJECT ShortcutFunctions.cpp InOrderQueue.cpp InteropRetain.cpp + Properties.cpp ) diff --git a/sycl/unittests/queue/Properties.cpp b/sycl/unittests/queue/Properties.cpp new file mode 100644 index 0000000000000..af7c6c941ef08 --- /dev/null +++ b/sycl/unittests/queue/Properties.cpp @@ -0,0 +1,90 @@ +//==-------- Properties.cpp --- check properties handling in RT --- --------==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include + +template void DatalessQueuePropertyCheck() { + try { + sycl::queue Queue{PropertyType{}}; + ASSERT_TRUE(Queue.has_property()); + Queue.get_property(); + // no explicit checks, we expect no exception to be thrown + } catch (...) { + FAIL(); + } +} + +TEST(QueueProperties, ValidDatalessProperties) { + sycl::unittest::UrMock<> Mock; + DatalessQueuePropertyCheck(); + DatalessQueuePropertyCheck(); + DatalessQueuePropertyCheck< + sycl::ext::oneapi::property::queue::discard_events>(); + DatalessQueuePropertyCheck< + sycl::ext::oneapi::property::queue::priority_normal>(); + DatalessQueuePropertyCheck< + sycl::ext::oneapi::property::queue::priority_low>(); + DatalessQueuePropertyCheck< + sycl::ext::oneapi::property::queue::priority_high>(); + DatalessQueuePropertyCheck< + sycl::ext::intel::property::queue::no_immediate_command_list>(); + DatalessQueuePropertyCheck< + sycl::ext::intel::property::queue::immediate_command_list>(); + DatalessQueuePropertyCheck< + sycl::ext::oneapi::cuda::property::queue::use_default_stream>(); +} + +inline ur_result_t urDeviceGetInfoRedefined(void *pParams) { + auto params = reinterpret_cast(pParams); + switch (*params->ppropName) { + case UR_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES: { + if (*params->ppPropValue) + *static_cast(*params->ppPropValue) = 8; + if (*params->ppPropSizeRet) + **params->ppPropSizeRet = sizeof(int32_t); + return UR_RESULT_SUCCESS; + } + default: + return UR_RESULT_SUCCESS; + } +} + +TEST(QueueProperties, ValidPropertyComputeIndex) { + sycl::unittest::UrMock<> Mock; + mock::getCallbacks().set_after_callback("urDeviceGetInfo", + &urDeviceGetInfoRedefined); + try { + sycl::queue Queue{sycl::ext::intel::property::queue::compute_index{1}}; + ASSERT_TRUE( + Queue.has_property()); + EXPECT_EQ( + Queue.get_property() + .get_index(), + 1); + // no explicit checks, we expect no exception to be thrown + } catch (...) { + FAIL(); + } +} + +TEST(QueueProperties, SetUnsupportedParam) { + sycl::unittest::UrMock<> Mock; + try { + sycl::queue Queue{sycl::property::image::use_host_ptr{}}; + } catch (sycl::exception &e) { + EXPECT_EQ(e.code(), sycl::errc::invalid); + EXPECT_STREQ(e.what(), "The property list contains property unsupported " + "for the current object"); + return; + } + + FAIL() << "Test must exit in exception handler. Exception is not thrown."; +} From 6e673acec03b839cb098117f38f8baa6ae25f49f Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Mon, 2 Sep 2024 09:01:12 -0700 Subject: [PATCH 03/27] fix code-review comments Signed-off-by: Tikhomirova, Kseniya --- sycl/include/sycl/property_list.hpp | 21 +++++++++++++++++++-- sycl/source/detail/queue_impl.cpp | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/sycl/include/sycl/property_list.hpp b/sycl/include/sycl/property_list.hpp index a58cb26995c91..15d6a30857d35 100644 --- a/sycl/include/sycl/property_list.hpp +++ b/sycl/include/sycl/property_list.hpp @@ -23,6 +23,10 @@ inline namespace _V1 { namespace ext::oneapi { template class accessor_property_list; } // namespace ext::oneapi +namespace detail +{ + class PropertyValidator; +} //namespace detail /// Objects of the property_list class are containers for the SYCL properties /// @@ -64,17 +68,30 @@ class property_list : protected detail::PropertyListBase { template operator ext::oneapi::accessor_property_list(); - using PropertyListBase::checkPropsAndThrow; - private: property_list( std::bitset DataLessProps, std::vector> PropsWithData) : sycl::detail::PropertyListBase(DataLessProps, PropsWithData) {} + template friend class ext::oneapi::accessor_property_list; + friend class detail::PropertyValidator; }; +namespace detail +{ + class PropertyValidator + { + public: + static void checkPropsAndThrow(const property_list& PropList, std::function FunctionForDataless, + std::function FunctionForData) + { + PropList.checkPropsAndThrow(FunctionForDataless, FunctionForData); + } + }; +} //namespace detail + } // namespace _V1 } // namespace sycl diff --git a/sycl/source/detail/queue_impl.cpp b/sycl/source/detail/queue_impl.cpp index ffbec780b25e6..f39fab875ca74 100644 --- a/sycl/source/detail/queue_impl.cpp +++ b/sycl/source/detail/queue_impl.cpp @@ -830,7 +830,7 @@ void queue_impl::verifyProps(const property_list &Props) const { return false; } }; - Props.checkPropsAndThrow(CheckDataLessProperties, CheckPropertiesWithData); + detail::PropertyValidator::checkPropsAndThrow(Props, CheckDataLessProperties, CheckPropertiesWithData); } } // namespace detail From 34d65d91b947be83493026454dd0287caffa3da0 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Mon, 2 Sep 2024 09:26:43 -0700 Subject: [PATCH 04/27] fix format Signed-off-by: Tikhomirova, Kseniya --- sycl/include/sycl/property_list.hpp | 30 +++++++++++++---------------- sycl/source/detail/queue_impl.cpp | 3 ++- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/sycl/include/sycl/property_list.hpp b/sycl/include/sycl/property_list.hpp index 15d6a30857d35..59620f56a707c 100644 --- a/sycl/include/sycl/property_list.hpp +++ b/sycl/include/sycl/property_list.hpp @@ -23,10 +23,9 @@ inline namespace _V1 { namespace ext::oneapi { template class accessor_property_list; } // namespace ext::oneapi -namespace detail -{ - class PropertyValidator; -} //namespace detail +namespace detail { +class PropertyValidator; +} // namespace detail /// Objects of the property_list class are containers for the SYCL properties /// @@ -74,24 +73,21 @@ class property_list : protected detail::PropertyListBase { std::vector> PropsWithData) : sycl::detail::PropertyListBase(DataLessProps, PropsWithData) {} - template friend class ext::oneapi::accessor_property_list; friend class detail::PropertyValidator; }; -namespace detail -{ - class PropertyValidator - { - public: - static void checkPropsAndThrow(const property_list& PropList, std::function FunctionForDataless, - std::function FunctionForData) - { - PropList.checkPropsAndThrow(FunctionForDataless, FunctionForData); - } - }; -} //namespace detail +namespace detail { +class PropertyValidator { +public: + static void checkPropsAndThrow(const property_list &PropList, + std::function FunctionForDataless, + std::function FunctionForData) { + PropList.checkPropsAndThrow(FunctionForDataless, FunctionForData); + } +}; +} // namespace detail } // namespace _V1 } // namespace sycl diff --git a/sycl/source/detail/queue_impl.cpp b/sycl/source/detail/queue_impl.cpp index f39fab875ca74..d225e90014337 100644 --- a/sycl/source/detail/queue_impl.cpp +++ b/sycl/source/detail/queue_impl.cpp @@ -830,7 +830,8 @@ void queue_impl::verifyProps(const property_list &Props) const { return false; } }; - detail::PropertyValidator::checkPropsAndThrow(Props, CheckDataLessProperties, CheckPropertiesWithData); + detail::PropertyValidator::checkPropsAndThrow(Props, CheckDataLessProperties, + CheckPropertiesWithData); } } // namespace detail From 05b73982b29ac292d94633e15ed91a6e55ef4253 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Mon, 2 Sep 2024 10:51:10 -0700 Subject: [PATCH 05/27] add check to buffer & image Signed-off-by: Tikhomirova, Kseniya --- .../sycl/properties/buffer_properties.def | 19 ++ .../sycl/properties/buffer_properties.hpp | 49 ++--- .../sycl/properties/image_properties.def | 16 ++ .../sycl/properties/image_properties.hpp | 65 +++---- sycl/source/detail/buffer_impl.cpp | 29 +++ sycl/source/detail/buffer_impl.hpp | 11 +- sycl/source/detail/image_impl.cpp | 27 +++ sycl/source/detail/image_impl.hpp | 11 ++ sycl/unittests/buffer/CMakeLists.txt | 1 + sycl/unittests/buffer/Properties.cpp | 181 ++++++++++++++++++ 10 files changed, 335 insertions(+), 74 deletions(-) create mode 100644 sycl/include/sycl/properties/buffer_properties.def create mode 100644 sycl/include/sycl/properties/image_properties.def create mode 100644 sycl/unittests/buffer/Properties.cpp diff --git a/sycl/include/sycl/properties/buffer_properties.def b/sycl/include/sycl/properties/buffer_properties.def new file mode 100644 index 0000000000000..779c3454fe518 --- /dev/null +++ b/sycl/include/sycl/properties/buffer_properties.def @@ -0,0 +1,19 @@ +// --*- c++ -*--- +#ifndef __SYCL_DATA_LESS_PROP +#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) +#endif +#ifndef __SYCL_MANUALLY_DEFINED_PROP +#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) +#endif + +__SYCL_DATA_LESS_PROP(property::buffer, use_host_ptr, BufferUseHostPtr) +__SYCL_DATA_LESS_PROP(ext::oneapi::property::buffer, use_pinned_host_memory, BufferUsePinnedHostMemory) + +// Contains data field, defined explicitly. +__SYCL_MANUALLY_DEFINED_PROP(property::buffer, use_mutex) +__SYCL_MANUALLY_DEFINED_PROP(property::buffer, context_bound) +__SYCL_MANUALLY_DEFINED_PROP(property::buffer, mem_channel) +__SYCL_MANUALLY_DEFINED_PROP(property::buffer::detail, buffer_location) + +#undef __SYCL_DATA_LESS_PROP +#undef __SYCL_MANUALLY_DEFINED_PROP diff --git a/sycl/include/sycl/properties/buffer_properties.hpp b/sycl/include/sycl/properties/buffer_properties.hpp index d904597944eec..d41ccaa656a49 100644 --- a/sycl/include/sycl/properties/buffer_properties.hpp +++ b/sycl/include/sycl/properties/buffer_properties.hpp @@ -19,11 +19,14 @@ namespace sycl { inline namespace _V1 { +#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \ + namespace NS_QUALIFIER { \ + class PROP_NAME \ + : public sycl::detail::DataLessProperty {}; \ + } +#include namespace property::buffer { -class use_host_ptr : public detail::DataLessProperty { -}; - class use_mutex : public detail::PropertyWithData { public: use_mutex(std::mutex &MutexRef) : MMutex(MutexRef) {} @@ -69,41 +72,19 @@ class buffer_location } // namespace detail } // namespace property::buffer -namespace ext::oneapi::property::buffer { - -class use_pinned_host_memory : public sycl::detail::DataLessProperty< - sycl::detail::BufferUsePinnedHostMemory> {}; -} // namespace ext::oneapi::property::buffer - // Forward declaration template class buffer; -// Buffer property trait specializations -template -struct is_property_of> - : std::true_type {}; -template -struct is_property_of> - : std::true_type {}; -template -struct is_property_of> - : std::true_type {}; -template -struct is_property_of> - : std::true_type {}; -template -struct is_property_of> - : std::true_type {}; -template -struct is_property_of> - : std::true_type {}; +#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) \ + template \ + struct is_property_of> \ + : std::true_type {}; +#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \ + __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) + +#include } // namespace _V1 } // namespace sycl diff --git a/sycl/include/sycl/properties/image_properties.def b/sycl/include/sycl/properties/image_properties.def new file mode 100644 index 0000000000000..9e5c02a346e12 --- /dev/null +++ b/sycl/include/sycl/properties/image_properties.def @@ -0,0 +1,16 @@ +// --*- c++ -*--- +#ifndef __SYCL_DATA_LESS_PROP +#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) +#endif +#ifndef __SYCL_MANUALLY_DEFINED_PROP +#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) +#endif + +__SYCL_DATA_LESS_PROP(property::image, use_host_ptr, ImageUseHostPtr) + +// Contains data field, defined explicitly. +__SYCL_MANUALLY_DEFINED_PROP(property::image, use_mutex) +__SYCL_MANUALLY_DEFINED_PROP(property::image, context_bound) + +#undef __SYCL_DATA_LESS_PROP +#undef __SYCL_MANUALLY_DEFINED_PROP diff --git a/sycl/include/sycl/properties/image_properties.hpp b/sycl/include/sycl/properties/image_properties.hpp index 43e6a22d81713..748bb935058ca 100644 --- a/sycl/include/sycl/properties/image_properties.hpp +++ b/sycl/include/sycl/properties/image_properties.hpp @@ -18,10 +18,14 @@ namespace sycl { inline namespace _V1 { -namespace property::image { -class use_host_ptr : public detail::DataLessProperty { -}; +#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \ + namespace NS_QUALIFIER { \ + class PROP_NAME \ + : public sycl::detail::DataLessProperty {}; \ + } +#include +namespace property::image { class use_mutex : public detail::PropertyWithData { public: use_mutex(std::mutex &MutexRef) : MMutex(MutexRef) {} @@ -50,41 +54,30 @@ template class sampled_image; template class unsampled_image; // SYCL 1.2.1 image property trait specializations -template -struct is_property_of> : std::true_type {}; -template -struct is_property_of> - : std::true_type {}; -template -struct is_property_of> : std::true_type {}; +#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) \ + template \ + struct is_property_of < NS_QUALIFIER::PROP_NAME, \ + image : std::true_type {}; +#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \ + __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) +#include // SYCL 2020 image property trait specializations -template -struct is_property_of> : std::true_type { -}; -template -struct is_property_of> : std::true_type { -}; -template -struct is_property_of> : std::true_type { -}; -template -struct is_property_of> - : std::true_type {}; -template -struct is_property_of> - : std::true_type {}; -template -struct is_property_of> - : std::true_type {}; +#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) \ + template \ + struct is_property_of < NS_QUALIFIER::PROP_NAME, \ + sampled_image : std::true_type {}; +#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \ + __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) +#include + +#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) \ + template \ + struct is_property_of < NS_QUALIFIER::PROP_NAME, \ + unsampled_image : std::true_type {}; +#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \ + __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) +#include } // namespace _V1 } // namespace sycl diff --git a/sycl/source/detail/buffer_impl.cpp b/sycl/source/detail/buffer_impl.cpp index 1a7c7825a0417..c52b0f028a53b 100644 --- a/sycl/source/detail/buffer_impl.cpp +++ b/sycl/source/detail/buffer_impl.cpp @@ -13,6 +13,7 @@ #include #include #include +#include namespace sycl { inline namespace _V1 { @@ -99,6 +100,34 @@ buffer_impl::getNativeVector(backend BackendName) const { addInteropObject(Handles); return Handles; } + +void buffer_impl::verifyProps(const property_list &Props) const { + auto CheckDataLessProperties = [](int PropertyKind) { +#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \ + case NS_QUALIFIER::PROP_NAME::getKind(): \ + return true; +#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) + switch (PropertyKind) { +#include + default: + return false; + } + }; + auto CheckPropertiesWithData = [](int PropertyKind) { +#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) +#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) \ + case NS_QUALIFIER::PROP_NAME::getKind(): \ + return true; + switch (PropertyKind) { +#include + default: + return false; + } + }; + detail::PropertyValidator::checkPropsAndThrow(Props, CheckDataLessProperties, + CheckPropertiesWithData); +} + } // namespace detail } // namespace _V1 } // namespace sycl diff --git a/sycl/source/detail/buffer_impl.hpp b/sycl/source/detail/buffer_impl.hpp index 3c81af88be1db..f7a7e0999344d 100644 --- a/sycl/source/detail/buffer_impl.hpp +++ b/sycl/source/detail/buffer_impl.hpp @@ -46,7 +46,7 @@ class buffer_impl final : public SYCLMemObjT { buffer_impl(size_t SizeInBytes, size_t, const property_list &Props, std::unique_ptr Allocator) : BaseT(SizeInBytes, Props, std::move(Allocator)) { - + verifyProps(Props); if (Props.has_property()) throw sycl::exception( make_error_code(errc::invalid), @@ -57,7 +57,7 @@ class buffer_impl final : public SYCLMemObjT { const property_list &Props, std::unique_ptr Allocator) : BaseT(SizeInBytes, Props, std::move(Allocator)) { - + verifyProps(Props); if (Props.has_property< sycl::ext::oneapi::property::buffer::use_pinned_host_memory>()) throw sycl::exception( @@ -71,7 +71,7 @@ class buffer_impl final : public SYCLMemObjT { const property_list &Props, std::unique_ptr Allocator) : BaseT(SizeInBytes, Props, std::move(Allocator)) { - + verifyProps(Props); if (Props.has_property< sycl::ext::oneapi::property::buffer::use_pinned_host_memory>()) throw sycl::exception( @@ -86,7 +86,7 @@ class buffer_impl final : public SYCLMemObjT { const property_list &Props, std::unique_ptr Allocator, bool IsConstPtr) : BaseT(SizeInBytes, Props, std::move(Allocator)) { - + verifyProps(Props); if (Props.has_property< sycl::ext::oneapi::property::buffer::use_pinned_host_memory>()) throw sycl::exception( @@ -103,6 +103,7 @@ class buffer_impl final : public SYCLMemObjT { std::unique_ptr Allocator, bool IsConstPtr) : BaseT(SizeInBytes, Props, std::move(Allocator)) { + verifyProps(Props); if (Props.has_property< sycl::ext::oneapi::property::buffer::use_pinned_host_memory>()) throw sycl::exception( @@ -152,6 +153,8 @@ class buffer_impl final : public SYCLMemObjT { void addInteropObject(std::vector &Handles) const; std::vector getNativeVector(backend BackendName) const; + + void verifyProps(const property_list &Props) const; }; } // namespace detail diff --git a/sycl/source/detail/image_impl.cpp b/sycl/source/detail/image_impl.cpp index c93b3d59ce751..859eecfaf0306 100644 --- a/sycl/source/detail/image_impl.cpp +++ b/sycl/source/detail/image_impl.cpp @@ -482,6 +482,33 @@ void image_impl::unsampledImageDestructorNotification(void *UserObj) { XPTIRegistry::unsampledImageDestructorNotification(UserObj); } +void image_impl::verifyProps(const property_list &Props) const { + auto CheckDataLessProperties = [](int PropertyKind) { +#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \ + case NS_QUALIFIER::PROP_NAME::getKind(): \ + return true; +#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) + switch (PropertyKind) { +#include + default: + return false; + } + }; + auto CheckPropertiesWithData = [](int PropertyKind) { +#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) +#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) \ + case NS_QUALIFIER::PROP_NAME::getKind(): \ + return true; + switch (PropertyKind) { +#include + default: + return false; + } + }; + detail::PropertyValidator::checkPropsAndThrow(Props, CheckDataLessProperties, + CheckPropertiesWithData); +} + } // namespace detail } // namespace _V1 } // namespace sycl diff --git a/sycl/source/detail/image_impl.hpp b/sycl/source/detail/image_impl.hpp index 008d86df2799e..c2e8366f2dc31 100644 --- a/sycl/source/detail/image_impl.hpp +++ b/sycl/source/detail/image_impl.hpp @@ -102,6 +102,7 @@ class image_impl final : public SYCLMemObjT { MRange(ImageRange), MOrder(Order), MType(Type), MNumChannels(getImageNumberChannels(MOrder)), MElementSize(getImageElementSize(MNumChannels, MType)) { + verifyProps(PropList); setPitches(); BaseT::handleHostData(HData, detail::getNextPowerOfTwo(MElementSize)); } @@ -114,6 +115,7 @@ class image_impl final : public SYCLMemObjT { MRange(ImageRange), MOrder(Order), MType(Type), MNumChannels(getImageNumberChannels(MOrder)), MElementSize(getImageElementSize(MNumChannels, MType)) { + verifyProps(PropList); setPitches(); BaseT::handleHostData(HData, detail::getNextPowerOfTwo(MElementSize)); } @@ -126,6 +128,7 @@ class image_impl final : public SYCLMemObjT { MRange(ImageRange), MOrder(Order), MType(Type), MNumChannels(getImageNumberChannels(MOrder)), MElementSize(getImageElementSize(MNumChannels, MType)) { + verifyProps(PropList); setPitches(Pitch); BaseT::handleHostData(HData, detail::getNextPowerOfTwo(MElementSize)); } @@ -139,6 +142,7 @@ class image_impl final : public SYCLMemObjT { MRange(ImageRange), MOrder(Order), MType(Type), MNumChannels(getImageNumberChannels(MOrder)), MElementSize(getImageElementSize(MNumChannels, MType)) { + verifyProps(PropList); setPitches(); BaseT::handleHostData(std::const_pointer_cast(HData), detail::getNextPowerOfTwo(MElementSize), IsConstPtr); @@ -153,6 +157,7 @@ class image_impl final : public SYCLMemObjT { MRange(ImageRange), MOrder(Order), MType(Type), MNumChannels(getImageNumberChannels(MOrder)), MElementSize(getImageElementSize(MNumChannels, MType)) { + verifyProps(PropList); setPitches(Pitch); BaseT::handleHostData(std::const_pointer_cast(HData), detail::getNextPowerOfTwo(MElementSize), IsConstPtr); @@ -168,6 +173,7 @@ class image_impl final : public SYCLMemObjT { MNumChannels(getImageNumberChannels(MOrder)), MElementSize(getImageElementSize(MNumChannels, MType)), MSampler(Sampler) { + verifyProps(PropList); setPitches(); BaseT::handleHostData(HData, detail::getNextPowerOfTwo(MElementSize)); } @@ -182,6 +188,7 @@ class image_impl final : public SYCLMemObjT { MNumChannels(getImageNumberChannels(MOrder)), MElementSize(getImageElementSize(MNumChannels, MType)), MSampler(Sampler) { + verifyProps(PropList); setPitches(Pitch); BaseT::handleHostData(HData, detail::getNextPowerOfTwo(MElementSize)); } @@ -196,6 +203,7 @@ class image_impl final : public SYCLMemObjT { MNumChannels(getImageNumberChannels(MOrder)), MElementSize(getImageElementSize(MNumChannels, MType)), MSampler(Sampler) { + verifyProps(PropList); setPitches(); BaseT::handleHostData(std::const_pointer_cast(HData), detail::getNextPowerOfTwo(MElementSize), @@ -213,6 +221,7 @@ class image_impl final : public SYCLMemObjT { MNumChannels(getImageNumberChannels(MOrder)), MElementSize(getImageElementSize(MNumChannels, MType)), MSampler(Sampler) { + verifyProps(PropList); setPitches(Pitch); BaseT::handleHostData(std::const_pointer_cast(HData), detail::getNextPowerOfTwo(MElementSize), @@ -341,6 +350,8 @@ class image_impl final : public SYCLMemObjT { // Image may carry a 2020 sampler. std::optional MSampler = std::nullopt; + + void verifyProps(const property_list &Props) const; }; } // namespace detail } // namespace _V1 diff --git a/sycl/unittests/buffer/CMakeLists.txt b/sycl/unittests/buffer/CMakeLists.txt index 4f520dfe60879..744ad2ef12ad6 100644 --- a/sycl/unittests/buffer/CMakeLists.txt +++ b/sycl/unittests/buffer/CMakeLists.txt @@ -6,4 +6,5 @@ add_sycl_unittest(BufferTests OBJECT MemChannel.cpp KernelArgMemObj.cpp SubbufferLargeSize.cpp + Properties.cpp ) diff --git a/sycl/unittests/buffer/Properties.cpp b/sycl/unittests/buffer/Properties.cpp new file mode 100644 index 0000000000000..367fbcf95297d --- /dev/null +++ b/sycl/unittests/buffer/Properties.cpp @@ -0,0 +1,181 @@ +//==-------- Properties.cpp --- check properties handling in RT --- --------==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +TEST(BufferProps, ValidPropsHostPtr) { + try { + int HostPtr[1]; + sycl::buffer Buf{HostPtr, 1, + sycl::property::buffer::use_host_ptr{}}; + // no explicit checks, we expect no exception to be thrown + } catch (...) { + FAIL(); + } +} + +TEST(BufferProps, ValidPropsContextBound) { + try { + sycl::unittest::UrMock<> Mock; + sycl::context Context; + sycl::buffer Buf{1, sycl::property::buffer::context_bound{Context}}; + // no explicit checks, we expect no exception to be thrown + } catch (...) { + FAIL(); + } +} + +TEST(BufferProps, ValidPropsMutex) { + try { + std::mutex Mutex; + sycl::buffer Buf{1, sycl::property::buffer::use_mutex{Mutex}}; + // no explicit checks, we expect no exception to be thrown + } catch (...) { + FAIL(); + } +} + +TEST(BufferProps, ValidPropsPinnedHostMem) { + try { + sycl::buffer Buf( + 1, {sycl::ext::oneapi::property::buffer::use_pinned_host_memory()}); + // no explicit checks, we expect no exception to be thrown + } catch (...) { + FAIL(); + } +} + +TEST(BufferProps, ValidPropsMemChannel) { + try { + sycl::buffer Buf(1, sycl::property::buffer::mem_channel{1}); + // no explicit checks, we expect no exception to be thrown + } catch (...) { + FAIL(); + } +} + +TEST(BufferProps, SetAndQueryMatch) { + try { + sycl::unittest::UrMock<> Mock; + std::mutex Mutex; + sycl::context Context; + int HostPtr[1]; + + sycl::buffer buf{HostPtr, + 1, + {sycl::property::buffer::use_host_ptr{}, + sycl::property::buffer::context_bound{Context}, + sycl::property::buffer::use_mutex{Mutex}}}; + + ASSERT_TRUE(buf.has_property()); + EXPECT_EQ( + buf.get_property().get_context(), + Context); + ASSERT_TRUE(buf.has_property()); + EXPECT_EQ( + buf.get_property().get_mutex_ptr(), + &Mutex); + EXPECT_TRUE(buf.has_property()); + // check some random not supported and not sent param + EXPECT_FALSE(buf.has_property()); + } catch (...) { + FAIL(); + } +} + +TEST(BufferProps, SetUnsupportedParam) { + try { + sycl::buffer buf{1, {sycl::property::image::use_host_ptr{}}}; + } catch (sycl::exception &e) { + EXPECT_EQ(e.code(), sycl::errc::invalid); + EXPECT_STREQ(e.what(), "The property list contains property unsupported " + "for the current object"); + return; + } + + FAIL() << "Test must exit in exception handler. Exception is not thrown."; +} + +TEST(ImageProps, ValidPropsHostPtr) { + try { + constexpr size_t ElementsCount = 4; + constexpr size_t ChannelsCount = 4; + float InitValue[ElementsCount * ChannelsCount]; + sycl::image<1> Image(&InitValue, sycl::image_channel_order::rgba, + sycl::image_channel_type::fp32, + sycl::range<1>(ElementsCount), + sycl::property::image::use_host_ptr{}); + // no explicit checks, we expect no exception to be thrown + } catch (...) { + FAIL(); + } +} + +TEST(ImageProps, ValidPropsContextBound) { + try { + sycl::unittest::UrMock<> Mock; + sycl::context Context; + constexpr size_t ElementsCount = 4; + sycl::image<1> Image(sycl::image_channel_order::rgba, + sycl::image_channel_type::fp32, + sycl::range<1>(ElementsCount), + sycl::property::image::context_bound{Context}); + // no explicit checks, we expect no exception to be thrown + } catch (...) { + FAIL(); + } +} + +TEST(ImageProps, ValidPropsMutex) { + try { + std::mutex Mutex; + constexpr size_t ElementsCount = 4; + sycl::image<1> Image( + sycl::image_channel_order::rgba, sycl::image_channel_type::fp32, + sycl::range<1>(ElementsCount), sycl::property::image::use_mutex{Mutex}); + // no explicit checks, we expect no exception to be thrown + } catch (...) { + FAIL(); + } +} + +TEST(ImageProps, SetUnsupportedParam) { + try { + std::mutex Mutex; + constexpr size_t ElementsCount = 4; + sycl::image<1> Image(sycl::image_channel_order::rgba, + sycl::image_channel_type::fp32, + sycl::range<1>(ElementsCount), + sycl::property::buffer::use_mutex{Mutex}); + } catch (sycl::exception &e) { + EXPECT_EQ(e.code(), sycl::errc::invalid); + EXPECT_STREQ(e.what(), "The property list contains property unsupported " + "for the current object"); + return; + } + + FAIL() << "Test must exit in exception handler. Exception is not thrown."; +} + +// TEST(USMAllocator, Properties) { +// sycl::unittest::UrMock<> Mock; +// try { +// sycl::queue Q; +// sycl::usm_allocator Allocator( +// Q, sycl::property::buffer::use_host_ptr{}); +// } catch (sycl::exception &e) { +// EXPECT_EQ(e.code(), sycl::errc::invalid); +// EXPECT_STREQ(e.what(), "The property list contains property unsupported " +// "for the current object"); +// return; +// } + +// FAIL() << "Test must exit in exception handler. Exception is not thrown."; +// } \ No newline at end of file From 10bd1812a15d6a32fe18ed00f9fc4d37314b7a00 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Mon, 2 Sep 2024 10:52:25 -0700 Subject: [PATCH 06/27] fix format Signed-off-by: Tikhomirova, Kseniya --- sycl/unittests/buffer/Properties.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/unittests/buffer/Properties.cpp b/sycl/unittests/buffer/Properties.cpp index 367fbcf95297d..53b4acd302bcb 100644 --- a/sycl/unittests/buffer/Properties.cpp +++ b/sycl/unittests/buffer/Properties.cpp @@ -178,4 +178,4 @@ TEST(ImageProps, SetUnsupportedParam) { // } // FAIL() << "Test must exit in exception handler. Exception is not thrown."; -// } \ No newline at end of file +// } From 87a169161e03082b0ceff68dd323ce28158d6f84 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Tue, 3 Sep 2024 02:21:59 -0700 Subject: [PATCH 07/27] fix build & format Signed-off-by: Tikhomirova, Kseniya --- sycl/include/sycl/properties/image_properties.hpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sycl/include/sycl/properties/image_properties.hpp b/sycl/include/sycl/properties/image_properties.hpp index 748bb935058ca..394ab4fd78c6f 100644 --- a/sycl/include/sycl/properties/image_properties.hpp +++ b/sycl/include/sycl/properties/image_properties.hpp @@ -56,8 +56,8 @@ template class unsampled_image; // SYCL 1.2.1 image property trait specializations #define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) \ template \ - struct is_property_of < NS_QUALIFIER::PROP_NAME, \ - image : std::true_type {}; + struct is_property_of> : std::true_type {}; #define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \ __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) #include @@ -65,16 +65,18 @@ template class unsampled_image; // SYCL 2020 image property trait specializations #define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) \ template \ - struct is_property_of < NS_QUALIFIER::PROP_NAME, \ - sampled_image : std::true_type {}; + struct is_property_of> \ + : std::true_type {}; #define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \ __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) #include #define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) \ template \ - struct is_property_of < NS_QUALIFIER::PROP_NAME, \ - unsampled_image : std::true_type {}; + struct is_property_of> \ + : std::true_type {}; #define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \ __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) #include From f3b6e394396a0f2405405f29c01b9faf63188b52 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Tue, 3 Sep 2024 03:01:06 -0700 Subject: [PATCH 08/27] add check to context Signed-off-by: Tikhomirova, Kseniya --- sycl/source/detail/context_impl.cpp | 9 +++++++++ sycl/source/detail/context_impl.hpp | 2 ++ 2 files changed, 11 insertions(+) diff --git a/sycl/source/detail/context_impl.cpp b/sycl/source/detail/context_impl.cpp index d738053302e54..ee271975f629c 100644 --- a/sycl/source/detail/context_impl.cpp +++ b/sycl/source/detail/context_impl.cpp @@ -32,6 +32,7 @@ context_impl::context_impl(const device &Device, async_handler AsyncHandler, MContext(nullptr), MPlatform(detail::getSyclObjImpl(Device.get_platform())), MPropList(PropList), MSupportBufferLocationByDevices(NotChecked) { + verifyProps(PropList); MKernelProgramCache.setContextPtr(this); } @@ -41,6 +42,7 @@ context_impl::context_impl(const std::vector Devices, : MOwnedByRuntime(true), MAsyncHandler(AsyncHandler), MDevices(Devices), MContext(nullptr), MPlatform(), MPropList(PropList), MSupportBufferLocationByDevices(NotChecked) { + verifyProps(PropList); MPlatform = detail::getSyclObjImpl(MDevices[0].get_platform()); std::vector DeviceIds; for (const auto &D : MDevices) { @@ -534,6 +536,13 @@ context_impl::getProgramForHostPipe(const device &Device, return getProgramForDevImgs(Device, ImgIdentifiers, "host_pipe"); } +void context_impl::verifyProps(const property_list &Props) const { + auto NoAllowedPropertiesCheck = [](int PropertyKind) { return false; } +}; +detail::PropertyValidator::checkPropsAndThrow(Props, NoAllowedPropertiesCheck, + NoAllowedPropertiesCheck); +} + } // namespace detail } // namespace _V1 } // namespace sycl diff --git a/sycl/source/detail/context_impl.hpp b/sycl/source/detail/context_impl.hpp index 48fb83f5807d9..557f46f76d514 100644 --- a/sycl/source/detail/context_impl.hpp +++ b/sycl/source/detail/context_impl.hpp @@ -305,6 +305,8 @@ class context_impl { std::unique_ptr> MDeviceGlobalUnregisteredData; std::mutex MDeviceGlobalUnregisteredDataMutex; + + void verifyProps(const property_list &Props) const; }; template From db53824adf2789b23b1b2cdebcbbd014166c6fef Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Thu, 29 Aug 2024 06:56:52 -0700 Subject: [PATCH 09/27] add test for context Signed-off-by: Tikhomirova, Kseniya --- sycl/unittests/context_device/Context.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sycl/unittests/context_device/Context.cpp b/sycl/unittests/context_device/Context.cpp index 3680a9de7bc97..548a909e80df8 100644 --- a/sycl/unittests/context_device/Context.cpp +++ b/sycl/unittests/context_device/Context.cpp @@ -61,3 +61,16 @@ TEST_F(ContextTest, CopyAssignmentOperator) { ASSERT_EQ(hash, std::hash()(WillContextCopy)); ASSERT_EQ(Context, WillContextCopy); } + +TEST_F(ContextTest, Properties) { + try { + sycl::context Context(sycl::property::queue::in_order{}); + } catch (sycl::exception &e) { + EXPECT_EQ(e.code(), sycl::errc::invalid); + EXPECT_STREQ(e.what(), "The property list contains property unsupported " + "for the current object"); + return; + } + + FAIL() << "Test must exit in exception handler. Exception is not thrown."; +} From c5a4eff1feb2b525120ffd4a99cc82d242a9325a Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Tue, 3 Sep 2024 03:03:49 -0700 Subject: [PATCH 10/27] fix build Signed-off-by: Tikhomirova, Kseniya --- sycl/source/detail/context_impl.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sycl/source/detail/context_impl.cpp b/sycl/source/detail/context_impl.cpp index ee271975f629c..cf51b9f9db517 100644 --- a/sycl/source/detail/context_impl.cpp +++ b/sycl/source/detail/context_impl.cpp @@ -537,10 +537,9 @@ context_impl::getProgramForHostPipe(const device &Device, } void context_impl::verifyProps(const property_list &Props) const { - auto NoAllowedPropertiesCheck = [](int PropertyKind) { return false; } -}; -detail::PropertyValidator::checkPropsAndThrow(Props, NoAllowedPropertiesCheck, - NoAllowedPropertiesCheck); + auto NoAllowedPropertiesCheck = [](int PropertyKind) { return false; }; + detail::PropertyValidator::checkPropsAndThrow(Props, NoAllowedPropertiesCheck, + NoAllowedPropertiesCheck); } } // namespace detail From d88c3f2f3da9e54e9f99f97188851d74d6656e0f Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Tue, 3 Sep 2024 03:06:20 -0700 Subject: [PATCH 11/27] add check to sampler Signed-off-by: Tikhomirova, Kseniya --- sycl/source/detail/sampler_impl.cpp | 10 +++++++++- sycl/source/detail/sampler_impl.hpp | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/sycl/source/detail/sampler_impl.cpp b/sycl/source/detail/sampler_impl.cpp index dd117814fba2c..e1be5743bc931 100644 --- a/sycl/source/detail/sampler_impl.cpp +++ b/sycl/source/detail/sampler_impl.cpp @@ -19,7 +19,9 @@ sampler_impl::sampler_impl(coordinate_normalization_mode normalizationMode, filtering_mode filteringMode, const property_list &propList) : MCoordNormMode(normalizationMode), MAddrMode(addressingMode), - MFiltMode(filteringMode), MPropList(propList) {} + MFiltMode(filteringMode), MPropList(propList) { + verifyProps(MPropList); +} sampler_impl::sampler_impl(cl_sampler clSampler, const context &syclContext) { const PluginPtr &Plugin = getSyclObjImpl(syclContext)->getPlugin(); @@ -153,6 +155,12 @@ sampler_impl::get_coordinate_normalization_mode() const { return MCoordNormMode; } +void sampler_impl::verifyProps(const property_list &Props) const { + auto NoAllowedPropertiesCheck = [](int PropertyKind) { return false; }; + detail::PropertyValidator::checkPropsAndThrow(Props, NoAllowedPropertiesCheck, + NoAllowedPropertiesCheck); +} + } // namespace detail } // namespace _V1 } // namespace sycl diff --git a/sycl/source/detail/sampler_impl.hpp b/sycl/source/detail/sampler_impl.hpp index cfa4c83b15607..2589ad9244a3a 100644 --- a/sycl/source/detail/sampler_impl.hpp +++ b/sycl/source/detail/sampler_impl.hpp @@ -55,6 +55,8 @@ class sampler_impl { addressing_mode MAddrMode; filtering_mode MFiltMode; property_list MPropList; + + void verifyProps(const property_list &Props) const; }; } // namespace detail From d83f367faa9293b8b586a80097a5a2d0ccfbc0d9 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Fri, 30 Aug 2024 04:15:29 -0700 Subject: [PATCH 12/27] add test for sampler Signed-off-by: Tikhomirova, Kseniya --- sycl/test-e2e/Basic/sampler/sampler.cpp | 16 --------------- sycl/unittests/CMakeLists.txt | 1 + sycl/unittests/sampler/CMakeLists.txt | 3 +++ sycl/unittests/sampler/Properties.cpp | 26 +++++++++++++++++++++++++ 4 files changed, 30 insertions(+), 16 deletions(-) create mode 100644 sycl/unittests/sampler/CMakeLists.txt create mode 100644 sycl/unittests/sampler/Properties.cpp diff --git a/sycl/test-e2e/Basic/sampler/sampler.cpp b/sycl/test-e2e/Basic/sampler/sampler.cpp index 738408812f098..45081127f6314 100644 --- a/sycl/test-e2e/Basic/sampler/sampler.cpp +++ b/sycl/test-e2e/Basic/sampler/sampler.cpp @@ -83,21 +83,5 @@ int main() { }); } - { - sycl::sampler Sampler( - sycl::coordinate_normalization_mode::unnormalized, - sycl::addressing_mode::clamp, sycl::filtering_mode::nearest, - sycl::property_list{sycl::property::buffer::use_host_ptr{}}); - - if (!Sampler.has_property()) { - std::cerr << "Line " << __LINE__ << ": Property was not found" - << std::endl; - return 1; - } - - sycl::property::buffer::use_host_ptr Prop = - Sampler.get_property(); - } - return 0; } diff --git a/sycl/unittests/CMakeLists.txt b/sycl/unittests/CMakeLists.txt index ec740f913ed4d..aff7f6d76b24d 100644 --- a/sycl/unittests/CMakeLists.txt +++ b/sycl/unittests/CMakeLists.txt @@ -57,3 +57,4 @@ add_subdirectory(buffer/l0_specific) if (NOT WIN32) add_subdirectory(xpti_trace) endif() +add_subdirectory(sampler) diff --git a/sycl/unittests/sampler/CMakeLists.txt b/sycl/unittests/sampler/CMakeLists.txt new file mode 100644 index 0000000000000..f26b608afa5e4 --- /dev/null +++ b/sycl/unittests/sampler/CMakeLists.txt @@ -0,0 +1,3 @@ +add_sycl_unittest(SamplerTests OBJECT + Properties.cpp +) diff --git a/sycl/unittests/sampler/Properties.cpp b/sycl/unittests/sampler/Properties.cpp new file mode 100644 index 0000000000000..d6e8d285c2910 --- /dev/null +++ b/sycl/unittests/sampler/Properties.cpp @@ -0,0 +1,26 @@ +//==-------- Properties.cpp --- check properties handling in RT --- --------==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +TEST(SamplerTest, Properties) { + try { + sycl::sampler Sampler( + sycl::coordinate_normalization_mode::unnormalized, + sycl::addressing_mode::clamp, sycl::filtering_mode::nearest, + sycl::property_list{sycl::property::buffer::use_host_ptr{}}); + } catch (sycl::exception &e) { + EXPECT_EQ(e.code(), sycl::errc::invalid); + EXPECT_STREQ(e.what(), "The property list contains property unsupported " + "for the current object"); + return; + } + + FAIL() << "Test must exit in exception handler. Exception is not thrown."; +} \ No newline at end of file From 8edf0c1b0fe6b382550f1a5299efd73f89547456 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Tue, 3 Sep 2024 03:08:23 -0700 Subject: [PATCH 13/27] add check to stream Signed-off-by: Tikhomirova, Kseniya --- sycl/source/detail/stream_impl.cpp | 7 +++++++ sycl/source/detail/stream_impl.hpp | 2 ++ 2 files changed, 9 insertions(+) diff --git a/sycl/source/detail/stream_impl.cpp b/sycl/source/detail/stream_impl.cpp index d0094c025c844..54ae19f82c586 100644 --- a/sycl/source/detail/stream_impl.cpp +++ b/sycl/source/detail/stream_impl.cpp @@ -23,6 +23,7 @@ stream_impl::stream_impl(size_t BufferSize, size_t MaxStatementSize, : BufferSize_(BufferSize), MaxStatementSize_(MaxStatementSize), PropList_(PropList), Buf_(range<1>(BufferSize + OffsetSize + 1)), FlushBuf_(range<1>(MaxStatementSize + FLUSH_BUF_OFFSET_SIZE)) { + verifyProps(PropList_); // Additional place is allocated in the stream buffer for the offset variable // and the end of line symbol. Buffers are created without host pointers so // that they are released in a deferred manner. Disable copy back on buffer @@ -97,6 +98,12 @@ void stream_impl::generateFlushCommand(handler &cgh) { }); } +void stream_impl::verifyProps(const property_list &Props) const { + auto NoAllowedPropertiesCheck = [](int PropertyKind) { return false; }; + detail::PropertyValidator::checkPropsAndThrow(Props, NoAllowedPropertiesCheck, + NoAllowedPropertiesCheck); +} + } // namespace detail } // namespace _V1 } // namespace sycl diff --git a/sycl/source/detail/stream_impl.hpp b/sycl/source/detail/stream_impl.hpp index 87edfdec0bd90..69f85acffb6f4 100644 --- a/sycl/source/detail/stream_impl.hpp +++ b/sycl/source/detail/stream_impl.hpp @@ -67,6 +67,8 @@ class stream_impl { // Additinonal memory is allocated in the beginning of the stream buffer for // 2 variables: offset in the stream buffer and offset in the flush buffer. static const size_t OffsetSize = 2 * sizeof(unsigned); + + void verifyProps(const property_list &Props) const; }; } // namespace detail From a9c8c396fdb14e1cd9786fe94e458b9738dc6f5b Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Thu, 29 Aug 2024 07:02:43 -0700 Subject: [PATCH 14/27] add test for stream Signed-off-by: Tikhomirova, Kseniya --- sycl/unittests/stream/stream.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sycl/unittests/stream/stream.cpp b/sycl/unittests/stream/stream.cpp index 0811abff8cf77..7fee0309f84c3 100644 --- a/sycl/unittests/stream/stream.cpp +++ b/sycl/unittests/stream/stream.cpp @@ -59,3 +59,26 @@ TEST(Stream, TestStreamConstructorExceptionNoAllocation) { ASSERT_EQ(GBufferCreateCounter, 0u) << "Buffers were unexpectedly created."; } + +TEST(Stream, Properties) { + sycl::unittest::UrMock<> Mock; + sycl::queue Queue; + Queue + .submit([&](sycl::handler &CGH) { + try { + sycl::stream Stream{256, 256, CGH, sycl::property::queue::in_order{}}; + FAIL() << "No exception was thrown."; + } catch (const sycl::exception &e) { + EXPECT_EQ(e.code(), sycl::errc::invalid); + EXPECT_STREQ(e.what(), + "The property list contains property unsupported " + "for the current object"); + return; + } catch (...) { + FAIL() << "Unexpected exception was thrown."; + } + + CGH.single_task>([=]() {}); + }) + .wait(); +} From 0587a714a3b7ee12bca23b804f4403ec918657c3 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Tue, 3 Sep 2024 03:20:12 -0700 Subject: [PATCH 15/27] update tests Signed-off-by: Tikhomirova, Kseniya --- sycl/test/include_deps/sycl_accessor.hpp.cpp | 1 + sycl/test/include_deps/sycl_detail_core.hpp.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/sycl/test/include_deps/sycl_accessor.hpp.cpp b/sycl/test/include_deps/sycl_accessor.hpp.cpp index 36e9a5ad3961e..7069ea4287cae 100644 --- a/sycl/test/include_deps/sycl_accessor.hpp.cpp +++ b/sycl/test/include_deps/sycl_accessor.hpp.cpp @@ -115,5 +115,6 @@ // CHECK-NEXT: detail/string_view.hpp // CHECK-NEXT: detail/util.hpp // CHECK-NEXT: device_selector.hpp +// CHECK-NEXT: buffer_properties.def // CHECK-NEXT: sampler.hpp // CHECK-EMPTY: diff --git a/sycl/test/include_deps/sycl_detail_core.hpp.cpp b/sycl/test/include_deps/sycl_detail_core.hpp.cpp index 400fb2c13c493..a31b326648044 100644 --- a/sycl/test/include_deps/sycl_detail_core.hpp.cpp +++ b/sycl/test/include_deps/sycl_detail_core.hpp.cpp @@ -116,6 +116,7 @@ // CHECK-NEXT: detail/string_view.hpp // CHECK-NEXT: detail/util.hpp // CHECK-NEXT: device_selector.hpp +// CHECK-NEXT: properties/buffer_properties.def // CHECK-NEXT: sampler.hpp // CHECK-NEXT: queue.hpp // CHECK-NEXT: detail/assert_happened.hpp From f02ca36ffd96342743f58091520d587d3d7b98b7 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Tue, 3 Sep 2024 04:30:59 -0700 Subject: [PATCH 16/27] add check to reduction Signed-off-by: Tikhomirova, Kseniya --- .../sycl/properties/reduction_properties.def | 12 +++++++++ .../sycl/properties/reduction_properties.hpp | 10 ++++--- sycl/include/sycl/reduction.hpp | 8 ++++++ sycl/source/detail/reduction.cpp | 27 +++++++++++++++++++ 4 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 sycl/include/sycl/properties/reduction_properties.def diff --git a/sycl/include/sycl/properties/reduction_properties.def b/sycl/include/sycl/properties/reduction_properties.def new file mode 100644 index 0000000000000..49b6480c3d123 --- /dev/null +++ b/sycl/include/sycl/properties/reduction_properties.def @@ -0,0 +1,12 @@ +// --*- c++ -*--- +#ifndef __SYCL_DATA_LESS_PROP +#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) +#endif +#ifndef __SYCL_MANUALLY_DEFINED_PROP +#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) +#endif + +__SYCL_DATA_LESS_PROP(property::reduction, initialize_to_identity, InitializeToIdentity) + +#undef __SYCL_DATA_LESS_PROP +#undef __SYCL_MANUALLY_DEFINED_PROP diff --git a/sycl/include/sycl/properties/reduction_properties.hpp b/sycl/include/sycl/properties/reduction_properties.hpp index eaabf22524979..ae112479e9efd 100644 --- a/sycl/include/sycl/properties/reduction_properties.hpp +++ b/sycl/include/sycl/properties/reduction_properties.hpp @@ -12,10 +12,12 @@ namespace sycl { inline namespace _V1 { -namespace property::reduction { -class initialize_to_identity - : public detail::DataLessProperty {}; -} // namespace property::reduction +#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \ + namespace NS_QUALIFIER { \ + class PROP_NAME \ + : public sycl::detail::DataLessProperty {}; \ + } +#include // Reduction property trait specializations } // namespace _V1 diff --git a/sycl/include/sycl/reduction.hpp b/sycl/include/sycl/reduction.hpp index 737306818767b..a4e2b699e797a 100644 --- a/sycl/include/sycl/reduction.hpp +++ b/sycl/include/sycl/reduction.hpp @@ -504,6 +504,8 @@ class ReducerElement { private: value_type MValue; }; + +__SYCL_EXPORT void verifyReductionProps(const property_list &Props); } // namespace detail // We explicitly claim std::optional as device-copyable in sycl/types.hpp. @@ -2843,6 +2845,7 @@ template auto reduction(buffer Var, handler &CGH, BinaryOperation Combiner, const property_list &PropList = {}) { std::ignore = CGH; + detail::verifyReductionProps(PropList); bool InitializeToIdentity = PropList.has_property(); return detail::make_reduction( @@ -2857,6 +2860,7 @@ auto reduction(buffer Var, handler &CGH, template auto reduction(T *Var, BinaryOperation Combiner, const property_list &PropList = {}) { + detail::verifyReductionProps(PropList); bool InitializeToIdentity = PropList.has_property(); return detail::make_reduction( @@ -2870,6 +2874,7 @@ template auto reduction(buffer Var, handler &CGH, const T &Identity, BinaryOperation Combiner, const property_list &PropList = {}) { std::ignore = CGH; + detail::verifyReductionProps(PropList); bool InitializeToIdentity = PropList.has_property(); return detail::make_reduction( @@ -2882,6 +2887,7 @@ auto reduction(buffer Var, handler &CGH, const T &Identity, template auto reduction(T *Var, const T &Identity, BinaryOperation Combiner, const property_list &PropList = {}) { + detail::verifyReductionProps(PropList); bool InitializeToIdentity = PropList.has_property(); return detail::make_reduction( @@ -2897,6 +2903,7 @@ template > auto reduction(span Span, BinaryOperation Combiner, const property_list &PropList = {}) { + detail::verifyReductionProps(PropList); bool InitializeToIdentity = PropList.has_property(); return detail::make_reduction( @@ -2910,6 +2917,7 @@ template > auto reduction(span Span, const T &Identity, BinaryOperation Combiner, const property_list &PropList = {}) { + detail::verifyReductionProps(PropList); bool InitializeToIdentity = PropList.has_property(); return detail::make_reduction( diff --git a/sycl/source/detail/reduction.cpp b/sycl/source/detail/reduction.cpp index 4ad7d207fe6ec..8ad478aec0acd 100644 --- a/sycl/source/detail/reduction.cpp +++ b/sycl/source/detail/reduction.cpp @@ -179,6 +179,33 @@ addCounterInit(handler &CGH, std::shared_ptr &Queue, CGH.depends_on(createSyclObjFromImpl(EventImpl)); } +__SYCL_EXPORT void verifyReductionProps(const property_list &Props) { + auto CheckDataLessProperties = [](int PropertyKind) { +#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \ + case NS_QUALIFIER::PROP_NAME::getKind(): \ + return true; +#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) + switch (PropertyKind) { +#include + default: + return false; + } + }; + auto CheckPropertiesWithData = [](int PropertyKind) { +#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) +#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) \ + case NS_QUALIFIER::PROP_NAME::getKind(): \ + return true; + switch (PropertyKind) { +#include + default: + return false; + } + }; + detail::PropertyValidator::checkPropsAndThrow(Props, CheckDataLessProperties, + CheckPropertiesWithData); +} + } // namespace detail } // namespace _V1 } // namespace sycl From 72fc90d51fd077b435cf80ab1c77146e8bbbcf82 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Fri, 30 Aug 2024 04:46:39 -0700 Subject: [PATCH 17/27] add test for reduction Signed-off-by: Tikhomirova, Kseniya --- sycl/unittests/CMakeLists.txt | 1 + sycl/unittests/reduction/CMakeLists.txt | 3 ++ sycl/unittests/reduction/Properties.cpp | 40 +++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 sycl/unittests/reduction/CMakeLists.txt create mode 100644 sycl/unittests/reduction/Properties.cpp diff --git a/sycl/unittests/CMakeLists.txt b/sycl/unittests/CMakeLists.txt index aff7f6d76b24d..cc103358a10ad 100644 --- a/sycl/unittests/CMakeLists.txt +++ b/sycl/unittests/CMakeLists.txt @@ -58,3 +58,4 @@ if (NOT WIN32) add_subdirectory(xpti_trace) endif() add_subdirectory(sampler) +add_subdirectory(reduction) diff --git a/sycl/unittests/reduction/CMakeLists.txt b/sycl/unittests/reduction/CMakeLists.txt new file mode 100644 index 0000000000000..47d16980ceb66 --- /dev/null +++ b/sycl/unittests/reduction/CMakeLists.txt @@ -0,0 +1,3 @@ +add_sycl_unittest(ReductionTests OBJECT + Properties.cpp +) diff --git a/sycl/unittests/reduction/Properties.cpp b/sycl/unittests/reduction/Properties.cpp new file mode 100644 index 0000000000000..1b04b046016c6 --- /dev/null +++ b/sycl/unittests/reduction/Properties.cpp @@ -0,0 +1,40 @@ +//==-------- Properties.cpp --- check properties handling in RT --- --------==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +TEST(ReductionTest, InvalidProperties) { + int ReduVar = 0; + try { + auto Redu = sycl::reduction( + &ReduVar, int{0}, sycl::plus<>(), + sycl::property_list{sycl::property::buffer::use_host_ptr{}}); + } catch (sycl::exception &e) { + EXPECT_EQ(e.code(), sycl::errc::invalid); + EXPECT_STREQ(e.what(), "The property list contains property unsupported " + "for the current object"); + return; + } + + FAIL() << "Test must exit in exception handler. Exception is not thrown."; +} + +TEST(ReductionTest, ValidPropertyInitializeToIdentity) { + int ReduVar = 0; + try { + auto Redu = sycl::reduction( + &ReduVar, int{0}, sycl::plus<>(), + sycl::property_list{ + sycl::property::reduction::initialize_to_identity{}}); + // no explicit checks, we expect no exception to be thrown + } catch (...) { + FAIL(); + } +} From 4e5f586d9080d2e717da26c0a9ff48de8d790c9b Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Tue, 3 Sep 2024 04:35:04 -0700 Subject: [PATCH 18/27] add check to usm_allocator Signed-off-by: Tikhomirova, Kseniya --- sycl/include/sycl/usm/usm_allocator.hpp | 13 +++++++++++-- sycl/source/detail/usm/usm_impl.cpp | 6 ++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/sycl/include/sycl/usm/usm_allocator.hpp b/sycl/include/sycl/usm/usm_allocator.hpp index fde0dae175b48..4f3b0fb63a313 100644 --- a/sycl/include/sycl/usm/usm_allocator.hpp +++ b/sycl/include/sycl/usm/usm_allocator.hpp @@ -21,6 +21,11 @@ namespace sycl { inline namespace _V1 { + +/// Validates usm_allocator properties +/// Throws sycl::exception if incorrect property is passed. +__SYCL_EXPORT void verifyUSMAllocatorProperties(const property_list &PropList); + template class usm_allocator { public: @@ -41,10 +46,14 @@ class usm_allocator { usm_allocator() = delete; usm_allocator(const context &Ctxt, const device &Dev, const property_list &PropList = {}) - : MContext(Ctxt), MDevice(Dev), MPropList(PropList) {} + : MContext(Ctxt), MDevice(Dev), MPropList(PropList) { + verifyUSMAllocatorProperties(MPropList); + } usm_allocator(const queue &Q, const property_list &PropList = {}) : MContext(Q.get_context()), MDevice(Q.get_device()), - MPropList(PropList) {} + MPropList(PropList) { + verifyUSMAllocatorProperties(MPropList); + } usm_allocator(const usm_allocator &) = default; usm_allocator(usm_allocator &&) noexcept = default; usm_allocator &operator=(const usm_allocator &Other) { diff --git a/sycl/source/detail/usm/usm_impl.cpp b/sycl/source/detail/usm/usm_impl.cpp index 3270907ee9a0d..68c168559293b 100644 --- a/sycl/source/detail/usm/usm_impl.cpp +++ b/sycl/source/detail/usm/usm_impl.cpp @@ -642,5 +642,11 @@ void release_from_device_copy(const void *Ptr, const queue &Queue) { } } // namespace ext::oneapi::experimental +__SYCL_EXPORT void verifyUSMAllocatorProperties(const property_list &PropList) { + auto NoAllowedPropertiesCheck = [](int PropertyKind) { return false; }; + detail::PropertyValidator::checkPropsAndThrow( + PropList, NoAllowedPropertiesCheck, NoAllowedPropertiesCheck); +} + } // namespace _V1 } // namespace sycl From 2d99591b1724b09e1f8b8d0c7f1f0dbc725430c4 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Fri, 30 Aug 2024 04:24:44 -0700 Subject: [PATCH 19/27] add test for usm_allocator Signed-off-by: Tikhomirova, Kseniya --- sycl/unittests/buffer/Properties.cpp | 30 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/sycl/unittests/buffer/Properties.cpp b/sycl/unittests/buffer/Properties.cpp index 53b4acd302bcb..fc8a07b37d40f 100644 --- a/sycl/unittests/buffer/Properties.cpp +++ b/sycl/unittests/buffer/Properties.cpp @@ -164,18 +164,18 @@ TEST(ImageProps, SetUnsupportedParam) { FAIL() << "Test must exit in exception handler. Exception is not thrown."; } -// TEST(USMAllocator, Properties) { -// sycl::unittest::UrMock<> Mock; -// try { -// sycl::queue Q; -// sycl::usm_allocator Allocator( -// Q, sycl::property::buffer::use_host_ptr{}); -// } catch (sycl::exception &e) { -// EXPECT_EQ(e.code(), sycl::errc::invalid); -// EXPECT_STREQ(e.what(), "The property list contains property unsupported " -// "for the current object"); -// return; -// } - -// FAIL() << "Test must exit in exception handler. Exception is not thrown."; -// } +TEST(USMAllocator, Properties) { + sycl::unittest::UrMock<> Mock; + try { + sycl::queue Q; + sycl::usm_allocator Allocator( + Q, sycl::property::buffer::use_host_ptr{}); + } catch (sycl::exception &e) { + EXPECT_EQ(e.code(), sycl::errc::invalid); + EXPECT_STREQ(e.what(), "The property list contains property unsupported " + "for the current object"); + return; + } + + FAIL() << "Test must exit in exception handler. Exception is not thrown."; +} From 0973de005ca597de10119a1816dbe581ebf8d7f5 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Tue, 3 Sep 2024 04:39:07 -0700 Subject: [PATCH 20/27] update linux symbols Signed-off-by: Tikhomirova, Kseniya --- sycl/test/abi/sycl_symbols_linux.dump | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sycl/test/abi/sycl_symbols_linux.dump b/sycl/test/abi/sycl_symbols_linux.dump index 26822ac6e3bf2..9bc079455fb40 100644 --- a/sycl/test/abi/sycl_symbols_linux.dump +++ b/sycl/test/abi/sycl_symbols_linux.dump @@ -2984,6 +2984,7 @@ _ZN4sycl3_V121__isgreaterequal_implENS0_6detail9half_impl4halfES3_ _ZN4sycl3_V121__isgreaterequal_implEdd _ZN4sycl3_V121__isgreaterequal_implEff _ZN4sycl3_V122accelerator_selector_vERKNS0_6deviceE +_ZN4sycl3_V128verifyUSMAllocatorPropertiesERKNS0_13property_listE _ZN4sycl3_V13ext5intel12experimental15online_compilerILNS3_15source_languageE0EE7compileIJSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISE_EEEEES8_IhSaIhEERKSE_DpRKT_ _ZN4sycl3_V13ext5intel12experimental15online_compilerILNS3_15source_languageE1EE7compileIJSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISE_EEEEES8_IhSaIhEERKSE_DpRKT_ _ZN4sycl3_V13ext5intel12experimental9pipe_base13get_pipe_nameB5cxx11EPKv @@ -3264,6 +3265,7 @@ _ZN4sycl3_V16detail20associateWithHandlerERNS0_7handlerEPNS1_28SampledImageAcces _ZN4sycl3_V16detail20associateWithHandlerERNS0_7handlerEPNS1_30UnsampledImageAccessorBaseHostENS0_12image_targetE _ZN4sycl3_V16detail20getDeviceFromHandlerERNS0_7handlerE _ZN4sycl3_V16detail20markBufferAsInternalERKSt10shared_ptrINS1_11buffer_implEE +_ZN4sycl3_V16detail20verifyReductionPropsERKNS0_13property_listE _ZN4sycl3_V16detail21LocalAccessorBaseHost12getNumOfDimsEv _ZN4sycl3_V16detail21LocalAccessorBaseHost14getElementSizeEv _ZN4sycl3_V16detail21LocalAccessorBaseHost6getPtrEv From e76b4aead8dbfe65f0a0cea6ca933a32f4f200a6 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Tue, 3 Sep 2024 04:40:07 -0700 Subject: [PATCH 21/27] fix stream test Signed-off-by: Tikhomirova, Kseniya --- sycl/test-e2e/Basic/stream/stream.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/sycl/test-e2e/Basic/stream/stream.cpp b/sycl/test-e2e/Basic/stream/stream.cpp index fe3429cffad2b..171bea8be9812 100644 --- a/sycl/test-e2e/Basic/stream/stream.cpp +++ b/sycl/test-e2e/Basic/stream/stream.cpp @@ -33,15 +33,9 @@ int main() { // Check constructor and getters Queue.submit([&](handler &CGH) { - stream Out(1024, 80, CGH, - property_list{property::buffer::context_bound{Context}}); + stream Out(1024, 80, CGH); assert(Out.size() == 1024); assert(Out.get_work_item_buffer_size() == 80); - assert(Out.has_property()); - assert(!Out.has_property()); - assert( - Out.get_property().get_context() == - Context); sycl::accessor accSize(bufSize, CGH, sycl::write_only); sycl::accessor accWorkItemBufferSize(bufWorkItemBufferSize, CGH, From 4f25430920157088e06962cb097e4d70d9878a09 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Tue, 3 Sep 2024 04:46:14 -0700 Subject: [PATCH 22/27] fix format Signed-off-by: Tikhomirova, Kseniya --- sycl/unittests/sampler/Properties.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/unittests/sampler/Properties.cpp b/sycl/unittests/sampler/Properties.cpp index d6e8d285c2910..f828be32fb951 100644 --- a/sycl/unittests/sampler/Properties.cpp +++ b/sycl/unittests/sampler/Properties.cpp @@ -23,4 +23,4 @@ TEST(SamplerTest, Properties) { } FAIL() << "Test must exit in exception handler. Exception is not thrown."; -} \ No newline at end of file +} From 80acde2da6e3d3b8d95204846b557acec1db8c36 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Wed, 4 Sep 2024 09:45:24 -0700 Subject: [PATCH 23/27] add check to accessor Signed-off-by: Tikhomirova, Kseniya --- .../sycl/properties/accessor_properties.hpp | 22 +++++----- .../runtime_accessor_properties.def | 17 ++++++++ sycl/source/accessor.cpp | 42 +++++++++++++++++++ 3 files changed, 69 insertions(+), 12 deletions(-) create mode 100644 sycl/include/sycl/properties/runtime_accessor_properties.def diff --git a/sycl/include/sycl/properties/accessor_properties.hpp b/sycl/include/sycl/properties/accessor_properties.hpp index 7fa61e67850e3..fafd6367f0cfd 100644 --- a/sycl/include/sycl/properties/accessor_properties.hpp +++ b/sycl/include/sycl/properties/accessor_properties.hpp @@ -20,19 +20,17 @@ namespace sycl { inline namespace _V1 { -namespace property { - -class no_init : public detail::DataLessProperty {}; - -class __SYCL2020_DEPRECATED("spelling is now: no_init") noinit - : public detail::DataLessProperty {}; - -} // namespace property - -inline constexpr property::no_init no_init; -__SYCL2020_DEPRECATED("spelling is now: no_init") -inline constexpr property::noinit noinit; +#define __SYCL_DATA_LESS_PROP_DEPRECATED_ALIAS(NS_QUALIFIER, PROP_NAME, \ + ENUM_VAL, WARNING) \ + namespace NS_QUALIFIER { \ + class WARNING PROP_NAME \ + : public sycl::detail::DataLessProperty {}; \ + } \ + WARNING inline constexpr NS_QUALIFIER::PROP_NAME PROP_NAME; +#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \ + __SYCL_DATA_LESS_PROP_DEPRECATED_ALIAS(NS_QUALIFIER, PROP_NAME, ENUM_VAL, ) +#include namespace ext::intel { namespace property { diff --git a/sycl/include/sycl/properties/runtime_accessor_properties.def b/sycl/include/sycl/properties/runtime_accessor_properties.def new file mode 100644 index 0000000000000..36bf997f83dae --- /dev/null +++ b/sycl/include/sycl/properties/runtime_accessor_properties.def @@ -0,0 +1,17 @@ +// --*- c++ -*--- +#ifndef __SYCL_DATA_LESS_PROP +#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) +#endif +#ifndef __SYCL_MANUALLY_DEFINED_PROP +#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) +#endif +#ifndef __SYCL_DATA_LESS_PROP_DEPRECATED_ALIAS +#define __SYCL_DATA_LESS_PROP_DEPRECATED_ALIAS(NS_QUALIFIER, PROP_NAME, ENUM_VAL, WARNING) +#endif + +__SYCL_DATA_LESS_PROP(property, no_init, NoInit) +__SYCL_DATA_LESS_PROP_DEPRECATED_ALIAS(property, noinit, NoInit, __SYCL2020_DEPRECATED("spelling is now: no_init")) + +#undef __SYCL_DATA_LESS_PROP +#undef __SYCL_MANUALLY_DEFINED_PROP +#undef __SYCL_DATA_LESS_PROP_DEPRECATED_ALIAS diff --git a/sycl/source/accessor.cpp b/sycl/source/accessor.cpp index aa3547a4a44a6..f3a8cd3893f10 100644 --- a/sycl/source/accessor.cpp +++ b/sycl/source/accessor.cpp @@ -23,12 +23,46 @@ device getDeviceFromHandler(handler &cgh) { return getSyclObjImpl(cgh)->MGraph->getDevice(); } +// property::no_init is supported now for +// accessor +// host_accessor +// unsampled_image_accessor +// host_unsampled_image_accessor + +static void verifyAccessorProps(const property_list &Props) { + auto CheckDataLessProperties = [](int PropertyKind) { +#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \ + case NS_QUALIFIER::PROP_NAME::getKind(): \ + return true; +#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) + switch (PropertyKind) { +#include + default: + return false; + } + }; + auto CheckPropertiesWithData = [](int PropertyKind) { +#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) +#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) \ + case NS_QUALIFIER::PROP_NAME::getKind(): \ + return true; + switch (PropertyKind) { +#include + default: + return false; + } + }; + detail::PropertyValidator::checkPropsAndThrow(Props, CheckDataLessProperties, + CheckPropertiesWithData); +} + AccessorBaseHost::AccessorBaseHost(id<3> Offset, range<3> AccessRange, range<3> MemoryRange, access::mode AccessMode, void *SYCLMemObject, int Dims, int ElemSize, size_t OffsetInBytes, bool IsSubBuffer, const property_list &PropertyList) { + verifyAccessorProps(PropertyList); impl = std::shared_ptr( new AccessorImplHost(Offset, AccessRange, MemoryRange, AccessMode, (detail::SYCLMemObjI *)SYCLMemObject, Dims, ElemSize, @@ -41,6 +75,7 @@ AccessorBaseHost::AccessorBaseHost(id<3> Offset, range<3> AccessRange, int Dims, int ElemSize, bool IsPlaceH, size_t OffsetInBytes, bool IsSubBuffer, const property_list &PropertyList) { + verifyAccessorProps(PropertyList); impl = std::shared_ptr( new AccessorImplHost(Offset, AccessRange, MemoryRange, AccessMode, (detail::SYCLMemObjI *)SYCLMemObject, Dims, ElemSize, @@ -82,6 +117,7 @@ bool AccessorBaseHost::isMemoryObjectUsedByGraph() const { LocalAccessorBaseHost::LocalAccessorBaseHost( sycl::range<3> Size, int Dims, int ElemSize, const property_list &PropertyList) { + verifyAccessorProps(PropertyList); impl = std::shared_ptr( new LocalAccessorImplHost(Size, Dims, ElemSize, PropertyList)); } @@ -115,6 +151,7 @@ UnsampledImageAccessorBaseHost::UnsampledImageAccessorBaseHost( sycl::range<3> Size, access_mode AccessMode, void *SYCLMemObject, int Dims, int ElemSize, id<3> Pitch, image_channel_type ChannelType, image_channel_order ChannelOrder, const property_list &PropertyList) { + verifyAccessorProps(PropertyList); impl = std::make_shared( Size, AccessMode, (detail::SYCLMemObjI *)SYCLMemObject, Dims, ElemSize, Pitch, ChannelType, ChannelOrder, PropertyList); @@ -152,6 +189,11 @@ SampledImageAccessorBaseHost::SampledImageAccessorBaseHost( id<3> Pitch, image_channel_type ChannelType, image_channel_order ChannelOrder, image_sampler Sampler, const property_list &PropertyList) { + { + auto NoAllowedPropertiesCheck = [](int PropertyKind) { return false; }; + detail::PropertyValidator::checkPropsAndThrow( + PropertyList, NoAllowedPropertiesCheck, NoAllowedPropertiesCheck); + } impl = std::make_shared( Size, (detail::SYCLMemObjI *)SYCLMemObject, Dims, ElemSize, Pitch, ChannelType, ChannelOrder, Sampler, PropertyList); From 05cf71dcd37c32a21e3f700b9609a7b1c4f493fb Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Wed, 4 Sep 2024 10:04:24 -0700 Subject: [PATCH 24/27] add test for sampled/unsampled_image Signed-off-by: Tikhomirova, Kseniya --- sycl/unittests/buffer/Properties.cpp | 72 ++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/sycl/unittests/buffer/Properties.cpp b/sycl/unittests/buffer/Properties.cpp index fc8a07b37d40f..56393f643b6b5 100644 --- a/sycl/unittests/buffer/Properties.cpp +++ b/sycl/unittests/buffer/Properties.cpp @@ -179,3 +179,75 @@ TEST(USMAllocator, Properties) { FAIL() << "Test must exit in exception handler. Exception is not thrown."; } + +TEST(SampledImage, ValidPropsHostPtr) { + try { + sycl::image_sampler Sampler{ + sycl::addressing_mode::none, + sycl::coordinate_normalization_mode::unnormalized, + sycl::filtering_mode::linear}; + + constexpr size_t ElementsCount = 4; + constexpr size_t ChannelsCount = 4; + int InitValue[ElementsCount * ChannelsCount]; + sycl::sampled_image<1> Image(&InitValue, sycl::image_format::r8g8b8a8_unorm, + Sampler, sycl::range<1>(ElementsCount), + sycl::property::image::use_host_ptr{}); + // no explicit checks, we expect no exception to be thrown + } catch (...) { + FAIL(); + } +} + +TEST(SampledImage, SetUnsupportedParam) { + try { + sycl::image_sampler Sampler{ + sycl::addressing_mode::none, + sycl::coordinate_normalization_mode::unnormalized, + sycl::filtering_mode::linear}; + + constexpr size_t ElementsCount = 4; + constexpr size_t ChannelsCount = 4; + int InitValue[ElementsCount * ChannelsCount]; + sycl::sampled_image<1> Image(&InitValue, sycl::image_format::r8g8b8a8_unorm, + Sampler, sycl::range<1>(ElementsCount), + sycl::property::buffer::use_host_ptr{}); + } catch (sycl::exception &e) { + EXPECT_EQ(e.code(), sycl::errc::invalid); + EXPECT_STREQ(e.what(), "The property list contains property unsupported " + "for the current object"); + return; + } + + FAIL() << "Test must exit in exception handler. Exception is not thrown."; +} + +TEST(UnsampledImage, ValidPropsHostPtr) { + try { + constexpr size_t ElementsCount = 4; + constexpr size_t ChannelsCount = 4; + int InitValue[ElementsCount * ChannelsCount]; + sycl::unsampled_image<1> Image( + &InitValue, sycl::image_format::r8g8b8a8_unorm, + sycl::range<1>(ElementsCount), sycl::property::image::use_host_ptr{}); + // no explicit checks, we expect no exception to be thrown + } catch (...) { + FAIL(); + } +} + +TEST(UnsampledImage, SetUnsupportedParam) { + try { + constexpr size_t ElementsCount = 4; + sycl::unsampled_image<1> Image(sycl::image_format::r8g8b8a8_unorm, + sycl::range<1>(ElementsCount), + sycl::property::buffer::use_host_ptr{}); + } catch (sycl::exception &e) { + EXPECT_EQ(e.code(), sycl::errc::invalid); + EXPECT_STREQ(e.what(), "The property list contains property unsupported " + "for the current object"); + return; + } + + FAIL() << "Test must exit in exception handler. Exception is not thrown."; +} From f16372f3aa0844686c01f278ed85b910cd8103ff Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Tue, 17 Sep 2024 09:13:05 -0700 Subject: [PATCH 25/27] fix tests Signed-off-by: Tikhomirova, Kseniya --- sycl/test/include_deps/sycl_accessor.hpp.cpp | 1 + sycl/test/include_deps/sycl_detail_core.hpp.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/sycl/test/include_deps/sycl_accessor.hpp.cpp b/sycl/test/include_deps/sycl_accessor.hpp.cpp index 55b4678980cb9..cd138f0f949c1 100644 --- a/sycl/test/include_deps/sycl_accessor.hpp.cpp +++ b/sycl/test/include_deps/sycl_accessor.hpp.cpp @@ -88,6 +88,7 @@ // CHECK-NEXT: detail/handler_proxy.hpp // CHECK-NEXT: pointers.hpp // CHECK-NEXT: properties/accessor_properties.hpp +// CHECK-NEXT: properties/runtime_accessor_properties.def // CHECK-NEXT: properties/buffer_properties.hpp // CHECK-NEXT: context.hpp // CHECK-NEXT: async_handler.hpp diff --git a/sycl/test/include_deps/sycl_detail_core.hpp.cpp b/sycl/test/include_deps/sycl_detail_core.hpp.cpp index 049c3e9b6d6b5..86650c79156e1 100644 --- a/sycl/test/include_deps/sycl_detail_core.hpp.cpp +++ b/sycl/test/include_deps/sycl_detail_core.hpp.cpp @@ -89,6 +89,7 @@ // CHECK-NEXT: detail/handler_proxy.hpp // CHECK-NEXT: pointers.hpp // CHECK-NEXT: properties/accessor_properties.hpp +// CHECK-NEXT: properties/runtime_accessor_properties.def // CHECK-NEXT: properties/buffer_properties.hpp // CHECK-NEXT: context.hpp // CHECK-NEXT: async_handler.hpp From 6fa9b2baf9dd93b0698811c90f612555d13395fe Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Mon, 7 Oct 2024 06:04:13 -0700 Subject: [PATCH 26/27] add a few accessor tests Signed-off-by: Tikhomirova, Kseniya --- sycl/unittests/accessor/CMakeLists.txt | 1 + sycl/unittests/accessor/RuntimeProperties.cpp | 154 ++++++++++++++++++ 2 files changed, 155 insertions(+) create mode 100644 sycl/unittests/accessor/RuntimeProperties.cpp diff --git a/sycl/unittests/accessor/CMakeLists.txt b/sycl/unittests/accessor/CMakeLists.txt index cb5e27e6d6aae..e41fc54a30f8e 100644 --- a/sycl/unittests/accessor/CMakeLists.txt +++ b/sycl/unittests/accessor/CMakeLists.txt @@ -7,4 +7,5 @@ add_sycl_unittest(AccessorTests OBJECT HostAccessorIterator.cpp HostAccessorReverseIterator.cpp LocalAccessorDefaultCtor.cpp + RuntimeProperties.cpp ) diff --git a/sycl/unittests/accessor/RuntimeProperties.cpp b/sycl/unittests/accessor/RuntimeProperties.cpp new file mode 100644 index 0000000000000..0346a30ac44c9 --- /dev/null +++ b/sycl/unittests/accessor/RuntimeProperties.cpp @@ -0,0 +1,154 @@ +//==---- RuntimeProperties.cpp --- check properties handling in RT --- -----==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +TEST(AccessorProperties, ValidPropsNoInit) { + sycl::unittest::UrMock<> Mock; + sycl::queue Queue; + try { + sycl::buffer Buf{1}; + std::ignore = Queue.submit([&](sycl::handler &cgh) { + sycl::accessor + BuffAcc(Buf, cgh, sycl::property::no_init{}); + cgh.fill(BuffAcc, 1); + }); + // no explicit checks, we expect no exception to be thrown + } catch (...) { + FAIL(); + } +} + +TEST(AccessorProperties, SetUnsupportedParam) { + sycl::unittest::UrMock<> Mock; + sycl::queue Queue; + try { + sycl::buffer Buf{1}; + std::ignore = Queue.submit([&](sycl::handler &cgh) { + // compile-time property is not supported in runtime + sycl::accessor + BuffAcc(Buf, cgh, sycl::ext::oneapi::property::no_alias{}); + cgh.fill(BuffAcc, 1); + }); + } catch (sycl::exception &e) { + EXPECT_EQ(e.code(), sycl::errc::invalid); + EXPECT_STREQ(e.what(), "The property list contains property unsupported " + "for the current object"); + return; + } +} + +TEST(HostAccessorProperties, ValidPropsNoInit) { + sycl::unittest::UrMock<> Mock; + sycl::queue Queue; + try { + sycl::buffer Buf{1}; + sycl::host_accessor BuffAcc( + Buf, sycl::property::no_init{}); + // no explicit checks, we expect no exception to be thrown + } catch (...) { + FAIL(); + } +} + +TEST(HostAccessorProperties, SetUnsupportedParam) { + sycl::unittest::UrMock<> Mock; + sycl::queue Queue; + try { + sycl::buffer Buf{1}; + sycl::host_accessor BuffAcc( + Buf, sycl::ext::oneapi::property::no_alias{}); + } catch (sycl::exception &e) { + EXPECT_EQ(e.code(), sycl::errc::invalid); + EXPECT_STREQ(e.what(), "The property list contains property unsupported " + "for the current object"); + return; + } +} + +// no test for image_accesor since it doesn't have property parameter in +// constructor. + +TEST(SampledAccessorProperties, NoSupportedProps) { + sycl::unittest::UrMock<> Mock; + sycl::queue Queue; + try { + sycl::image_sampler Sampler{ + sycl::addressing_mode::none, + sycl::coordinate_normalization_mode::unnormalized, + sycl::filtering_mode::linear}; + + constexpr size_t ElementsCount = 4; + constexpr size_t ChannelsCount = 4; + int InitValue[ElementsCount * ChannelsCount]; + sycl::sampled_image<1> Image(&InitValue, sycl::image_format::r8g8b8a8_unorm, + Sampler, sycl::range<1>(ElementsCount), + sycl::property::image::use_host_ptr{}); + std::ignore = Queue.submit([&](sycl::handler &cgh) { + sycl::sampled_image_accessor + ImageAcc(Image, cgh, sycl::property::no_init{}); + cgh.single_task([=]() {}); + }); + } catch (sycl::exception &e) { + EXPECT_EQ(e.code(), sycl::errc::invalid); + EXPECT_STREQ(e.what(), "The property list contains property unsupported " + "for the current object"); + return; + } + FAIL() << "Test must exit in exception handler. Exception is not thrown."; +} + +TEST(UnsampledImageAccessor, ValidPropsNoInit) { + sycl::unittest::UrMock<> Mock; + sycl::queue Queue; + try { + constexpr size_t ElementsCount = 4; + constexpr size_t ChannelsCount = 4; + int InitValue[ElementsCount * ChannelsCount]; + sycl::unsampled_image<1> Image( + &InitValue, sycl::image_format::r8g8b8a8_unorm, + sycl::range<1>(ElementsCount), sycl::property::image::use_host_ptr{}); + std::ignore = Queue.submit([&](sycl::handler &cgh) { + sycl::unsampled_image_accessor + ImageAcc(Image, cgh, sycl::property::no_init{}); + cgh.single_task([=]() {}); + }); + } catch (sycl::exception &e) { + EXPECT_EQ(e.code(), sycl::errc::feature_not_supported); + EXPECT_STREQ(e.what(), "Device associated with command group handler does " + "not have aspect::image."); + return; + } +} + +TEST(UnsampledImageAccessor, SetUnsupportedParam) { + sycl::unittest::UrMock<> Mock; + sycl::queue Queue; + try { + constexpr size_t ElementsCount = 4; + sycl::unsampled_image<1> Image(sycl::image_format::r8g8b8a8_unorm, + sycl::range<1>(ElementsCount), + sycl::property::buffer::use_host_ptr{}); + std::ignore = Queue.submit([&](sycl::handler &cgh) { + sycl::unsampled_image_accessor + ImageAcc(Image, cgh, sycl::ext::oneapi::property::no_alias{}); + cgh.single_task([=]() {}); + }); + } catch (sycl::exception &e) { + EXPECT_EQ(e.code(), sycl::errc::invalid); + EXPECT_STREQ(e.what(), "The property list contains property unsupported " + "for the current object"); + return; + } + + FAIL() << "Test must exit in exception handler. Exception is not thrown."; +} From e44a496786e72ad39ecb5b7ec0af603e107c3bd8 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Tue, 8 Oct 2024 08:39:58 -0700 Subject: [PATCH 27/27] fix win build Signed-off-by: Tikhomirova, Kseniya --- sycl/source/accessor.cpp | 17 +++++------------ sycl/source/detail/reduction.cpp | 14 ++------------ sycl/test/abi/sycl_symbols_windows.dump | 4 +++- 3 files changed, 10 insertions(+), 25 deletions(-) diff --git a/sycl/source/accessor.cpp b/sycl/source/accessor.cpp index f3a8cd3893f10..0b1fab02fa6bd 100644 --- a/sycl/source/accessor.cpp +++ b/sycl/source/accessor.cpp @@ -41,19 +41,12 @@ static void verifyAccessorProps(const property_list &Props) { return false; } }; - auto CheckPropertiesWithData = [](int PropertyKind) { -#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) -#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) \ - case NS_QUALIFIER::PROP_NAME::getKind(): \ - return true; - switch (PropertyKind) { -#include - default: - return false; - } - }; + // When new properties with data are added - please implement the second + // function with props include. + // Absence of any properties causes warning (+error) now. + auto NoAllowedPropertiesCheck = [](int) { return false; }; detail::PropertyValidator::checkPropsAndThrow(Props, CheckDataLessProperties, - CheckPropertiesWithData); + NoAllowedPropertiesCheck); } AccessorBaseHost::AccessorBaseHost(id<3> Offset, range<3> AccessRange, diff --git a/sycl/source/detail/reduction.cpp b/sycl/source/detail/reduction.cpp index 8ad478aec0acd..6e2d49d909f29 100644 --- a/sycl/source/detail/reduction.cpp +++ b/sycl/source/detail/reduction.cpp @@ -191,19 +191,9 @@ __SYCL_EXPORT void verifyReductionProps(const property_list &Props) { return false; } }; - auto CheckPropertiesWithData = [](int PropertyKind) { -#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) -#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) \ - case NS_QUALIFIER::PROP_NAME::getKind(): \ - return true; - switch (PropertyKind) { -#include - default: - return false; - } - }; + auto NoAllowedPropertiesCheck = [](int) { return false; }; detail::PropertyValidator::checkPropsAndThrow(Props, CheckDataLessProperties, - CheckPropertiesWithData); + NoAllowedPropertiesCheck); } } // namespace detail diff --git a/sycl/test/abi/sycl_symbols_windows.dump b/sycl/test/abi/sycl_symbols_windows.dump index 17a1e6b9fc167..0235b489f24f0 100644 --- a/sycl/test/abi/sycl_symbols_windows.dump +++ b/sycl/test/abi/sycl_symbols_windows.dump @@ -4267,10 +4267,12 @@ ?update@executable_command_graph@detail@experimental@oneapi@ext@_V1@sycl@@QEAAXAEBV?$vector@Vnode@experimental@oneapi@ext@_V1@sycl@@V?$allocator@Vnode@experimental@oneapi@ext@_V1@sycl@@@std@@@std@@@Z ?update@executable_command_graph@detail@experimental@oneapi@ext@_V1@sycl@@QEAAXAEBVnode@34567@@Z ?updateAccessor@dynamic_parameter_base@detail@experimental@oneapi@ext@_V1@sycl@@IEAAXPEBVAccessorBaseHost@267@@Z -?updateValue@dynamic_parameter_base@detail@experimental@oneapi@ext@_V1@sycl@@IEAAXPEBX_K@Z ?updateValue@dynamic_parameter_base@detail@experimental@oneapi@ext@_V1@sycl@@IEAAXPEBVraw_kernel_arg@34567@_K@Z +?updateValue@dynamic_parameter_base@detail@experimental@oneapi@ext@_V1@sycl@@IEAAXPEBX_K@Z ?use_kernel_bundle@handler@_V1@sycl@@QEAAXAEBV?$kernel_bundle@$01@23@@Z ?verifyDeviceHasProgressGuarantee@handler@_V1@sycl@@AEAAXW4forward_progress_guarantee@experimental@oneapi@ext@23@W4execution_scope@56723@1@Z +?verifyReductionProps@detail@_V1@sycl@@YAXAEBVproperty_list@23@@Z +?verifyUSMAllocatorProperties@_V1@sycl@@YAXAEBVproperty_list@12@@Z ?verifyUsedKernelBundleInternal@handler@_V1@sycl@@AEAAXVstring_view@detail@23@@Z ?wait@event@_V1@sycl@@QEAAXXZ ?wait@event@_V1@sycl@@SAXAEBV?$vector@Vevent@_V1@sycl@@V?$allocator@Vevent@_V1@sycl@@@std@@@std@@@Z