From 9d6a1bf246c7b026dc7340f5e814a98e36229a38 Mon Sep 17 00:00:00 2001 From: mdimakov Date: Thu, 3 Feb 2022 14:31:44 +0300 Subject: [PATCH 01/27] Return cleanupdep This reverts commit 34a46899b1915fd07531fdd20c5f8c7370a6b79a. --- sycl/source/detail/scheduler/commands.hpp | 3 +-- sycl/source/detail/scheduler/graph_builder.cpp | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sycl/source/detail/scheduler/commands.hpp b/sycl/source/detail/scheduler/commands.hpp index 82c42711b2da1..fda358de85310 100644 --- a/sycl/source/detail/scheduler/commands.hpp +++ b/sycl/source/detail/scheduler/commands.hpp @@ -20,7 +20,6 @@ #include #include #include -#include #include __SYCL_INLINE_NAMESPACE(cl) { @@ -189,7 +188,7 @@ class Command { return nullptr; } - virtual ~Command() { MEvent->cleanupDependencyEvents(); } + virtual ~Command() = default; const char *getBlockReason() const; diff --git a/sycl/source/detail/scheduler/graph_builder.cpp b/sycl/source/detail/scheduler/graph_builder.cpp index ed2ee3e6f78dc..ff867ae2d1815 100644 --- a/sycl/source/detail/scheduler/graph_builder.cpp +++ b/sycl/source/detail/scheduler/graph_builder.cpp @@ -129,6 +129,7 @@ static void handleVisitedNodes(std::vector &Visited) { for (Command *Cmd : Visited) { if (Cmd->MMarks.MToBeDeleted) { Cmd->getEvent()->setCommand(nullptr); + Cmd->getEvent()->cleanupDependencyEvents(); delete Cmd; } else Cmd->MMarks.MVisited = false; @@ -1186,6 +1187,7 @@ void Scheduler::GraphBuilder::cleanupCommand(Command *Cmd) { } Cmd->getEvent()->setCommand(nullptr); + Cmd->getEvent()->cleanupDependencyEvents(); delete Cmd; } From a3c2249a4b1a95c5cb6c6ddb961b1505dd65ff3f Mon Sep 17 00:00:00 2001 From: mdimakov Date: Thu, 3 Feb 2022 15:05:52 +0300 Subject: [PATCH 02/27] Return old option --- sycl/source/detail/event_impl.cpp | 48 ++++--------------- sycl/source/detail/event_impl.hpp | 29 ----------- sycl/source/detail/scheduler/commands.cpp | 10 +--- sycl/source/detail/scheduler/commands.hpp | 6 +-- .../source/detail/scheduler/graph_builder.cpp | 3 +- .../detail/scheduler/graph_processor.cpp | 15 ++++++ sycl/source/detail/scheduler/scheduler.cpp | 5 ++ sycl/source/detail/scheduler/scheduler.hpp | 8 +++- sycl/source/event.cpp | 2 +- 9 files changed, 43 insertions(+), 83 deletions(-) diff --git a/sycl/source/detail/event_impl.cpp b/sycl/source/detail/event_impl.cpp index f615f37214208..922dda6393909 100644 --- a/sycl/source/detail/event_impl.cpp +++ b/sycl/source/detail/event_impl.cpp @@ -221,24 +221,18 @@ void event_impl::wait( void event_impl::wait_and_throw( std::shared_ptr Self) { - Scheduler &Sched = Scheduler::getInstance(); - + Command *Cmd = static_cast(Self->getCommand()); QueueImplPtr submittedQueue = nullptr; - { - Scheduler::ReadLockT Lock(Sched.MGraphLock); - Command *Cmd = static_cast(Self->getCommand()); - if (Cmd) - submittedQueue = Cmd->getSubmittedQueue(); - } + if (Cmd) + submittedQueue = Cmd->getSubmittedQueue(); + wait(Self); - { - Scheduler::ReadLockT Lock(Sched.MGraphLock); - for (auto &EventImpl : getWaitList()) { - Command *Cmd = (Command *)EventImpl->getCommand(); - if (Cmd) - Cmd->getSubmittedQueue()->throw_asynchronous(); - } + for (auto &EventImpl : + detail::Scheduler::getInstance().getWaitList(std::move(Self))) { + Command *Cmd = (Command *)EventImpl->getCommand(); + if (Cmd) + Cmd->getSubmittedQueue()->throw_asynchronous(); } if (submittedQueue) submittedQueue->throw_asynchronous(); @@ -345,24 +339,6 @@ pi_native_handle event_impl::getNative() const { return Handle; } -std::vector event_impl::getWaitList() { - if (MState == HES_Discarded) - throw sycl::exception( - make_error_code(errc::invalid), - "get_wait_list() cannot be used for a discarded event."); - - std::lock_guard Lock(MMutex); - - std::vector Result; - Result.reserve(MPreparedDepsEvents.size() + MPreparedHostDepsEvents.size()); - Result.insert(Result.end(), MPreparedDepsEvents.begin(), - MPreparedDepsEvents.end()); - Result.insert(Result.end(), MPreparedHostDepsEvents.begin(), - MPreparedHostDepsEvents.end()); - - return Result; -} - void event_impl::flushIfNeeded(const QueueImplPtr &UserQueue) { if (MIsFlushed) return; @@ -389,12 +365,6 @@ void event_impl::flushIfNeeded(const QueueImplPtr &UserQueue) { MIsFlushed = true; } -void event_impl::cleanupDependencyEvents() { - std::lock_guard Lock(MMutex); - MPreparedDepsEvents.clear(); - MPreparedHostDepsEvents.clear(); -} - } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/event_impl.hpp b/sycl/source/detail/event_impl.hpp index 0e7b896a596f7..1afeda1c3635b 100644 --- a/sycl/source/detail/event_impl.hpp +++ b/sycl/source/detail/event_impl.hpp @@ -27,8 +27,6 @@ class context_impl; using ContextImplPtr = std::shared_ptr; class queue_impl; using QueueImplPtr = std::shared_ptr; -class event_impl; -using EventImplPtr = std::shared_ptr; class event_impl { public: @@ -169,33 +167,12 @@ class event_impl { /// \return a native handle. pi_native_handle getNative() const; - /// Returns vector of event dependencies. - /// - /// @return a reference to MPreparedDepsEvents. - std::vector> &getPreparedDepsEvents() { - return MPreparedDepsEvents; - } - - /// Returns vector of host event dependencies. - /// - /// @return a reference to MPreparedHostDepsEvents. - std::vector> &getPreparedHostDepsEvents() { - return MPreparedHostDepsEvents; - } - - /// Returns vector of event_impl that this event_impl depends on. - /// - /// @return a vector of "immediate" dependencies for this event_impl. - std::vector getWaitList(); /// Performs a flush on the queue associated with this event if the user queue /// is different and the task associated with this event hasn't been submitted /// to the device yet. void flushIfNeeded(const QueueImplPtr &UserQueue); - /// Cleans dependencies of this event_impl - void cleanupDependencyEvents(); - /// Checks if this event is discarded by SYCL implementation. /// /// \return true if this event is discarded. @@ -223,10 +200,6 @@ class event_impl { void *MCommand = nullptr; std::weak_ptr MQueue; - /// Dependency events prepared for waiting by backend. - std::vector MPreparedDepsEvents; - std::vector MPreparedHostDepsEvents; - /// Indicates that the task associated with this event has been submitted by /// the queue to the device. std::atomic MIsFlushed = false; @@ -241,8 +214,6 @@ class event_impl { // handled by post enqueue cleanup yet and has to be deleted by cleanup after // wait. bool MNeedsCleanupAfterWait = false; - - std::mutex MMutex; }; } // namespace detail diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index 7a7d4f594a13d..83b13d35dba7b 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -351,16 +351,10 @@ void Command::waitForEvents(QueueImplPtr Queue, } } -/// It is safe to bind MPreparedDepsEvents and MPreparedHostDepsEvents -/// references to event_impl class members because Command -/// should not outlive the event connected to it. Command::Command(CommandType Type, QueueImplPtr Queue) - : MQueue(std::move(Queue)), - MEvent(std::make_shared(MQueue)), - MPreparedDepsEvents(MEvent->getPreparedDepsEvents()), - MPreparedHostDepsEvents(MEvent->getPreparedHostDepsEvents()), - MType(Type) { + : MQueue(std::move(Queue)), MType(Type) { MSubmittedQueue = MQueue; + MEvent.reset(new detail::event_impl(MQueue)); MEvent->setCommand(this); MEvent->setContextImpl(MQueue->getContextImplPtr()); MEnqueueStatus = EnqueueResultT::SyclEnqueueReady; diff --git a/sycl/source/detail/scheduler/commands.hpp b/sycl/source/detail/scheduler/commands.hpp index fda358de85310..92ce332a1dde9 100644 --- a/sycl/source/detail/scheduler/commands.hpp +++ b/sycl/source/detail/scheduler/commands.hpp @@ -207,14 +207,14 @@ class Command { virtual bool supportsPostEnqueueCleanup() const; protected: + EventImplPtr MEvent; QueueImplPtr MQueue; QueueImplPtr MSubmittedQueue; - EventImplPtr MEvent; /// Dependency events prepared for waiting by backend. /// See processDepEvent for details. - std::vector &MPreparedDepsEvents; - std::vector &MPreparedHostDepsEvents; + std::vector MPreparedDepsEvents; + std::vector MPreparedHostDepsEvents; void waitForEvents(QueueImplPtr Queue, std::vector &RawEvents, RT::PiEvent &Event); diff --git a/sycl/source/detail/scheduler/graph_builder.cpp b/sycl/source/detail/scheduler/graph_builder.cpp index ff867ae2d1815..02e5bd81f967b 100644 --- a/sycl/source/detail/scheduler/graph_builder.cpp +++ b/sycl/source/detail/scheduler/graph_builder.cpp @@ -129,7 +129,6 @@ static void handleVisitedNodes(std::vector &Visited) { for (Command *Cmd : Visited) { if (Cmd->MMarks.MToBeDeleted) { Cmd->getEvent()->setCommand(nullptr); - Cmd->getEvent()->cleanupDependencyEvents(); delete Cmd; } else Cmd->MMarks.MVisited = false; @@ -1187,7 +1186,7 @@ void Scheduler::GraphBuilder::cleanupCommand(Command *Cmd) { } Cmd->getEvent()->setCommand(nullptr); - Cmd->getEvent()->cleanupDependencyEvents(); + //Cmd->getEvent()->cleanupDependencyEvents(); delete Cmd; } diff --git a/sycl/source/detail/scheduler/graph_processor.cpp b/sycl/source/detail/scheduler/graph_processor.cpp index 6e533df30a09c..04ea6c729acbc 100644 --- a/sycl/source/detail/scheduler/graph_processor.cpp +++ b/sycl/source/detail/scheduler/graph_processor.cpp @@ -21,6 +21,21 @@ static Command *getCommand(const EventImplPtr &Event) { return (Command *)Event->getCommand(); } +std::vector +Scheduler::GraphProcessor::getWaitList(EventImplPtr Event) { + Command *Cmd = getCommand(Event); + // Command can be nullptr if user creates cl::sycl::event explicitly, + // as such event is not mapped to any SYCL task. + if (!Cmd) + return {}; + std::vector Result; + for (const DepDesc &Dep : Cmd->MDeps) { + if (Dep.MDepCommand) + Result.push_back(Dep.MDepCommand->getEvent()); + } + return Result; +} + void Scheduler::GraphProcessor::waitForEvent(EventImplPtr Event, ReadLockT &GraphReadLock, std::vector &ToCleanUp, diff --git a/sycl/source/detail/scheduler/scheduler.cpp b/sycl/source/detail/scheduler/scheduler.cpp index 232ee0a5d6e47..96bc694c8ce48 100644 --- a/sycl/source/detail/scheduler/scheduler.cpp +++ b/sycl/source/detail/scheduler/scheduler.cpp @@ -213,6 +213,11 @@ Scheduler &Scheduler::getInstance() { return GlobalHandler::instance().getScheduler(); } +std::vector Scheduler::getWaitList(EventImplPtr Event) { + ReadLockT Lock(MGraphLock); + return GraphProcessor::getWaitList(std::move(Event)); +} + void Scheduler::waitForEvent(EventImplPtr Event) { ReadLockT Lock(MGraphLock); // It's fine to leave the lock unlocked upon return from waitForEvent as diff --git a/sycl/source/detail/scheduler/scheduler.hpp b/sycl/source/detail/scheduler/scheduler.hpp index 18ed2f5004c06..3f0341d6b5da4 100644 --- a/sycl/source/detail/scheduler/scheduler.hpp +++ b/sycl/source/detail/scheduler/scheduler.hpp @@ -427,6 +427,9 @@ class Scheduler { /// \return an instance of the scheduler object. static Scheduler &getInstance(); + /// \return a vector of "immediate" dependencies for the Event given. + std::vector getWaitList(EventImplPtr Event); + /// Allocate buffers in the pool for a provided stream /// /// \param Impl to the stream object @@ -728,6 +731,10 @@ class Scheduler { /// \ingroup sycl_graph class GraphProcessor { public: + /// \return a list of events that represent immediate dependencies of the + /// command associated with Event passed. + static std::vector getWaitList(EventImplPtr Event); + /// Waits for the command, associated with Event passed, is completed. /// \param GraphReadLock read-lock which is already acquired for reading /// \param ToCleanUp container for commands that can be cleaned up. @@ -773,7 +780,6 @@ class Scheduler { friend class Command; friend class DispatchHostTask; friend class queue_impl; - friend class event_impl; /// Stream buffers structure. /// diff --git a/sycl/source/event.cpp b/sycl/source/event.cpp index ef084f219e899..8171b0afacfc0 100644 --- a/sycl/source/event.cpp +++ b/sycl/source/event.cpp @@ -55,7 +55,7 @@ void event::wait_and_throw(const std::vector &EventList) { std::vector event::get_wait_list() { std::vector Result; - for (auto &EventImpl : impl->getWaitList()) + for (auto &EventImpl : detail::Scheduler::getInstance().getWaitList(impl)) Result.push_back(detail::createSyclObjFromImpl(EventImpl)); return Result; From 879aefe174cc3f02d670ecf289efd8132f6fd885 Mon Sep 17 00:00:00 2001 From: mdimakov Date: Wed, 16 Feb 2022 18:44:41 +0300 Subject: [PATCH 03/27] Revert "Revert "working draft"" This reverts commit a68ee9cf2bd421fb67fdf6e6e9be0a18b0d43f6b. --- sycl/include/CL/sycl/accessor.hpp | 77 ++++++++++++++++--- sycl/include/CL/sycl/detail/pi.h | 2 + .../CL/sycl/detail/property_helper.hpp | 3 +- .../CL/sycl/detail/property_list_base.hpp | 24 ++++++ .../include/CL/sycl/detail/sycl_mem_obj_i.hpp | 6 ++ .../include/CL/sycl/detail/sycl_mem_obj_t.hpp | 8 ++ .../sycl/properties/accessor_properties.hpp | 3 + .../CL/sycl/properties/buffer_properties.hpp | 16 ++++ sycl/include/CL/sycl/property_list.hpp | 7 ++ sycl/plugins/opencl/pi_opencl.cpp | 1 + sycl/source/detail/memory_manager.cpp | 15 +++- sycl/test/abi/vtable.cpp | 4 +- .../scheduler/LinkedAllocaDependencies.cpp | 2 + 13 files changed, 151 insertions(+), 17 deletions(-) diff --git a/sycl/include/CL/sycl/accessor.hpp b/sycl/include/CL/sycl/accessor.hpp index cf13264b4fca0..a8cafe00fe9b6 100644 --- a/sycl/include/CL/sycl/accessor.hpp +++ b/sycl/include/CL/sycl/accessor.hpp @@ -1199,7 +1199,9 @@ class __SYCL_SPECIAL_CLASS accessor : buffer &BufferRef, TagT, const property_list &PropertyList = {}, const detail::code_location CodeLoc = detail::code_location::current()) - : accessor(BufferRef, PropertyList, CodeLoc) {} + : accessor(BufferRef, PropertyList, CodeLoc) { + deleteAccPropsFromBuf(detail::getSyclObjImpl(BufferRef).get()); + } template &PropertyList = {}, const detail::code_location CodeLoc = detail::code_location::current()) - : accessor(BufferRef, PropertyList, CodeLoc) {} + : accessor(BufferRef, PropertyList, CodeLoc) { + addOrReplaceAccPropsInBuf(PropertyList, detail::getSyclObjImpl(BufferRef).get()); + } #endif template &BufferRef, handler &CommandGroupHandler, TagT, const property_list &PropertyList = {}, const detail::code_location CodeLoc = detail::code_location::current()) - : accessor(BufferRef, CommandGroupHandler, PropertyList, CodeLoc) {} + : accessor(BufferRef, CommandGroupHandler, PropertyList, CodeLoc) { + deleteAccPropsFromBuf(detail::getSyclObjImpl(BufferRef).get()); + } template &PropertyList = {}, const detail::code_location CodeLoc = detail::code_location::current()) - : accessor(BufferRef, CommandGroupHandler, PropertyList, CodeLoc) {} + : accessor(BufferRef, CommandGroupHandler, PropertyList, CodeLoc) { + addOrReplaceAccPropsInBuf(PropertyList, detail::getSyclObjImpl(BufferRef).get()); + } #endif @@ -1345,7 +1353,9 @@ class __SYCL_SPECIAL_CLASS accessor : buffer &BufferRef, range AccessRange, TagT, const property_list &PropertyList = {}, const detail::code_location CodeLoc = detail::code_location::current()) - : accessor(BufferRef, AccessRange, {}, PropertyList, CodeLoc) {} + : accessor(BufferRef, AccessRange, {}, PropertyList, CodeLoc) { + deleteAccPropsFromBuf(detail::getSyclObjImpl(BufferRef).get()); + } template &PropertyList = {}, const detail::code_location CodeLoc = detail::code_location::current()) - : accessor(BufferRef, AccessRange, {}, PropertyList, CodeLoc) {} + : accessor(BufferRef, AccessRange, {}, PropertyList, CodeLoc) { + addOrReplaceAccPropsInBuf(PropertyList, detail::getSyclObjImpl(BufferRef).get()); + } #endif template &BufferRef, range AccessRange, id AccessOffset, TagT, const property_list &PropertyList = {}, const detail::code_location CodeLoc = detail::code_location::current()) - : accessor(BufferRef, AccessRange, AccessOffset, PropertyList, CodeLoc) {} + : accessor(BufferRef, AccessRange, AccessOffset, PropertyList, CodeLoc) { + deleteAccPropsFromBuf(detail::getSyclObjImpl(BufferRef).get()); + } template &PropertyList = {}, const detail::code_location CodeLoc = detail::code_location::current()) - : accessor(BufferRef, AccessRange, AccessOffset, PropertyList, CodeLoc) {} + : accessor(BufferRef, AccessRange, AccessOffset, PropertyList, CodeLoc) { + addOrReplaceAccPropsInBuf(PropertyList, detail::getSyclObjImpl(BufferRef).get()); + } #endif template @@ -1768,6 +1792,35 @@ class __SYCL_SPECIAL_CLASS accessor : "buffer size must be greater than zero.", PI_INVALID_VALUE); } + +/// my TODO: rename function +#if __cplusplus >= 201703L + template + void addOrReplaceAccPropsInBuf( + const sycl::ext::oneapi::accessor_property_list &PropertyList, + detail::SYCLMemObjI *SYCLMemObject) { + if constexpr (PropertyListT::template has_property< + sycl::ext::intel::property::buffer_location>()) { + auto location = (PropertyListT::template get_property< + sycl::ext::intel::property::buffer_location>()).get_location(); + property_list PropList{sycl::property::buffer::detail::buffer_location(location)}; + SYCLMemObject->addOrReplaceAccessorProperties(PropList); + } else { + deleteAccPropsFromBuf(SYCLMemObject); + } + /*if (PropertyList.template has_property()){ + auto location = PropertyList.template get_property().get_location(); + property_list PropList{sycl::property::buffer::detail::buffer_location(location)}; + SYCLMemObject->addOrReplaceAccessorProperties(PropList); + } else { + deleteAccPropsFromBuf(SYCLMemObject); + }*/ + } + + void deleteAccPropsFromBuf(detail::SYCLMemObjI *SYCLMemObject) { + SYCLMemObject->deleteAccessorProperty(sycl::detail::PropWithDataKind::AccPropBufferLocation); + } +#endif }; #if __cplusplus >= 201703L diff --git a/sycl/include/CL/sycl/detail/pi.h b/sycl/include/CL/sycl/detail/pi.h index b7eb25ed62ec0..ee95e10a13310 100644 --- a/sycl/include/CL/sycl/detail/pi.h +++ b/sycl/include/CL/sycl/detail/pi.h @@ -589,6 +589,8 @@ constexpr pi_map_flags PI_MAP_WRITE_INVALIDATE_REGION = // make the translation to OpenCL transparent. using pi_mem_properties = pi_bitfield; constexpr pi_mem_properties PI_MEM_PROPERTIES_CHANNEL = CL_MEM_CHANNEL_INTEL; +constexpr pi_mem_properties PI_MEM_PROPERTIES_ALLOC_BUFFER_LOCATION = + CL_MEM_ALLOC_BUFFER_LOCATION_INTEL; // NOTE: queue properties are implemented this way to better support bit // manipulations diff --git a/sycl/include/CL/sycl/detail/property_helper.hpp b/sycl/include/CL/sycl/detail/property_helper.hpp index 12bc497ee2a70..ecd942f310201 100644 --- a/sycl/include/CL/sycl/detail/property_helper.hpp +++ b/sycl/include/CL/sycl/detail/property_helper.hpp @@ -47,7 +47,8 @@ enum PropWithDataKind { ImageUseMutex = 2, ImageContextBound = 3, BufferMemChannel = 4, - PropWithDataKindSize = 5 + AccPropBufferLocation = 5, + PropWithDataKindSize = 6 }; // Base class for dataless properties, needed to check that the type of an diff --git a/sycl/include/CL/sycl/detail/property_list_base.hpp b/sycl/include/CL/sycl/detail/property_list_base.hpp index 0bdea3e85b7ae..242f82612e6fb 100644 --- a/sycl/include/CL/sycl/detail/property_list_base.hpp +++ b/sycl/include/CL/sycl/detail/property_list_base.hpp @@ -103,6 +103,30 @@ class PropertyListBase { PI_INVALID_VALUE); } + void add_or_replace_accessor_properties_helper( + const std::vector> &PropsWithData) { + for (auto &Prop : PropsWithData) { + if (Prop->isSame(sycl::detail::PropWithDataKind::AccPropBufferLocation)) { + delete_accessor_property_helper(sycl::detail::PropWithDataKind::AccPropBufferLocation); + MPropsWithData.push_back(Prop); + } + } + } + + void delete_accessor_property_helper(const PropWithDataKind &Kind) { + auto It = MPropsWithData.begin(); + for (; It != MPropsWithData.end(); ++It) { + if ((*It)->isSame(Kind)) + break; + } + if (It != MPropsWithData.end()) { + std::iter_swap(It, MPropsWithData.end() - 1); + MPropsWithData.pop_back(); + } + } + + + // Stores enabled/disabled for simple properties std::bitset MDataLessProps; // Stores shared_ptrs to complex properties diff --git a/sycl/include/CL/sycl/detail/sycl_mem_obj_i.hpp b/sycl/include/CL/sycl/detail/sycl_mem_obj_i.hpp index c37d4945f1e9c..044b9ddfa3503 100644 --- a/sycl/include/CL/sycl/detail/sycl_mem_obj_i.hpp +++ b/sycl/include/CL/sycl/detail/sycl_mem_obj_i.hpp @@ -10,6 +10,7 @@ #include #include +#include __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { @@ -65,6 +66,11 @@ class SYCLMemObjI { // interoperability constructor, nullptr otherwise. virtual ContextImplPtr getInteropContext() const = 0; + + virtual void addOrReplaceAccessorProperties(const property_list &PropertyList) = 0; + + virtual void deleteAccessorProperty(const PropWithDataKind &Kind) = 0; + protected: // Pointer to the record that contains the memory commands. This is managed // by the scheduler. diff --git a/sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp b/sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp index 09639d011f923..449dd381b7d76 100644 --- a/sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp +++ b/sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp @@ -111,6 +111,14 @@ class __SYCL_EXPORT SYCLMemObjT : public SYCLMemObjI { return MProps.get_property(); } + __SYCL_DLL_LOCAL void addOrReplaceAccessorProperties(const property_list &PropertyList) override { + MProps.add_or_replace_accessor_properties(PropertyList); + } + + __SYCL_DLL_LOCAL void deleteAccessorProperty(const PropWithDataKind &Kind) override { + MProps.delete_accessor_property(Kind); + } + template __SYCL_DLL_LOCAL AllocatorT get_allocator() const { return MAllocator->getAllocator(); diff --git a/sycl/include/CL/sycl/properties/accessor_properties.hpp b/sycl/include/CL/sycl/properties/accessor_properties.hpp index 4b608ff9c2fce..d3ded056a3fe1 100644 --- a/sycl/include/CL/sycl/properties/accessor_properties.hpp +++ b/sycl/include/CL/sycl/properties/accessor_properties.hpp @@ -58,6 +58,9 @@ struct buffer_location { constexpr bool operator!=(const buffer_location::instance &) const { return A != B; } + int get_location() { + return A; + } }; }; } // namespace property diff --git a/sycl/include/CL/sycl/properties/buffer_properties.hpp b/sycl/include/CL/sycl/properties/buffer_properties.hpp index fc36a17b77ca5..9b6bae872a839 100644 --- a/sycl/include/CL/sycl/properties/buffer_properties.hpp +++ b/sycl/include/CL/sycl/properties/buffer_properties.hpp @@ -51,6 +51,16 @@ class mem_channel : public detail::PropertyWithData< uint32_t MChannel; }; +namespace detail{ +class buffer_location : public sycl::detail::PropertyWithData { +public: + buffer_location(uint64_t Location) : MLocation(Location) {} + uint64_t get_buffer_location() const { return MLocation; } + +private: + uint64_t MLocation; +}; +} // namespace detail } // namespace buffer } // namespace property @@ -75,6 +85,8 @@ template <> struct is_property : std::true_type {}; template <> struct is_property : std::true_type {}; template <> +struct is_property : std::true_type {}; +template <> struct is_property : std::true_type {}; template <> struct is_property : std::true_type {}; @@ -91,6 +103,10 @@ struct is_property_of> : std::true_type {}; template +struct is_property_of> + : std::true_type {}; +template struct is_property_of> : std::true_type {}; diff --git a/sycl/include/CL/sycl/property_list.hpp b/sycl/include/CL/sycl/property_list.hpp index fa523a6676e2a..8c9a8183a6c1f 100644 --- a/sycl/include/CL/sycl/property_list.hpp +++ b/sycl/include/CL/sycl/property_list.hpp @@ -51,6 +51,13 @@ class property_list : protected detail::PropertyListBase { return has_property_helper(); } + void add_or_replace_accessor_properties(const property_list &PropertyList) { + add_or_replace_accessor_properties_helper(PropertyList.MPropsWithData); + } + void delete_accessor_property(const sycl::detail::PropWithDataKind &Kind) { + delete_accessor_property_helper(Kind); + } + template operator ext::oneapi::accessor_property_list(); private: diff --git a/sycl/plugins/opencl/pi_opencl.cpp b/sycl/plugins/opencl/pi_opencl.cpp index 8123da1c709d2..bcd96cf8edf15 100644 --- a/sycl/plugins/opencl/pi_opencl.cpp +++ b/sycl/plugins/opencl/pi_opencl.cpp @@ -670,6 +670,7 @@ pi_result piMemBufferCreate(pi_context context, pi_mem_flags flags, size_t size, ret_err = getExtFuncFromContext( context, &FuncPtr); + //cl_mem_properties_intel props[3] = {CL_MEM_ALLOC_BUFFER_LOCATION_INTEL, 1, 0}; if (FuncPtr) { *ret_mem = cast(FuncPtr(cast(context), properties, cast(flags), size, host_ptr, diff --git a/sycl/source/detail/memory_manager.cpp b/sycl/source/detail/memory_manager.cpp index 1cd77083e0c16..9c78daad562e0 100644 --- a/sycl/source/detail/memory_manager.cpp +++ b/sycl/source/detail/memory_manager.cpp @@ -148,7 +148,7 @@ void memBufferCreateHelper(const plugin &Plugin, pi_context Ctx, }}; #endif Plugin.call(Ctx, Flags, Size, HostPtr, RetMem, - Props); + nullptr); } } @@ -362,8 +362,17 @@ MemoryManager::allocateBufferObject(ContextImplPtr TargetContext, void *UserPtr, RT::PiMem NewMem = nullptr; const detail::plugin &Plugin = TargetContext->getPlugin(); - memBufferCreateHelper(Plugin, TargetContext->getHandleRef(), CreationFlags, - Size, UserPtr, &NewMem, nullptr); + std::cout << "Allocate" << std::endl; + if (PropsList.has_property()) { + auto location = PropsList.get_property().get_buffer_location(); + pi_mem_properties props[3] = {PI_MEM_PROPERTIES_ALLOC_BUFFER_LOCATION, location, 0}; + memBufferCreateHelper(Plugin, TargetContext->getHandleRef(), CreationFlags, + Size, UserPtr, &NewMem, props); + + } else { + memBufferCreateHelper(Plugin, TargetContext->getHandleRef(), CreationFlags, + Size, UserPtr, &NewMem, nullptr); + } return NewMem; } diff --git a/sycl/test/abi/vtable.cpp b/sycl/test/abi/vtable.cpp index 44aa731cf5823..23c2e2194b458 100644 --- a/sycl/test/abi/vtable.cpp +++ b/sycl/test/abi/vtable.cpp @@ -25,7 +25,7 @@ void foo(sycl::detail::HostKernelBase &HKB) { void foo(sycl::detail::SYCLMemObjI &MemObj) { (void)MemObj.getType(); } -// CHECK: Vtable for 'sycl::detail::SYCLMemObjI' (11 entries). +// CHECK: Vtable for 'sycl::detail::SYCLMemObjI' (13 entries). // CHECK-NEXT: 0 | offset_to_top (0) // CHECK-NEXT: 1 | sycl::detail::SYCLMemObjI RTTI // CHECK-NEXT: -- (sycl::detail::SYCLMemObjI, 0) vtable address -- @@ -38,6 +38,8 @@ void foo(sycl::detail::SYCLMemObjI &MemObj) { (void)MemObj.getType(); } // CHECK-NEXT: 8 | void sycl::detail::SYCLMemObjI::releaseHostMem(void *) [pure] // CHECK-NEXT: 9 | size_t sycl::detail::SYCLMemObjI::getSize() const [pure] // CHECK-NEXT: 10 | sycl::detail::ContextImplPtr sycl::detail::SYCLMemObjI::getInteropContext() const [pure] +// CHECK-NEXT: 11 | void sycl::detail::SYCLMemObjI::addOrReplaceAccessorProperties(const sycl::property_list &) [pure] +// CHECK-NEXT: 12 | void sycl::detail::SYCLMemObjI::deleteAccessorProperty(const sycl::detail::PropWithDataKind &) [pure] void foo(sycl::detail::pi::DeviceBinaryImage &Img) { Img.print(); } // CHECK: Vtable for 'sycl::detail::pi::DeviceBinaryImage' (6 entries). diff --git a/sycl/unittests/scheduler/LinkedAllocaDependencies.cpp b/sycl/unittests/scheduler/LinkedAllocaDependencies.cpp index 4864bcf4aa2ff..dc0283dc60f65 100644 --- a/sycl/unittests/scheduler/LinkedAllocaDependencies.cpp +++ b/sycl/unittests/scheduler/LinkedAllocaDependencies.cpp @@ -34,6 +34,8 @@ class MemObjMock : public cl::sycl::detail::SYCLMemObjI { void releaseHostMem(void *) {} size_t getSize() const override { return 10; } detail::ContextImplPtr getInteropContext() const override { return nullptr; } + void addOrReplaceAccessorProperties(const property_list &PropertyList) {} + void deleteAccessorProperty(const detail::PropWithDataKind &Kind) {} }; static cl::sycl::device getDeviceWithHostUnifiedMemory() { From 7396044ce46339505231014e9d96c12601a4756b Mon Sep 17 00:00:00 2001 From: mdimakov Date: Wed, 16 Feb 2022 22:41:04 +0300 Subject: [PATCH 04/27] Delete debugging cout --- sycl/source/detail/memory_manager.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/sycl/source/detail/memory_manager.cpp b/sycl/source/detail/memory_manager.cpp index 9c78daad562e0..91a343bafed6e 100644 --- a/sycl/source/detail/memory_manager.cpp +++ b/sycl/source/detail/memory_manager.cpp @@ -362,7 +362,6 @@ MemoryManager::allocateBufferObject(ContextImplPtr TargetContext, void *UserPtr, RT::PiMem NewMem = nullptr; const detail::plugin &Plugin = TargetContext->getPlugin(); - std::cout << "Allocate" << std::endl; if (PropsList.has_property()) { auto location = PropsList.get_property().get_buffer_location(); pi_mem_properties props[3] = {PI_MEM_PROPERTIES_ALLOC_BUFFER_LOCATION, location, 0}; From 7b414f97962ba04d78de5ef7a5eba96e76e1fdf8 Mon Sep 17 00:00:00 2001 From: mdimakov Date: Thu, 17 Feb 2022 12:18:44 +0300 Subject: [PATCH 05/27] Working draft --- sycl/include/CL/sycl/accessor.hpp | 37 ++++++++++----------------- sycl/source/detail/memory_manager.cpp | 2 +- 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/sycl/include/CL/sycl/accessor.hpp b/sycl/include/CL/sycl/accessor.hpp index a8cafe00fe9b6..44c75b2325e52 100644 --- a/sycl/include/CL/sycl/accessor.hpp +++ b/sycl/include/CL/sycl/accessor.hpp @@ -1200,7 +1200,7 @@ class __SYCL_SPECIAL_CLASS accessor : const property_list &PropertyList = {}, const detail::code_location CodeLoc = detail::code_location::current()) : accessor(BufferRef, PropertyList, CodeLoc) { - deleteAccPropsFromBuf(detail::getSyclObjImpl(BufferRef).get()); + adjustAccPropsInBuf(detail::getSyclObjImpl(BufferRef).get()); } template AccessOffset, TagT, const property_list &PropertyList = {}, const detail::code_location CodeLoc = detail::code_location::current()) : accessor(BufferRef, AccessRange, AccessOffset, PropertyList, CodeLoc) { - deleteAccPropsFromBuf(detail::getSyclObjImpl(BufferRef).get()); + adjustAccPropsInBuf(detail::getSyclObjImpl(BufferRef).get()); } template = 201703L template - void addOrReplaceAccPropsInBuf( - const sycl::ext::oneapi::accessor_property_list &PropertyList, - detail::SYCLMemObjI *SYCLMemObject) { + void adjustAccPropsInBuf(detail::SYCLMemObjI *SYCLMemObject, + const sycl::ext::oneapi::accessor_property_list &PropertyList = {}) { if constexpr (PropertyListT::template has_property< sycl::ext::intel::property::buffer_location>()) { auto location = (PropertyListT::template get_property< @@ -1808,13 +1806,6 @@ class __SYCL_SPECIAL_CLASS accessor : } else { deleteAccPropsFromBuf(SYCLMemObject); } - /*if (PropertyList.template has_property()){ - auto location = PropertyList.template get_property().get_location(); - property_list PropList{sycl::property::buffer::detail::buffer_location(location)}; - SYCLMemObject->addOrReplaceAccessorProperties(PropList); - } else { - deleteAccPropsFromBuf(SYCLMemObject); - }*/ } void deleteAccPropsFromBuf(detail::SYCLMemObjI *SYCLMemObject) { diff --git a/sycl/source/detail/memory_manager.cpp b/sycl/source/detail/memory_manager.cpp index 91a343bafed6e..e9c15f1bde11d 100644 --- a/sycl/source/detail/memory_manager.cpp +++ b/sycl/source/detail/memory_manager.cpp @@ -148,7 +148,7 @@ void memBufferCreateHelper(const plugin &Plugin, pi_context Ctx, }}; #endif Plugin.call(Ctx, Flags, Size, HostPtr, RetMem, - nullptr); + Props); } } From e340604499695a2f71c0ad5a3e8644df0e6feb99 Mon Sep 17 00:00:00 2001 From: mdimakov Date: Thu, 17 Feb 2022 13:06:52 +0300 Subject: [PATCH 06/27] Clang-format fix --- sycl/include/CL/sycl/accessor.hpp | 62 ++++++++++--------- .../CL/sycl/detail/property_list_base.hpp | 5 +- .../include/CL/sycl/detail/sycl_mem_obj_i.hpp | 6 +- .../include/CL/sycl/detail/sycl_mem_obj_t.hpp | 6 +- .../sycl/properties/accessor_properties.hpp | 4 +- .../CL/sycl/properties/buffer_properties.hpp | 6 +- sycl/source/detail/memory_manager.cpp | 11 ++-- 7 files changed, 54 insertions(+), 46 deletions(-) diff --git a/sycl/include/CL/sycl/accessor.hpp b/sycl/include/CL/sycl/accessor.hpp index 44c75b2325e52..79cef46f1491b 100644 --- a/sycl/include/CL/sycl/accessor.hpp +++ b/sycl/include/CL/sycl/accessor.hpp @@ -1200,8 +1200,8 @@ class __SYCL_SPECIAL_CLASS accessor : const property_list &PropertyList = {}, const detail::code_location CodeLoc = detail::code_location::current()) : accessor(BufferRef, PropertyList, CodeLoc) { - adjustAccPropsInBuf(detail::getSyclObjImpl(BufferRef).get()); - } + adjustAccPropsInBuf(detail::getSyclObjImpl(BufferRef).get()); + } template AccessOffset, TagT, const property_list &PropertyList = {}, const detail::code_location CodeLoc = detail::code_location::current()) : accessor(BufferRef, AccessRange, AccessOffset, PropertyList, CodeLoc) { - adjustAccPropsInBuf(detail::getSyclObjImpl(BufferRef).get()); - } + adjustAccPropsInBuf(detail::getSyclObjImpl(BufferRef).get()); + } template @@ -1796,12 +1796,15 @@ class __SYCL_SPECIAL_CLASS accessor : #if __cplusplus >= 201703L template void adjustAccPropsInBuf(detail::SYCLMemObjI *SYCLMemObject, - const sycl::ext::oneapi::accessor_property_list &PropertyList = {}) { + const sycl::ext::oneapi::accessor_property_list< + PropTypes...> &PropertyList = {}) { if constexpr (PropertyListT::template has_property< - sycl::ext::intel::property::buffer_location>()) { + sycl::ext::intel::property::buffer_location>()) { auto location = (PropertyListT::template get_property< - sycl::ext::intel::property::buffer_location>()).get_location(); - property_list PropList{sycl::property::buffer::detail::buffer_location(location)}; + sycl::ext::intel::property::buffer_location>()) + .get_location(); + property_list PropList{ + sycl::property::buffer::detail::buffer_location(location)}; SYCLMemObject->addOrReplaceAccessorProperties(PropList); } else { deleteAccPropsFromBuf(SYCLMemObject); @@ -1809,7 +1812,8 @@ class __SYCL_SPECIAL_CLASS accessor : } void deleteAccPropsFromBuf(detail::SYCLMemObjI *SYCLMemObject) { - SYCLMemObject->deleteAccessorProperty(sycl::detail::PropWithDataKind::AccPropBufferLocation); + SYCLMemObject->deleteAccessorProperty( + sycl::detail::PropWithDataKind::AccPropBufferLocation); } #endif }; diff --git a/sycl/include/CL/sycl/detail/property_list_base.hpp b/sycl/include/CL/sycl/detail/property_list_base.hpp index 242f82612e6fb..3cdf773d4b2f6 100644 --- a/sycl/include/CL/sycl/detail/property_list_base.hpp +++ b/sycl/include/CL/sycl/detail/property_list_base.hpp @@ -107,7 +107,8 @@ class PropertyListBase { const std::vector> &PropsWithData) { for (auto &Prop : PropsWithData) { if (Prop->isSame(sycl::detail::PropWithDataKind::AccPropBufferLocation)) { - delete_accessor_property_helper(sycl::detail::PropWithDataKind::AccPropBufferLocation); + delete_accessor_property_helper( + sycl::detail::PropWithDataKind::AccPropBufferLocation); MPropsWithData.push_back(Prop); } } @@ -125,8 +126,6 @@ class PropertyListBase { } } - - // Stores enabled/disabled for simple properties std::bitset MDataLessProps; // Stores shared_ptrs to complex properties diff --git a/sycl/include/CL/sycl/detail/sycl_mem_obj_i.hpp b/sycl/include/CL/sycl/detail/sycl_mem_obj_i.hpp index 044b9ddfa3503..08cf232b1bdf2 100644 --- a/sycl/include/CL/sycl/detail/sycl_mem_obj_i.hpp +++ b/sycl/include/CL/sycl/detail/sycl_mem_obj_i.hpp @@ -9,8 +9,8 @@ #pragma once #include -#include #include +#include __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { @@ -66,8 +66,8 @@ class SYCLMemObjI { // interoperability constructor, nullptr otherwise. virtual ContextImplPtr getInteropContext() const = 0; - - virtual void addOrReplaceAccessorProperties(const property_list &PropertyList) = 0; + virtual void + addOrReplaceAccessorProperties(const property_list &PropertyList) = 0; virtual void deleteAccessorProperty(const PropWithDataKind &Kind) = 0; diff --git a/sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp b/sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp index 449dd381b7d76..06ae6ae703dd2 100644 --- a/sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp +++ b/sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp @@ -111,11 +111,13 @@ class __SYCL_EXPORT SYCLMemObjT : public SYCLMemObjI { return MProps.get_property(); } - __SYCL_DLL_LOCAL void addOrReplaceAccessorProperties(const property_list &PropertyList) override { + __SYCL_DLL_LOCAL void + addOrReplaceAccessorProperties(const property_list &PropertyList) override { MProps.add_or_replace_accessor_properties(PropertyList); } - __SYCL_DLL_LOCAL void deleteAccessorProperty(const PropWithDataKind &Kind) override { + __SYCL_DLL_LOCAL void + deleteAccessorProperty(const PropWithDataKind &Kind) override { MProps.delete_accessor_property(Kind); } diff --git a/sycl/include/CL/sycl/properties/accessor_properties.hpp b/sycl/include/CL/sycl/properties/accessor_properties.hpp index d3ded056a3fe1..a0a97649c7cba 100644 --- a/sycl/include/CL/sycl/properties/accessor_properties.hpp +++ b/sycl/include/CL/sycl/properties/accessor_properties.hpp @@ -58,9 +58,7 @@ struct buffer_location { constexpr bool operator!=(const buffer_location::instance &) const { return A != B; } - int get_location() { - return A; - } + int get_location() { return A; } }; }; } // namespace property diff --git a/sycl/include/CL/sycl/properties/buffer_properties.hpp b/sycl/include/CL/sycl/properties/buffer_properties.hpp index 9b6bae872a839..e201f0af2ec09 100644 --- a/sycl/include/CL/sycl/properties/buffer_properties.hpp +++ b/sycl/include/CL/sycl/properties/buffer_properties.hpp @@ -51,8 +51,10 @@ class mem_channel : public detail::PropertyWithData< uint32_t MChannel; }; -namespace detail{ -class buffer_location : public sycl::detail::PropertyWithData { +namespace detail { +class buffer_location + : public sycl::detail::PropertyWithData< + sycl::detail::PropWithDataKind::AccPropBufferLocation> { public: buffer_location(uint64_t Location) : MLocation(Location) {} uint64_t get_buffer_location() const { return MLocation; } diff --git a/sycl/source/detail/memory_manager.cpp b/sycl/source/detail/memory_manager.cpp index e9c15f1bde11d..243cb307e2576 100644 --- a/sycl/source/detail/memory_manager.cpp +++ b/sycl/source/detail/memory_manager.cpp @@ -363,11 +363,14 @@ MemoryManager::allocateBufferObject(ContextImplPtr TargetContext, void *UserPtr, RT::PiMem NewMem = nullptr; const detail::plugin &Plugin = TargetContext->getPlugin(); if (PropsList.has_property()) { - auto location = PropsList.get_property().get_buffer_location(); - pi_mem_properties props[3] = {PI_MEM_PROPERTIES_ALLOC_BUFFER_LOCATION, location, 0}; + auto location = + PropsList.get_property() + .get_buffer_location(); + pi_mem_properties props[3] = {PI_MEM_PROPERTIES_ALLOC_BUFFER_LOCATION, + location, 0}; memBufferCreateHelper(Plugin, TargetContext->getHandleRef(), CreationFlags, - Size, UserPtr, &NewMem, props); - + Size, UserPtr, &NewMem, props); + } else { memBufferCreateHelper(Plugin, TargetContext->getHandleRef(), CreationFlags, Size, UserPtr, &NewMem, nullptr); From 7e1922ee543b0995690df85fbc0cc861e60802bc Mon Sep 17 00:00:00 2001 From: mdimakov Date: Thu, 17 Feb 2022 16:43:36 +0300 Subject: [PATCH 07/27] Update files --- sycl/source/detail/event_impl.cpp | 48 +++++++++++++++---- sycl/source/detail/event_impl.hpp | 29 +++++++++++ sycl/source/detail/scheduler/commands.cpp | 10 +++- sycl/source/detail/scheduler/commands.hpp | 9 ++-- .../source/detail/scheduler/graph_builder.cpp | 1 - .../detail/scheduler/graph_processor.cpp | 15 ------ sycl/source/detail/scheduler/scheduler.cpp | 5 -- sycl/source/detail/scheduler/scheduler.hpp | 8 +--- sycl/source/event.cpp | 2 +- 9 files changed, 83 insertions(+), 44 deletions(-) diff --git a/sycl/source/detail/event_impl.cpp b/sycl/source/detail/event_impl.cpp index 922dda6393909..f615f37214208 100644 --- a/sycl/source/detail/event_impl.cpp +++ b/sycl/source/detail/event_impl.cpp @@ -221,18 +221,24 @@ void event_impl::wait( void event_impl::wait_and_throw( std::shared_ptr Self) { - Command *Cmd = static_cast(Self->getCommand()); - QueueImplPtr submittedQueue = nullptr; - if (Cmd) - submittedQueue = Cmd->getSubmittedQueue(); + Scheduler &Sched = Scheduler::getInstance(); + QueueImplPtr submittedQueue = nullptr; + { + Scheduler::ReadLockT Lock(Sched.MGraphLock); + Command *Cmd = static_cast(Self->getCommand()); + if (Cmd) + submittedQueue = Cmd->getSubmittedQueue(); + } wait(Self); - for (auto &EventImpl : - detail::Scheduler::getInstance().getWaitList(std::move(Self))) { - Command *Cmd = (Command *)EventImpl->getCommand(); - if (Cmd) - Cmd->getSubmittedQueue()->throw_asynchronous(); + { + Scheduler::ReadLockT Lock(Sched.MGraphLock); + for (auto &EventImpl : getWaitList()) { + Command *Cmd = (Command *)EventImpl->getCommand(); + if (Cmd) + Cmd->getSubmittedQueue()->throw_asynchronous(); + } } if (submittedQueue) submittedQueue->throw_asynchronous(); @@ -339,6 +345,24 @@ pi_native_handle event_impl::getNative() const { return Handle; } +std::vector event_impl::getWaitList() { + if (MState == HES_Discarded) + throw sycl::exception( + make_error_code(errc::invalid), + "get_wait_list() cannot be used for a discarded event."); + + std::lock_guard Lock(MMutex); + + std::vector Result; + Result.reserve(MPreparedDepsEvents.size() + MPreparedHostDepsEvents.size()); + Result.insert(Result.end(), MPreparedDepsEvents.begin(), + MPreparedDepsEvents.end()); + Result.insert(Result.end(), MPreparedHostDepsEvents.begin(), + MPreparedHostDepsEvents.end()); + + return Result; +} + void event_impl::flushIfNeeded(const QueueImplPtr &UserQueue) { if (MIsFlushed) return; @@ -365,6 +389,12 @@ void event_impl::flushIfNeeded(const QueueImplPtr &UserQueue) { MIsFlushed = true; } +void event_impl::cleanupDependencyEvents() { + std::lock_guard Lock(MMutex); + MPreparedDepsEvents.clear(); + MPreparedHostDepsEvents.clear(); +} + } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/event_impl.hpp b/sycl/source/detail/event_impl.hpp index 1afeda1c3635b..0e7b896a596f7 100644 --- a/sycl/source/detail/event_impl.hpp +++ b/sycl/source/detail/event_impl.hpp @@ -27,6 +27,8 @@ class context_impl; using ContextImplPtr = std::shared_ptr; class queue_impl; using QueueImplPtr = std::shared_ptr; +class event_impl; +using EventImplPtr = std::shared_ptr; class event_impl { public: @@ -167,12 +169,33 @@ class event_impl { /// \return a native handle. pi_native_handle getNative() const; + /// Returns vector of event dependencies. + /// + /// @return a reference to MPreparedDepsEvents. + std::vector> &getPreparedDepsEvents() { + return MPreparedDepsEvents; + } + + /// Returns vector of host event dependencies. + /// + /// @return a reference to MPreparedHostDepsEvents. + std::vector> &getPreparedHostDepsEvents() { + return MPreparedHostDepsEvents; + } + + /// Returns vector of event_impl that this event_impl depends on. + /// + /// @return a vector of "immediate" dependencies for this event_impl. + std::vector getWaitList(); /// Performs a flush on the queue associated with this event if the user queue /// is different and the task associated with this event hasn't been submitted /// to the device yet. void flushIfNeeded(const QueueImplPtr &UserQueue); + /// Cleans dependencies of this event_impl + void cleanupDependencyEvents(); + /// Checks if this event is discarded by SYCL implementation. /// /// \return true if this event is discarded. @@ -200,6 +223,10 @@ class event_impl { void *MCommand = nullptr; std::weak_ptr MQueue; + /// Dependency events prepared for waiting by backend. + std::vector MPreparedDepsEvents; + std::vector MPreparedHostDepsEvents; + /// Indicates that the task associated with this event has been submitted by /// the queue to the device. std::atomic MIsFlushed = false; @@ -214,6 +241,8 @@ class event_impl { // handled by post enqueue cleanup yet and has to be deleted by cleanup after // wait. bool MNeedsCleanupAfterWait = false; + + std::mutex MMutex; }; } // namespace detail diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index 50bc321631fd0..13c08efb63a6a 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -353,10 +353,16 @@ void Command::waitForEvents(QueueImplPtr Queue, } } +/// It is safe to bind MPreparedDepsEvents and MPreparedHostDepsEvents +/// references to event_impl class members because Command +/// should not outlive the event connected to it. Command::Command(CommandType Type, QueueImplPtr Queue) - : MQueue(std::move(Queue)), MType(Type) { + : MQueue(std::move(Queue)), + MEvent(std::make_shared(MQueue)), + MPreparedDepsEvents(MEvent->getPreparedDepsEvents()), + MPreparedHostDepsEvents(MEvent->getPreparedHostDepsEvents()), + MType(Type) { MSubmittedQueue = MQueue; - MEvent.reset(new detail::event_impl(MQueue)); MEvent->setCommand(this); MEvent->setContextImpl(MQueue->getContextImplPtr()); MEnqueueStatus = EnqueueResultT::SyclEnqueueReady; diff --git a/sycl/source/detail/scheduler/commands.hpp b/sycl/source/detail/scheduler/commands.hpp index 92ce332a1dde9..82c42711b2da1 100644 --- a/sycl/source/detail/scheduler/commands.hpp +++ b/sycl/source/detail/scheduler/commands.hpp @@ -20,6 +20,7 @@ #include #include #include +#include #include __SYCL_INLINE_NAMESPACE(cl) { @@ -188,7 +189,7 @@ class Command { return nullptr; } - virtual ~Command() = default; + virtual ~Command() { MEvent->cleanupDependencyEvents(); } const char *getBlockReason() const; @@ -207,14 +208,14 @@ class Command { virtual bool supportsPostEnqueueCleanup() const; protected: - EventImplPtr MEvent; QueueImplPtr MQueue; QueueImplPtr MSubmittedQueue; + EventImplPtr MEvent; /// Dependency events prepared for waiting by backend. /// See processDepEvent for details. - std::vector MPreparedDepsEvents; - std::vector MPreparedHostDepsEvents; + std::vector &MPreparedDepsEvents; + std::vector &MPreparedHostDepsEvents; void waitForEvents(QueueImplPtr Queue, std::vector &RawEvents, RT::PiEvent &Event); diff --git a/sycl/source/detail/scheduler/graph_builder.cpp b/sycl/source/detail/scheduler/graph_builder.cpp index 02e5bd81f967b..ed2ee3e6f78dc 100644 --- a/sycl/source/detail/scheduler/graph_builder.cpp +++ b/sycl/source/detail/scheduler/graph_builder.cpp @@ -1186,7 +1186,6 @@ void Scheduler::GraphBuilder::cleanupCommand(Command *Cmd) { } Cmd->getEvent()->setCommand(nullptr); - //Cmd->getEvent()->cleanupDependencyEvents(); delete Cmd; } diff --git a/sycl/source/detail/scheduler/graph_processor.cpp b/sycl/source/detail/scheduler/graph_processor.cpp index 04ea6c729acbc..6e533df30a09c 100644 --- a/sycl/source/detail/scheduler/graph_processor.cpp +++ b/sycl/source/detail/scheduler/graph_processor.cpp @@ -21,21 +21,6 @@ static Command *getCommand(const EventImplPtr &Event) { return (Command *)Event->getCommand(); } -std::vector -Scheduler::GraphProcessor::getWaitList(EventImplPtr Event) { - Command *Cmd = getCommand(Event); - // Command can be nullptr if user creates cl::sycl::event explicitly, - // as such event is not mapped to any SYCL task. - if (!Cmd) - return {}; - std::vector Result; - for (const DepDesc &Dep : Cmd->MDeps) { - if (Dep.MDepCommand) - Result.push_back(Dep.MDepCommand->getEvent()); - } - return Result; -} - void Scheduler::GraphProcessor::waitForEvent(EventImplPtr Event, ReadLockT &GraphReadLock, std::vector &ToCleanUp, diff --git a/sycl/source/detail/scheduler/scheduler.cpp b/sycl/source/detail/scheduler/scheduler.cpp index 96bc694c8ce48..232ee0a5d6e47 100644 --- a/sycl/source/detail/scheduler/scheduler.cpp +++ b/sycl/source/detail/scheduler/scheduler.cpp @@ -213,11 +213,6 @@ Scheduler &Scheduler::getInstance() { return GlobalHandler::instance().getScheduler(); } -std::vector Scheduler::getWaitList(EventImplPtr Event) { - ReadLockT Lock(MGraphLock); - return GraphProcessor::getWaitList(std::move(Event)); -} - void Scheduler::waitForEvent(EventImplPtr Event) { ReadLockT Lock(MGraphLock); // It's fine to leave the lock unlocked upon return from waitForEvent as diff --git a/sycl/source/detail/scheduler/scheduler.hpp b/sycl/source/detail/scheduler/scheduler.hpp index 3f0341d6b5da4..18ed2f5004c06 100644 --- a/sycl/source/detail/scheduler/scheduler.hpp +++ b/sycl/source/detail/scheduler/scheduler.hpp @@ -427,9 +427,6 @@ class Scheduler { /// \return an instance of the scheduler object. static Scheduler &getInstance(); - /// \return a vector of "immediate" dependencies for the Event given. - std::vector getWaitList(EventImplPtr Event); - /// Allocate buffers in the pool for a provided stream /// /// \param Impl to the stream object @@ -731,10 +728,6 @@ class Scheduler { /// \ingroup sycl_graph class GraphProcessor { public: - /// \return a list of events that represent immediate dependencies of the - /// command associated with Event passed. - static std::vector getWaitList(EventImplPtr Event); - /// Waits for the command, associated with Event passed, is completed. /// \param GraphReadLock read-lock which is already acquired for reading /// \param ToCleanUp container for commands that can be cleaned up. @@ -780,6 +773,7 @@ class Scheduler { friend class Command; friend class DispatchHostTask; friend class queue_impl; + friend class event_impl; /// Stream buffers structure. /// diff --git a/sycl/source/event.cpp b/sycl/source/event.cpp index 8171b0afacfc0..ef084f219e899 100644 --- a/sycl/source/event.cpp +++ b/sycl/source/event.cpp @@ -55,7 +55,7 @@ void event::wait_and_throw(const std::vector &EventList) { std::vector event::get_wait_list() { std::vector Result; - for (auto &EventImpl : detail::Scheduler::getInstance().getWaitList(impl)) + for (auto &EventImpl : impl->getWaitList()) Result.push_back(detail::createSyclObjFromImpl(EventImpl)); return Result; From 531d38eb2542dfc5ca132908681e27b2073ebdaa Mon Sep 17 00:00:00 2001 From: mdimakov Date: Fri, 18 Feb 2022 10:34:28 +0300 Subject: [PATCH 08/27] No longer use of sycl_mem_obj_i --- sycl/include/CL/sycl/accessor.hpp | 6 ++++-- sycl/include/CL/sycl/detail/property_list_base.hpp | 1 + sycl/include/CL/sycl/detail/sycl_mem_obj_i.hpp | 6 ------ sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp | 4 ++-- sycl/test/abi/vtable.cpp | 4 +--- sycl/unittests/scheduler/LinkedAllocaDependencies.cpp | 2 -- 6 files changed, 8 insertions(+), 15 deletions(-) diff --git a/sycl/include/CL/sycl/accessor.hpp b/sycl/include/CL/sycl/accessor.hpp index 79cef46f1491b..b887530424dd3 100644 --- a/sycl/include/CL/sycl/accessor.hpp +++ b/sycl/include/CL/sycl/accessor.hpp @@ -1805,14 +1805,16 @@ class __SYCL_SPECIAL_CLASS accessor : .get_location(); property_list PropList{ sycl::property::buffer::detail::buffer_location(location)}; - SYCLMemObject->addOrReplaceAccessorProperties(PropList); + detail::SYCLMemObjT *SYCLMemObjectT = dynamic_cast(SYCLMemObject); + SYCLMemObjectT->addOrReplaceAccessorProperties(PropList); } else { deleteAccPropsFromBuf(SYCLMemObject); } } void deleteAccPropsFromBuf(detail::SYCLMemObjI *SYCLMemObject) { - SYCLMemObject->deleteAccessorProperty( + detail::SYCLMemObjT *SYCLMemObjectT = dynamic_cast(SYCLMemObject); + SYCLMemObjectT->deleteAccessorProperty( sycl::detail::PropWithDataKind::AccPropBufferLocation); } #endif diff --git a/sycl/include/CL/sycl/detail/property_list_base.hpp b/sycl/include/CL/sycl/detail/property_list_base.hpp index 3cdf773d4b2f6..eed8cf9ad4252 100644 --- a/sycl/include/CL/sycl/detail/property_list_base.hpp +++ b/sycl/include/CL/sycl/detail/property_list_base.hpp @@ -110,6 +110,7 @@ class PropertyListBase { delete_accessor_property_helper( sycl::detail::PropWithDataKind::AccPropBufferLocation); MPropsWithData.push_back(Prop); + break; } } } diff --git a/sycl/include/CL/sycl/detail/sycl_mem_obj_i.hpp b/sycl/include/CL/sycl/detail/sycl_mem_obj_i.hpp index 08cf232b1bdf2..c37d4945f1e9c 100644 --- a/sycl/include/CL/sycl/detail/sycl_mem_obj_i.hpp +++ b/sycl/include/CL/sycl/detail/sycl_mem_obj_i.hpp @@ -9,7 +9,6 @@ #pragma once #include -#include #include __SYCL_INLINE_NAMESPACE(cl) { @@ -66,11 +65,6 @@ class SYCLMemObjI { // interoperability constructor, nullptr otherwise. virtual ContextImplPtr getInteropContext() const = 0; - virtual void - addOrReplaceAccessorProperties(const property_list &PropertyList) = 0; - - virtual void deleteAccessorProperty(const PropWithDataKind &Kind) = 0; - protected: // Pointer to the record that contains the memory commands. This is managed // by the scheduler. diff --git a/sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp b/sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp index 06ae6ae703dd2..6dea0b923460d 100644 --- a/sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp +++ b/sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp @@ -112,12 +112,12 @@ class __SYCL_EXPORT SYCLMemObjT : public SYCLMemObjI { } __SYCL_DLL_LOCAL void - addOrReplaceAccessorProperties(const property_list &PropertyList) override { + addOrReplaceAccessorProperties(const property_list &PropertyList) { MProps.add_or_replace_accessor_properties(PropertyList); } __SYCL_DLL_LOCAL void - deleteAccessorProperty(const PropWithDataKind &Kind) override { + deleteAccessorProperty(const PropWithDataKind &Kind) { MProps.delete_accessor_property(Kind); } diff --git a/sycl/test/abi/vtable.cpp b/sycl/test/abi/vtable.cpp index 23c2e2194b458..44aa731cf5823 100644 --- a/sycl/test/abi/vtable.cpp +++ b/sycl/test/abi/vtable.cpp @@ -25,7 +25,7 @@ void foo(sycl::detail::HostKernelBase &HKB) { void foo(sycl::detail::SYCLMemObjI &MemObj) { (void)MemObj.getType(); } -// CHECK: Vtable for 'sycl::detail::SYCLMemObjI' (13 entries). +// CHECK: Vtable for 'sycl::detail::SYCLMemObjI' (11 entries). // CHECK-NEXT: 0 | offset_to_top (0) // CHECK-NEXT: 1 | sycl::detail::SYCLMemObjI RTTI // CHECK-NEXT: -- (sycl::detail::SYCLMemObjI, 0) vtable address -- @@ -38,8 +38,6 @@ void foo(sycl::detail::SYCLMemObjI &MemObj) { (void)MemObj.getType(); } // CHECK-NEXT: 8 | void sycl::detail::SYCLMemObjI::releaseHostMem(void *) [pure] // CHECK-NEXT: 9 | size_t sycl::detail::SYCLMemObjI::getSize() const [pure] // CHECK-NEXT: 10 | sycl::detail::ContextImplPtr sycl::detail::SYCLMemObjI::getInteropContext() const [pure] -// CHECK-NEXT: 11 | void sycl::detail::SYCLMemObjI::addOrReplaceAccessorProperties(const sycl::property_list &) [pure] -// CHECK-NEXT: 12 | void sycl::detail::SYCLMemObjI::deleteAccessorProperty(const sycl::detail::PropWithDataKind &) [pure] void foo(sycl::detail::pi::DeviceBinaryImage &Img) { Img.print(); } // CHECK: Vtable for 'sycl::detail::pi::DeviceBinaryImage' (6 entries). diff --git a/sycl/unittests/scheduler/LinkedAllocaDependencies.cpp b/sycl/unittests/scheduler/LinkedAllocaDependencies.cpp index dc0283dc60f65..4864bcf4aa2ff 100644 --- a/sycl/unittests/scheduler/LinkedAllocaDependencies.cpp +++ b/sycl/unittests/scheduler/LinkedAllocaDependencies.cpp @@ -34,8 +34,6 @@ class MemObjMock : public cl::sycl::detail::SYCLMemObjI { void releaseHostMem(void *) {} size_t getSize() const override { return 10; } detail::ContextImplPtr getInteropContext() const override { return nullptr; } - void addOrReplaceAccessorProperties(const property_list &PropertyList) {} - void deleteAccessorProperty(const detail::PropWithDataKind &Kind) {} }; static cl::sycl::device getDeviceWithHostUnifiedMemory() { From 30b9d01ec939b0789fe638d7a624f70380760f0c Mon Sep 17 00:00:00 2001 From: mdimakov Date: Fri, 18 Feb 2022 15:16:26 +0300 Subject: [PATCH 09/27] Add test for buffer_location --- sycl/unittests/CMakeLists.txt | 1 + sycl/unittests/buffer/CMakeLists.txt | 3 + sycl/unittests/buffer/buffer_location.cpp | 177 ++++++++++++++++++++++ 3 files changed, 181 insertions(+) create mode 100644 sycl/unittests/buffer/CMakeLists.txt create mode 100644 sycl/unittests/buffer/buffer_location.cpp diff --git a/sycl/unittests/CMakeLists.txt b/sycl/unittests/CMakeLists.txt index 533b85305c330..e57de233bec27 100644 --- a/sycl/unittests/CMakeLists.txt +++ b/sycl/unittests/CMakeLists.txt @@ -33,3 +33,4 @@ add_subdirectory(program_manager) add_subdirectory(assert) add_subdirectory(Extensions) add_subdirectory(windows) +add_subdirectory(buffer) diff --git a/sycl/unittests/buffer/CMakeLists.txt b/sycl/unittests/buffer/CMakeLists.txt new file mode 100644 index 0000000000000..e19a713008d85 --- /dev/null +++ b/sycl/unittests/buffer/CMakeLists.txt @@ -0,0 +1,3 @@ +add_sycl_unittest(BufferTests OBJECT + buffer_location.cpp +) diff --git a/sycl/unittests/buffer/buffer_location.cpp b/sycl/unittests/buffer/buffer_location.cpp new file mode 100644 index 0000000000000..d32cdaf0d6f79 --- /dev/null +++ b/sycl/unittests/buffer/buffer_location.cpp @@ -0,0 +1,177 @@ +//==-------- buffer_location.cpp --- check buffer_location property --------==// +// +// 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 +#include + +#include + +const uint64_t DEFAULT_VALUE = 7777; +static uint64_t PassedLocation = DEFAULT_VALUE; + +pi_result redefinedMemBufferCreate(pi_context, pi_mem_flags, size_t size, + void *, pi_mem *, + const pi_mem_properties *properties) { + PassedLocation = DEFAULT_VALUE; + if (!properties) + return PI_SUCCESS; + + // properties must be ended by 0 + size_t I = 0; + while (true) { + if (properties[I] != 0) { + if (properties[I] != PI_MEM_PROPERTIES_ALLOC_BUFFER_LOCATION) { + I += 2; + } else { + PassedLocation = properties[I + 1]; + break; + } + } + } + + return PI_SUCCESS; +} + +class BufferTest : public ::testing::Test { +public: + BufferTest() : Plt{sycl::default_selector()} {} + +protected: + void SetUp() override { + if (Plt.is_host() || Plt.get_backend() != sycl::backend::opencl) { + return; + } + + Mock = std::make_unique(Plt); + + setupDefaultMockAPIs(*Mock); + Mock->redefine( + redefinedMemBufferCreate); + } + +protected: + std::unique_ptr Mock; + sycl::platform Plt; +}; + +// Test that buffer_location was passed correctly +TEST_F(BufferTest, BufferLocationOnly) { + sycl::context Context{Plt}; + sycl::queue Queue{Context, sycl::default_selector{}}; + + const uint64_t BUFFER_LOCATION = 2; + cl::sycl::buffer Buf(3); + Queue + .submit([&](cl::sycl::handler &cgh) { + sycl::ext::oneapi::accessor_property_list PL{ + sycl::ext::intel::buffer_location}; + sycl::accessor>> + Acc{Buf, cgh, sycl::read_write, PL}; + cgh.single_task([=]() { Acc[0] = 4; }); + }) + .wait(); + EXPECT_EQ(PassedLocation, BUFFER_LOCATION); +} + +// Test that buffer_location was passed correcty if there is one more accessor +// property and buffer_location is correctly chaned by creating new accessors +TEST_F(BufferTest, BufferLocationWithAnotherProp) { + const uint64_t BUFFER_LOCATION = 5; + const uint64_t BUFFER_LOCATION2 = 3; + + sycl::context Context{Plt}; + sycl::queue Queue{Context, sycl::default_selector{}}; + + cl::sycl::buffer Buf(3); + Queue + .submit([&](cl::sycl::handler &cgh) { + sycl::ext::oneapi::accessor_property_list PL{ + sycl::ext::oneapi::no_alias, + sycl::ext::intel::buffer_location}; + sycl::accessor< + int, 1, cl::sycl::access::mode::write, + cl::sycl::access::target::global_buffer, + cl::sycl::access::placeholder::false_t, + cl::sycl::ext::oneapi::accessor_property_list< + cl::sycl::ext::oneapi::property::no_alias::instance, + cl::sycl::ext::intel::property::buffer_location::instance< + BUFFER_LOCATION>>> + Acc{Buf, cgh, sycl::write_only, PL}; + + cgh.single_task([=]() { Acc[0] = 4; }); + }) + .wait(); + EXPECT_EQ(PassedLocation, BUFFER_LOCATION); + + // Check that if new accessor created, buffer_location is changed + Queue + .submit([&](cl::sycl::handler &cgh) { + sycl::ext::oneapi::accessor_property_list PL{ + sycl::ext::intel::buffer_location}; + sycl::accessor>> + Acc{Buf, cgh, sycl::write_only, PL}; + }) + .wait(); + std::shared_ptr BufImpl = + sycl::detail::getSyclObjImpl(Buf); + EXPECT_EQ( + BufImpl->get_property() + .get_buffer_location(), + BUFFER_LOCATION2); + + // Check that if new accessor created, buffer_location is deleted from buffer + Queue + .submit([&](cl::sycl::handler &cgh) { + sycl::ext::oneapi::accessor_property_list PL{ + sycl::ext::oneapi::no_alias, sycl::ext::intel::buffer_location<1>}; + sycl::accessor> + Acc{Buf, cgh, sycl::write_only}; + }) + .wait(); + // std::shared_ptr BufImpl = + // sycl::detail::getSyclObjImpl(Buf); + EXPECT_EQ( + BufImpl->has_property(), + 0); +} + +// Test that there is no buffer_location property +TEST_F(BufferTest, WOBufferLocation) { + sycl::context Context{Plt}; + sycl::queue Queue{Context, sycl::default_selector{}}; + + cl::sycl::buffer Buf(3); + Queue + .submit([&](cl::sycl::handler &cgh) { + sycl::accessor> + Acc{Buf, cgh, sycl::read_write}; + cgh.single_task([=]() { Acc[0] = 4; }); + }) + .wait(); + EXPECT_EQ(PassedLocation, DEFAULT_VALUE); +} From 9f84f3bf0946db255b4c77432b63ab6bcc716c72 Mon Sep 17 00:00:00 2001 From: mdimakov Date: Fri, 18 Feb 2022 15:57:20 +0300 Subject: [PATCH 10/27] Add check for opencl backend --- sycl/unittests/buffer/buffer_location.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sycl/unittests/buffer/buffer_location.cpp b/sycl/unittests/buffer/buffer_location.cpp index d32cdaf0d6f79..269ede715a745 100644 --- a/sycl/unittests/buffer/buffer_location.cpp +++ b/sycl/unittests/buffer/buffer_location.cpp @@ -48,6 +48,9 @@ class BufferTest : public ::testing::Test { protected: void SetUp() override { if (Plt.is_host() || Plt.get_backend() != sycl::backend::opencl) { + std::cout << "This test is only supported on OpenCL backend\n"; + std::cout << "Current platform is " + << Plt.get_info(); return; } @@ -65,6 +68,10 @@ class BufferTest : public ::testing::Test { // Test that buffer_location was passed correctly TEST_F(BufferTest, BufferLocationOnly) { + if (Plt.is_host() || Plt.get_backend() != sycl::backend::opencl) { + return; + } + sycl::context Context{Plt}; sycl::queue Queue{Context, sycl::default_selector{}}; @@ -90,6 +97,10 @@ TEST_F(BufferTest, BufferLocationOnly) { // Test that buffer_location was passed correcty if there is one more accessor // property and buffer_location is correctly chaned by creating new accessors TEST_F(BufferTest, BufferLocationWithAnotherProp) { + if (Plt.is_host() || Plt.get_backend() != sycl::backend::opencl) { + return; + } + const uint64_t BUFFER_LOCATION = 5; const uint64_t BUFFER_LOCATION2 = 3; @@ -159,6 +170,10 @@ TEST_F(BufferTest, BufferLocationWithAnotherProp) { // Test that there is no buffer_location property TEST_F(BufferTest, WOBufferLocation) { + if (Plt.is_host() || Plt.get_backend() != sycl::backend::opencl) { + return; + } + sycl::context Context{Plt}; sycl::queue Queue{Context, sycl::default_selector{}}; From 9f5be75985e88d34db975e6f4e8b85d130f76636 Mon Sep 17 00:00:00 2001 From: mdimakov Date: Fri, 18 Feb 2022 18:18:53 +0300 Subject: [PATCH 11/27] Fix unittest problems for windows --- sycl/unittests/buffer/buffer_location.cpp | 62 +++++++++++------------ 1 file changed, 29 insertions(+), 33 deletions(-) diff --git a/sycl/unittests/buffer/buffer_location.cpp b/sycl/unittests/buffer/buffer_location.cpp index 269ede715a745..4788522706799 100644 --- a/sycl/unittests/buffer/buffer_location.cpp +++ b/sycl/unittests/buffer/buffer_location.cpp @@ -25,7 +25,7 @@ pi_result redefinedMemBufferCreate(pi_context, pi_mem_flags, size_t size, if (!properties) return PI_SUCCESS; - // properties must be ended by 0 + // properties must ended by 0 size_t I = 0; while (true) { if (properties[I] != 0) { @@ -75,23 +75,23 @@ TEST_F(BufferTest, BufferLocationOnly) { sycl::context Context{Plt}; sycl::queue Queue{Context, sycl::default_selector{}}; - const uint64_t BUFFER_LOCATION = 2; cl::sycl::buffer Buf(3); Queue .submit([&](cl::sycl::handler &cgh) { - sycl::ext::oneapi::accessor_property_list PL{ - sycl::ext::intel::buffer_location}; - sycl::accessor>> + sycl::ext::oneapi::accessor_property_list< + cl::sycl::ext::intel::property::buffer_location::instance<2>> + PL{sycl::ext::intel::buffer_location<2>}; + sycl::accessor< + int, 1, cl::sycl::access::mode::read_write, + cl::sycl::access::target::global_buffer, + cl::sycl::access::placeholder::false_t, + cl::sycl::ext::oneapi::accessor_property_list< + cl::sycl::ext::intel::property::buffer_location::instance<2>>> Acc{Buf, cgh, sycl::read_write, PL}; cgh.single_task([=]() { Acc[0] = 4; }); }) .wait(); - EXPECT_EQ(PassedLocation, BUFFER_LOCATION); + EXPECT_EQ(PassedLocation, 2); } // Test that buffer_location was passed correcty if there is one more accessor @@ -101,44 +101,43 @@ TEST_F(BufferTest, BufferLocationWithAnotherProp) { return; } - const uint64_t BUFFER_LOCATION = 5; - const uint64_t BUFFER_LOCATION2 = 3; - sycl::context Context{Plt}; sycl::queue Queue{Context, sycl::default_selector{}}; cl::sycl::buffer Buf(3); Queue .submit([&](cl::sycl::handler &cgh) { - sycl::ext::oneapi::accessor_property_list PL{ - sycl::ext::oneapi::no_alias, - sycl::ext::intel::buffer_location}; + sycl::ext::oneapi::accessor_property_list< + cl::sycl::ext::oneapi::property::no_alias::instance, + cl::sycl::ext::intel::property::buffer_location::instance<5>> + PL{sycl::ext::oneapi::no_alias, + sycl::ext::intel::buffer_location<5>}; sycl::accessor< int, 1, cl::sycl::access::mode::write, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t, cl::sycl::ext::oneapi::accessor_property_list< cl::sycl::ext::oneapi::property::no_alias::instance, - cl::sycl::ext::intel::property::buffer_location::instance< - BUFFER_LOCATION>>> + cl::sycl::ext::intel::property::buffer_location::instance<5>>> Acc{Buf, cgh, sycl::write_only, PL}; cgh.single_task([=]() { Acc[0] = 4; }); }) .wait(); - EXPECT_EQ(PassedLocation, BUFFER_LOCATION); + EXPECT_EQ(PassedLocation, 5); // Check that if new accessor created, buffer_location is changed Queue .submit([&](cl::sycl::handler &cgh) { - sycl::ext::oneapi::accessor_property_list PL{ - sycl::ext::intel::buffer_location}; - sycl::accessor>> + sycl::ext::oneapi::accessor_property_list< + cl::sycl::ext::intel::property::buffer_location::instance<3>> + PL{sycl::ext::intel::buffer_location<3>}; + sycl::accessor< + int, 1, cl::sycl::access::mode::write, + cl::sycl::access::target::global_buffer, + cl::sycl::access::placeholder::false_t, + cl::sycl::ext::oneapi::accessor_property_list< + cl::sycl::ext::intel::property::buffer_location::instance<3>>> Acc{Buf, cgh, sycl::write_only, PL}; }) .wait(); @@ -147,13 +146,11 @@ TEST_F(BufferTest, BufferLocationWithAnotherProp) { EXPECT_EQ( BufImpl->get_property() .get_buffer_location(), - BUFFER_LOCATION2); + 3); // Check that if new accessor created, buffer_location is deleted from buffer Queue .submit([&](cl::sycl::handler &cgh) { - sycl::ext::oneapi::accessor_property_list PL{ - sycl::ext::oneapi::no_alias, sycl::ext::intel::buffer_location<1>}; sycl::accessor BufImpl = - // sycl::detail::getSyclObjImpl(Buf); + EXPECT_EQ( BufImpl->has_property(), 0); From 5914d97b5624465b0d4be5886ecf3716695e35bc Mon Sep 17 00:00:00 2001 From: mdimakov Date: Fri, 18 Feb 2022 18:26:11 +0300 Subject: [PATCH 12/27] Add windows symbols --- sycl/test/abi/sycl_symbols_windows.dump | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sycl/test/abi/sycl_symbols_windows.dump b/sycl/test/abi/sycl_symbols_windows.dump index e6bb784eca0d8..8275d08107cfe 100644 --- a/sycl/test/abi/sycl_symbols_windows.dump +++ b/sycl/test/abi/sycl_symbols_windows.dump @@ -1088,6 +1088,7 @@ ?acospi@__host_std@cl@@YAMM@Z ?acospi@__host_std@cl@@YANN@Z ?addHostAccessorAndWait@detail@sycl@cl@@YAXPEAVAccessorImplHost@123@@Z +?addOrReplaceAccessorProperties@SYCLMemObjT@detail@sycl@cl@@QEAAXAEBVproperty_list@34@@Z ?addReduction@handler@sycl@cl@@AEAAXAEBV?$shared_ptr@$$CBX@std@@@Z ?addStream@handler@sycl@cl@@AEAAXAEBV?$shared_ptr@Vstream_impl@detail@sycl@cl@@@std@@@Z ?advise_usm@MemoryManager@detail@sycl@cl@@SAXPEBXV?$shared_ptr@Vqueue_impl@detail@sycl@cl@@@std@@_KW4_pi_mem_advice@@V?$vector@PEAU_pi_event@@V?$allocator@PEAU_pi_event@@@std@@@6@AEAPEAU_pi_event@@@Z @@ -1686,6 +1687,7 @@ ?degrees@__host_std@cl@@YA?AVhalf@half_impl@detail@sycl@2@V34562@@Z ?degrees@__host_std@cl@@YAMM@Z ?degrees@__host_std@cl@@YANN@Z +?deleteAccessorProperty@SYCLMemObjT@detail@sycl@cl@@QEAAXAEBW4PropWithDataKind@234@@Z ?depends_on@handler@sycl@cl@@QEAAXAEBV?$vector@Vevent@sycl@cl@@V?$allocator@Vevent@sycl@cl@@@std@@@std@@@Z ?depends_on@handler@sycl@cl@@QEAAXVevent@23@@Z ?destructorNotification@buffer_impl@detail@sycl@cl@@QEAAXPEAX@Z From cbcc0d3bd43861c83798012bf5faeb45d1f5a6a8 Mon Sep 17 00:00:00 2001 From: mdimakov Date: Fri, 18 Feb 2022 18:50:31 +0300 Subject: [PATCH 13/27] fix types --- sycl/unittests/buffer/buffer_location.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sycl/unittests/buffer/buffer_location.cpp b/sycl/unittests/buffer/buffer_location.cpp index 4788522706799..428fd34683a62 100644 --- a/sycl/unittests/buffer/buffer_location.cpp +++ b/sycl/unittests/buffer/buffer_location.cpp @@ -91,7 +91,7 @@ TEST_F(BufferTest, BufferLocationOnly) { cgh.single_task([=]() { Acc[0] = 4; }); }) .wait(); - EXPECT_EQ(PassedLocation, 2); + EXPECT_EQ(PassedLocation, (uint64_t)2); } // Test that buffer_location was passed correcty if there is one more accessor @@ -124,7 +124,7 @@ TEST_F(BufferTest, BufferLocationWithAnotherProp) { cgh.single_task([=]() { Acc[0] = 4; }); }) .wait(); - EXPECT_EQ(PassedLocation, 5); + EXPECT_EQ(PassedLocation, (uint64_t)5); // Check that if new accessor created, buffer_location is changed Queue @@ -146,7 +146,7 @@ TEST_F(BufferTest, BufferLocationWithAnotherProp) { EXPECT_EQ( BufImpl->get_property() .get_buffer_location(), - 3); + (uint64_t)3); // Check that if new accessor created, buffer_location is deleted from buffer Queue From 6f560f69e1b8ad119d49a4f5759d41abdd71a9ef Mon Sep 17 00:00:00 2001 From: mdimakov Date: Mon, 21 Feb 2022 10:47:59 +0300 Subject: [PATCH 14/27] Remove extra parameter from adjustAccPropsInBu --- sycl/include/CL/sycl/accessor.hpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/sycl/include/CL/sycl/accessor.hpp b/sycl/include/CL/sycl/accessor.hpp index b887530424dd3..e2587b5b9f549 100644 --- a/sycl/include/CL/sycl/accessor.hpp +++ b/sycl/include/CL/sycl/accessor.hpp @@ -1215,7 +1215,7 @@ class __SYCL_SPECIAL_CLASS accessor : {}, const detail::code_location CodeLoc = detail::code_location::current()) : accessor(BufferRef, PropertyList, CodeLoc) { - adjustAccPropsInBuf(detail::getSyclObjImpl(BufferRef).get(), PropertyList); + adjustAccPropsInBuf(detail::getSyclObjImpl(BufferRef).get()); } #endif @@ -1310,7 +1310,7 @@ class __SYCL_SPECIAL_CLASS accessor : {}, const detail::code_location CodeLoc = detail::code_location::current()) : accessor(BufferRef, CommandGroupHandler, PropertyList, CodeLoc) { - adjustAccPropsInBuf(detail::getSyclObjImpl(BufferRef).get(), PropertyList); + adjustAccPropsInBuf(detail::getSyclObjImpl(BufferRef).get()); } #endif @@ -1370,7 +1370,7 @@ class __SYCL_SPECIAL_CLASS accessor : {}, const detail::code_location CodeLoc = detail::code_location::current()) : accessor(BufferRef, AccessRange, {}, PropertyList, CodeLoc) { - adjustAccPropsInBuf(detail::getSyclObjImpl(BufferRef).get(), PropertyList); + adjustAccPropsInBuf(detail::getSyclObjImpl(BufferRef).get()); } #endif @@ -1433,7 +1433,7 @@ class __SYCL_SPECIAL_CLASS accessor : const detail::code_location CodeLoc = detail::code_location::current()) : accessor(BufferRef, CommandGroupHandler, AccessRange, {}, PropertyList, CodeLoc) { - adjustAccPropsInBuf(detail::getSyclObjImpl(BufferRef).get(), PropertyList); + adjustAccPropsInBuf(detail::getSyclObjImpl(BufferRef).get()); } #endif @@ -1531,7 +1531,7 @@ class __SYCL_SPECIAL_CLASS accessor : {}, const detail::code_location CodeLoc = detail::code_location::current()) : accessor(BufferRef, AccessRange, AccessOffset, PropertyList, CodeLoc) { - adjustAccPropsInBuf(detail::getSyclObjImpl(BufferRef).get(), PropertyList); + adjustAccPropsInBuf(detail::getSyclObjImpl(BufferRef).get()); } #endif @@ -1631,7 +1631,7 @@ class __SYCL_SPECIAL_CLASS accessor : const detail::code_location CodeLoc = detail::code_location::current()) : accessor(BufferRef, CommandGroupHandler, AccessRange, AccessOffset, PropertyList, CodeLoc) { - adjustAccPropsInBuf(detail::getSyclObjImpl(BufferRef).get(), PropertyList); + adjustAccPropsInBuf(detail::getSyclObjImpl(BufferRef).get()); } #endif @@ -1795,9 +1795,7 @@ class __SYCL_SPECIAL_CLASS accessor : #if __cplusplus >= 201703L template - void adjustAccPropsInBuf(detail::SYCLMemObjI *SYCLMemObject, - const sycl::ext::oneapi::accessor_property_list< - PropTypes...> &PropertyList = {}) { + void adjustAccPropsInBuf(detail::SYCLMemObjI *SYCLMemObject) { if constexpr (PropertyListT::template has_property< sycl::ext::intel::property::buffer_location>()) { auto location = (PropertyListT::template get_property< From c1fd1ea7f678276f0ccfbbc8d55d43809a224d37 Mon Sep 17 00:00:00 2001 From: mdimakov Date: Mon, 21 Feb 2022 10:48:35 +0300 Subject: [PATCH 15/27] Remove comment line --- sycl/plugins/opencl/pi_opencl.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/sycl/plugins/opencl/pi_opencl.cpp b/sycl/plugins/opencl/pi_opencl.cpp index bcd96cf8edf15..8123da1c709d2 100644 --- a/sycl/plugins/opencl/pi_opencl.cpp +++ b/sycl/plugins/opencl/pi_opencl.cpp @@ -670,7 +670,6 @@ pi_result piMemBufferCreate(pi_context context, pi_mem_flags flags, size_t size, ret_err = getExtFuncFromContext( context, &FuncPtr); - //cl_mem_properties_intel props[3] = {CL_MEM_ALLOC_BUFFER_LOCATION_INTEL, 1, 0}; if (FuncPtr) { *ret_mem = cast(FuncPtr(cast(context), properties, cast(flags), size, host_ptr, From 794953dc00a5f1864a7f35b72bd8149bc6551aa2 Mon Sep 17 00:00:00 2001 From: mdimakov Date: Thu, 24 Feb 2022 21:07:36 +0300 Subject: [PATCH 16/27] Move pi property --- sycl/include/CL/sycl/detail/pi.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sycl/include/CL/sycl/detail/pi.h b/sycl/include/CL/sycl/detail/pi.h index ee95e10a13310..cbe37bc665240 100644 --- a/sycl/include/CL/sycl/detail/pi.h +++ b/sycl/include/CL/sycl/detail/pi.h @@ -312,7 +312,8 @@ typedef enum { PI_EXT_ONEAPI_DEVICE_INFO_MAX_GLOBAL_WORK_GROUPS = 0x20000, PI_EXT_ONEAPI_DEVICE_INFO_MAX_WORK_GROUPS_1D = 0x20001, PI_EXT_ONEAPI_DEVICE_INFO_MAX_WORK_GROUPS_2D = 0x20002, - PI_EXT_ONEAPI_DEVICE_INFO_MAX_WORK_GROUPS_3D = 0x20003 + PI_EXT_ONEAPI_DEVICE_INFO_MAX_WORK_GROUPS_3D = 0x20003, + PI_MEM_PROPERTIES_ALLOC_BUFFER_LOCATION = CL_MEM_ALLOC_BUFFER_LOCATION_INTEL } _pi_device_info; typedef enum { @@ -589,8 +590,6 @@ constexpr pi_map_flags PI_MAP_WRITE_INVALIDATE_REGION = // make the translation to OpenCL transparent. using pi_mem_properties = pi_bitfield; constexpr pi_mem_properties PI_MEM_PROPERTIES_CHANNEL = CL_MEM_CHANNEL_INTEL; -constexpr pi_mem_properties PI_MEM_PROPERTIES_ALLOC_BUFFER_LOCATION = - CL_MEM_ALLOC_BUFFER_LOCATION_INTEL; // NOTE: queue properties are implemented this way to better support bit // manipulations From 841d59f3a535feae79865b22238c733dcb8143d1 Mon Sep 17 00:00:00 2001 From: mdimakov Date: Mon, 28 Feb 2022 17:40:50 +0300 Subject: [PATCH 17/27] Adjust test for accelerator --- ...buffer_location.cpp => BufferLocation.cpp} | 25 ++++++++++++++++--- sycl/unittests/buffer/CMakeLists.txt | 2 +- 2 files changed, 23 insertions(+), 4 deletions(-) rename sycl/unittests/buffer/{buffer_location.cpp => BufferLocation.cpp} (86%) diff --git a/sycl/unittests/buffer/buffer_location.cpp b/sycl/unittests/buffer/BufferLocation.cpp similarity index 86% rename from sycl/unittests/buffer/buffer_location.cpp rename to sycl/unittests/buffer/BufferLocation.cpp index 428fd34683a62..3d36931b91655 100644 --- a/sycl/unittests/buffer/buffer_location.cpp +++ b/sycl/unittests/buffer/BufferLocation.cpp @@ -5,6 +5,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// +#define SYCL2020_DISABLE_DEPRECATION_WARNINGS #include #include @@ -41,6 +42,22 @@ pi_result redefinedMemBufferCreate(pi_context, pi_mem_flags, size_t size, return PI_SUCCESS; } +static pi_result redefinedDeviceGetInfo(pi_device device, + pi_device_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret) { + if (param_name == PI_DEVICE_INFO_TYPE) { + auto *Result = reinterpret_cast<_pi_device_type *>(param_value); + *Result = PI_DEVICE_TYPE_ACC; + } + if (param_name == PI_DEVICE_INFO_COMPILER_AVAILABLE) { + auto *Result = reinterpret_cast(param_value); + *Result = true; + } + return PI_SUCCESS; +} + class BufferTest : public ::testing::Test { public: BufferTest() : Plt{sycl::default_selector()} {} @@ -59,6 +76,8 @@ class BufferTest : public ::testing::Test { setupDefaultMockAPIs(*Mock); Mock->redefine( redefinedMemBufferCreate); + Mock->redefine( + redefinedDeviceGetInfo); } protected: @@ -73,7 +92,7 @@ TEST_F(BufferTest, BufferLocationOnly) { } sycl::context Context{Plt}; - sycl::queue Queue{Context, sycl::default_selector{}}; + sycl::queue Queue{Context, sycl::accelerator_selector{}}; cl::sycl::buffer Buf(3); Queue @@ -102,7 +121,7 @@ TEST_F(BufferTest, BufferLocationWithAnotherProp) { } sycl::context Context{Plt}; - sycl::queue Queue{Context, sycl::default_selector{}}; + sycl::queue Queue{Context, sycl::accelerator_selector{}}; cl::sycl::buffer Buf(3); Queue @@ -171,7 +190,7 @@ TEST_F(BufferTest, WOBufferLocation) { } sycl::context Context{Plt}; - sycl::queue Queue{Context, sycl::default_selector{}}; + sycl::queue Queue{Context, sycl::accelerator_selector{}}; cl::sycl::buffer Buf(3); Queue diff --git a/sycl/unittests/buffer/CMakeLists.txt b/sycl/unittests/buffer/CMakeLists.txt index e19a713008d85..d8123f31f0982 100644 --- a/sycl/unittests/buffer/CMakeLists.txt +++ b/sycl/unittests/buffer/CMakeLists.txt @@ -1,3 +1,3 @@ add_sycl_unittest(BufferTests OBJECT - buffer_location.cpp + BufferLocation.cpp ) From 7af9aec7d10424b46b3bed61612443a120518188 Mon Sep 17 00:00:00 2001 From: mdimakov Date: Mon, 28 Feb 2022 17:49:23 +0300 Subject: [PATCH 18/27] Check for support buffer location --- sycl/source/detail/memory_manager.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/sycl/source/detail/memory_manager.cpp b/sycl/source/detail/memory_manager.cpp index 243cb307e2576..5bc4c4970d07b 100644 --- a/sycl/source/detail/memory_manager.cpp +++ b/sycl/source/detail/memory_manager.cpp @@ -362,7 +362,24 @@ MemoryManager::allocateBufferObject(ContextImplPtr TargetContext, void *UserPtr, RT::PiMem NewMem = nullptr; const detail::plugin &Plugin = TargetContext->getPlugin(); - if (PropsList.has_property()) { + + // Check that devices within context has support of buffer location + size_t return_size = 0; + pi_device_info device_info; + bool IsBufferLocSupported = true; + auto Devices = TargetContext->getDevices(); + for (auto &Device : Devices) { + const RT::PiDevice PiDevice = getSyclObjImpl(Device)->getHandleRef(); + if (Plugin.call_nocheck( + PiDevice, PI_MEM_PROPERTIES_ALLOC_BUFFER_LOCATION, + sizeof(pi_device_info), &device_info, &return_size) != PI_SUCCESS) { + IsBufferLocSupported = false; + break; + } + } + + if (PropsList.has_property() && + IsBufferLocSupported) { auto location = PropsList.get_property() .get_buffer_location(); From ccf73a63822962464eec97433e86daf8d4cbacbb Mon Sep 17 00:00:00 2001 From: mdimakov Date: Mon, 28 Feb 2022 17:51:15 +0300 Subject: [PATCH 19/27] Check that buffer is allocated on FPGA --- sycl/source/detail/memory_manager.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/sycl/source/detail/memory_manager.cpp b/sycl/source/detail/memory_manager.cpp index 5bc4c4970d07b..8cbfe6028cb7f 100644 --- a/sycl/source/detail/memory_manager.cpp +++ b/sycl/source/detail/memory_manager.cpp @@ -363,16 +363,11 @@ MemoryManager::allocateBufferObject(ContextImplPtr TargetContext, void *UserPtr, RT::PiMem NewMem = nullptr; const detail::plugin &Plugin = TargetContext->getPlugin(); - // Check that devices within context has support of buffer location - size_t return_size = 0; - pi_device_info device_info; + // buffer_location property has a meaning only on FPGA devices bool IsBufferLocSupported = true; auto Devices = TargetContext->getDevices(); for (auto &Device : Devices) { - const RT::PiDevice PiDevice = getSyclObjImpl(Device)->getHandleRef(); - if (Plugin.call_nocheck( - PiDevice, PI_MEM_PROPERTIES_ALLOC_BUFFER_LOCATION, - sizeof(pi_device_info), &device_info, &return_size) != PI_SUCCESS) { + if (!Device.is_accelerator()) { IsBufferLocSupported = false; break; } From 7401044798cf241849f71dad4bd4b25fd0983ea2 Mon Sep 17 00:00:00 2001 From: mdimakov Date: Mon, 28 Feb 2022 18:06:01 +0300 Subject: [PATCH 20/27] Use property as pi_mem_properties --- sycl/include/CL/sycl/detail/pi.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sycl/include/CL/sycl/detail/pi.h b/sycl/include/CL/sycl/detail/pi.h index cbe37bc665240..ee95e10a13310 100644 --- a/sycl/include/CL/sycl/detail/pi.h +++ b/sycl/include/CL/sycl/detail/pi.h @@ -312,8 +312,7 @@ typedef enum { PI_EXT_ONEAPI_DEVICE_INFO_MAX_GLOBAL_WORK_GROUPS = 0x20000, PI_EXT_ONEAPI_DEVICE_INFO_MAX_WORK_GROUPS_1D = 0x20001, PI_EXT_ONEAPI_DEVICE_INFO_MAX_WORK_GROUPS_2D = 0x20002, - PI_EXT_ONEAPI_DEVICE_INFO_MAX_WORK_GROUPS_3D = 0x20003, - PI_MEM_PROPERTIES_ALLOC_BUFFER_LOCATION = CL_MEM_ALLOC_BUFFER_LOCATION_INTEL + PI_EXT_ONEAPI_DEVICE_INFO_MAX_WORK_GROUPS_3D = 0x20003 } _pi_device_info; typedef enum { @@ -590,6 +589,8 @@ constexpr pi_map_flags PI_MAP_WRITE_INVALIDATE_REGION = // make the translation to OpenCL transparent. using pi_mem_properties = pi_bitfield; constexpr pi_mem_properties PI_MEM_PROPERTIES_CHANNEL = CL_MEM_CHANNEL_INTEL; +constexpr pi_mem_properties PI_MEM_PROPERTIES_ALLOC_BUFFER_LOCATION = + CL_MEM_ALLOC_BUFFER_LOCATION_INTEL; // NOTE: queue properties are implemented this way to better support bit // manipulations From 4d548846221b21799da61a62f7755bc33b59f829 Mon Sep 17 00:00:00 2001 From: mdimakov Date: Tue, 1 Mar 2022 20:10:32 +0300 Subject: [PATCH 21/27] Add check for buffer_location property for context devices --- sycl/source/detail/context_impl.cpp | 29 ++++++++++++++++++++++++--- sycl/source/detail/context_impl.hpp | 5 +++++ sycl/source/detail/memory_manager.cpp | 29 +++++++++------------------ 3 files changed, 40 insertions(+), 23 deletions(-) diff --git a/sycl/source/detail/context_impl.cpp b/sycl/source/detail/context_impl.cpp index 18390606df128..a9df1c8e56ee0 100644 --- a/sycl/source/detail/context_impl.cpp +++ b/sycl/source/detail/context_impl.cpp @@ -28,7 +28,8 @@ namespace detail { context_impl::context_impl(const device &Device, async_handler AsyncHandler, const property_list &PropList) : MAsyncHandler(AsyncHandler), MDevices(1, Device), MContext(nullptr), - MPlatform(), MPropList(PropList), MHostContext(Device.is_host()) { + MPlatform(), MPropList(PropList), MHostContext(Device.is_host()), + SupportBufferLocationByDevices(2) { MKernelProgramCache.setContextPtr(this); } @@ -36,7 +37,8 @@ context_impl::context_impl(const std::vector Devices, async_handler AsyncHandler, const property_list &PropList) : MAsyncHandler(AsyncHandler), MDevices(Devices), MContext(nullptr), - MPlatform(), MPropList(PropList), MHostContext(false) { + MPlatform(), MPropList(PropList), MHostContext(false), + SupportBufferLocationByDevices(2) { MPlatform = detail::getSyclObjImpl(MDevices[0].get_platform()); std::vector DeviceIds; for (const auto &D : MDevices) { @@ -66,7 +68,7 @@ context_impl::context_impl(const std::vector Devices, context_impl::context_impl(RT::PiContext PiContext, async_handler AsyncHandler, const plugin &Plugin) : MAsyncHandler(AsyncHandler), MDevices(), MContext(PiContext), MPlatform(), - MHostContext(false) { + MHostContext(false), SupportBufferLocationByDevices(2) { std::vector DeviceIds; size_t DevicesNum = 0; @@ -206,6 +208,27 @@ pi_native_handle context_impl::getNative() const { return Handle; } +bool context_impl::isBufferLocationSupported() { + // If check has already done return resut + if (SupportBufferLocationByDevices < 2) + return SupportBufferLocationByDevices == 0 ? false : true; + // Check that devices within context has support of buffer location + size_t return_size = 0; + pi_device_info device_info; + SupportBufferLocationByDevices = 1; + auto Plugin = getPlugin(); + for (auto &Device : MDevices) { + const RT::PiDevice PiDevice = getSyclObjImpl(Device)->getHandleRef(); + if (Plugin.call_nocheck( + PiDevice, (pi_device_info)PI_MEM_PROPERTIES_ALLOC_BUFFER_LOCATION, + sizeof(pi_device_info), &device_info, &return_size) != PI_SUCCESS) { + SupportBufferLocationByDevices = 0; + break; + } + } + return SupportBufferLocationByDevices == 0 ? false : true; +} + } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/context_impl.hpp b/sycl/source/detail/context_impl.hpp index d1a52181e9d33..ea746093b7af6 100644 --- a/sycl/source/detail/context_impl.hpp +++ b/sycl/source/detail/context_impl.hpp @@ -167,6 +167,9 @@ class context_impl { /// \return a native handle. pi_native_handle getNative() const; + // Returns true if buffer_location property is supported by devices + bool isBufferLocationSupported(); + private: async_handler MAsyncHandler; std::vector MDevices; @@ -177,6 +180,8 @@ class context_impl { std::map, RT::PiProgram> MCachedLibPrograms; mutable KernelProgramCache MKernelProgramCache; + // 0 - not supported, 1 - supported, 2 - check has not done yet + int SupportBufferLocationByDevices; }; } // namespace detail diff --git a/sycl/source/detail/memory_manager.cpp b/sycl/source/detail/memory_manager.cpp index 8cbfe6028cb7f..c203ebda3434b 100644 --- a/sycl/source/detail/memory_manager.cpp +++ b/sycl/source/detail/memory_manager.cpp @@ -363,30 +363,19 @@ MemoryManager::allocateBufferObject(ContextImplPtr TargetContext, void *UserPtr, RT::PiMem NewMem = nullptr; const detail::plugin &Plugin = TargetContext->getPlugin(); - // buffer_location property has a meaning only on FPGA devices - bool IsBufferLocSupported = true; - auto Devices = TargetContext->getDevices(); - for (auto &Device : Devices) { - if (!Device.is_accelerator()) { - IsBufferLocSupported = false; - break; - } - } - - if (PropsList.has_property() && - IsBufferLocSupported) { - auto location = + if (PropsList.has_property()) + if (TargetContext->isBufferLocationSupported()) { + auto location = PropsList.get_property() .get_buffer_location(); - pi_mem_properties props[3] = {PI_MEM_PROPERTIES_ALLOC_BUFFER_LOCATION, + pi_mem_properties props[3] = {PI_MEM_PROPERTIES_ALLOC_BUFFER_LOCATION, location, 0}; - memBufferCreateHelper(Plugin, TargetContext->getHandleRef(), CreationFlags, + memBufferCreateHelper(Plugin, TargetContext->getHandleRef(), CreationFlags, Size, UserPtr, &NewMem, props); - - } else { - memBufferCreateHelper(Plugin, TargetContext->getHandleRef(), CreationFlags, - Size, UserPtr, &NewMem, nullptr); - } + return NewMem; + } + memBufferCreateHelper(Plugin, TargetContext->getHandleRef(), CreationFlags, + Size, UserPtr, &NewMem, nullptr); return NewMem; } From 6de4bc7eaa024bd4e2403ce6975aa2b2d607e0e7 Mon Sep 17 00:00:00 2001 From: mdimakov Date: Wed, 2 Mar 2022 17:19:09 +0300 Subject: [PATCH 22/27] Address to review comments --- sycl/include/CL/sycl/detail/property_helper.hpp | 2 +- sycl/source/detail/context_impl.cpp | 17 ++++++++--------- sycl/source/detail/context_impl.hpp | 11 ++++++++--- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/sycl/include/CL/sycl/detail/property_helper.hpp b/sycl/include/CL/sycl/detail/property_helper.hpp index ecd942f310201..291327c13caab 100644 --- a/sycl/include/CL/sycl/detail/property_helper.hpp +++ b/sycl/include/CL/sycl/detail/property_helper.hpp @@ -48,7 +48,7 @@ enum PropWithDataKind { ImageContextBound = 3, BufferMemChannel = 4, AccPropBufferLocation = 5, - PropWithDataKindSize = 6 + PropWithDataKindSize = 6, }; // Base class for dataless properties, needed to check that the type of an diff --git a/sycl/source/detail/context_impl.cpp b/sycl/source/detail/context_impl.cpp index a9df1c8e56ee0..4b46c44958eb2 100644 --- a/sycl/source/detail/context_impl.cpp +++ b/sycl/source/detail/context_impl.cpp @@ -29,7 +29,7 @@ context_impl::context_impl(const device &Device, async_handler AsyncHandler, const property_list &PropList) : MAsyncHandler(AsyncHandler), MDevices(1, Device), MContext(nullptr), MPlatform(), MPropList(PropList), MHostContext(Device.is_host()), - SupportBufferLocationByDevices(2) { + SupportBufferLocationByDevices(NotChecked) { MKernelProgramCache.setContextPtr(this); } @@ -38,7 +38,7 @@ context_impl::context_impl(const std::vector Devices, const property_list &PropList) : MAsyncHandler(AsyncHandler), MDevices(Devices), MContext(nullptr), MPlatform(), MPropList(PropList), MHostContext(false), - SupportBufferLocationByDevices(2) { + SupportBufferLocationByDevices(NotChecked) { MPlatform = detail::getSyclObjImpl(MDevices[0].get_platform()); std::vector DeviceIds; for (const auto &D : MDevices) { @@ -68,7 +68,7 @@ context_impl::context_impl(const std::vector Devices, context_impl::context_impl(RT::PiContext PiContext, async_handler AsyncHandler, const plugin &Plugin) : MAsyncHandler(AsyncHandler), MDevices(), MContext(PiContext), MPlatform(), - MHostContext(false), SupportBufferLocationByDevices(2) { + MHostContext(false), SupportBufferLocationByDevices(NotChecked) { std::vector DeviceIds; size_t DevicesNum = 0; @@ -208,21 +208,20 @@ pi_native_handle context_impl::getNative() const { return Handle; } -bool context_impl::isBufferLocationSupported() { - // If check has already done return resut - if (SupportBufferLocationByDevices < 2) - return SupportBufferLocationByDevices == 0 ? false : true; +bool context_impl::isBufferLocationSupported() const { + if (SupportBufferLocationByDevices != NotChecked) + return SupportBufferLocationByDevices == Supported ? true : false; // Check that devices within context has support of buffer location size_t return_size = 0; pi_device_info device_info; - SupportBufferLocationByDevices = 1; + SupportBufferLocationByDevices = Supported; auto Plugin = getPlugin(); for (auto &Device : MDevices) { const RT::PiDevice PiDevice = getSyclObjImpl(Device)->getHandleRef(); if (Plugin.call_nocheck( PiDevice, (pi_device_info)PI_MEM_PROPERTIES_ALLOC_BUFFER_LOCATION, sizeof(pi_device_info), &device_info, &return_size) != PI_SUCCESS) { - SupportBufferLocationByDevices = 0; + SupportBufferLocationByDevices = NotSupported; break; } } diff --git a/sycl/source/detail/context_impl.hpp b/sycl/source/detail/context_impl.hpp index ea746093b7af6..9391dcf2eae41 100644 --- a/sycl/source/detail/context_impl.hpp +++ b/sycl/source/detail/context_impl.hpp @@ -168,7 +168,13 @@ class context_impl { pi_native_handle getNative() const; // Returns true if buffer_location property is supported by devices - bool isBufferLocationSupported(); + bool isBufferLocationSupported() const; + + enum PropertySupport { + NotSupported = 0, + Supported = 1, + NotChecked = 2 + }; private: async_handler MAsyncHandler; @@ -180,8 +186,7 @@ class context_impl { std::map, RT::PiProgram> MCachedLibPrograms; mutable KernelProgramCache MKernelProgramCache; - // 0 - not supported, 1 - supported, 2 - check has not done yet - int SupportBufferLocationByDevices; + mutable PropertySupport SupportBufferLocationByDevices; }; } // namespace detail From 82394cba7cf2b65b621ed3dbfb14c780fb2b3359 Mon Sep 17 00:00:00 2001 From: maximdimakov Date: Wed, 2 Mar 2022 17:22:28 +0300 Subject: [PATCH 23/27] Update sycl/source/detail/context_impl.cpp Co-authored-by: sergei --- sycl/source/detail/context_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/source/detail/context_impl.cpp b/sycl/source/detail/context_impl.cpp index 4b46c44958eb2..4beb2f97bde45 100644 --- a/sycl/source/detail/context_impl.cpp +++ b/sycl/source/detail/context_impl.cpp @@ -211,7 +211,7 @@ pi_native_handle context_impl::getNative() const { bool context_impl::isBufferLocationSupported() const { if (SupportBufferLocationByDevices != NotChecked) return SupportBufferLocationByDevices == Supported ? true : false; - // Check that devices within context has support of buffer location + // Check that devices within context have support of buffer location size_t return_size = 0; pi_device_info device_info; SupportBufferLocationByDevices = Supported; From e5e4fb3afe0b4408dbc6295232bd795b3d1494fe Mon Sep 17 00:00:00 2001 From: mdimakov Date: Wed, 2 Mar 2022 17:19:09 +0300 Subject: [PATCH 24/27] Address to review comments --- sycl/include/CL/sycl/detail/property_helper.hpp | 2 +- sycl/source/detail/context_impl.cpp | 17 ++++++++--------- sycl/source/detail/context_impl.hpp | 11 ++++++++--- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/sycl/include/CL/sycl/detail/property_helper.hpp b/sycl/include/CL/sycl/detail/property_helper.hpp index ecd942f310201..291327c13caab 100644 --- a/sycl/include/CL/sycl/detail/property_helper.hpp +++ b/sycl/include/CL/sycl/detail/property_helper.hpp @@ -48,7 +48,7 @@ enum PropWithDataKind { ImageContextBound = 3, BufferMemChannel = 4, AccPropBufferLocation = 5, - PropWithDataKindSize = 6 + PropWithDataKindSize = 6, }; // Base class for dataless properties, needed to check that the type of an diff --git a/sycl/source/detail/context_impl.cpp b/sycl/source/detail/context_impl.cpp index a9df1c8e56ee0..4b46c44958eb2 100644 --- a/sycl/source/detail/context_impl.cpp +++ b/sycl/source/detail/context_impl.cpp @@ -29,7 +29,7 @@ context_impl::context_impl(const device &Device, async_handler AsyncHandler, const property_list &PropList) : MAsyncHandler(AsyncHandler), MDevices(1, Device), MContext(nullptr), MPlatform(), MPropList(PropList), MHostContext(Device.is_host()), - SupportBufferLocationByDevices(2) { + SupportBufferLocationByDevices(NotChecked) { MKernelProgramCache.setContextPtr(this); } @@ -38,7 +38,7 @@ context_impl::context_impl(const std::vector Devices, const property_list &PropList) : MAsyncHandler(AsyncHandler), MDevices(Devices), MContext(nullptr), MPlatform(), MPropList(PropList), MHostContext(false), - SupportBufferLocationByDevices(2) { + SupportBufferLocationByDevices(NotChecked) { MPlatform = detail::getSyclObjImpl(MDevices[0].get_platform()); std::vector DeviceIds; for (const auto &D : MDevices) { @@ -68,7 +68,7 @@ context_impl::context_impl(const std::vector Devices, context_impl::context_impl(RT::PiContext PiContext, async_handler AsyncHandler, const plugin &Plugin) : MAsyncHandler(AsyncHandler), MDevices(), MContext(PiContext), MPlatform(), - MHostContext(false), SupportBufferLocationByDevices(2) { + MHostContext(false), SupportBufferLocationByDevices(NotChecked) { std::vector DeviceIds; size_t DevicesNum = 0; @@ -208,21 +208,20 @@ pi_native_handle context_impl::getNative() const { return Handle; } -bool context_impl::isBufferLocationSupported() { - // If check has already done return resut - if (SupportBufferLocationByDevices < 2) - return SupportBufferLocationByDevices == 0 ? false : true; +bool context_impl::isBufferLocationSupported() const { + if (SupportBufferLocationByDevices != NotChecked) + return SupportBufferLocationByDevices == Supported ? true : false; // Check that devices within context has support of buffer location size_t return_size = 0; pi_device_info device_info; - SupportBufferLocationByDevices = 1; + SupportBufferLocationByDevices = Supported; auto Plugin = getPlugin(); for (auto &Device : MDevices) { const RT::PiDevice PiDevice = getSyclObjImpl(Device)->getHandleRef(); if (Plugin.call_nocheck( PiDevice, (pi_device_info)PI_MEM_PROPERTIES_ALLOC_BUFFER_LOCATION, sizeof(pi_device_info), &device_info, &return_size) != PI_SUCCESS) { - SupportBufferLocationByDevices = 0; + SupportBufferLocationByDevices = NotSupported; break; } } diff --git a/sycl/source/detail/context_impl.hpp b/sycl/source/detail/context_impl.hpp index ea746093b7af6..9391dcf2eae41 100644 --- a/sycl/source/detail/context_impl.hpp +++ b/sycl/source/detail/context_impl.hpp @@ -168,7 +168,13 @@ class context_impl { pi_native_handle getNative() const; // Returns true if buffer_location property is supported by devices - bool isBufferLocationSupported(); + bool isBufferLocationSupported() const; + + enum PropertySupport { + NotSupported = 0, + Supported = 1, + NotChecked = 2 + }; private: async_handler MAsyncHandler; @@ -180,8 +186,7 @@ class context_impl { std::map, RT::PiProgram> MCachedLibPrograms; mutable KernelProgramCache MKernelProgramCache; - // 0 - not supported, 1 - supported, 2 - check has not done yet - int SupportBufferLocationByDevices; + mutable PropertySupport SupportBufferLocationByDevices; }; } // namespace detail From d2701b6b52dbce13fe63c34ec0a963fbd8cb61d4 Mon Sep 17 00:00:00 2001 From: mdimakov Date: Thu, 3 Mar 2022 16:11:47 +0300 Subject: [PATCH 25/27] Add check for extension --- sycl/source/detail/context_impl.cpp | 10 ++-------- sycl/unittests/buffer/BufferLocation.cpp | 9 +++++++++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/sycl/source/detail/context_impl.cpp b/sycl/source/detail/context_impl.cpp index 4beb2f97bde45..1b85e2df0c838 100644 --- a/sycl/source/detail/context_impl.cpp +++ b/sycl/source/detail/context_impl.cpp @@ -212,20 +212,14 @@ bool context_impl::isBufferLocationSupported() const { if (SupportBufferLocationByDevices != NotChecked) return SupportBufferLocationByDevices == Supported ? true : false; // Check that devices within context have support of buffer location - size_t return_size = 0; - pi_device_info device_info; SupportBufferLocationByDevices = Supported; - auto Plugin = getPlugin(); for (auto &Device : MDevices) { - const RT::PiDevice PiDevice = getSyclObjImpl(Device)->getHandleRef(); - if (Plugin.call_nocheck( - PiDevice, (pi_device_info)PI_MEM_PROPERTIES_ALLOC_BUFFER_LOCATION, - sizeof(pi_device_info), &device_info, &return_size) != PI_SUCCESS) { + if (!Device.has_extension("cl_intel_mem_alloc_buffer_location")) { SupportBufferLocationByDevices = NotSupported; break; } } - return SupportBufferLocationByDevices == 0 ? false : true; + return SupportBufferLocationByDevices == Supported ? true : false; } } // namespace detail diff --git a/sycl/unittests/buffer/BufferLocation.cpp b/sycl/unittests/buffer/BufferLocation.cpp index 3d36931b91655..44741cc4071b8 100644 --- a/sycl/unittests/buffer/BufferLocation.cpp +++ b/sycl/unittests/buffer/BufferLocation.cpp @@ -55,6 +55,15 @@ static pi_result redefinedDeviceGetInfo(pi_device device, auto *Result = reinterpret_cast(param_value); *Result = true; } + if (param_name == PI_DEVICE_INFO_EXTENSIONS) { + const std::string name = "cl_intel_mem_alloc_buffer_location"; + if (!param_value) { + *param_value_size_ret = name.size(); + } else { + char *dst = static_cast(param_value); + strcpy(dst, name.data()); + } + } return PI_SUCCESS; } From 3db4cfc94d3628ef33fa6c1be7eae52a8f8980bc Mon Sep 17 00:00:00 2001 From: mdimakov Date: Thu, 3 Mar 2022 23:28:46 +0300 Subject: [PATCH 26/27] Clang-format fix --- sycl/unittests/buffer/BufferLocation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/unittests/buffer/BufferLocation.cpp b/sycl/unittests/buffer/BufferLocation.cpp index 44741cc4071b8..5d2313ee5dd15 100644 --- a/sycl/unittests/buffer/BufferLocation.cpp +++ b/sycl/unittests/buffer/BufferLocation.cpp @@ -57,7 +57,7 @@ static pi_result redefinedDeviceGetInfo(pi_device device, } if (param_name == PI_DEVICE_INFO_EXTENSIONS) { const std::string name = "cl_intel_mem_alloc_buffer_location"; - if (!param_value) { + if (!param_value) { *param_value_size_ret = name.size(); } else { char *dst = static_cast(param_value); From 13e14d43731441bbcb4b174a5e218c917c236ec8 Mon Sep 17 00:00:00 2001 From: mdimakov Date: Tue, 15 Mar 2022 18:56:46 +0300 Subject: [PATCH 27/27] Address review comment --- sycl/source/detail/context_impl.cpp | 16 ++++++++-------- sycl/source/detail/context_impl.hpp | 2 +- sycl/unittests/CMakeLists.txt | 1 + 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/sycl/source/detail/context_impl.cpp b/sycl/source/detail/context_impl.cpp index 1b85e2df0c838..c10188b83fc15 100644 --- a/sycl/source/detail/context_impl.cpp +++ b/sycl/source/detail/context_impl.cpp @@ -29,7 +29,7 @@ context_impl::context_impl(const device &Device, async_handler AsyncHandler, const property_list &PropList) : MAsyncHandler(AsyncHandler), MDevices(1, Device), MContext(nullptr), MPlatform(), MPropList(PropList), MHostContext(Device.is_host()), - SupportBufferLocationByDevices(NotChecked) { + MSupportBufferLocationByDevices(NotChecked) { MKernelProgramCache.setContextPtr(this); } @@ -38,7 +38,7 @@ context_impl::context_impl(const std::vector Devices, const property_list &PropList) : MAsyncHandler(AsyncHandler), MDevices(Devices), MContext(nullptr), MPlatform(), MPropList(PropList), MHostContext(false), - SupportBufferLocationByDevices(NotChecked) { + MSupportBufferLocationByDevices(NotChecked) { MPlatform = detail::getSyclObjImpl(MDevices[0].get_platform()); std::vector DeviceIds; for (const auto &D : MDevices) { @@ -68,7 +68,7 @@ context_impl::context_impl(const std::vector Devices, context_impl::context_impl(RT::PiContext PiContext, async_handler AsyncHandler, const plugin &Plugin) : MAsyncHandler(AsyncHandler), MDevices(), MContext(PiContext), MPlatform(), - MHostContext(false), SupportBufferLocationByDevices(NotChecked) { + MHostContext(false), MSupportBufferLocationByDevices(NotChecked) { std::vector DeviceIds; size_t DevicesNum = 0; @@ -209,17 +209,17 @@ pi_native_handle context_impl::getNative() const { } bool context_impl::isBufferLocationSupported() const { - if (SupportBufferLocationByDevices != NotChecked) - return SupportBufferLocationByDevices == Supported ? true : false; + if (MSupportBufferLocationByDevices != NotChecked) + return MSupportBufferLocationByDevices == Supported ? true : false; // Check that devices within context have support of buffer location - SupportBufferLocationByDevices = Supported; + MSupportBufferLocationByDevices = Supported; for (auto &Device : MDevices) { if (!Device.has_extension("cl_intel_mem_alloc_buffer_location")) { - SupportBufferLocationByDevices = NotSupported; + MSupportBufferLocationByDevices = NotSupported; break; } } - return SupportBufferLocationByDevices == Supported ? true : false; + return MSupportBufferLocationByDevices == Supported ? true : false; } } // namespace detail diff --git a/sycl/source/detail/context_impl.hpp b/sycl/source/detail/context_impl.hpp index 26d8ca7ef0626..9049ab1a12760 100644 --- a/sycl/source/detail/context_impl.hpp +++ b/sycl/source/detail/context_impl.hpp @@ -182,7 +182,7 @@ class context_impl { std::map, RT::PiProgram> MCachedLibPrograms; mutable KernelProgramCache MKernelProgramCache; - mutable PropertySupport SupportBufferLocationByDevices; + mutable PropertySupport MSupportBufferLocationByDevices; }; } // namespace detail diff --git a/sycl/unittests/CMakeLists.txt b/sycl/unittests/CMakeLists.txt index e57de233bec27..83eb6cccc44b7 100644 --- a/sycl/unittests/CMakeLists.txt +++ b/sycl/unittests/CMakeLists.txt @@ -33,4 +33,5 @@ add_subdirectory(program_manager) add_subdirectory(assert) add_subdirectory(Extensions) add_subdirectory(windows) +add_subdirectory(event) add_subdirectory(buffer)