@@ -62,7 +62,9 @@ event queue_impl::memset(const std::shared_ptr<detail::queue_impl> &Self,
62
62
63
63
event ResEvent = prepareUSMEvent (Self, NativeEvent);
64
64
// Track only if we won't be able to handle it with piQueueFinish.
65
- if (!MSupportOOO)
65
+ // FIXME these events are stored for level zero until as a workaround, remove
66
+ // once piEventRelease no longer calls wait on the event in the plugin.
67
+ if (!MSupportOOO || getPlugin ().getBackend () == backend::level_zero)
66
68
addSharedEvent (ResEvent);
67
69
return ResEvent;
68
70
}
@@ -79,7 +81,9 @@ event queue_impl::memcpy(const std::shared_ptr<detail::queue_impl> &Self,
79
81
80
82
event ResEvent = prepareUSMEvent (Self, NativeEvent);
81
83
// Track only if we won't be able to handle it with piQueueFinish.
82
- if (!MSupportOOO)
84
+ // FIXME these events are stored for level zero until as a workaround, remove
85
+ // once piEventRelease no longer calls wait on the event in the plugin.
86
+ if (!MSupportOOO || getPlugin ().getBackend () == backend::level_zero)
83
87
addSharedEvent (ResEvent);
84
88
return ResEvent;
85
89
}
@@ -97,7 +101,9 @@ event queue_impl::mem_advise(const std::shared_ptr<detail::queue_impl> &Self,
97
101
98
102
event ResEvent = prepareUSMEvent (Self, NativeEvent);
99
103
// Track only if we won't be able to handle it with piQueueFinish.
100
- if (!MSupportOOO)
104
+ // FIXME these events are stored for level zero until as a workaround, remove
105
+ // once piEventRelease no longer calls wait on the event in the plugin.
106
+ if (!MSupportOOO || getPlugin ().getBackend () == backend::level_zero)
101
107
addSharedEvent (ResEvent);
102
108
return ResEvent;
103
109
}
@@ -109,7 +115,11 @@ void queue_impl::addEvent(const event &Event) {
109
115
// if there is no command on the event, we cannot track it with MEventsWeak
110
116
// as that will leave it with no owner. Track in MEventsShared only if we're
111
117
// unable to call piQueueFinish during wait.
112
- if (is_host () || !MSupportOOO)
118
+ // FIXME these events are stored for level zero until as a workaround,
119
+ // remove once piEventRelease no longer calls wait on the event in the
120
+ // plugin.
121
+ if (is_host () || !MSupportOOO ||
122
+ getPlugin ().getBackend () == backend::level_zero)
113
123
addSharedEvent (Event);
114
124
} else {
115
125
std::weak_ptr<event_impl> EventWeakPtr{Eimpl};
@@ -122,7 +132,10 @@ void queue_impl::addEvent(const event &Event) {
122
132
// / but some events have no other owner. In this case,
123
133
// / addSharedEvent will have the queue track the events via a shared pointer.
124
134
void queue_impl::addSharedEvent (const event &Event) {
125
- assert (is_host () || !MSupportOOO);
135
+ // FIXME The assertion should be corrected once the Level Zero workaround is
136
+ // removed.
137
+ assert (is_host () || !MSupportOOO ||
138
+ getPlugin ().getBackend () == backend::level_zero);
126
139
std::lock_guard<std::mutex> Lock (MMutex);
127
140
// Events stored in MEventsShared are not released anywhere else aside from
128
141
// calls to queue::wait/wait_and_throw, which a user application might not
@@ -274,6 +287,12 @@ void queue_impl::wait(const detail::code_location &CodeLoc) {
274
287
if (std::shared_ptr<event_impl> EventImplSharedPtr =
275
288
EventImplWeakPtr.lock ())
276
289
EventImplSharedPtr->cleanupCommand (EventImplSharedPtr);
290
+ // FIXME these events are stored for level zero until as a workaround,
291
+ // remove once piEventRelease no longer calls wait on the event in the
292
+ // plugin.
293
+ if (Plugin.getBackend () == backend::level_zero) {
294
+ SharedEvents.clear ();
295
+ }
277
296
assert (SharedEvents.empty () && " Queues that support calling piQueueFinish "
278
297
" shouldn't have shared events" );
279
298
} else {
0 commit comments