@@ -743,12 +743,8 @@ pi_result _pi_queue::signalEvent(pi_command_list_ptr_t CommandList) {
743
743
this , &SpecialEvent, PI_COMMAND_TYPE_USER, CommandList,
744
744
/* IsDiscarded */ false , /* ForceHostVisible */ false ));
745
745
746
- // We want a barrier in the beginning of a next command list waiting for this
747
- // special event.
748
- ActiveBarriers.push_back (SpecialEvent);
749
-
750
- // We don't need additional dependency through LastCommandEvent.
751
- LastCommandEvent = nullptr ;
746
+ PI_CALL (piEventRelease (SpecialEvent));
747
+ LastCommandEvent = SpecialEvent;
752
748
753
749
ZE_CALL (zeCommandListAppendSignalEvent,
754
750
(CommandList->first , SpecialEvent->ZeEvent ));
@@ -1098,24 +1094,9 @@ _pi_queue::resetCommandList(pi_command_list_ptr_t CommandList,
1098
1094
std::vector<pi_event> &EventListToCleanup) {
1099
1095
bool UseCopyEngine = CommandList->second .isCopy (this );
1100
1096
1101
- if (isInOrderQueue () && isDiscardEvents ()) {
1102
- // If there were discarded events in the command list then we have to
1103
- // release events from wait lists associated with them.
1104
- for (auto WaitList : CommandList->second .WaitLists ) {
1105
- std::list<pi_event> EventsToBeReleased;
1106
- WaitList.collectEventsForReleaseAndDestroyPiZeEventList (
1107
- EventsToBeReleased);
1108
-
1109
- // Event may be in the wait list of more than one event. But we have to
1110
- // cleanup it only once, that's why use unordered_set to make it happen.
1111
- std::unordered_set<pi_event> Events;
1112
- std::copy (EventsToBeReleased.begin (), EventsToBeReleased.end (),
1113
- std::inserter (Events, Events.begin ()));
1114
-
1115
- for (auto Event : Events)
1116
- EventListToCleanup.push_back (Event);
1117
- }
1118
- CommandList->second .WaitLists .clear ();
1097
+ if (CommandList->second .SpecialEvent ) {
1098
+ EventListToCleanup.push_back (CommandList->second .SpecialEvent );
1099
+ CommandList->second .SpecialEvent = nullptr ;
1119
1100
}
1120
1101
1121
1102
// Immediate commandlists do not have an associated fence.
@@ -1995,6 +1976,20 @@ pi_result _pi_queue::insertActiveBarriers(pi_command_list_ptr_t &CmdList,
1995
1976
if (ActiveBarriers.empty ())
1996
1977
return PI_SUCCESS;
1997
1978
1979
+ // For in-order queue every command depends on the previous one so we don't
1980
+ // need to insert active barriers for every next command list.
1981
+ // But we have to handle LastCommandEvent as an active barrier if we have
1982
+ // discard_events mode.
1983
+ if (isInOrderQueue () && isDiscardEvents () && LastCommandEvent) {
1984
+ ZE_CALL (zeCommandListAppendBarrier,
1985
+ (CmdList->first , nullptr , 1 , &(LastCommandEvent->ZeEvent )));
1986
+ CmdList->second .SpecialEvent = LastCommandEvent;
1987
+ // This event will be released on command list completion.
1988
+ PI_CALL (piEventRetain (CmdList->second .SpecialEvent ));
1989
+ LastCommandEvent = nullptr ;
1990
+ return PI_SUCCESS;
1991
+ }
1992
+
1998
1993
// Create a wait-list and retain events. This will filter out finished events.
1999
1994
_pi_ze_event_list_t ActiveBarriersWaitList;
2000
1995
if (auto Res = ActiveBarriersWaitList.createAndRetainPiZeEventList (
@@ -2007,12 +2002,9 @@ pi_result _pi_queue::insertActiveBarriers(pi_command_list_ptr_t &CmdList,
2007
2002
PI_CALL (piEventReleaseInternal (BarrierEvent));
2008
2003
ActiveBarriers.clear ();
2009
2004
2010
- // For in-order queue every command depends on the previous one so we don't
2011
- // need to insert active barriers for every next command list.
2012
- if (!isInOrderQueue ())
2013
- ActiveBarriers.insert (
2014
- ActiveBarriers.end (), ActiveBarriersWaitList.PiEventList ,
2015
- ActiveBarriersWaitList.PiEventList + ActiveBarriersWaitList.Length );
2005
+ ActiveBarriers.insert (
2006
+ ActiveBarriers.end (), ActiveBarriersWaitList.PiEventList ,
2007
+ ActiveBarriersWaitList.PiEventList + ActiveBarriersWaitList.Length );
2016
2008
2017
2009
// If there are more active barriers, insert a barrier on the command-list. We
2018
2010
// do not need an event for finishing so we pass nullptr.
@@ -2021,12 +2013,6 @@ pi_result _pi_queue::insertActiveBarriers(pi_command_list_ptr_t &CmdList,
2021
2013
(CmdList->first , nullptr , ActiveBarriersWaitList.Length ,
2022
2014
ActiveBarriersWaitList.ZeEventList ));
2023
2015
2024
- // Active barriers are released at queue synchronization, but for in-order
2025
- // queue we don't keep them till that point so store them in the command list,
2026
- // they will be released on completion of command list.
2027
- if (isInOrderQueue ())
2028
- CmdList->second .WaitLists .push_back (ActiveBarriersWaitList);
2029
-
2030
2016
return PI_SUCCESS;
2031
2017
}
2032
2018
0 commit comments