diff --git a/sycl/source/detail/queue_impl.cpp b/sycl/source/detail/queue_impl.cpp index 9052fdcab8621..619123bf8a69c 100644 --- a/sycl/source/detail/queue_impl.cpp +++ b/sycl/source/detail/queue_impl.cpp @@ -272,50 +272,36 @@ void queue_impl::wait(const detail::code_location &CodeLoc) { // directly. Otherwise, only wait for unenqueued or host task events, starting // from the latest submitted task in order to minimize total amount of calls, // then handle the rest with piQueueFinish. - // TODO the new workflow has worse performance with Level Zero, keep the old - // behavior until this is addressed - if (!is_host() && - getPlugin().getBackend() == backend::ext_oneapi_level_zero) { + bool SupportsPiFinish = !is_host() && MSupportOOO; + for (auto EventImplWeakPtrIt = WeakEvents.rbegin(); + EventImplWeakPtrIt != WeakEvents.rend(); ++EventImplWeakPtrIt) { + if (std::shared_ptr EventImplSharedPtr = + EventImplWeakPtrIt->lock()) { + // A nullptr PI event indicates that piQueueFinish will not cover it, + // either because it's a host task event or an unenqueued one. + if (!SupportsPiFinish || nullptr == EventImplSharedPtr->getHandleRef()) { + EventImplSharedPtr->wait(EventImplSharedPtr); + } + } + } + if (SupportsPiFinish) { + const detail::plugin &Plugin = getPlugin(); + Plugin.call(getHandleRef()); for (std::weak_ptr &EventImplWeakPtr : WeakEvents) if (std::shared_ptr EventImplSharedPtr = EventImplWeakPtr.lock()) - EventImplSharedPtr->wait(EventImplSharedPtr); + EventImplSharedPtr->cleanupCommand(EventImplSharedPtr); + // FIXME these events are stored for level zero until as a workaround, + // remove once piEventRelease no longer calls wait on the event in the + // plugin. + if (Plugin.getBackend() == backend::level_zero) { + SharedEvents.clear(); + } + assert(SharedEvents.empty() && "Queues that support calling piQueueFinish " + "shouldn't have shared events"); + } else { for (event &Event : SharedEvents) Event.wait(); - } else { - bool SupportsPiFinish = !is_host() && MSupportOOO; - for (auto EventImplWeakPtrIt = WeakEvents.rbegin(); - EventImplWeakPtrIt != WeakEvents.rend(); ++EventImplWeakPtrIt) { - if (std::shared_ptr EventImplSharedPtr = - EventImplWeakPtrIt->lock()) { - // A nullptr PI event indicates that piQueueFinish will not cover it, - // either because it's a host task event or an unenqueued one. - if (!SupportsPiFinish || - nullptr == EventImplSharedPtr->getHandleRef()) { - EventImplSharedPtr->wait(EventImplSharedPtr); - } - } - } - if (SupportsPiFinish) { - const detail::plugin &Plugin = getPlugin(); - Plugin.call(getHandleRef()); - for (std::weak_ptr &EventImplWeakPtr : WeakEvents) - if (std::shared_ptr EventImplSharedPtr = - EventImplWeakPtr.lock()) - EventImplSharedPtr->cleanupCommand(EventImplSharedPtr); - // FIXME these events are stored for level zero until as a workaround, - // remove once piEventRelease no longer calls wait on the event in the - // plugin. - if (Plugin.getBackend() == backend::ext_oneapi_level_zero) { - SharedEvents.clear(); - } - assert(SharedEvents.empty() && - "Queues that support calling piQueueFinish " - "shouldn't have shared events"); - } else { - for (event &Event : SharedEvents) - Event.wait(); - } } #ifdef XPTI_ENABLE_INSTRUMENTATION instrumentationEpilog(TelemetryEvent, Name, StreamID, IId); diff --git a/sycl/unittests/queue/Wait.cpp b/sycl/unittests/queue/Wait.cpp index 5781f65f78d0d..2877396ed95a5 100644 --- a/sycl/unittests/queue/Wait.cpp +++ b/sycl/unittests/queue/Wait.cpp @@ -92,14 +92,6 @@ bool preparePiMock(platform &Plt) { << std::endl; return false; } - // TODO remove once queue:wait() is lowered to PiQueueFinish with level zero - // as well. - if (detail::getSyclObjImpl(Plt)->getPlugin().getBackend() == - backend::ext_oneapi_level_zero) { - std::cout << "Not run on Level Zero, old behavior is kept there temporarily" - << std::endl; - return false; - } unittest::PiMock Mock{Plt}; Mock.redefine(redefinedQueueCreate);