diff --git a/sycl/source/detail/queue_impl.cpp b/sycl/source/detail/queue_impl.cpp index 545cff3b9c5c3..ab066ed1906a4 100644 --- a/sycl/source/detail/queue_impl.cpp +++ b/sycl/source/detail/queue_impl.cpp @@ -354,7 +354,7 @@ event queue_impl::submitMemOpHelper(const std::shared_ptr &Self, getExtendDependencyList(DepEvents, MutableDepEvents, Lock); if (areEventsSafeForSchedulerBypass(ExpandedDepEvents, MContext)) { - if (MHasDiscardEventsSupport) { + if (MSupportsDiscardingPiEvents) { MemOpFunc(MemOpArgs..., getPIEvents(ExpandedDepEvents), /*PiEvent*/ nullptr, /*EventImplPtr*/ nullptr); return createDiscardedEvent(); diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index 810f991d6667f..f91c7ac09abb4 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -113,8 +113,8 @@ class queue_impl { MDiscardEvents( has_property()), MIsProfilingEnabled(has_property()), - MHasDiscardEventsSupport(MDiscardEvents && - (MHostQueue ? true : MIsInorder)), + MSupportsDiscardingPiEvents(MDiscardEvents && + (MHostQueue ? true : MIsInorder)), MQueueID{ MNextAvailableQueueID.fetch_add(1, std::memory_order_relaxed)} { if (has_property()) { @@ -288,8 +288,8 @@ class queue_impl { MDiscardEvents( has_property()), MIsProfilingEnabled(has_property()), - MHasDiscardEventsSupport(MDiscardEvents && - (MHostQueue ? true : MIsInorder)), + MSupportsDiscardingPiEvents(MDiscardEvents && + (MHostQueue ? true : MIsInorder)), MQueueID{ MNextAvailableQueueID.fetch_add(1, std::memory_order_relaxed)} { queue_impl_interop(PiQueue); @@ -310,8 +310,8 @@ class queue_impl { MDiscardEvents( has_property()), MIsProfilingEnabled(has_property()), - MHasDiscardEventsSupport(MDiscardEvents && - (MHostQueue ? true : MIsInorder)) { + MSupportsDiscardingPiEvents(MDiscardEvents && + (MHostQueue ? true : MIsInorder)) { queue_impl_interop(PiQueue); } @@ -367,7 +367,9 @@ class queue_impl { bool is_host() const { return MHostQueue; } /// \return true if this queue has discard_events support. - bool has_discard_events_support() const { return MHasDiscardEventsSupport; } + bool supportsDiscardingPiEvents() const { + return MSupportsDiscardingPiEvents; + } bool isInOrder() const { return MIsInorder; } @@ -959,12 +961,11 @@ class queue_impl { const bool MIsProfilingEnabled; protected: - // This flag says if we can discard events based on a queue "setup" which will - // be common for all operations submitted to the queue. This is a must - // condition for discarding, but even if it's true, in some cases, we won't be - // able to discard events, because the final decision is made right before the - // operation itself. - const bool MHasDiscardEventsSupport; + // Indicates whether the queue supports discarding PI events for tasks + // submitted to it. This condition is necessary but not sufficient, PI events + // should be discarded only if they also don't represent potential implicit + // dependencies for future tasks in other queues. + const bool MSupportsDiscardingPiEvents; // Command graph which is associated with this queue for the purposes of // recording commands to it. diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index 455a8353ce3f0..9f58b51e10c2b 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -2678,7 +2678,7 @@ pi_int32 ExecCGCommand::enqueueImpCommandBuffer() { } sycl::detail::pi::PiEvent *Event = - (MQueue->has_discard_events_support() && + (MQueue->supportsDiscardingPiEvents() && MCommandGroup->getRequirements().size() == 0) ? nullptr : &MEvent->getHandleRef(); @@ -2825,11 +2825,11 @@ pi_int32 ExecCGCommand::enqueueImpQueue() { auto RawEvents = getPiEvents(EventImpls); flushCrossQueueDeps(EventImpls, getWorkerQueue()); - bool DiscardEvent = (MQueue->has_discard_events_support() && - MCommandGroup->getRequirements().size() == 0); + bool DiscardPiEvent = (MQueue->supportsDiscardingPiEvents() && + MCommandGroup->getRequirements().size() == 0); sycl::detail::pi::PiEvent *Event = - DiscardEvent ? nullptr : &MEvent->getHandleRef(); - detail::EventImplPtr EventImpl = DiscardEvent ? nullptr : MEvent; + DiscardPiEvent ? nullptr : &MEvent->getHandleRef(); + detail::EventImplPtr EventImpl = DiscardPiEvent ? nullptr : MEvent; switch (MCommandGroup->getType()) { diff --git a/sycl/source/handler.cpp b/sycl/source/handler.cpp index 02ffef951d1b5..70681a7504358 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -292,7 +292,7 @@ event handler::finalize() { }; bool DiscardEvent = false; - if (MQueue->has_discard_events_support()) { + if (MQueue->supportsDiscardingPiEvents()) { // Kernel only uses assert if it's non interop one bool KernelUsesAssert = !(MKernel && MKernel->isInterop()) &&