mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 07:14:10 +08:00
Patch printf buffer in implicit args in L0
Related-To: NEO-5081 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
c88db681d6
commit
e82c2e4653
@@ -856,6 +856,13 @@ ze_result_t KernelImp::initialize(const ze_kernel_desc_t *desc) {
|
||||
this->patchCrossthreadDataWithPrivateAllocation(this->privateMemoryGraphicsAllocation);
|
||||
this->residencyContainer.push_back(this->privateMemoryGraphicsAllocation);
|
||||
}
|
||||
if (kernelDescriptor.kernelAttributes.flags.requiresImplicitArgs) {
|
||||
pImplicitArgs = std::make_unique<NEO::ImplicitArgs>();
|
||||
*pImplicitArgs = {};
|
||||
pImplicitArgs->structSize = sizeof(NEO::ImplicitArgs);
|
||||
pImplicitArgs->structVersion = 0;
|
||||
pImplicitArgs->simdWidth = kernelDescriptor.kernelAttributes.simdSize;
|
||||
}
|
||||
|
||||
this->createPrintfBuffer();
|
||||
|
||||
@@ -872,24 +879,22 @@ ze_result_t KernelImp::initialize(const ze_kernel_desc_t *desc) {
|
||||
neoDevice->initializeRayTracing();
|
||||
this->residencyContainer.push_back(neoDevice->getRTMemoryBackedBuffer());
|
||||
}
|
||||
if (kernelDescriptor.kernelAttributes.flags.requiresImplicitArgs) {
|
||||
pImplicitArgs = std::make_unique<NEO::ImplicitArgs>();
|
||||
*pImplicitArgs = {};
|
||||
pImplicitArgs->structSize = sizeof(NEO::ImplicitArgs);
|
||||
pImplicitArgs->structVersion = 0;
|
||||
pImplicitArgs->simdWidth = kernelDescriptor.kernelAttributes.simdSize;
|
||||
}
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
void KernelImp::createPrintfBuffer() {
|
||||
if (this->kernelImmData->getDescriptor().kernelAttributes.flags.usesPrintf) {
|
||||
if (this->kernelImmData->getDescriptor().kernelAttributes.flags.usesPrintf || pImplicitArgs) {
|
||||
this->printfBuffer = PrintfHandler::createPrintfBuffer(this->module->getDevice());
|
||||
this->residencyContainer.push_back(printfBuffer);
|
||||
NEO::patchPointer(ArrayRef<uint8_t>(crossThreadData.get(), crossThreadDataSize),
|
||||
this->getImmutableData()->getDescriptor().payloadMappings.implicitArgs.printfSurfaceAddress,
|
||||
static_cast<uintptr_t>(this->printfBuffer->getGpuAddressToPatch()));
|
||||
if (this->kernelImmData->getDescriptor().kernelAttributes.flags.usesPrintf) {
|
||||
NEO::patchPointer(ArrayRef<uint8_t>(crossThreadData.get(), crossThreadDataSize),
|
||||
this->getImmutableData()->getDescriptor().payloadMappings.implicitArgs.printfSurfaceAddress,
|
||||
static_cast<uintptr_t>(this->printfBuffer->getGpuAddressToPatch()));
|
||||
}
|
||||
if (pImplicitArgs) {
|
||||
pImplicitArgs->printfBufferPtr = printfBuffer->getGpuAddress();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -725,6 +725,7 @@ HWTEST_F(CmdlistAppendLaunchKernelTests, givenKernelWithImplicitArgsWhenAppendLa
|
||||
expectedImplicitArgs.groupCountY = 2;
|
||||
expectedImplicitArgs.groupCountZ = 1;
|
||||
expectedImplicitArgs.localIdTablePtr = indirectHeap->getGraphicsAllocation()->getGpuAddress();
|
||||
expectedImplicitArgs.printfBufferPtr = kernel->getPrintfBufferAllocation()->getGpuAddress();
|
||||
|
||||
auto sizeForImplicitArgPatching = kernel->getSizeForImplicitArgsPatching();
|
||||
|
||||
|
||||
@@ -2041,11 +2041,10 @@ TEST_F(PrintfTest, WhenCreatingPrintfBufferThenCrossThreadDataIsPatched) {
|
||||
|
||||
using KernelImplicitArgTests = Test<ModuleImmutableDataFixture>;
|
||||
|
||||
TEST_F(KernelImplicitArgTests, givenImplicitArgsRequiredWhenCreatingKernelThenImplicitArgsAreCreated) {
|
||||
TEST_F(KernelImplicitArgTests, givenKernelWithImplicitArgsWhenInitializeThenPrintfSurfaceIsCreatedAndProperlyPatchedInImplicitArgs) {
|
||||
std::unique_ptr<MockImmutableData> mockKernelImmData = std::make_unique<MockImmutableData>(0u);
|
||||
|
||||
mockKernelImmData->kernelDescriptor->kernelAttributes.flags.requiresImplicitArgs = true;
|
||||
auto simd = mockKernelImmData->kernelDescriptor->kernelAttributes.simdSize;
|
||||
mockKernelImmData->kernelDescriptor->kernelAttributes.flags.usesPrintf = false;
|
||||
|
||||
createModuleFromBinary(0u, false, mockKernelImmData.get());
|
||||
|
||||
@@ -2058,9 +2057,31 @@ TEST_F(KernelImplicitArgTests, givenImplicitArgsRequiredWhenCreatingKernelThenIm
|
||||
auto pImplicitArgs = kernel->getImplicitArgs();
|
||||
ASSERT_NE(nullptr, pImplicitArgs);
|
||||
|
||||
ImplicitArgs expectedImplicitArgs{sizeof(ImplicitArgs)};
|
||||
expectedImplicitArgs.simdWidth = simd;
|
||||
EXPECT_EQ(0, memcmp(pImplicitArgs, &expectedImplicitArgs, sizeof(ImplicitArgs)));
|
||||
auto printfSurface = kernel->getPrintfBufferAllocation();
|
||||
ASSERT_NE(nullptr, printfSurface);
|
||||
|
||||
EXPECT_NE(0u, pImplicitArgs->printfBufferPtr);
|
||||
EXPECT_EQ(printfSurface->getGpuAddress(), pImplicitArgs->printfBufferPtr);
|
||||
}
|
||||
|
||||
TEST_F(KernelImplicitArgTests, givenImplicitArgsRequiredWhenCreatingKernelThenImplicitArgsAreCreated) {
|
||||
std::unique_ptr<MockImmutableData> mockKernelImmData = std::make_unique<MockImmutableData>(0u);
|
||||
|
||||
mockKernelImmData->kernelDescriptor->kernelAttributes.flags.requiresImplicitArgs = true;
|
||||
|
||||
createModuleFromBinary(0u, false, mockKernelImmData.get());
|
||||
|
||||
auto kernel = std::make_unique<MockKernel>(module.get());
|
||||
|
||||
ze_kernel_desc_t kernelDesc{ZE_STRUCTURE_TYPE_KERNEL_DESC};
|
||||
kernel->initialize(&kernelDesc);
|
||||
|
||||
EXPECT_TRUE(kernel->getKernelDescriptor().kernelAttributes.flags.requiresImplicitArgs);
|
||||
auto pImplicitArgs = kernel->getImplicitArgs();
|
||||
ASSERT_NE(nullptr, pImplicitArgs);
|
||||
|
||||
EXPECT_EQ(sizeof(ImplicitArgs), pImplicitArgs->structSize);
|
||||
EXPECT_EQ(0u, pImplicitArgs->structVersion);
|
||||
}
|
||||
|
||||
TEST_F(KernelImplicitArgTests, givenKernelWithImplicitArgsWhenSettingKernelParamsThenImplicitArgsAreUpdated) {
|
||||
@@ -2094,6 +2115,7 @@ TEST_F(KernelImplicitArgTests, givenKernelWithImplicitArgsWhenSettingKernelParam
|
||||
expectedImplicitArgs.groupCountX = 3;
|
||||
expectedImplicitArgs.groupCountY = 2;
|
||||
expectedImplicitArgs.groupCountZ = 1;
|
||||
expectedImplicitArgs.printfBufferPtr = kernel->getPrintfBufferAllocation()->getGpuAddress();
|
||||
|
||||
kernel->setGroupSize(4, 5, 6);
|
||||
kernel->setGroupCount(3, 2, 1);
|
||||
@@ -2128,5 +2150,6 @@ TEST_F(KernelImplicitArgTests, givenKernelWithoutImplicitArgsWhenPatchingImplici
|
||||
|
||||
EXPECT_EQ(0, memcmp(data, initData, 64));
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
|
||||
Reference in New Issue
Block a user