Skip to content

Commit 215fbda

Browse files
fix: use gpuAddress when patching sync buffer
Related-To: NEO-11533 Related-To: HSD-18039788811 Signed-off-by: Fabian Zwoliński <[email protected]> Source: 6a50320
1 parent 1707226 commit 215fbda

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

level_zero/core/source/kernel/kernel_imp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ void KernelImp::patchSyncBuffer(NEO::GraphicsAllocation *gfxAllocation, size_t b
11821182
this->internalResidencyContainer.push_back(gfxAllocation);
11831183
NEO::patchPointer(ArrayRef<uint8_t>(crossThreadData.get(), crossThreadDataSize),
11841184
this->getImmutableData()->getDescriptor().payloadMappings.implicitArgs.syncBufferAddress,
1185-
static_cast<uintptr_t>(ptrOffset(gfxAllocation->getGpuAddressToPatch(), bufferOffset)));
1185+
static_cast<uintptr_t>(ptrOffset(gfxAllocation->getGpuAddress(), bufferOffset)));
11861186
}
11871187

11881188
void KernelImp::patchRegionGroupBarrier(NEO::GraphicsAllocation *gfxAllocation, size_t bufferOffset) {

level_zero/core/test/unit_tests/sources/kernel/test_kernel.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4169,5 +4169,37 @@ TEST_F(BindlessKernelTest, givenBindlessKernelWithInlineSamplersWhenPatchingSamp
41694169
EXPECT_EQ(patchValue2, crossThreadData[6]);
41704170
}
41714171

4172+
using KernelSyncBufferTest = Test<ModuleFixture>;
4173+
4174+
TEST_F(KernelSyncBufferTest, GivenSyncBufferArgWhenPatchingSyncBufferThenPtrIsCorrectlyPatchedInCrossThreadData) {
4175+
Mock<KernelImp> kernel;
4176+
neoDevice->incRefInternal();
4177+
4178+
Mock<Module> mockModule(device, nullptr);
4179+
kernel.module = &mockModule;
4180+
4181+
kernel.crossThreadData = std::make_unique<uint8_t[]>(64);
4182+
kernel.crossThreadDataSize = 64;
4183+
4184+
auto &syncBuffer = kernel.immutableData.kernelDescriptor->payloadMappings.implicitArgs.syncBufferAddress;
4185+
syncBuffer.stateless = 0x8;
4186+
syncBuffer.pointerSize = 8;
4187+
4188+
NEO::MockGraphicsAllocation alloc;
4189+
alloc.setGpuPtr(0xffff800300060000);
4190+
alloc.setGpuBaseAddress(0xffff800300000000);
4191+
alloc.allocationOffset = 0x0;
4192+
4193+
size_t bufferOffset = 0u;
4194+
4195+
kernel.patchSyncBuffer(&alloc, bufferOffset);
4196+
4197+
auto patchValue = *reinterpret_cast<uint64_t *>(ptrOffset(kernel.crossThreadData.get(), syncBuffer.stateless));
4198+
auto expectedPatchValue = ptrOffset(alloc.getGpuAddress(), bufferOffset);
4199+
EXPECT_EQ(expectedPatchValue, patchValue);
4200+
4201+
neoDevice->decRefInternal();
4202+
}
4203+
41724204
} // namespace ult
41734205
} // namespace L0

0 commit comments

Comments
 (0)