File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -3849,6 +3849,15 @@ static pi_result cleanupAfterEvent(pi_event Event) {
3849
3849
PI_CALL (piKernelRelease (pi_cast<pi_kernel>(Event->CommandData )));
3850
3850
Event->CommandData = nullptr ;
3851
3851
}
3852
+
3853
+ if (!Event->CleanedUp ) {
3854
+ Event->CleanedUp = true ;
3855
+ // Release this event since we explicitly retained it on creation.
3856
+ // NOTE: that this needs to be done only once for an event so
3857
+ // this is guarded with the CleanedUp flag.
3858
+ //
3859
+ PI_CALL (piEventRelease (Event));
3860
+ }
3852
3861
}
3853
3862
3854
3863
// Make a list of all the dependent events that must have signalled
@@ -3873,9 +3882,6 @@ static pi_result cleanupAfterEvent(pi_event Event) {
3873
3882
PI_CALL (piEventRelease (DepEvent));
3874
3883
}
3875
3884
3876
- // Finally, release this event since we explicitly retained it on creation.
3877
- PI_CALL (piEventRelease (Event));
3878
-
3879
3885
return PI_SUCCESS;
3880
3886
}
3881
3887
@@ -3937,6 +3943,9 @@ pi_result piEventRetain(pi_event Event) {
3937
3943
3938
3944
pi_result piEventRelease (pi_event Event) {
3939
3945
PI_ASSERT (Event, PI_INVALID_EVENT);
3946
+ if (!Event->RefCount ) {
3947
+ die (" piEventRelease: called on a destroyed event" );
3948
+ }
3940
3949
3941
3950
if (--(Event->RefCount ) == 0 ) {
3942
3951
cleanupAfterEvent (Event);
Original file line number Diff line number Diff line change @@ -584,6 +584,12 @@ struct _pi_event : _pi_object {
584
584
// enqueued, and must then be released when this event has signalled.
585
585
// This list must be destroyed once the event has signalled.
586
586
_pi_ze_event_list_t WaitList;
587
+
588
+ // Tracks if the needed cleanupAfterEvent was already performed for
589
+ // a completed event. This allows to control that some cleanup
590
+ // actions are performed only once.
591
+ //
592
+ bool CleanedUp = {false };
587
593
};
588
594
589
595
struct _pi_program : _pi_object {
You can’t perform that action at this time.
0 commit comments