Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 25 additions & 39 deletions sycl/source/detail/queue_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<event_impl> 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<detail::PiApiKind::piQueueFinish>(getHandleRef());
for (std::weak_ptr<event_impl> &EventImplWeakPtr : WeakEvents)
if (std::shared_ptr<event_impl> 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<event_impl> 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<detail::PiApiKind::piQueueFinish>(getHandleRef());
for (std::weak_ptr<event_impl> &EventImplWeakPtr : WeakEvents)
if (std::shared_ptr<event_impl> 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);
Expand Down
8 changes: 0 additions & 8 deletions sycl/unittests/queue/Wait.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<detail::PiApiKind::piQueueCreate>(redefinedQueueCreate);
Expand Down