Skip to content

[SYCL][L0][Plugin] Fix a crash in resetCommandLists #6315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions sycl/plugins/level_zero/pi_level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ _pi_queue::resetCommandList(pi_command_list_ptr_t CommandList,
// calls.
ZE_CALL(zeFenceReset, (CommandList->second.ZeFence));
ZE_CALL(zeCommandListReset, (CommandList->first));
CommandList->second.InUse = false;
CommandList->second.ZeFenceInUse = false;
}

auto &EventList = CommandList->second.EventList;
Expand Down Expand Up @@ -1140,8 +1140,8 @@ pi_result resetCommandLists(pi_queue Queue) {
for (auto &&it = Queue->CommandListMap.begin();
it != Queue->CommandListMap.end(); ++it) {
// It is possible that the fence was already noted as signalled and
// reset. In that case the InUse flag will be false.
if (it->second.InUse) {
// reset. In that case the ZeFenceInUse flag will be false.
if (it->second.ZeFence != nullptr && it->second.ZeFenceInUse) {
ze_result_t ZeResult =
ZE_CALL_NOCHECK(zeFenceQueryStatus, (it->second.ZeFence));
if (ZeResult == ZE_RESULT_SUCCESS) {
Expand Down Expand Up @@ -1220,7 +1220,8 @@ _pi_context::getAvailableCommandList(pi_queue Queue,
auto it = Queue->CommandListMap.find(ZeCommandList);
if (it != Queue->CommandListMap.end()) {
CommandList = it;
CommandList->second.InUse = true;
if (CommandList->second.ZeFence != nullptr)
CommandList->second.ZeFenceInUse = true;
} else {
// If there is a command list available on this context, but it
// wasn't yet used in this queue then create a new entry in this
Expand Down Expand Up @@ -3360,7 +3361,7 @@ pi_result piQueueRelease(pi_queue Queue) {
// For immediate commandlists we don't need to do an L0 reset of the
// commandlist but do need to do event cleanup which is also in the
// resetCommandList function.
if (it->second.InUse) {
if (it->second.ZeFence != nullptr && it->second.ZeFenceInUse) {
Queue->resetCommandList(it, true, EventListToCleanup);
}
// TODO: remove "if" when the problem is fixed in the level zero
Expand Down
2 changes: 1 addition & 1 deletion sycl/plugins/level_zero/pi_level_zero.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ struct pi_command_list_info_t {
// was not yet signaled at the time all events in that list were already
// completed (we are polling the fence at events completion). The fence
// may be still "in-use" due to sporadic delay in HW.
bool InUse{false};
bool ZeFenceInUse{false};

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