mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-19 06:24:51 +08:00
feature: add L0 API to append kernel with all params
Related-To: NEO-14560 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
95b0b16c0a
commit
48881bfb9a
@@ -134,6 +134,22 @@ ze_result_t zeCommandListAppendWaitExternalSemaphoreExt(
|
||||
return L0::CommandList::fromHandle(hCommandList)->appendWaitExternalSemaphores(numSemaphores, phSemaphores, waitParams, hSignalEvent, numWaitEvents, phWaitEvents);
|
||||
}
|
||||
|
||||
ze_result_t zeCommandListAppendLaunchKernelWithArguments(
|
||||
ze_command_list_handle_t hCommandList,
|
||||
ze_kernel_handle_t hKernel,
|
||||
const ze_group_count_t groupCounts,
|
||||
const ze_group_size_t groupSizes,
|
||||
void **pArguments,
|
||||
void *pNext,
|
||||
ze_event_handle_t hSignalEvent,
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) {
|
||||
if (!hCommandList) {
|
||||
return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
|
||||
}
|
||||
return L0::CommandList::fromHandle(hCommandList)->appendLaunchKernelWithArguments(hKernel, groupCounts, groupSizes, pArguments, pNext, hSignalEvent, numWaitEvents, phWaitEvents);
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
|
||||
extern "C" {
|
||||
@@ -270,4 +286,17 @@ ZE_APIEXPORT ze_result_t ZE_APICALL zeCommandListAppendWaitExternalSemaphoreExt(
|
||||
ze_event_handle_t *phWaitEvents) {
|
||||
return L0::CommandList::fromHandle(hCommandList)->appendWaitExternalSemaphores(numSemaphores, phSemaphores, waitParams, hSignalEvent, numWaitEvents, phWaitEvents);
|
||||
}
|
||||
}
|
||||
|
||||
ze_result_t ZE_APICALL zeCommandListAppendLaunchKernelWithArguments(
|
||||
ze_command_list_handle_t hCommandList,
|
||||
ze_kernel_handle_t hKernel,
|
||||
const ze_group_count_t groupCounts,
|
||||
const ze_group_size_t groupSizes,
|
||||
void **pArguments,
|
||||
void *pNext,
|
||||
ze_event_handle_t hSignalEvent,
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) {
|
||||
return L0::zeCommandListAppendLaunchKernelWithArguments(hCommandList, hKernel, groupCounts, groupSizes, pArguments, pNext, hSignalEvent, numWaitEvents, phWaitEvents);
|
||||
}
|
||||
} // extern "C"
|
||||
@@ -121,6 +121,16 @@ struct CommandList : _ze_command_list_handle_t {
|
||||
const uint32_t *pNumLaunchArguments,
|
||||
const ze_group_count_t *pLaunchArgumentsBuffer, ze_event_handle_t hEvent,
|
||||
uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents, bool relaxedOrderingDispatch) = 0;
|
||||
virtual ze_result_t appendLaunchKernelWithArguments(ze_kernel_handle_t hKernel,
|
||||
const ze_group_count_t groupCounts,
|
||||
const ze_group_size_t groupSizes,
|
||||
|
||||
void **pArguments,
|
||||
void *pNext,
|
||||
ze_event_handle_t hSignalEvent,
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) = 0;
|
||||
|
||||
virtual ze_result_t appendMemAdvise(ze_device_handle_t hDevice, const void *ptr, size_t size,
|
||||
ze_memory_advice_t advice) = 0;
|
||||
virtual ze_result_t executeMemAdvise(ze_device_handle_t hDevice,
|
||||
|
||||
@@ -133,6 +133,15 @@ struct CommandListCoreFamily : public CommandListImp {
|
||||
ze_event_handle_t hEvent,
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents, bool relaxedOrderingDispatch) override;
|
||||
ze_result_t appendLaunchKernelWithArguments(ze_kernel_handle_t hKernel,
|
||||
const ze_group_count_t groupCounts,
|
||||
const ze_group_size_t groupSizes,
|
||||
|
||||
void **pArguments,
|
||||
void *pNext,
|
||||
ze_event_handle_t hSignalEvent,
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) override;
|
||||
ze_result_t appendMemAdvise(ze_device_handle_t hDevice,
|
||||
const void *ptr, size_t size,
|
||||
ze_memory_advice_t advice) override;
|
||||
|
||||
@@ -557,6 +557,65 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendLaunchMultipleKernelsInd
|
||||
return ret;
|
||||
}
|
||||
|
||||
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,
|
||||
void *pNext,
|
||||
ze_event_handle_t hSignalEvent,
|
||||
uint32_t numWaitEvents,
|
||||
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);
|
||||
|
||||
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<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;
|
||||
}
|
||||
}
|
||||
|
||||
L0::CmdListKernelLaunchParams launchParams = {};
|
||||
launchParams.skipInOrderNonWalkerSignaling = this->skipInOrderNonWalkerSignalingAllowed(hSignalEvent);
|
||||
|
||||
return this->appendLaunchKernel(hKernel, groupCounts, hSignalEvent, numWaitEvents, phWaitEvents, launchParams, false);
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendEventReset(ze_event_handle_t hEvent) {
|
||||
auto event = Event::fromHandle(hEvent);
|
||||
|
||||
@@ -36,6 +36,8 @@ void *ExtensionFunctionAddressHelper::getExtensionFunctionAddress(const std::str
|
||||
RETURN_FUNC_PTR_IF_EXIST(zerIdentifierTranslateToDeviceHandle);
|
||||
RETURN_FUNC_PTR_IF_EXIST(zeDeviceSynchronize);
|
||||
|
||||
RETURN_FUNC_PTR_IF_EXIST(zeCommandListAppendLaunchKernelWithArguments);
|
||||
|
||||
RETURN_FUNC_PTR_IF_EXIST(zexKernelGetBaseAddress);
|
||||
RETURN_FUNC_PTR_IF_EXIST(zexKernelGetArgumentSize);
|
||||
RETURN_FUNC_PTR_IF_EXIST(zexKernelGetArgumentType);
|
||||
|
||||
@@ -373,6 +373,16 @@ struct MockCommandList : public CommandList {
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents, bool relaxedOrderingDispatch));
|
||||
|
||||
ADDMETHOD_NOBASE(appendLaunchKernelWithArguments, ze_result_t, ZE_RESULT_SUCCESS,
|
||||
(ze_kernel_handle_t hKernel,
|
||||
const ze_group_count_t groupCounts,
|
||||
const ze_group_size_t groupSizes,
|
||||
void **pArguments,
|
||||
void *pNext,
|
||||
ze_event_handle_t hSignalEvent,
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents));
|
||||
|
||||
ADDMETHOD_NOBASE(appendSoftwareTag, ze_result_t, ZE_RESULT_SUCCESS,
|
||||
(const char *data));
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2024 Intel Corporation
|
||||
* Copyright (C) 2020-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -119,9 +119,21 @@ struct Mock<::L0::KernelImp> : public WhiteBox<::L0::KernelImp> {
|
||||
|
||||
if (checkPassedArgumentValues) {
|
||||
UNRECOVERABLE_IF(argIndex >= passedArgumentValues.size());
|
||||
auto &explicitArgs = getImmutableData()->getDescriptor().payloadMappings.explicitArgs;
|
||||
if (explicitArgs[argIndex].type == NEO::ArgDescriptor::argTValue) {
|
||||
|
||||
size_t maxArgSize = 0u;
|
||||
|
||||
for (const auto &element : explicitArgs[argIndex].as<NEO::ArgDescValue>().elements) {
|
||||
maxArgSize += element.size;
|
||||
}
|
||||
argSize = std::min(maxArgSize, argSize);
|
||||
}
|
||||
|
||||
passedArgumentValues[argIndex].resize(argSize);
|
||||
memcpy(passedArgumentValues[argIndex].data(), pArgValue, argSize);
|
||||
if (pArgValue) {
|
||||
memcpy(passedArgumentValues[argIndex].data(), pArgValue, argSize);
|
||||
}
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
} else {
|
||||
|
||||
@@ -3272,5 +3272,191 @@ HWTEST2_F(CommandListCreateTests, givenEmptySvmManagerWhenIsAllocationImportedTh
|
||||
EXPECT_FALSE(commandListCore->isAllocationImported(nullptr, svmManager));
|
||||
}
|
||||
|
||||
using CommandListAppendLaunchKernelWithArgumentsTests = Test<CommandListCreateFixture>;
|
||||
TEST_F(CommandListAppendLaunchKernelWithArgumentsTests, givenNullptrInputWhenAppendLaunchKernelWithArgumentsThenErrorIsReturned) {
|
||||
|
||||
const ze_group_count_t groupCounts{1, 2, 3};
|
||||
const ze_group_size_t groupSizes{4, 5, 6};
|
||||
auto retVal = zeCommandListAppendLaunchKernelWithArguments(nullptr, nullptr, groupCounts, groupSizes, nullptr, nullptr, nullptr, 0, nullptr);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_NULL_HANDLE, retVal);
|
||||
|
||||
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::renderCompute, 0u, retVal, false));
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, retVal);
|
||||
|
||||
retVal = zeCommandListAppendLaunchKernelWithArguments(commandList->toHandle(), nullptr, groupCounts, groupSizes, nullptr, nullptr, nullptr, 0, nullptr);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_NULL_HANDLE, retVal);
|
||||
|
||||
NEO::KernelInfo kernelInfo{};
|
||||
uint8_t kernelHeap[10]{};
|
||||
kernelInfo.heapInfo.pKernelHeap = kernelHeap;
|
||||
kernelInfo.heapInfo.kernelHeapSize = sizeof(kernelHeap);
|
||||
kernelInfo.kernelDescriptor.kernelMetadata.kernelName = "kernel";
|
||||
kernelInfo.kernelDescriptor.payloadMappings.explicitArgs.resize(1);
|
||||
kernelInfo.kernelDescriptor.payloadMappings.explicitArgs[0].type = NEO::ArgDescriptor::argTPointer; // arg buffer
|
||||
kernelInfo.kernelDescriptor.payloadMappings.explicitArgs[0].as<NEO::ArgDescPointer>().bindful = NEO::undefined<NEO::SurfaceStateHeapOffset>;
|
||||
kernelInfo.kernelDescriptor.payloadMappings.explicitArgs[0].as<NEO::ArgDescPointer>().bindless = NEO::undefined<NEO::SurfaceStateHeapOffset>;
|
||||
|
||||
auto kernelImmutableData = std::make_unique<KernelImmutableData>(device);
|
||||
auto mockIsaAllocation = std::make_unique<MockGraphicsAllocation>(reinterpret_cast<void *>(0x543000), 10);
|
||||
mockIsaAllocation->setAllocationType(NEO::AllocationType::kernelIsa);
|
||||
kernelImmutableData->setIsaPerKernelAllocation(mockIsaAllocation.release());
|
||||
kernelImmutableData->initialize(&kernelInfo, device, 0, nullptr, nullptr, false);
|
||||
|
||||
std::unique_ptr<L0::ult::Module> mockModule = std::make_unique<L0::ult::Module>(device, nullptr, ModuleType::user);
|
||||
mockModule->kernelImmDatas.push_back(std::move(kernelImmutableData));
|
||||
|
||||
Mock<::L0::KernelImp> kernel;
|
||||
kernel.module = mockModule.get();
|
||||
ze_kernel_desc_t desc = {ZE_STRUCTURE_TYPE_KERNEL_DESC};
|
||||
desc.pKernelName = kernelInfo.kernelDescriptor.kernelMetadata.kernelName.c_str();
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, kernel.initialize(&desc));
|
||||
retVal = zeCommandListAppendLaunchKernelWithArguments(commandList->toHandle(), kernel.toHandle(), groupCounts, groupSizes, nullptr, nullptr, nullptr, 0, nullptr);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_NULL_POINTER, retVal);
|
||||
}
|
||||
|
||||
TEST_F(CommandListAppendLaunchKernelWithArgumentsTests, givenIncorrectGroupSizeWhenAppendLaunchKernelWithArgumentsThenErrorIsReturned) {
|
||||
|
||||
const ze_group_count_t groupCounts{1, 2, 3};
|
||||
const ze_group_size_t groupSizes{std::numeric_limits<uint32_t>::max(), std::numeric_limits<uint32_t>::max(), std::numeric_limits<uint32_t>::max()};
|
||||
|
||||
auto retVal = ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
|
||||
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::renderCompute, 0u, retVal, false));
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, retVal);
|
||||
|
||||
std::unique_ptr<L0::ult::Module> mockModule = std::make_unique<L0::ult::Module>(device, nullptr, ModuleType::user);
|
||||
Mock<::L0::KernelImp> kernel;
|
||||
kernel.module = mockModule.get();
|
||||
|
||||
void *arguments = nullptr;
|
||||
retVal = zeCommandListAppendLaunchKernelWithArguments(commandList->toHandle(), kernel.toHandle(), groupCounts, groupSizes, &arguments, nullptr, nullptr, 0, nullptr);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION, retVal);
|
||||
}
|
||||
|
||||
TEST_F(CommandListAppendLaunchKernelWithArgumentsTests, whenAppendLaunchKernelWithArgumentsThenProperKernelArgumentsAreSet) {
|
||||
|
||||
const ze_group_count_t groupCounts{1, 2, 3};
|
||||
const ze_group_size_t groupSizes{4, 5, 6};
|
||||
|
||||
auto retVal = ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
|
||||
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::renderCompute, 0u, retVal, false));
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, retVal);
|
||||
|
||||
NEO::KernelInfo kernelInfo{};
|
||||
uint8_t kernelHeap[10]{};
|
||||
kernelInfo.heapInfo.pKernelHeap = kernelHeap;
|
||||
kernelInfo.heapInfo.kernelHeapSize = sizeof(kernelHeap);
|
||||
kernelInfo.kernelDescriptor.kernelMetadata.kernelName = "kernel";
|
||||
kernelInfo.kernelDescriptor.payloadMappings.explicitArgs.resize(5);
|
||||
kernelInfo.kernelDescriptor.payloadMappings.explicitArgs[0].type = NEO::ArgDescriptor::argTPointer; // arg buffer
|
||||
kernelInfo.kernelDescriptor.payloadMappings.explicitArgs[0].as<NEO::ArgDescPointer>().bindful = NEO::undefined<NEO::SurfaceStateHeapOffset>;
|
||||
kernelInfo.kernelDescriptor.payloadMappings.explicitArgs[0].as<NEO::ArgDescPointer>().bindless = NEO::undefined<NEO::SurfaceStateHeapOffset>;
|
||||
|
||||
kernelInfo.kernelDescriptor.payloadMappings.explicitArgs[1].type = NEO::ArgDescriptor::argTImage; // arg image
|
||||
kernelInfo.kernelDescriptor.payloadMappings.explicitArgs[2].type = NEO::ArgDescriptor::argTSampler; // arg sampler
|
||||
kernelInfo.kernelDescriptor.payloadMappings.explicitArgs[3].type = NEO::ArgDescriptor::argTValue; // arg immediate
|
||||
kernelInfo.kernelDescriptor.payloadMappings.explicitArgs[3].as<NEO::ArgDescValue>().elements.resize(3);
|
||||
kernelInfo.kernelDescriptor.payloadMappings.explicitArgs[3].as<NEO::ArgDescValue>().elements[0].size = 4;
|
||||
kernelInfo.kernelDescriptor.payloadMappings.explicitArgs[3].as<NEO::ArgDescValue>().elements[0].sourceOffset = 0;
|
||||
kernelInfo.kernelDescriptor.payloadMappings.explicitArgs[3].as<NEO::ArgDescValue>().elements[1].size = 8;
|
||||
kernelInfo.kernelDescriptor.payloadMappings.explicitArgs[3].as<NEO::ArgDescValue>().elements[1].sourceOffset = 4;
|
||||
kernelInfo.kernelDescriptor.payloadMappings.explicitArgs[3].as<NEO::ArgDescValue>().elements[2].size = 4;
|
||||
kernelInfo.kernelDescriptor.payloadMappings.explicitArgs[3].as<NEO::ArgDescValue>().elements[2].sourceOffset = 12;
|
||||
|
||||
kernelInfo.kernelDescriptor.payloadMappings.explicitArgs[4].type = NEO::ArgDescriptor::argTPointer; // arg slm
|
||||
kernelInfo.kernelDescriptor.payloadMappings.explicitArgs[4].getTraits().addressQualifier = NEO::KernelArgMetadata::AddrLocal;
|
||||
kernelInfo.kernelDescriptor.payloadMappings.explicitArgs[4].as<NEO::ArgDescPointer>().bindful = NEO::undefined<NEO::SurfaceStateHeapOffset>;
|
||||
kernelInfo.kernelDescriptor.payloadMappings.explicitArgs[4].as<NEO::ArgDescPointer>().bindless = NEO::undefined<NEO::SurfaceStateHeapOffset>;
|
||||
|
||||
auto kernelImmutableData = std::make_unique<KernelImmutableData>(device);
|
||||
auto mockIsaAllocation = std::make_unique<MockGraphicsAllocation>(reinterpret_cast<void *>(0x543000), 10);
|
||||
mockIsaAllocation->setAllocationType(NEO::AllocationType::kernelIsa);
|
||||
kernelImmutableData->setIsaPerKernelAllocation(mockIsaAllocation.release());
|
||||
kernelImmutableData->initialize(&kernelInfo, device, 0, nullptr, nullptr, false);
|
||||
|
||||
std::unique_ptr<L0::ult::Module> mockModule = std::make_unique<L0::ult::Module>(device, nullptr, ModuleType::user);
|
||||
mockModule->kernelImmDatas.push_back(std::move(kernelImmutableData));
|
||||
|
||||
Mock<::L0::KernelImp> kernel;
|
||||
kernel.module = mockModule.get();
|
||||
ze_kernel_desc_t desc = {ZE_STRUCTURE_TYPE_KERNEL_DESC};
|
||||
desc.pKernelName = kernelInfo.kernelDescriptor.kernelMetadata.kernelName.c_str();
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, kernel.initialize(&desc));
|
||||
kernel.checkPassedArgumentValues = true;
|
||||
kernel.passedArgumentValues.resize(5);
|
||||
|
||||
void *argBuffer = reinterpret_cast<void *>(0xDEADF00);
|
||||
ze_image_handle_t argImage = reinterpret_cast<ze_image_handle_t>(0x1234F000);
|
||||
ze_sampler_handle_t argSampler = reinterpret_cast<ze_sampler_handle_t>(0x1235F000);
|
||||
uint8_t argImmediate[16]{};
|
||||
size_t argSlm = 0x60;
|
||||
|
||||
void *arguments[] = {&argBuffer, &argImage, &argSampler, &argImmediate, &argSlm};
|
||||
retVal = zeCommandListAppendLaunchKernelWithArguments(commandList->toHandle(), kernel.toHandle(), groupCounts, groupSizes, arguments, nullptr, nullptr, 0, nullptr);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, retVal);
|
||||
|
||||
EXPECT_EQ(sizeof(argBuffer), kernel.passedArgumentValues[0].size());
|
||||
EXPECT_EQ(0, memcmp(&argBuffer, kernel.passedArgumentValues[0].data(), sizeof(argBuffer)));
|
||||
|
||||
EXPECT_EQ(sizeof(argImage), kernel.passedArgumentValues[1].size());
|
||||
EXPECT_EQ(0, memcmp(&argImage, kernel.passedArgumentValues[1].data(), sizeof(argImage)));
|
||||
|
||||
EXPECT_EQ(sizeof(argSampler), kernel.passedArgumentValues[2].size());
|
||||
EXPECT_EQ(0, memcmp(&argSampler, kernel.passedArgumentValues[2].data(), sizeof(argSampler)));
|
||||
|
||||
EXPECT_EQ(sizeof(argImmediate), kernel.passedArgumentValues[3].size()); // manually reduced by mock
|
||||
EXPECT_EQ(0, memcmp(&argImmediate, kernel.passedArgumentValues[3].data(), sizeof(argImmediate)));
|
||||
|
||||
EXPECT_EQ(argSlm, kernel.passedArgumentValues[4].size());
|
||||
|
||||
EXPECT_EQ(groupSizes.groupSizeX, kernel.getGroupSize()[0]);
|
||||
EXPECT_EQ(groupSizes.groupSizeY, kernel.getGroupSize()[1]);
|
||||
EXPECT_EQ(groupSizes.groupSizeZ, kernel.getGroupSize()[2]);
|
||||
}
|
||||
|
||||
TEST_F(CommandListAppendLaunchKernelWithArgumentsTests, givenKernelWithoutArgumentsAndNullptrArgumentsPointerWhenAppendLaunchKernelWithArgumentsThenKernelIsAppendedWithoutError) {
|
||||
|
||||
const ze_group_count_t groupCounts{1, 2, 3};
|
||||
const ze_group_size_t groupSizes{4, 5, 6};
|
||||
|
||||
auto retVal = ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
|
||||
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::renderCompute, 0u, retVal, false));
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, retVal);
|
||||
|
||||
NEO::KernelInfo kernelInfo{};
|
||||
uint8_t kernelHeap[10]{};
|
||||
kernelInfo.heapInfo.pKernelHeap = kernelHeap;
|
||||
kernelInfo.heapInfo.kernelHeapSize = sizeof(kernelHeap);
|
||||
kernelInfo.kernelDescriptor.kernelMetadata.kernelName = "kernel";
|
||||
kernelInfo.kernelDescriptor.payloadMappings.explicitArgs.resize(0);
|
||||
|
||||
auto kernelImmutableData = std::make_unique<KernelImmutableData>(device);
|
||||
auto mockIsaAllocation = std::make_unique<MockGraphicsAllocation>(reinterpret_cast<void *>(0x543000), 10);
|
||||
mockIsaAllocation->setAllocationType(NEO::AllocationType::kernelIsa);
|
||||
kernelImmutableData->setIsaPerKernelAllocation(mockIsaAllocation.release());
|
||||
kernelImmutableData->initialize(&kernelInfo, device, 0, nullptr, nullptr, false);
|
||||
|
||||
std::unique_ptr<L0::ult::Module> mockModule = std::make_unique<L0::ult::Module>(device, nullptr, ModuleType::user);
|
||||
mockModule->kernelImmDatas.push_back(std::move(kernelImmutableData));
|
||||
|
||||
Mock<::L0::KernelImp> kernel;
|
||||
kernel.module = mockModule.get();
|
||||
ze_kernel_desc_t desc = {ZE_STRUCTURE_TYPE_KERNEL_DESC};
|
||||
desc.pKernelName = kernelInfo.kernelDescriptor.kernelMetadata.kernelName.c_str();
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, kernel.initialize(&desc));
|
||||
|
||||
retVal = zeCommandListAppendLaunchKernelWithArguments(commandList->toHandle(), kernel.toHandle(), groupCounts, groupSizes, nullptr, nullptr, nullptr, 0, nullptr);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, retVal);
|
||||
|
||||
EXPECT_EQ(groupSizes.groupSizeX, kernel.getGroupSize()[0]);
|
||||
EXPECT_EQ(groupSizes.groupSizeY, kernel.getGroupSize()[1]);
|
||||
EXPECT_EQ(groupSizes.groupSizeZ, kernel.getGroupSize()[2]);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
|
||||
@@ -1213,6 +1213,8 @@ TEST_F(DriverExperimentalApiTest, whenRetrievingApiFunctionThenExpectProperPoint
|
||||
decltype(&zerIdentifierTranslateToDeviceHandle) expectedZerIdentifierTranslateToDeviceHandle = zerIdentifierTranslateToDeviceHandle;
|
||||
decltype(&zeDeviceSynchronize) expectedZeDeviceSynchronize = zeDeviceSynchronize;
|
||||
|
||||
decltype(&zeCommandListAppendLaunchKernelWithArguments) expectedZeCommandListAppendLaunchKernelWithArguments = zeCommandListAppendLaunchKernelWithArguments;
|
||||
|
||||
decltype(&zexKernelGetBaseAddress) expectedKernelGetBaseAddress = L0::zexKernelGetBaseAddress;
|
||||
decltype(&zeIntelGetDriverVersionString) expectedIntelGetDriverVersionString = zeIntelGetDriverVersionString;
|
||||
decltype(&zeIntelMediaCommunicationCreate) expectedIntelMediaCommunicationCreate = L0::zeIntelMediaCommunicationCreate;
|
||||
@@ -1251,6 +1253,9 @@ TEST_F(DriverExperimentalApiTest, whenRetrievingApiFunctionThenExpectProperPoint
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetExtensionFunctionAddress(driverHandle, "zeDeviceSynchronize", &funPtr));
|
||||
EXPECT_EQ(expectedZeDeviceSynchronize, reinterpret_cast<decltype(&zeDeviceSynchronize)>(funPtr));
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetExtensionFunctionAddress(driverHandle, "zeCommandListAppendLaunchKernelWithArguments", &funPtr));
|
||||
EXPECT_EQ(expectedZeCommandListAppendLaunchKernelWithArguments, reinterpret_cast<decltype(&zeCommandListAppendLaunchKernelWithArguments)>(funPtr));
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetExtensionFunctionAddress(driverHandle, "zexKernelGetBaseAddress", &funPtr));
|
||||
EXPECT_EQ(expectedKernelGetBaseAddress, reinterpret_cast<decltype(&zexKernelGetBaseAddress)>(funPtr));
|
||||
|
||||
|
||||
@@ -332,6 +332,48 @@ ze_device_handle_t ZE_APICALL zerIdentifierTranslateToDeviceHandle(uint32_t iden
|
||||
/// - ::ZE_RESULT_ERROR_DEVICE_LOST
|
||||
ze_result_t ZE_APICALL zeDeviceSynchronize(ze_device_handle_t hDevice); ///> [in] handle of the device
|
||||
|
||||
/// @brief Append with arguments
|
||||
///
|
||||
/// @details
|
||||
/// - The application may call this function from simultaneous threads.
|
||||
/// - The implementation of this function should be lock-free.
|
||||
/// - Appends kernel to command list with arguments.
|
||||
/// - Kernel object state is updated with new arguments, as if separate zeKernelSetArgumentValue were called.
|
||||
/// - If argument is SLM (size), then SLM size in bytes for this resource is provided under pointer on specific index and its type is size_t.
|
||||
/// - If argument is an immediate type (i.e. structure, non pointer type), then values under pointer must contain full size of immediate type.
|
||||
///
|
||||
/// @returns
|
||||
/// - ::ZE_RESULT_SUCCESS
|
||||
/// - ::ZE_RESULT_ERROR_DEVICE_LOST
|
||||
/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY
|
||||
/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY
|
||||
/// - ::ZE_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION
|
||||
/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE
|
||||
/// + `nullptr == hCommandList`
|
||||
/// + `nullptr == hKernel`
|
||||
/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER
|
||||
/// + `nullptr == pArguments`
|
||||
/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT
|
||||
/// - ::ZE_RESULT_ERROR_INVALID_SIZE
|
||||
/// + `(nullptr == phWaitEvents) && (0 < numWaitEvents)`
|
||||
typedef struct _ze_group_size_t {
|
||||
uint32_t groupSizeX; ///< [in] local work-group size in X dimension
|
||||
uint32_t groupSizeY; ///< [in] local work-group size in Y dimension
|
||||
uint32_t groupSizeZ; ///< [in] local work-group size in Z dimension
|
||||
|
||||
} ze_group_size_t;
|
||||
|
||||
ze_result_t ZE_APICALL zeCommandListAppendLaunchKernelWithArguments(
|
||||
ze_command_list_handle_t hCommandList, ///< [in] handle of the command list
|
||||
ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object
|
||||
const ze_group_count_t groupCounts, ///< [in] thread group counts
|
||||
const ze_group_size_t groupSizes, ///< [in] thread group sizes
|
||||
void **pArguments, ///< [in] kernel arguments; pointer to list where each argument represents a pointer to the argument value on specific index
|
||||
void *pNext, ///< [in][optional] extensions
|
||||
ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion
|
||||
uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching
|
||||
ze_event_handle_t *phWaitEvents); ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait on before launching
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user