From 91f0ce64779cca20ecbd97d7c355ee7d805df8b4 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Mon, 2 Sep 2024 07:08:50 -0700 Subject: [PATCH 01/38] 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/38] 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/38] 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/38] 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/38] 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/38] 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/38] 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/38] 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/38] 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/38] 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/38] 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/38] 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/38] 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/38] 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/38] 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/38] 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/38] 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/38] 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/38] 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/38] 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/38] 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/38] 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/38] 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/38] 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/38] 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/38] 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 a80b944d55067e992b6f91d53fcf012ffe5f04d7 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Mon, 7 Oct 2024 08:34:40 -0700 Subject: [PATCH 27/38] add check for kernel bundle free methods Signed-off-by: Tikhomirova, Kseniya --- .../program_manager/program_manager.cpp | 25 ++++++++++++++--- .../kernel-and-program/KernelBuildOptions.cpp | 28 ++++++++++++++++++- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/sycl/source/detail/program_manager/program_manager.cpp b/sycl/source/detail/program_manager/program_manager.cpp index 6ab92c6e27d04..1b40bb9b15ee5 100644 --- a/sycl/source/detail/program_manager/program_manager.cpp +++ b/sycl/source/detail/program_manager/program_manager.cpp @@ -2330,7 +2330,12 @@ std::vector ProgramManager::getSYCLDeviceImages( device_image_plain ProgramManager::compile(const device_image_plain &DeviceImage, const std::vector &Devs, - const property_list &) { + const property_list &PropList) { + { + auto NoAllowedPropertiesCheck = [](int PropertyKind) { return false; }; + detail::PropertyValidator::checkPropsAndThrow( + PropList, NoAllowedPropertiesCheck, NoAllowedPropertiesCheck); + } // TODO: Extract compile options from property list once the Spec clarifies // how they can be passed. @@ -2396,7 +2401,11 @@ std::vector ProgramManager::link(const device_image_plain &DeviceImage, const std::vector &Devs, const property_list &PropList) { - (void)PropList; + { + auto NoAllowedPropertiesCheck = [](int PropertyKind) { return false; }; + detail::PropertyValidator::checkPropsAndThrow( + PropList, NoAllowedPropertiesCheck, NoAllowedPropertiesCheck); + } std::vector URPrograms; URPrograms.push_back(getSyclObjImpl(DeviceImage)->get_ur_program_ref()); @@ -2513,7 +2522,11 @@ ProgramManager::link(const device_image_plain &DeviceImage, device_image_plain ProgramManager::build(const device_image_plain &DeviceImage, const std::vector &Devs, const property_list &PropList) { - (void)PropList; + { + auto NoAllowedPropertiesCheck = [](int PropertyKind) { return false; }; + detail::PropertyValidator::checkPropsAndThrow( + PropList, NoAllowedPropertiesCheck, NoAllowedPropertiesCheck); + } const std::shared_ptr &InputImpl = getSyclObjImpl(DeviceImage); @@ -2674,7 +2687,11 @@ ProgramManager::getOrCreateKernel(const context &Context, const property_list &PropList, ur_program_handle_t Program) { - (void)PropList; + { + auto NoAllowedPropertiesCheck = [](int PropertyKind) { return false; }; + detail::PropertyValidator::checkPropsAndThrow( + PropList, NoAllowedPropertiesCheck, NoAllowedPropertiesCheck); + } const ContextImplPtr Ctx = getSyclObjImpl(Context); diff --git a/sycl/unittests/kernel-and-program/KernelBuildOptions.cpp b/sycl/unittests/kernel-and-program/KernelBuildOptions.cpp index f994c62578c69..52d242b0d745d 100644 --- a/sycl/unittests/kernel-and-program/KernelBuildOptions.cpp +++ b/sycl/unittests/kernel-and-program/KernelBuildOptions.cpp @@ -109,13 +109,39 @@ TEST(KernelBuildOptions, KernelBundleBasic) { sycl::kernel_bundle KernelBundle = sycl::get_kernel_bundle(Ctx, {Dev}, {KernelID}); + try { + // no supported properties now + auto ExecBundle = sycl::build(KernelBundle, sycl::property::no_init{}); + FAIL(); + } 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"); + } auto ExecBundle = sycl::build(KernelBundle); EXPECT_EQ(BuildOpts, "-compile-img -vc-codegen -disable-finalizer-msg -link-img"); - + try { + auto ObjBundle = sycl::compile(KernelBundle, KernelBundle.get_devices(), + sycl::property::no_init{}); + FAIL(); + } 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"); + } auto ObjBundle = sycl::compile(KernelBundle, KernelBundle.get_devices()); EXPECT_EQ(BuildOpts, "-compile-img -vc-codegen -disable-finalizer-msg"); + try { + auto LinkBundle = sycl::link(ObjBundle, ObjBundle.get_devices(), + sycl::property::no_init{}); + FAIL(); + } 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"); + } auto LinkBundle = sycl::link(ObjBundle, ObjBundle.get_devices()); EXPECT_EQ(BuildOpts, "-link-img"); } From 75cefe09246ed0c03e59ebe3106a222241e59424 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Wed, 9 Oct 2024 07:40:26 -0700 Subject: [PATCH 28/38] move graph properties to files Signed-off-by: Tikhomirova, Kseniya --- .../detail/properties/graph_properties.def | 26 ++++++ .../detail/properties/graph_properties.hpp | 82 +++++++++++++++++ .../detail/properties/node_properties.def | 17 ++++ .../sycl/ext/oneapi/experimental/graph.hpp | 90 +------------------ 4 files changed, 127 insertions(+), 88 deletions(-) create mode 100644 sycl/include/sycl/ext/oneapi/experimental/detail/properties/graph_properties.def create mode 100644 sycl/include/sycl/ext/oneapi/experimental/detail/properties/graph_properties.hpp create mode 100644 sycl/include/sycl/ext/oneapi/experimental/detail/properties/node_properties.def diff --git a/sycl/include/sycl/ext/oneapi/experimental/detail/properties/graph_properties.def b/sycl/include/sycl/ext/oneapi/experimental/detail/properties/graph_properties.def new file mode 100644 index 0000000000000..ce177a9bb0a16 --- /dev/null +++ b/sycl/include/sycl/ext/oneapi/experimental/detail/properties/graph_properties.def @@ -0,0 +1,26 @@ +// --*- 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 + +/// Property passed to command_graph constructor to disable checking for cycles. +__SYCL_DATA_LESS_PROP(property::graph, no_cycle_check, GraphNoCycleCheck) + +/// Property passed to command_graph constructor to allow buffers to be used +/// with graphs. Passing this property represents a promise from the user that +/// the buffer will outlive any graph that it is used in. +__SYCL_DATA_LESS_PROP(property::graph, assume_buffer_outlives_graph, GraphAssumeBufferOutlivesGraph) + +/// Property passed to command_graph::finalize() to +/// mark the resulting executable command_graph as able to be updated. +__SYCL_DATA_LESS_PROP(property::graph, updatable, GraphUpdatable) + +/// Property used to enable executable graph profiling. Enables profiling on +/// events returned by submissions of the executable graph +__SYCL_DATA_LESS_PROP(property::graph, enable_profiling, GraphEnableProfiling) + +#undef __SYCL_DATA_LESS_PROP +#undef __SYCL_MANUALLY_DEFINED_PROP diff --git a/sycl/include/sycl/ext/oneapi/experimental/detail/properties/graph_properties.hpp b/sycl/include/sycl/ext/oneapi/experimental/detail/properties/graph_properties.hpp new file mode 100644 index 0000000000000..a92ccfdcb5778 --- /dev/null +++ b/sycl/include/sycl/ext/oneapi/experimental/detail/properties/graph_properties.hpp @@ -0,0 +1,82 @@ +//==----------- queue_properties.hpp --- SYCL queue properties -------------==// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#pragma once + +#include // for DataLessPropKind +#include // for is_property_of + +#include // for true_type + +namespace sycl { +inline namespace _V1 { +namespace ext { +namespace oneapi { +namespace experimental { +#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \ + namespace NS_QUALIFIER { \ + class PROP_NAME \ + : public sycl::detail::DataLessProperty {}; \ + } +#include + +#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \ + namespace NS_QUALIFIER { \ + class PROP_NAME \ + : public sycl::detail::DataLessProperty {}; \ + } +#include + +class node; +namespace property::node { +/// Property used to define dependent nodes when creating a new node with +/// command_graph::add(). +class depends_on : public ::sycl::detail::PropertyWithData< + ::sycl::detail::GraphNodeDependencies> { +public: + template depends_on(NodeTN... nodes) : MDeps{nodes...} {} + + const std::vector<::sycl::ext::oneapi::experimental::node> & + get_dependencies() const { + return MDeps; + } + +private: + const std::vector<::sycl::ext::oneapi::experimental::node> MDeps; +}; +} // namespace property::node + +// Graph property trait specializations. +enum class graph_state; +template class command_graph; + +} // namespace experimental +} // namespace oneapi +} // namespace ext + +#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 + +#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/ext/oneapi/experimental/detail/properties/node_properties.def b/sycl/include/sycl/ext/oneapi/experimental/detail/properties/node_properties.def new file mode 100644 index 0000000000000..7ded7609ca2d0 --- /dev/null +++ b/sycl/include/sycl/ext/oneapi/experimental/detail/properties/node_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 + +/// Property used to to add all previous graph leaves as dependencies when +/// creating a new node with command_graph::add(). +__SYCL_DATA_LESS_PROP(property::node, depends_on_all_leaves, GraphDependOnAllLeaves) + +// Contains data field, defined explicitly. +__SYCL_MANUALLY_DEFINED_PROP(property::node, depends_on) + +#undef __SYCL_DATA_LESS_PROP +#undef __SYCL_MANUALLY_DEFINED_PROP diff --git a/sycl/include/sycl/ext/oneapi/experimental/graph.hpp b/sycl/include/sycl/ext/oneapi/experimental/graph.hpp index e15d5ed5a6b7a..0126e8933734e 100644 --- a/sycl/include/sycl/ext/oneapi/experimental/graph.hpp +++ b/sycl/include/sycl/ext/oneapi/experimental/graph.hpp @@ -14,7 +14,8 @@ #include // for kernel_param_kind_t #include // for DataLessPropKind, PropWith... #include // for device -#include // for range, nd_range +#include // for graph properties classes +#include // for range, nd_range #include // for is_property, is_property_of #include // for property_list @@ -145,74 +146,6 @@ class __SYCL_EXPORT node { std::shared_ptr impl; }; -namespace property { -namespace graph { - -/// Property passed to command_graph constructor to disable checking for cycles. -/// -class no_cycle_check : public ::sycl::detail::DataLessProperty< - ::sycl::detail::GraphNoCycleCheck> { -public: - no_cycle_check() = default; -}; - -/// Property passed to command_graph constructor to allow buffers to be used -/// with graphs. Passing this property represents a promise from the user that -/// the buffer will outlive any graph that it is used in. -/// -class assume_buffer_outlives_graph - : public ::sycl::detail::DataLessProperty< - ::sycl::detail::GraphAssumeBufferOutlivesGraph> { -public: - assume_buffer_outlives_graph() = default; -}; - -/// Property passed to command_graph::finalize() to -/// mark the resulting executable command_graph as able to be updated. -class updatable - : public ::sycl::detail::DataLessProperty<::sycl::detail::GraphUpdatable> { -public: - updatable() = default; -}; - -/// Property used to enable executable graph profiling. Enables profiling on -/// events returned by submissions of the executable graph -class enable_profiling : public ::sycl::detail::DataLessProperty< - ::sycl::detail::GraphEnableProfiling> { -public: - enable_profiling() = default; -}; -} // namespace graph - -namespace node { - -/// Property used to define dependent nodes when creating a new node with -/// command_graph::add(). -class depends_on : public ::sycl::detail::PropertyWithData< - ::sycl::detail::GraphNodeDependencies> { -public: - template depends_on(NodeTN... nodes) : MDeps{nodes...} {} - - const std::vector<::sycl::ext::oneapi::experimental::node> & - get_dependencies() const { - return MDeps; - } - -private: - const std::vector<::sycl::ext::oneapi::experimental::node> MDeps; -}; - -/// Property used to to add all previous graph leaves as dependencies when -/// creating a new node with command_graph::add(). -class depends_on_all_leaves : public ::sycl::detail::DataLessProperty< - ::sycl::detail::GraphDependOnAllLeaves> { -public: - depends_on_all_leaves() = default; -}; - -} // namespace node -} // namespace property - namespace detail { // Templateless modifiable command-graph base class. class __SYCL_EXPORT modifiable_command_graph { @@ -497,24 +430,5 @@ command_graph(const context &SyclContext, const device &SyclDevice, } // namespace oneapi } // namespace ext -template <> -struct is_property - : std::true_type {}; - -template <> -struct is_property - : std::true_type {}; - -template <> -struct is_property_of< - ext::oneapi::experimental::property::graph::no_cycle_check, - ext::oneapi::experimental::command_graph< - ext::oneapi::experimental::graph_state::modifiable>> : std::true_type { -}; - -template <> -struct is_property_of : std::true_type {}; - } // namespace _V1 } // namespace sycl From f9c7862f8a0a5ecb3b2a1459c945f3f82c802344 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Wed, 9 Oct 2024 09:36:59 -0700 Subject: [PATCH 29/38] enable check for graph Signed-off-by: Tikhomirova, Kseniya --- .../sycl/ext/oneapi/experimental/graph.hpp | 4 + sycl/source/detail/graph_impl.cpp | 85 ++++++++++++++++++- sycl/source/detail/graph_impl.hpp | 22 +---- .../include_deps/sycl_detail_core.hpp.cpp | 3 + 4 files changed, 91 insertions(+), 23 deletions(-) diff --git a/sycl/include/sycl/ext/oneapi/experimental/graph.hpp b/sycl/include/sycl/ext/oneapi/experimental/graph.hpp index 0126e8933734e..80ed62f0cc9c1 100644 --- a/sycl/include/sycl/ext/oneapi/experimental/graph.hpp +++ b/sycl/include/sycl/ext/oneapi/experimental/graph.hpp @@ -167,6 +167,7 @@ class __SYCL_EXPORT modifiable_command_graph { /// @param PropList Property list used to pass [0..n] predecessor nodes. /// @return Constructed empty node which has been added to the graph. node add(const property_list &PropList = {}) { + checkNodePropertiesAndThrow(PropList); if (PropList.has_property()) { auto Deps = PropList.get_property(); node Node = addImpl(Deps.get_dependencies()); @@ -187,6 +188,7 @@ class __SYCL_EXPORT modifiable_command_graph { /// @param PropList Property list used to pass [0..n] predecessor nodes. /// @return Constructed node which has been added to the graph. template node add(T CGF, const property_list &PropList = {}) { + checkNodePropertiesAndThrow(PropList); if (PropList.has_property()) { auto Deps = PropList.get_property(); node Node = addImpl(CGF, Deps.get_dependencies()); @@ -285,6 +287,8 @@ class __SYCL_EXPORT modifiable_command_graph { friend T sycl::detail::createSyclObjFromImpl(decltype(T::impl) ImplObj); std::shared_ptr impl; + + void checkNodePropertiesAndThrow(const property_list &Properties); }; // Templateless executable command-graph base class. diff --git a/sycl/source/detail/graph_impl.cpp b/sycl/source/detail/graph_impl.cpp index 3fbda06f69b62..30b09886b96ff 100644 --- a/sycl/source/detail/graph_impl.cpp +++ b/sycl/source/detail/graph_impl.cpp @@ -296,6 +296,57 @@ void exec_graph_impl::makePartitions() { } } +static void checkGraphPropertiesAndThrow(const property_list &Properties) { + 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; + } + }; + sycl::detail::PropertyValidator::checkPropsAndThrow( + Properties, CheckDataLessProperties, CheckPropertiesWithData); +} + +graph_impl::graph_impl(const sycl::context &SyclContext, + const sycl::device &SyclDevice, + const sycl::property_list &PropList) + : MContext(SyclContext), MDevice(SyclDevice), MRecordingQueues(), + MEventsMap(), MInorderQueueMap() { + checkGraphPropertiesAndThrow(PropList); + if (PropList.has_property()) { + MSkipCycleChecks = true; + } + if (PropList.has_property()) { + MAllowBuffers = true; + } + + if (!SyclDevice.has(aspect::ext_oneapi_limited_graph) && + !SyclDevice.has(aspect::ext_oneapi_graph)) { + std::stringstream Stream; + Stream << SyclDevice.get_backend(); + std::string BackendString = Stream.str(); + throw sycl::exception( + sycl::make_error_code(errc::invalid), + BackendString + " backend is not supported by SYCL Graph extension."); + } +} + graph_impl::~graph_impl() { try { clearQueues(); @@ -781,7 +832,7 @@ exec_graph_impl::exec_graph_impl(sycl::context Context, MIsUpdatable(PropList.has_property()), MEnableProfiling( PropList.has_property()) { - + checkGraphPropertiesAndThrow(PropList); // If the graph has been marked as updatable then check if the backend // actually supports that. Devices supporting aspect::ext_oneapi_graph must // have support for graph update. @@ -1586,7 +1637,9 @@ modifiable_command_graph::finalize(const sycl::property_list &PropList) const { void modifiable_command_graph::begin_recording( queue &RecordingQueue, const sycl::property_list &PropList) { - std::ignore = PropList; + // No properties is handled here originally, just check that properties are + // related to graph at all. + checkGraphPropertiesAndThrow(PropList); auto QueueImpl = sycl::detail::getSyclObjImpl(RecordingQueue); assert(QueueImpl); @@ -1670,6 +1723,34 @@ std::vector modifiable_command_graph::get_root_nodes() const { return createNodesFromImpls(Impls); } +void modifiable_command_graph::checkNodePropertiesAndThrow( + const property_list &Properties) { + 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; + } + }; + sycl::detail::PropertyValidator::checkPropsAndThrow( + Properties, CheckDataLessProperties, CheckPropertiesWithData); +} + executable_command_graph::executable_command_graph( const std::shared_ptr &Graph, const sycl::context &Ctx, const property_list &PropList) diff --git a/sycl/source/detail/graph_impl.hpp b/sycl/source/detail/graph_impl.hpp index 4ee34830f39a2..8ab09f56724b1 100644 --- a/sycl/source/detail/graph_impl.hpp +++ b/sycl/source/detail/graph_impl.hpp @@ -860,27 +860,7 @@ class graph_impl : public std::enable_shared_from_this { /// @param SyclDevice Device to create nodes with. /// @param PropList Optional list of properties. graph_impl(const sycl::context &SyclContext, const sycl::device &SyclDevice, - const sycl::property_list &PropList = {}) - : MContext(SyclContext), MDevice(SyclDevice), MRecordingQueues(), - MEventsMap(), MInorderQueueMap() { - if (PropList.has_property()) { - MSkipCycleChecks = true; - } - if (PropList - .has_property()) { - MAllowBuffers = true; - } - - if (!SyclDevice.has(aspect::ext_oneapi_limited_graph) && - !SyclDevice.has(aspect::ext_oneapi_graph)) { - std::stringstream Stream; - Stream << SyclDevice.get_backend(); - std::string BackendString = Stream.str(); - throw sycl::exception( - sycl::make_error_code(errc::invalid), - BackendString + " backend is not supported by SYCL Graph extension."); - } - } + const sycl::property_list &PropList = {}); ~graph_impl(); diff --git a/sycl/test/include_deps/sycl_detail_core.hpp.cpp b/sycl/test/include_deps/sycl_detail_core.hpp.cpp index a9ca815bcfffd..e18a5be5e06fd 100644 --- a/sycl/test/include_deps/sycl_detail_core.hpp.cpp +++ b/sycl/test/include_deps/sycl_detail_core.hpp.cpp @@ -139,6 +139,9 @@ // CHECK-NEXT: ext/oneapi/properties/property_utils.hpp // CHECK-NEXT: ext/oneapi/properties/properties.hpp // CHECK-NEXT: ext/oneapi/experimental/graph.hpp +// CHECK-NEXT: ext/oneapi/experimental/detail/properties/graph_properties.hpp +// CHECK-NEXT: ext/oneapi/experimental/detail/properties/graph_properties.def +// CHECK-NEXT: ext/oneapi/experimental/detail/properties/node_properties.def // CHECK-NEXT: handler.hpp // CHECK-NEXT: detail/cl.h // CHECK-NEXT: CL/cl.h From 2d563ff2532e32c4a049565ed408e47958c11a17 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Wed, 9 Oct 2024 09:37:30 -0700 Subject: [PATCH 30/38] update linux symbols Signed-off-by: Tikhomirova, Kseniya --- sycl/test/abi/sycl_symbols_linux.dump | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sycl/test/abi/sycl_symbols_linux.dump b/sycl/test/abi/sycl_symbols_linux.dump index 30f1cb9d25308..0877a5df6e250 100644 --- a/sycl/test/abi/sycl_symbols_linux.dump +++ b/sycl/test/abi/sycl_symbols_linux.dump @@ -3080,6 +3080,7 @@ _ZN4sycl3_V13ext6oneapi12experimental6detail24modifiable_command_graph13end_reco _ZN4sycl3_V13ext6oneapi12experimental6detail24modifiable_command_graph15begin_recordingERKSt6vectorINS0_5queueESaIS7_EERKNS0_13property_listE _ZN4sycl3_V13ext6oneapi12experimental6detail24modifiable_command_graph15begin_recordingERNS0_5queueERKNS0_13property_listE _ZN4sycl3_V13ext6oneapi12experimental6detail24modifiable_command_graph24addGraphLeafDependenciesENS3_4nodeE +_ZN4sycl3_V13ext6oneapi12experimental6detail24modifiable_command_graph27checkNodePropertiesAndThrowERKNS0_13property_listE _ZN4sycl3_V13ext6oneapi12experimental6detail24modifiable_command_graph7addImplERKSt6vectorINS3_4nodeESaIS7_EE _ZN4sycl3_V13ext6oneapi12experimental6detail24modifiable_command_graph7addImplESt8functionIFvRNS0_7handlerEEERKSt6vectorINS3_4nodeESaISC_EE _ZN4sycl3_V13ext6oneapi12experimental6detail24modifiable_command_graph9make_edgeERNS3_4nodeES7_ @@ -3916,10 +3917,10 @@ _ZNK4sycl3_V16kernel16get_backend_infoINS0_4info6device15backend_versionEEENS0_6 _ZNK4sycl3_V16kernel16get_backend_infoINS0_4info6device7versionEEENS0_6detail20is_backend_info_descIT_E11return_typeEv _ZNK4sycl3_V16kernel16get_backend_infoINS0_4info8platform7versionEEENS0_6detail20is_backend_info_descIT_E11return_typeEv _ZNK4sycl3_V16kernel17get_kernel_bundleEv -_ZNK4sycl3_V16kernel3getEv +_ZNK4sycl3_V16kernel19ext_oneapi_get_infoINS0_3ext6oneapi12experimental4info21kernel_queue_specific19max_num_work_groupsEEENS0_6detail34is_kernel_queue_specific_info_descIT_E11return_typeENS0_5queueERKNS0_5rangeILi3EEEm _ZNK4sycl3_V16kernel19ext_oneapi_get_infoINS0_3ext6oneapi12experimental4info21kernel_queue_specific23max_num_work_group_syncEEENS0_6detail34is_kernel_queue_specific_info_descIT_E11return_typeENS0_5queueE _ZNK4sycl3_V16kernel19ext_oneapi_get_infoINS0_3ext6oneapi12experimental4info21kernel_queue_specific23max_num_work_group_syncEEENS0_6detail34is_kernel_queue_specific_info_descIT_E11return_typeENS0_5queueERKNS0_5rangeILi3EEEm -_ZNK4sycl3_V16kernel19ext_oneapi_get_infoINS0_3ext6oneapi12experimental4info21kernel_queue_specific19max_num_work_groupsEEENS0_6detail34is_kernel_queue_specific_info_descIT_E11return_typeENS0_5queueERKNS0_5rangeILi3EEEm +_ZNK4sycl3_V16kernel3getEv _ZNK4sycl3_V16kernel8get_infoINS0_4info22kernel_device_specific15work_group_sizeEEENS0_6detail35is_kernel_device_specific_info_descIT_E11return_typeERKNS0_6deviceE _ZNK4sycl3_V16kernel8get_infoINS0_4info22kernel_device_specific16global_work_sizeEEENS0_6detail35is_kernel_device_specific_info_descIT_E11return_typeERKNS0_6deviceE _ZNK4sycl3_V16kernel8get_infoINS0_4info22kernel_device_specific16private_mem_sizeEEENS0_6detail35is_kernel_device_specific_info_descIT_E11return_typeERKNS0_6deviceE From 483e645149608d04c605ba8a802ccf029062c87a Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Thu, 10 Oct 2024 03:45:48 -0700 Subject: [PATCH 31/38] add graph property validation Signed-off-by: Tikhomirova, Kseniya --- sycl/test/basic_tests/property_traits.cpp | 126 +++++++++++++++++++++- 1 file changed, 123 insertions(+), 3 deletions(-) diff --git a/sycl/test/basic_tests/property_traits.cpp b/sycl/test/basic_tests/property_traits.cpp index f827803220f34..85611b48b1a69 100644 --- a/sycl/test/basic_tests/property_traits.cpp +++ b/sycl/test/basic_tests/property_traits.cpp @@ -77,6 +77,19 @@ int main() { // Reduction is_property CHECK_IS_PROPERTY(property::reduction::initialize_to_identity); + // Graph is_property + CHECK_IS_PROPERTY(ext::oneapi::experimental::property::graph::no_cycle_check); + CHECK_IS_PROPERTY( + ext::oneapi::experimental::property::graph::assume_buffer_outlives_graph); + CHECK_IS_PROPERTY(ext::oneapi::experimental::property::graph::updatable); + CHECK_IS_PROPERTY( + ext::oneapi::experimental::property::graph::enable_profiling); + + // Node is_property + CHECK_IS_PROPERTY( + ext::oneapi::experimental::property::node::depends_on_all_leaves); + CHECK_IS_PROPERTY(ext::oneapi::experimental::property::node::depends_on); + //---------------------------------------------------------------------------- // is_property negative tests //---------------------------------------------------------------------------- @@ -127,8 +140,32 @@ int main() { CHECK_IS_PROPERTY_OF(ext::oneapi::cuda::property::queue::use_default_stream, queue); + // Graph is_property_of + CHECK_IS_PROPERTY_OF( + ext::oneapi::experimental::property::graph::no_cycle_check, + ext::oneapi::experimental::command_graph< + ext::oneapi::experimental::graph_state::modifiable>); + CHECK_IS_PROPERTY_OF( + ext::oneapi::experimental::property::graph::assume_buffer_outlives_graph, + ext::oneapi::experimental::command_graph< + ext::oneapi::experimental::graph_state::modifiable>); + CHECK_IS_PROPERTY_OF(ext::oneapi::experimental::property::graph::updatable, + ext::oneapi::experimental::command_graph< + ext::oneapi::experimental::graph_state::modifiable>); + CHECK_IS_PROPERTY_OF( + ext::oneapi::experimental::property::graph::enable_profiling, + ext::oneapi::experimental::command_graph< + ext::oneapi::experimental::graph_state::modifiable>); + + // Node is_property_of + CHECK_IS_PROPERTY_OF( + ext::oneapi::experimental::property::node::depends_on_all_leaves, + ext::oneapi::experimental::node); + CHECK_IS_PROPERTY_OF(ext::oneapi::experimental::property::node::depends_on, + ext::oneapi::experimental::node); + //---------------------------------------------------------------------------- - // is_property_of positive tests + // is_property_of negative tests //---------------------------------------------------------------------------- // Valid properties with invalid object type @@ -155,6 +192,24 @@ int main() { CHECK_IS_NOT_PROPERTY_OF( ext::oneapi::cuda::property::queue::use_default_stream, NotASYCLObject); + CHECK_IS_NOT_PROPERTY_OF( + ext::oneapi::experimental::property::graph::no_cycle_check, + NotASYCLObject); + CHECK_IS_NOT_PROPERTY_OF( + ext::oneapi::experimental::property::graph::assume_buffer_outlives_graph, + NotASYCLObject); + CHECK_IS_NOT_PROPERTY_OF( + ext::oneapi::experimental::property::graph::updatable, NotASYCLObject); + CHECK_IS_NOT_PROPERTY_OF( + ext::oneapi::experimental::property::graph::enable_profiling, + NotASYCLObject); + + CHECK_IS_NOT_PROPERTY_OF( + ext::oneapi::experimental::property::node::depends_on_all_leaves, + NotASYCLObject); + CHECK_IS_NOT_PROPERTY_OF( + ext::oneapi::experimental::property::node::depends_on, NotASYCLObject); + // Invalid properties with valid object type CHECK_IS_NOT_PROPERTY_OF(NotAProperty, accessor); CHECK_IS_NOT_PROPERTY_OF(NotAProperty, host_accessor); @@ -162,6 +217,10 @@ int main() { CHECK_IS_NOT_PROPERTY_OF(NotAProperty, context); CHECK_IS_NOT_PROPERTY_OF(NotAProperty, image<1>); CHECK_IS_NOT_PROPERTY_OF(NotAProperty, queue); + CHECK_IS_NOT_PROPERTY_OF(NotAProperty, ext::oneapi::experimental::node); + CHECK_IS_NOT_PROPERTY_OF( + NotAProperty, ext::oneapi::experimental::command_graph< + ext::oneapi::experimental::graph_state::modifiable>); // Invalid properties with invalid object type CHECK_IS_NOT_PROPERTY_OF(NotAProperty, NotASYCLObject); @@ -194,6 +253,23 @@ int main() { CHECK_IS_PROPERTY_V(property::queue::cuda::use_default_stream); CHECK_IS_PROPERTY_V(ext::oneapi::cuda::property::queue::use_default_stream); + // Reduction is_property_v + CHECK_IS_PROPERTY_V(property::reduction::initialize_to_identity); + + // Graph is_property_v + CHECK_IS_PROPERTY_V( + ext::oneapi::experimental::property::graph::no_cycle_check); + CHECK_IS_PROPERTY_V( + ext::oneapi::experimental::property::graph::assume_buffer_outlives_graph); + CHECK_IS_PROPERTY_V(ext::oneapi::experimental::property::graph::updatable); + CHECK_IS_PROPERTY_V( + ext::oneapi::experimental::property::graph::enable_profiling); + + // Node is_property_v + CHECK_IS_PROPERTY_V( + ext::oneapi::experimental::property::node::depends_on_all_leaves); + CHECK_IS_PROPERTY_V(ext::oneapi::experimental::property::node::depends_on); + //---------------------------------------------------------------------------- // is_property_v negative tests //---------------------------------------------------------------------------- @@ -264,8 +340,30 @@ int main() { CHECK_IS_PROPERTY_OF_V(ext::oneapi::cuda::property::queue::use_default_stream, queue); - // Reduction is_property_v - CHECK_IS_PROPERTY_V(property::reduction::initialize_to_identity); + // Graph is_property_of_v + CHECK_IS_PROPERTY_OF_V( + ext::oneapi::experimental::property::graph::no_cycle_check, + ext::oneapi::experimental::command_graph< + ext::oneapi::experimental::graph_state::modifiable>); + CHECK_IS_PROPERTY_OF_V( + ext::oneapi::experimental::property::graph::assume_buffer_outlives_graph, + ext::oneapi::experimental::command_graph< + ext::oneapi::experimental::graph_state::modifiable>); + CHECK_IS_PROPERTY_OF_V( + ext::oneapi::experimental::property::graph::updatable, + ext::oneapi::experimental::command_graph< + ext::oneapi::experimental::graph_state::modifiable>); + CHECK_IS_PROPERTY_OF_V( + ext::oneapi::experimental::property::graph::enable_profiling, + ext::oneapi::experimental::command_graph< + ext::oneapi::experimental::graph_state::modifiable>); + + // Node is_property_of_v + CHECK_IS_PROPERTY_OF_V( + ext::oneapi::experimental::property::node::depends_on_all_leaves, + ext::oneapi::experimental::node); + CHECK_IS_PROPERTY_OF_V(ext::oneapi::experimental::property::node::depends_on, + ext::oneapi::experimental::node); //---------------------------------------------------------------------------- // is_property_of positive tests @@ -295,6 +393,24 @@ int main() { CHECK_IS_NOT_PROPERTY_OF_V( ext::oneapi::cuda::property::queue::use_default_stream, NotASYCLObject); + CHECK_IS_NOT_PROPERTY_OF_V( + ext::oneapi::experimental::property::graph::no_cycle_check, + NotASYCLObject); + CHECK_IS_NOT_PROPERTY_OF_V( + ext::oneapi::experimental::property::graph::assume_buffer_outlives_graph, + NotASYCLObject); + CHECK_IS_NOT_PROPERTY_OF_V( + ext::oneapi::experimental::property::graph::updatable, NotASYCLObject); + CHECK_IS_NOT_PROPERTY_OF_V( + ext::oneapi::experimental::property::graph::enable_profiling, + NotASYCLObject); + + CHECK_IS_NOT_PROPERTY_OF_V( + ext::oneapi::experimental::property::node::depends_on_all_leaves, + NotASYCLObject); + CHECK_IS_NOT_PROPERTY_OF_V( + ext::oneapi::experimental::property::node::depends_on, NotASYCLObject); + // Invalid properties with valid object type CHECK_IS_NOT_PROPERTY_OF_V(NotAProperty, accessor); CHECK_IS_NOT_PROPERTY_OF_V(NotAProperty, host_accessor); @@ -302,6 +418,10 @@ int main() { CHECK_IS_NOT_PROPERTY_OF_V(NotAProperty, context); CHECK_IS_NOT_PROPERTY_OF_V(NotAProperty, image<1>); CHECK_IS_NOT_PROPERTY_OF_V(NotAProperty, queue); + CHECK_IS_NOT_PROPERTY_OF_V(NotAProperty, ext::oneapi::experimental::node); + CHECK_IS_NOT_PROPERTY_OF_V( + NotAProperty, ext::oneapi::experimental::command_graph< + ext::oneapi::experimental::graph_state::modifiable>); // Invalid properties with invalid object type CHECK_IS_NOT_PROPERTY_OF_V(NotAProperty, NotASYCLObject); From f009c2751df162d93a5d1f0f68f3d4d450ba103f Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Thu, 10 Oct 2024 04:48:07 -0700 Subject: [PATCH 32/38] add unittests Signed-off-by: Tikhomirova, Kseniya --- .../Extensions/CommandGraph/CMakeLists.txt | 1 + .../Extensions/CommandGraph/Properties.cpp | 47 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 sycl/unittests/Extensions/CommandGraph/Properties.cpp diff --git a/sycl/unittests/Extensions/CommandGraph/CMakeLists.txt b/sycl/unittests/Extensions/CommandGraph/CMakeLists.txt index b7213d2eaeae6..31f899f6a2349 100644 --- a/sycl/unittests/Extensions/CommandGraph/CMakeLists.txt +++ b/sycl/unittests/Extensions/CommandGraph/CMakeLists.txt @@ -10,4 +10,5 @@ add_sycl_unittest(CommandGraphExtensionTests OBJECT Regressions.cpp Subgraph.cpp Update.cpp + Properties.cpp ) diff --git a/sycl/unittests/Extensions/CommandGraph/Properties.cpp b/sycl/unittests/Extensions/CommandGraph/Properties.cpp new file mode 100644 index 0000000000000..ac6d6bdc1a462 --- /dev/null +++ b/sycl/unittests/Extensions/CommandGraph/Properties.cpp @@ -0,0 +1,47 @@ +//==------------------------- Properties.cpp -------------------------------==// +// +// 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 "Common.hpp" + +using namespace sycl; +using namespace sycl::ext::oneapi; + +class UnknownProperty : public ::sycl::detail::DataLessProperty< + ::sycl::detail::LastKnownDataLessPropKind + 1> { +public: + UnknownProperty() = default; +}; + +// Negative tests for properties of graph. Positive checks are included to other +// graph tests verifying exact properties usage. +TEST_F(CommandGraphTest, PropertiesCheckInvalidNode) { + try { + auto Node1 = Graph.add( + [&](sycl::handler &cgh) { cgh.single_task>([]() {}); }, + UnknownProperty{}); + } 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_F(CommandGraphTest, PropertiesCheckFinalize) { + try { + auto ExecGraphUpdatable = Graph.finalize(UnknownProperty{}); + } 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 460470a9ae59baf241c3296aa33e37e589211783 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Thu, 10 Oct 2024 07:21:56 -0700 Subject: [PATCH 33/38] update win symbols Signed-off-by: Tikhomirova, Kseniya --- sycl/test/abi/sycl_symbols_windows.dump | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sycl/test/abi/sycl_symbols_windows.dump b/sycl/test/abi/sycl_symbols_windows.dump index 17a1e6b9fc167..e8da003ce2d11 100644 --- a/sycl/test/abi/sycl_symbols_windows.dump +++ b/sycl/test/abi/sycl_symbols_windows.dump @@ -3720,6 +3720,7 @@ ?build_impl@detail@_V1@sycl@@YA?AV?$shared_ptr@Vkernel_bundle_impl@detail@_V1@sycl@@@std@@AEBV?$kernel_bundle@$0A@@23@AEBV?$vector@Vdevice@_V1@sycl@@V?$allocator@Vdevice@_V1@sycl@@@std@@@5@AEBVproperty_list@23@@Z ?cancel_fusion@fusion_wrapper@experimental@codeplay@ext@_V1@sycl@@QEAAXXZ ?category@exception@_V1@sycl@@QEBAAEBVerror_category@std@@XZ +?checkNodePropertiesAndThrow@modifiable_command_graph@detail@experimental@oneapi@ext@_V1@sycl@@IEAAXAEBVproperty_list@67@@Z ?clearArgs@handler@_V1@sycl@@AEAAXXZ ?code@exception@_V1@sycl@@QEBAAEBVerror_code@std@@XZ ?compile_impl@detail@_V1@sycl@@YA?AV?$shared_ptr@Vkernel_bundle_impl@detail@_V1@sycl@@@std@@AEBV?$kernel_bundle@$0A@@23@AEBV?$vector@Vdevice@_V1@sycl@@V?$allocator@Vdevice@_V1@sycl@@@std@@@5@AEBVproperty_list@23@@Z @@ -4267,10 +4268,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 From bd99f584f47905d3978bd4fbaa16de15acc4d7d5 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Fri, 11 Oct 2024 07:12:53 -0700 Subject: [PATCH 34/38] fix potential warnings Signed-off-by: Tikhomirova, Kseniya --- sycl/source/detail/graph_impl.cpp | 15 +++------------ .../detail/program_manager/program_manager.cpp | 8 ++++---- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/sycl/source/detail/graph_impl.cpp b/sycl/source/detail/graph_impl.cpp index 61aeff9af660d..57e346092840b 100644 --- a/sycl/source/detail/graph_impl.cpp +++ b/sycl/source/detail/graph_impl.cpp @@ -309,19 +309,10 @@ static void checkGraphPropertiesAndThrow(const property_list &Properties) { 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; - } - }; + // No properties with data for graph now. + auto NoAllowedPropertiesCheck = [](int) { return false; }; sycl::detail::PropertyValidator::checkPropsAndThrow( - Properties, CheckDataLessProperties, CheckPropertiesWithData); + Properties, CheckDataLessProperties, NoAllowedPropertiesCheck); } graph_impl::graph_impl(const sycl::context &SyclContext, diff --git a/sycl/source/detail/program_manager/program_manager.cpp b/sycl/source/detail/program_manager/program_manager.cpp index 0c4d6c8a83f30..0689a72fc114d 100644 --- a/sycl/source/detail/program_manager/program_manager.cpp +++ b/sycl/source/detail/program_manager/program_manager.cpp @@ -2335,7 +2335,7 @@ ProgramManager::compile(const device_image_plain &DeviceImage, const std::vector &Devs, const property_list &PropList) { { - auto NoAllowedPropertiesCheck = [](int PropertyKind) { return false; }; + auto NoAllowedPropertiesCheck = [](int) { return false; }; detail::PropertyValidator::checkPropsAndThrow( PropList, NoAllowedPropertiesCheck, NoAllowedPropertiesCheck); } @@ -2405,7 +2405,7 @@ ProgramManager::link(const device_image_plain &DeviceImage, const std::vector &Devs, const property_list &PropList) { { - auto NoAllowedPropertiesCheck = [](int PropertyKind) { return false; }; + auto NoAllowedPropertiesCheck = [](int) { return false; }; detail::PropertyValidator::checkPropsAndThrow( PropList, NoAllowedPropertiesCheck, NoAllowedPropertiesCheck); } @@ -2526,7 +2526,7 @@ device_image_plain ProgramManager::build(const device_image_plain &DeviceImage, const std::vector &Devs, const property_list &PropList) { { - auto NoAllowedPropertiesCheck = [](int PropertyKind) { return false; }; + auto NoAllowedPropertiesCheck = [](int) { return false; }; detail::PropertyValidator::checkPropsAndThrow( PropList, NoAllowedPropertiesCheck, NoAllowedPropertiesCheck); } @@ -2691,7 +2691,7 @@ ProgramManager::getOrCreateKernel(const context &Context, ur_program_handle_t Program) { { - auto NoAllowedPropertiesCheck = [](int PropertyKind) { return false; }; + auto NoAllowedPropertiesCheck = [](int) { return false; }; detail::PropertyValidator::checkPropsAndThrow( PropList, NoAllowedPropertiesCheck, NoAllowedPropertiesCheck); } From 8612578bb4510b30c93456515d56de0319effb2a Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Tue, 15 Oct 2024 06:39:11 -0700 Subject: [PATCH 35/38] fix forward declaration issues Signed-off-by: Tikhomirova, Kseniya --- .../detail/properties/graph_properties.hpp | 17 +---------------- .../sycl/ext/oneapi/experimental/graph.hpp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/sycl/include/sycl/ext/oneapi/experimental/detail/properties/graph_properties.hpp b/sycl/include/sycl/ext/oneapi/experimental/detail/properties/graph_properties.hpp index a92ccfdcb5778..8736d5595af9a 100644 --- a/sycl/include/sycl/ext/oneapi/experimental/detail/properties/graph_properties.hpp +++ b/sycl/include/sycl/ext/oneapi/experimental/detail/properties/graph_properties.hpp @@ -34,23 +34,8 @@ namespace experimental { class node; namespace property::node { -/// Property used to define dependent nodes when creating a new node with -/// command_graph::add(). -class depends_on : public ::sycl::detail::PropertyWithData< - ::sycl::detail::GraphNodeDependencies> { -public: - template depends_on(NodeTN... nodes) : MDeps{nodes...} {} - - const std::vector<::sycl::ext::oneapi::experimental::node> & - get_dependencies() const { - return MDeps; - } - -private: - const std::vector<::sycl::ext::oneapi::experimental::node> MDeps; -}; +class depends_on; } // namespace property::node - // Graph property trait specializations. enum class graph_state; template class command_graph; diff --git a/sycl/include/sycl/ext/oneapi/experimental/graph.hpp b/sycl/include/sycl/ext/oneapi/experimental/graph.hpp index 80ed62f0cc9c1..5f343fb496017 100644 --- a/sycl/include/sycl/ext/oneapi/experimental/graph.hpp +++ b/sycl/include/sycl/ext/oneapi/experimental/graph.hpp @@ -146,6 +146,24 @@ class __SYCL_EXPORT node { std::shared_ptr impl; }; +namespace property::node { +/// Property used to define dependent nodes when creating a new node with +/// command_graph::add(). +class depends_on : public ::sycl::detail::PropertyWithData< + ::sycl::detail::GraphNodeDependencies> { +public: + template depends_on(NodeTN... nodes) : MDeps{nodes...} {} + + const std::vector<::sycl::ext::oneapi::experimental::node> & + get_dependencies() const { + return MDeps; + } + +private: + const std::vector<::sycl::ext::oneapi::experimental::node> MDeps; +}; +} // namespace property::node + namespace detail { // Templateless modifiable command-graph base class. class __SYCL_EXPORT modifiable_command_graph { From 808287ac7f44524821db9d33b84c4c807534422b Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Thu, 19 Dec 2024 04:43:53 -0800 Subject: [PATCH 36/38] fix code-review comments Signed-off-by: Tikhomirova, Kseniya --- sycl/unittests/Extensions/CommandGraph/Properties.cpp | 2 +- sycl/unittests/kernel-and-program/KernelBuildOptions.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sycl/unittests/Extensions/CommandGraph/Properties.cpp b/sycl/unittests/Extensions/CommandGraph/Properties.cpp index ac6d6bdc1a462..a896e4ba47314 100644 --- a/sycl/unittests/Extensions/CommandGraph/Properties.cpp +++ b/sycl/unittests/Extensions/CommandGraph/Properties.cpp @@ -44,4 +44,4 @@ TEST_F(CommandGraphTest, PropertiesCheckFinalize) { } FAIL() << "Test must exit in exception handler. Exception is not thrown."; -} \ No newline at end of file +} diff --git a/sycl/unittests/kernel-and-program/KernelBuildOptions.cpp b/sycl/unittests/kernel-and-program/KernelBuildOptions.cpp index c262be31cb98c..2c34ba6d11604 100644 --- a/sycl/unittests/kernel-and-program/KernelBuildOptions.cpp +++ b/sycl/unittests/kernel-and-program/KernelBuildOptions.cpp @@ -111,7 +111,7 @@ TEST(KernelBuildOptions, KernelBundleBasic) { sycl::get_kernel_bundle(Ctx, {Dev}, {KernelID}); try { - // no supported properties now + // unsupported property auto ExecBundle = sycl::build(KernelBundle, sycl::property::no_init{}); FAIL(); } catch (sycl::exception &e) { From 7ceb2b88a8b3e9e75b6c24158f029eb24f0180f6 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Thu, 19 Dec 2024 06:57:52 -0800 Subject: [PATCH 37/38] fix comments Signed-off-by: Tikhomirova, Kseniya --- .../oneapi/experimental/detail/properties/graph_properties.hpp | 2 +- sycl/include/sycl/ext/oneapi/experimental/graph.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sycl/include/sycl/ext/oneapi/experimental/detail/properties/graph_properties.hpp b/sycl/include/sycl/ext/oneapi/experimental/detail/properties/graph_properties.hpp index 8736d5595af9a..6111e9f8aa5fb 100644 --- a/sycl/include/sycl/ext/oneapi/experimental/detail/properties/graph_properties.hpp +++ b/sycl/include/sycl/ext/oneapi/experimental/detail/properties/graph_properties.hpp @@ -1,4 +1,4 @@ -//==----------- queue_properties.hpp --- SYCL queue properties -------------==// +//==----------- graph_properties.hpp --- SYCL graph properties -------------==// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/sycl/include/sycl/ext/oneapi/experimental/graph.hpp b/sycl/include/sycl/ext/oneapi/experimental/graph.hpp index 114c19492fb8b..0df1c8d3cb5a2 100644 --- a/sycl/include/sycl/ext/oneapi/experimental/graph.hpp +++ b/sycl/include/sycl/ext/oneapi/experimental/graph.hpp @@ -339,7 +339,7 @@ class __SYCL_EXPORT modifiable_command_graph friend T sycl::detail::createSyclObjFromImpl(decltype(T::impl) ImplObj); std::shared_ptr impl; - void checkNodePropertiesAndThrow(const property_list &Properties); + static void checkNodePropertiesAndThrow(const property_list &Properties); }; #ifdef __SYCL_GRAPH_IMPL_CPP From 9e874d3360377a19607b56100a4230bfae6394d1 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Thu, 19 Dec 2024 09:26:58 -0800 Subject: [PATCH 38/38] update win symbols Signed-off-by: Tikhomirova, Kseniya --- sycl/test/abi/sycl_symbols_windows.dump | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/test/abi/sycl_symbols_windows.dump b/sycl/test/abi/sycl_symbols_windows.dump index a8746ce8c604f..a439081b1f382 100644 --- a/sycl/test/abi/sycl_symbols_windows.dump +++ b/sycl/test/abi/sycl_symbols_windows.dump @@ -3749,7 +3749,7 @@ ?build_impl@detail@_V1@sycl@@YA?AV?$shared_ptr@Vkernel_bundle_impl@detail@_V1@sycl@@@std@@AEBV?$kernel_bundle@$0A@@23@AEBV?$vector@Vdevice@_V1@sycl@@V?$allocator@Vdevice@_V1@sycl@@@std@@@5@AEBVproperty_list@23@@Z ?cancel_fusion@fusion_wrapper@experimental@codeplay@ext@_V1@sycl@@QEAAXXZ ?category@exception@_V1@sycl@@QEBAAEBVerror_category@std@@XZ -?checkNodePropertiesAndThrow@modifiable_command_graph@detail@experimental@oneapi@ext@_V1@sycl@@IEAAXAEBVproperty_list@67@@Z +?checkNodePropertiesAndThrow@modifiable_command_graph@detail@experimental@oneapi@ext@_V1@sycl@@KAXAEBVproperty_list@67@@Z ?clearArgs@handler@_V1@sycl@@AEAAXXZ ?code@exception@_V1@sycl@@QEBAAEBVerror_code@std@@XZ ?compile_impl@?$online_compiler@$00@experimental@intel@ext@_V1@sycl@@CA?AV?$vector@EV?$allocator@E@std@@@std@@Vstring_view@detail@56@AEBV?$vector@Vstring_view@detail@_V1@sycl@@V?$allocator@Vstring_view@detail@_V1@sycl@@@std@@@8@U?$pair@HH@8@W4device_type@info@56@Vdevice_arch@23456@_N0AEAPEAX6@Z