Skip to content

Commit 4e5f3f2

Browse files
[SYCL][L0] Address static analyzer issue with Queue->LastCommandEvent (#7787)
Signed-off-by: Sergey V Maslov <[email protected]>
1 parent bbcf93e commit 4e5f3f2

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2192,6 +2192,9 @@ pi_result _pi_ze_event_list_t::createAndRetainPiZeEventList(
21922192
}
21932193
}
21942194

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.
21952198
bool IncludeLastCommandEvent =
21962199
CurQueue->isInOrderQueue() && CurQueue->LastCommandEvent != nullptr;
21972200

@@ -2203,16 +2206,20 @@ pi_result _pi_ze_event_list_t::createAndRetainPiZeEventList(
22032206
IncludeLastCommandEvent = false;
22042207

22052208
try {
2209+
pi_uint32 TmpListLength = 0;
2210+
22062211
if (IncludeLastCommandEvent) {
22072212
this->ZeEventList = new ze_event_handle_t[EventListLength + 1];
22082213
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;
22092218
} else if (EventListLength > 0) {
22102219
this->ZeEventList = new ze_event_handle_t[EventListLength];
22112220
this->PiEventList = new pi_event[EventListLength];
22122221
}
22132222

2214-
pi_uint32 TmpListLength = 0;
2215-
22162223
if (EventListLength > 0) {
22172224
for (pi_uint32 I = 0; I < EventListLength; I++) {
22182225
PI_ASSERT(EventList[I] != nullptr, PI_ERROR_INVALID_VALUE);
@@ -2292,16 +2299,6 @@ pi_result _pi_ze_event_list_t::createAndRetainPiZeEventList(
22922299
}
22932300
}
22942301

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-
23052302
this->Length = TmpListLength;
23062303

23072304
} catch (...) {

0 commit comments

Comments
 (0)