Skip to content

[SYCL][L0] Report more informative error at command execution failure #5524

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 1 commit into from
Feb 10, 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
3 changes: 3 additions & 0 deletions sycl/include/CL/sycl/detail/pi.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ typedef enum {
PI_IMAGE_FORMAT_NOT_SUPPORTED = CL_IMAGE_FORMAT_NOT_SUPPORTED,
PI_MEM_OBJECT_ALLOCATION_FAILURE = CL_MEM_OBJECT_ALLOCATION_FAILURE,
PI_LINK_PROGRAM_FAILURE = CL_LINK_PROGRAM_FAILURE,
PI_COMMAND_EXECUTION_FAILURE =
-997, ///< PI_COMMAND_EXECUTION_FAILURE indicates an error occurred
///< during command enqueue or execution.
PI_FUNCTION_ADDRESS_IS_NOT_AVAILABLE =
-998, ///< PI_FUNCTION_ADDRESS_IS_NOT_AVAILABLE indicates a fallback
///< method determines the function exists but its address cannot be
Expand Down
24 changes: 18 additions & 6 deletions sycl/plugins/level_zero/pi_level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1376,8 +1376,17 @@ pi_result _pi_queue::executeCommandList(pi_command_list_ptr_t CommandList,
// Offload command list to the GPU for asynchronous execution
auto ZeCommandList = CommandList->first;
zePrint("Calling zeCommandQueueExecuteCommandLists with Index = %d\n", Index);
ZE_CALL(zeCommandQueueExecuteCommandLists,
(ZeCommandQueue, 1, &ZeCommandList, CommandList->second.ZeFence));
auto ZeResult = ZE_CALL_NOCHECK(
zeCommandQueueExecuteCommandLists,
(ZeCommandQueue, 1, &ZeCommandList, CommandList->second.ZeFence));
if (ZeResult != ZE_RESULT_SUCCESS) {
this->Healthy = false;
if (ZeResult == ZE_RESULT_ERROR_UNKNOWN) {
// Turn into a more informative end-user error.
return PI_COMMAND_EXECUTION_FAILURE;
}
return mapError(ZeResult);
}

// Check global control to make every command blocking for debugging.
if (IsBlocking || (ZeSerialize & ZeSerializeBlock) != 0) {
Expand Down Expand Up @@ -3176,10 +3185,13 @@ pi_result piQueueRelease(pi_queue Queue) {
return Res;

// Make sure all commands get executed.
ZE_CALL(zeHostSynchronize, (Queue->ZeComputeCommandQueue));
for (uint32_t i = 0; i < Queue->ZeCopyCommandQueues.size(); ++i) {
if (Queue->ZeCopyCommandQueues[i])
ZE_CALL(zeHostSynchronize, (Queue->ZeCopyCommandQueues[i]));
// Only do so for a healthy queue as otherwise sync may not be valid.
if (Queue->Healthy) {
ZE_CALL(zeHostSynchronize, (Queue->ZeComputeCommandQueue));
for (uint32_t i = 0; i < Queue->ZeCopyCommandQueues.size(); ++i) {
if (Queue->ZeCopyCommandQueues[i])
ZE_CALL(zeHostSynchronize, (Queue->ZeCopyCommandQueues[i]));
}
}

// Destroy all the fences created associated with this queue.
Expand Down
3 changes: 3 additions & 0 deletions sycl/plugins/level_zero/pi_level_zero.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,9 @@ struct _pi_queue : _pi_object {
// externally, and can wait for internal references to complete, and do proper
// cleanup of the queue.
std::atomic<pi_uint32> RefCountExternal{1};

// Indicates that the queue is healthy and all operations on it are OK.
bool Healthy{true};
};

struct _pi_mem : _pi_object {
Expand Down
Loading