Skip to content

Commit a61ac7a

Browse files
authored
[SYCL][L0][Plugin] Fix a crash in resetCommandLists (#6315)
Signed-off-by: Arvind Sudarsanam <[email protected]>
1 parent 5e34cab commit a61ac7a

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ _pi_queue::resetCommandList(pi_command_list_ptr_t CommandList,
897897
// calls.
898898
ZE_CALL(zeFenceReset, (CommandList->second.ZeFence));
899899
ZE_CALL(zeCommandListReset, (CommandList->first));
900-
CommandList->second.InUse = false;
900+
CommandList->second.ZeFenceInUse = false;
901901
}
902902

903903
auto &EventList = CommandList->second.EventList;
@@ -1140,8 +1140,8 @@ pi_result resetCommandLists(pi_queue Queue) {
11401140
for (auto &&it = Queue->CommandListMap.begin();
11411141
it != Queue->CommandListMap.end(); ++it) {
11421142
// It is possible that the fence was already noted as signalled and
1143-
// reset. In that case the InUse flag will be false.
1144-
if (it->second.InUse) {
1143+
// reset. In that case the ZeFenceInUse flag will be false.
1144+
if (it->second.ZeFence != nullptr && it->second.ZeFenceInUse) {
11451145
ze_result_t ZeResult =
11461146
ZE_CALL_NOCHECK(zeFenceQueryStatus, (it->second.ZeFence));
11471147
if (ZeResult == ZE_RESULT_SUCCESS) {
@@ -1220,7 +1220,8 @@ _pi_context::getAvailableCommandList(pi_queue Queue,
12201220
auto it = Queue->CommandListMap.find(ZeCommandList);
12211221
if (it != Queue->CommandListMap.end()) {
12221222
CommandList = it;
1223-
CommandList->second.InUse = true;
1223+
if (CommandList->second.ZeFence != nullptr)
1224+
CommandList->second.ZeFenceInUse = true;
12241225
} else {
12251226
// If there is a command list available on this context, but it
12261227
// wasn't yet used in this queue then create a new entry in this
@@ -3360,7 +3361,7 @@ pi_result piQueueRelease(pi_queue Queue) {
33603361
// For immediate commandlists we don't need to do an L0 reset of the
33613362
// commandlist but do need to do event cleanup which is also in the
33623363
// resetCommandList function.
3363-
if (it->second.InUse) {
3364+
if (it->second.ZeFence != nullptr && it->second.ZeFenceInUse) {
33643365
Queue->resetCommandList(it, true, EventListToCleanup);
33653366
}
33663367
// TODO: remove "if" when the problem is fixed in the level zero

sycl/plugins/level_zero/pi_level_zero.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ struct pi_command_list_info_t {
553553
// was not yet signaled at the time all events in that list were already
554554
// completed (we are polling the fence at events completion). The fence
555555
// may be still "in-use" due to sporadic delay in HW.
556-
bool InUse{false};
556+
bool ZeFenceInUse{false};
557557

558558
// Record the queue to which the command list will be submitted.
559559
ze_command_queue_handle_t ZeQueue{nullptr};

0 commit comments

Comments
 (0)