Skip to content

Commit 9db080b

Browse files
committed
[SYCL] Retain PI events until they have signalled
Signed-off-by: Sergey V Maslov <sergey.v.maslov@intel.com>
1 parent 733d5e3 commit 9db080b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,15 @@ createEventAndAssociateQueue(pi_queue Queue, pi_event *Event,
450450
// In piEventRelease, the reference counter of the Queue is decremented
451451
// to release it.
452452
piQueueRetainNoLock(Queue);
453+
454+
// SYCL RT does not track completion of the events, so it could
455+
// release a PI event as soon as that's not being waited in the app.
456+
// But we have to ensure that the event is not destroyed before
457+
// it is really signalled, so retain it explicitly here and
458+
// release in cleanupAfterEvent.
459+
//
460+
PI_CALL(piEventRetain(*Event));
461+
453462
return PI_SUCCESS;
454463
}
455464

@@ -3863,6 +3872,10 @@ static pi_result cleanupAfterEvent(pi_event Event) {
38633872
EventsToBeReleased);
38643873
PI_CALL(piEventRelease(DepEvent));
38653874
}
3875+
3876+
// Finally, release this event since we explicitly retained it on creation.
3877+
PI_CALL(piEventRelease(Event));
3878+
38663879
return PI_SUCCESS;
38673880
}
38683881

0 commit comments

Comments
 (0)