@@ -2192,6 +2192,9 @@ pi_result _pi_ze_event_list_t::createAndRetainPiZeEventList(
2192
2192
}
2193
2193
}
2194
2194
2195
+ // For in-order queues, every command should be executed only after the
2196
+ // previous command has finished. The event associated with the last
2197
+ // enqueued command is added into the waitlist to ensure in-order semantics.
2195
2198
bool IncludeLastCommandEvent =
2196
2199
CurQueue->isInOrderQueue () && CurQueue->LastCommandEvent != nullptr ;
2197
2200
@@ -2203,16 +2206,20 @@ pi_result _pi_ze_event_list_t::createAndRetainPiZeEventList(
2203
2206
IncludeLastCommandEvent = false ;
2204
2207
2205
2208
try {
2209
+ pi_uint32 TmpListLength = 0 ;
2210
+
2206
2211
if (IncludeLastCommandEvent) {
2207
2212
this ->ZeEventList = new ze_event_handle_t [EventListLength + 1 ];
2208
2213
this ->PiEventList = new pi_event[EventListLength + 1 ];
2214
+ std::shared_lock<pi_shared_mutex> Lock (CurQueue->LastCommandEvent ->Mutex );
2215
+ this ->ZeEventList [0 ] = CurQueue->LastCommandEvent ->ZeEvent ;
2216
+ this ->PiEventList [0 ] = CurQueue->LastCommandEvent ;
2217
+ TmpListLength = 1 ;
2209
2218
} else if (EventListLength > 0 ) {
2210
2219
this ->ZeEventList = new ze_event_handle_t [EventListLength];
2211
2220
this ->PiEventList = new pi_event[EventListLength];
2212
2221
}
2213
2222
2214
- pi_uint32 TmpListLength = 0 ;
2215
-
2216
2223
if (EventListLength > 0 ) {
2217
2224
for (pi_uint32 I = 0 ; I < EventListLength; I++) {
2218
2225
PI_ASSERT (EventList[I] != nullptr , PI_ERROR_INVALID_VALUE);
@@ -2292,16 +2299,6 @@ pi_result _pi_ze_event_list_t::createAndRetainPiZeEventList(
2292
2299
}
2293
2300
}
2294
2301
2295
- // For in-order queues, every command should be executed only after the
2296
- // previous command has finished. The event associated with the last
2297
- // enqueued command is added into the waitlist to ensure in-order semantics.
2298
- if (IncludeLastCommandEvent) {
2299
- std::shared_lock<pi_shared_mutex> Lock (CurQueue->LastCommandEvent ->Mutex );
2300
- this ->ZeEventList [TmpListLength] = CurQueue->LastCommandEvent ->ZeEvent ;
2301
- this ->PiEventList [TmpListLength] = CurQueue->LastCommandEvent ;
2302
- TmpListLength += 1 ;
2303
- }
2304
-
2305
2302
this ->Length = TmpListLength;
2306
2303
2307
2304
} catch (...) {
0 commit comments