@@ -122,6 +122,7 @@ void queue_impl::addEvent(const event &Event) {
122
122
// / but some events have no other owner. In this case,
123
123
// / addSharedEvent will have the queue track the events via a shared pointer.
124
124
void queue_impl::addSharedEvent (const event &Event) {
125
+ assert (is_host () || !MSupportOOO);
125
126
std::lock_guard<std::mutex> Lock (MMutex);
126
127
// Events stored in MEventsShared are not released anywhere else aside from
127
128
// calls to queue::wait/wait_and_throw, which a user application might not
@@ -254,26 +255,27 @@ void queue_impl::wait(const detail::code_location &CodeLoc) {
254
255
// directly. Otherwise, only wait for unenqueued or host task events, starting
255
256
// from the latest submitted task in order to minimize total amount of calls,
256
257
// then handle the rest with piQueueFinish.
258
+ bool SupportsPiFinish = !is_host () && MSupportOOO;
257
259
for (auto EventImplWeakPtrIt = WeakEvents.rbegin ();
258
260
EventImplWeakPtrIt != WeakEvents.rend (); ++EventImplWeakPtrIt) {
259
261
if (std::shared_ptr<event_impl> EventImplSharedPtr =
260
262
EventImplWeakPtrIt->lock ()) {
261
263
// A nullptr PI event indicates that piQueueFinish will not cover it,
262
264
// either because it's a host task event or an unenqueued one.
263
- if (is_host () || !MSupportOOO ||
264
- nullptr == EventImplSharedPtr->getHandleRef ()) {
265
+ if (!SupportsPiFinish || nullptr == EventImplSharedPtr->getHandleRef ()) {
265
266
EventImplSharedPtr->wait (EventImplSharedPtr);
266
267
}
267
268
}
268
269
}
269
- if (! is_host () && MSupportOOO ) {
270
+ if (SupportsPiFinish ) {
270
271
const detail::plugin &Plugin = getPlugin ();
271
272
Plugin.call <detail::PiApiKind::piQueueFinish>(getHandleRef ());
272
273
for (std::weak_ptr<event_impl> &EventImplWeakPtr : WeakEvents)
273
274
if (std::shared_ptr<event_impl> EventImplSharedPtr =
274
275
EventImplWeakPtr.lock ())
275
276
EventImplSharedPtr->cleanupCommand (EventImplSharedPtr);
276
- assert (SharedEvents.empty ());
277
+ assert (SharedEvents.empty () && " Queues that support calling piQueueFinish "
278
+ " shouldn't have shared events" );
277
279
} else {
278
280
for (event &Event : SharedEvents)
279
281
Event.wait ();
0 commit comments