refactor: move append kernel argument functionality code to separate method

Related-To: NEO-15606

Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2025-08-25 12:26:13 +00:00
committed by Compute-Runtime-Automation
parent 4e6b91251b
commit b2ea1d98e6
3 changed files with 46 additions and 38 deletions

View File

@@ -240,4 +240,47 @@ void CommandList::registerWalkerWithProfilingEnqueued(Event *event) {
}
}
ze_result_t CommandList::setKernelState(Kernel *kernel, const ze_group_size_t groupSizes, void **arguments) {
if (kernel == nullptr) {
return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
}
auto result = kernel->setGroupSize(groupSizes.groupSizeX, groupSizes.groupSizeY, groupSizes.groupSizeZ);
if (result != ZE_RESULT_SUCCESS) {
return result;
}
auto &args = kernel->getImmutableData()->getDescriptor().payloadMappings.explicitArgs;
if (args.size() > 0 && !arguments) {
return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
}
for (auto i = 0u; i < args.size(); i++) {
auto &arg = args[i];
auto argSize = sizeof(void *);
auto argValue = arguments[i];
switch (arg.type) {
case NEO::ArgDescriptor::argTPointer:
if (arg.getTraits().getAddressQualifier() == NEO::KernelArgMetadata::AddrLocal) {
argSize = *reinterpret_cast<const size_t *>(argValue);
argValue = nullptr;
}
break;
case NEO::ArgDescriptor::argTValue:
argSize = std::numeric_limits<size_t>::max();
break;
default:
break;
}
result = kernel->setArgumentValue(i, argSize, argValue);
if (result != ZE_RESULT_SUCCESS) {
return result;
}
}
return ZE_RESULT_SUCCESS;
}
} // namespace L0

View File

@@ -241,6 +241,8 @@ struct CommandList : _ze_command_list_handle_t {
return alloc && alloc->getAllocationType() == NEO::AllocationType::externalHostPtr;
}
static ze_result_t setKernelState(Kernel *kernel, const ze_group_size_t groupSizes, void **arguments);
inline ze_command_list_handle_t toHandle() { return this; }
uint32_t getCommandListPerThreadScratchSize(uint32_t slotId) const {

View File

@@ -587,7 +587,6 @@ template <GFXCORE_FAMILY gfxCoreFamily>
ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernelWithArguments(ze_kernel_handle_t hKernel,
const ze_group_count_t groupCounts,
const ze_group_size_t groupSizes,
void **pArguments,
const void *pNext,
ze_event_handle_t hSignalEvent,
@@ -595,46 +594,10 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernelWithArgument
ze_event_handle_t *phWaitEvents) {
auto kernel = L0::Kernel::fromHandle(hKernel);
if (kernel == nullptr) {
return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
}
auto result = kernel->setGroupSize(groupSizes.groupSizeX, groupSizes.groupSizeY, groupSizes.groupSizeZ);
auto result = CommandList::setKernelState(kernel, groupSizes, pArguments);
if (result != ZE_RESULT_SUCCESS) {
return result;
}
auto &args = kernel->getImmutableData()->getDescriptor().payloadMappings.explicitArgs;
if (args.size() > 0 && !pArguments) {
return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
}
for (auto i = 0u; i < args.size(); i++) {
auto &arg = args[i];
auto argSize = sizeof(void *);
auto argValue = pArguments[i];
switch (arg.type) {
case NEO::ArgDescriptor::argTPointer:
if (arg.getTraits().getAddressQualifier() == NEO::KernelArgMetadata::AddrLocal) {
argSize = *reinterpret_cast<const size_t *>(argValue);
argValue = nullptr;
}
break;
case NEO::ArgDescriptor::argTValue:
argSize = std::numeric_limits<size_t>::max();
default:
break;
}
result = kernel->setArgumentValue(i, argSize, argValue);
if (result != ZE_RESULT_SUCCESS) {
return result;
}
}
return this->appendLaunchKernelWithParameters(hKernel, &groupCounts, pNext, hSignalEvent, numWaitEvents, phWaitEvents);
}