Skip to content
Closed
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
21 changes: 12 additions & 9 deletions source/adapters/level_zero/command_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,13 +431,11 @@ ur_result_t enqueueCommandBufferFillHelper(
ur_exp_command_buffer_handle_t_::ur_exp_command_buffer_handle_t_(
ur_context_handle_t Context, ur_device_handle_t Device,
ze_command_list_handle_t CommandList,
ze_command_list_handle_t CommandListTranslated,
ze_command_list_handle_t CommandListResetEvents,
ze_command_list_handle_t CopyCommandList, ur_event_handle_t SignalEvent,
ur_event_handle_t WaitEvent, ur_event_handle_t AllResetEvent,
const ur_exp_command_buffer_desc_t *Desc, const bool IsInOrderCmdList)
: Context(Context), Device(Device), ZeComputeCommandList(CommandList),
ZeComputeCommandListTranslated(CommandListTranslated),
ZeCommandListResetEvents(CommandListResetEvents),
ZeCopyCommandList(CopyCommandList), SignalEvent(SignalEvent),
WaitEvent(WaitEvent), AllResetEvent(AllResetEvent), ZeFencesMap(),
Expand Down Expand Up @@ -702,11 +700,16 @@ urCommandBufferCreateExp(ur_context_handle_t Context, ur_device_handle_t Device,
(ZEL_HANDLE_COMMAND_LIST, ZeComputeCommandList,
(void **)&ZeComputeCommandListTranslated));

ze_command_list_handle_t ZeCopyCommandListTranslated = nullptr;
ZE2UR_CALL(zelLoaderTranslateHandle,
(ZEL_HANDLE_COMMAND_LIST, ZeCopyCommandList,
(void **)&ZeCopyCommandListTranslated));

try {
*CommandBuffer = new ur_exp_command_buffer_handle_t_(
Context, Device, ZeComputeCommandList, ZeComputeCommandListTranslated,
ZeCommandListResetEvents, ZeCopyCommandList, SignalEvent, WaitEvent,
AllResetEvent, CommandBufferDesc, IsInOrder);
Context, Device, ZeComputeCommandListTranslated,
ZeCommandListResetEvents, ZeCopyCommandListTranslated, SignalEvent,
WaitEvent, AllResetEvent, CommandBufferDesc, IsInOrder);
} catch (const std::bad_alloc &) {
return UR_RESULT_ERROR_OUT_OF_HOST_MEMORY;
} catch (...) {
Expand Down Expand Up @@ -862,9 +865,9 @@ createCommandHandle(ur_exp_command_buffer_handle_t CommandBuffer,
ZE_MUTABLE_COMMAND_EXP_FLAG_GLOBAL_OFFSET;

auto Platform = CommandBuffer->Context->getPlatform();
ZE2UR_CALL(Platform->ZeMutableCmdListExt.zexCommandListGetNextCommandIdExp,
(CommandBuffer->ZeComputeCommandListTranslated,
&ZeMutableCommandDesc, &CommandId));
ZE2UR_CALL(
Platform->ZeMutableCmdListExt.zexCommandListGetNextCommandIdExp,
(CommandBuffer->ZeComputeCommandList, &ZeMutableCommandDesc, &CommandId));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fail, you need to translate both handles, not just the copy above. This will break the code.

DEBUG_LOG(CommandId);

try {
Expand Down Expand Up @@ -1754,7 +1757,7 @@ ur_result_t updateKernelCommand(
auto Platform = CommandBuffer->Context->getPlatform();
ZE2UR_CALL(
Platform->ZeMutableCmdListExt.zexCommandListUpdateMutableCommandsExp,
(CommandBuffer->ZeComputeCommandListTranslated, &MutableCommandDesc));
Copy link
Contributor

@nrspruit nrspruit Jul 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You still need the translated compute command list handle. Any call to an extension function pointer requires all handles used are translated.

(CommandBuffer->ZeComputeCommandList, &MutableCommandDesc));

return UR_RESULT_SUCCESS;
}
Expand Down
4 changes: 0 additions & 4 deletions source/adapters/level_zero/command_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ struct ur_exp_command_buffer_handle_t_ : public _ur_object {
ur_exp_command_buffer_handle_t_(
ur_context_handle_t Context, ur_device_handle_t Device,
ze_command_list_handle_t CommandList,
ze_command_list_handle_t CommandListTranslated,
ze_command_list_handle_t CommandListResetEvents,
ze_command_list_handle_t CopyCommandList, ur_event_handle_t SignalEvent,
ur_event_handle_t WaitEvent, ur_event_handle_t AllResetEvent,
Expand Down Expand Up @@ -71,9 +70,6 @@ struct ur_exp_command_buffer_handle_t_ : public _ur_object {
ur_device_handle_t Device;
// Level Zero command list handle
ze_command_list_handle_t ZeComputeCommandList;
// Given a multi driver scenario, the driver handle must be translated to the
// internal driver handle to allow calls to driver experimental apis.
ze_command_list_handle_t ZeComputeCommandListTranslated;
// Level Zero command list handle
ze_command_list_handle_t ZeCommandListResetEvents;
// Level Zero Copy command list handle
Expand Down