Skip to content
Merged
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
64 changes: 8 additions & 56 deletions unified-runtime/source/adapters/level_zero/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,31 +121,15 @@ ur_result_t urBindlessImagesWaitExternalSemaphoreExp(
// We want to batch these commands to avoid extra submissions (costly)
bool OkToBatch = true;

// External semaphore operations require an immediate command list per the
// Level Zero spec. If the queue is not using immediate command lists,
// we need to get one specifically for this operation.
bool NeedTempImmCmdList = !hQueue->UsingImmCmdLists;

ur_ze_event_list_t TmpWaitList;
UR_CALL(TmpWaitList.createAndRetainUrZeEventList(
numEventsInWaitList, phEventWaitList, hQueue, UseCopyEngine));

// Get a new command list to be used on this call
ur_command_list_ptr_t CommandList{};
if (NeedTempImmCmdList) {
// Ensure the queue group has ImmCmdLists initialized so we can
// obtain an immediate command list.
auto &QGroup = hQueue->getQueueGroup(UseCopyEngine);
if (QGroup.ImmCmdLists.empty()) {
QGroup.ImmCmdLists = std::vector<ur_command_list_ptr_t>(
QGroup.ZeQueues.size(), hQueue->CommandListMap.end());
}
CommandList = QGroup.getImmCmdList();
} else {
UR_CALL(hQueue->Context->getAvailableCommandList(
hQueue, CommandList, UseCopyEngine, numEventsInWaitList,
phEventWaitList, OkToBatch, nullptr /*ForcedCmdQueue*/));
}
UR_CALL(hQueue->Context->getAvailableCommandList(
hQueue, CommandList, UseCopyEngine, numEventsInWaitList, phEventWaitList,
OkToBatch, nullptr /*ForcedCmdQueue*/));

ze_event_handle_t ZeEvent = nullptr;
ur_event_handle_t InternalEvent;
Expand Down Expand Up @@ -173,15 +157,7 @@ ur_result_t urBindlessImagesWaitExternalSemaphoreExp(
(ZeCommandList, 1, &hExtSemaphore, &WaitParams, ZeEvent,
WaitList.Length, WaitList.ZeEventList));

if (NeedTempImmCmdList) {
// Immediate command lists auto-execute; no explicit submission needed.
// Update LastCommandEvent for in-order queue semantics.
if (!CommandList->second.EventList.empty()) {
hQueue->LastCommandEvent = CommandList->second.EventList.back();
}
} else {
UR_CALL(hQueue->executeCommandList(CommandList, false, OkToBatch));
}
UR_CALL(hQueue->executeCommandList(CommandList, false, OkToBatch));

return UR_RESULT_SUCCESS;
}
Expand All @@ -203,31 +179,15 @@ ur_result_t urBindlessImagesSignalExternalSemaphoreExp(
// We want to batch these commands to avoid extra submissions (costly)
bool OkToBatch = true;

// External semaphore operations require an immediate command list per the
// Level Zero spec. If the queue is not using immediate command lists,
// we need to get one specifically for this operation.
bool NeedTempImmCmdList = !hQueue->UsingImmCmdLists;

ur_ze_event_list_t TmpWaitList;
UR_CALL(TmpWaitList.createAndRetainUrZeEventList(
numEventsInWaitList, phEventWaitList, hQueue, UseCopyEngine));

// Get a new command list to be used on this call
ur_command_list_ptr_t CommandList{};
if (NeedTempImmCmdList) {
// Ensure the queue group has ImmCmdLists initialized so we can
// obtain an immediate command list.
auto &QGroup = hQueue->getQueueGroup(UseCopyEngine);
if (QGroup.ImmCmdLists.empty()) {
QGroup.ImmCmdLists = std::vector<ur_command_list_ptr_t>(
QGroup.ZeQueues.size(), hQueue->CommandListMap.end());
}
CommandList = QGroup.getImmCmdList();
} else {
UR_CALL(hQueue->Context->getAvailableCommandList(
hQueue, CommandList, UseCopyEngine, numEventsInWaitList,
phEventWaitList, OkToBatch, nullptr /*ForcedCmdQueue*/));
}
UR_CALL(hQueue->Context->getAvailableCommandList(
hQueue, CommandList, UseCopyEngine, numEventsInWaitList, phEventWaitList,
OkToBatch, nullptr /*ForcedCmdQueue*/));

ze_event_handle_t ZeEvent = nullptr;
ur_event_handle_t InternalEvent;
Expand Down Expand Up @@ -256,15 +216,7 @@ ur_result_t urBindlessImagesSignalExternalSemaphoreExp(
(ZeCommandList, 1, &hExtSemaphore, &SignalParams, ZeEvent,
WaitList.Length, WaitList.ZeEventList));

if (NeedTempImmCmdList) {
// Immediate command lists auto-execute; no explicit submission needed.
// Update LastCommandEvent for in-order queue semantics.
if (!CommandList->second.EventList.empty()) {
hQueue->LastCommandEvent = CommandList->second.EventList.back();
}
} else {
UR_CALL(hQueue->executeCommandList(CommandList, false, OkToBatch));
}
UR_CALL(hQueue->executeCommandList(CommandList, false, OkToBatch));

return UR_RESULT_SUCCESS;
}
Expand Down
Loading