Skip to content

[UR] [L0 v2] Enable wait lists and signal events for command buffer in L0 adapter v2 #18442

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

Closed
wants to merge 8 commits into from
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
Original file line number Diff line number Diff line change
Expand Up @@ -1058,10 +1058,10 @@ ur_result_t urCommandBufferAppendKernelLaunchExp(
}

std::unique_ptr<kernel_command_handle> NewCommand;
UR_CALL(createCommandHandleUnlocked(
UR_CALL(createKernelCommandHandleUnlocked(
CommandBuffer, ZeCommandList, Kernel, WorkDim, GlobalWorkSize,
NumKernelAlternatives, KernelAlternatives, Platform, getZeKernelWrapped,
Device, NewCommand));
Device, false, 0, NewCommand));
*Command = NewCommand.get();
CommandBuffer->CommandHandles.push_back(std::move(NewCommand));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
kernel_command_handle::kernel_command_handle(
ur_exp_command_buffer_handle_t commandBuffer, ur_kernel_handle_t kernel,
uint64_t commandId, uint32_t workDim, uint32_t numKernelAlternatives,
ur_kernel_handle_t *kernelAlternatives)
: ur_exp_command_buffer_command_handle_t_(commandBuffer, commandId),
ur_kernel_handle_t *kernelAlternatives, bool hasSignalEvent,
uint32_t waitListSize)
: ur_exp_command_buffer_command_handle_t_(commandBuffer, commandId,
UR_COMMAND_KERNEL_LAUNCH,
hasSignalEvent, waitListSize),
workDim(workDim), kernel(kernel) {
// Add the default kernel to the list of valid kernels
ur::level_zero::urKernelRetain(kernel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,29 @@

struct ur_exp_command_buffer_command_handle_t_ : public ur_object {
ur_exp_command_buffer_command_handle_t_(
ur_exp_command_buffer_handle_t commandBuffer, uint64_t commandId)
: commandBuffer(commandBuffer), commandId(commandId) {}
ur_exp_command_buffer_handle_t commandBuffer, uint64_t commandId,
ur_command_t commandType, bool hasSignalEvent, uint32_t waitListSize)
: commandBuffer(commandBuffer), commandId(commandId),
commandType(commandType), waitListSize(waitListSize),
hasSignalEvent(hasSignalEvent) {}

virtual ~ur_exp_command_buffer_command_handle_t_() {}

// Command-buffer of this command.
ur_exp_command_buffer_handle_t commandBuffer;
// L0 command ID identifying this command
uint64_t commandId;
ur_command_t commandType;
uint32_t waitListSize = 0;
bool hasSignalEvent = false;
};

struct kernel_command_handle : public ur_exp_command_buffer_command_handle_t_ {
kernel_command_handle(ur_exp_command_buffer_handle_t commandBuffer,
ur_kernel_handle_t kernel, uint64_t commandId,
uint32_t workDim, uint32_t numKernelAlternatives,
ur_kernel_handle_t *kernelAlternatives);
ur_kernel_handle_t *kernelAlternatives,
bool hasSignalEvent, uint32_t waitListSize);

~kernel_command_handle();

Expand Down
10 changes: 10 additions & 0 deletions unified-runtime/source/adapters/level_zero/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1079,10 +1079,20 @@ ur_result_t urDeviceGetInfo(
UpdateCapabilities |=
UR_DEVICE_COMMAND_BUFFER_UPDATE_CAPABILITY_FLAG_KERNEL_HANDLE;
}
if (supportsFlags(ZE_MUTABLE_COMMAND_EXP_FLAG_SIGNAL_EVENT |
ZE_MUTABLE_COMMAND_EXP_FLAG_WAIT_EVENTS)) {
UpdateCapabilities |=
UR_DEVICE_COMMAND_BUFFER_UPDATE_CAPABILITY_FLAG_EVENTS;
}

return ReturnValue(UpdateCapabilities);
}
case UR_DEVICE_INFO_COMMAND_BUFFER_EVENT_SUPPORT_EXP:
#ifdef UR_ADAPTER_LEVEL_ZERO_V2
return ReturnValue(true);
#else
return ReturnValue(false);
#endif
case UR_DEVICE_INFO_COMMAND_BUFFER_SUBGRAPH_SUPPORT_EXP:
return ReturnValue(false);
case UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,18 +434,21 @@ ur_result_t validateCommandDescUnlocked(
* @param[in] KernelAlternatives List of kernel alternatives.
* @param[in] Platform The platform associated with the new command.
* @param[in] GetZeKernel Function to get the ze kernel handle.
* @param[in] hasSignalEvent Whether the command was created with a signal
* event.
* @param[in] waitListSize Size of the wait list of the created command.
* @param[out] Command The handle to the new command.
* @return UR_RESULT_SUCCESS or an error code on failure
*/
ur_result_t createCommandHandleUnlocked(
ur_result_t createKernelCommandHandleUnlocked(
ur_exp_command_buffer_handle_t CommandBuffer,
ze_command_list_handle_t ZeCommandList, ur_kernel_handle_t Kernel,
uint32_t WorkDim, const size_t *GlobalWorkSize,
uint32_t NumKernelAlternatives, ur_kernel_handle_t *KernelAlternatives,
ur_platform_handle_t Platform,
ur_result_t (*GetZeKernel)(ur_kernel_handle_t, ze_kernel_handle_t &,
ur_device_handle_t),
ur_device_handle_t Device,
ur_device_handle_t Device, bool hasSignalEvent, uint32_t waitListSize,
std::unique_ptr<kernel_command_handle> &Command) {

for (uint32_t i = 0; i < NumKernelAlternatives; ++i) {
Expand Down Expand Up @@ -508,7 +511,7 @@ ur_result_t createCommandHandleUnlocked(
try {
Command = std::make_unique<kernel_command_handle>(
CommandBuffer, Kernel, CommandId, WorkDim, NumKernelAlternatives,
KernelAlternatives);
KernelAlternatives, hasSignalEvent, waitListSize);

Command->setGlobalWorkSize(GlobalWorkSize);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ ur_result_t validateCommandDescUnlocked(
bool ZeDriverGlobalOffsetExtensionFound, size_t commandDescSize,
const ur_exp_command_buffer_update_kernel_launch_desc_t *CommandDescs);

ur_result_t createCommandHandleUnlocked(
ur_result_t createKernelCommandHandleUnlocked(
ur_exp_command_buffer_handle_t CommandBuffer,
ze_command_list_handle_t ZeCommandList, ur_kernel_handle_t Kernel,
uint32_t WorkDim, const size_t *GlobalWorkSize,
uint32_t NumKernelAlternatives, ur_kernel_handle_t *KernelAlternatives,
ur_platform_handle_t Platform,
ur_result_t (*getZeKernel)(ur_kernel_handle_t, ze_kernel_handle_t &,
ur_device_handle_t),
ur_device_handle_t Device, std::unique_ptr<kernel_command_handle> &Command);
ur_device_handle_t Device, bool hasSignalEvent, uint32_t waitListSize,
std::unique_ptr<kernel_command_handle> &Command);
Loading
Loading