Refactor: Common helper for Blit and CPU memory transfers

Change-Id: Icc61f82517e75e3066e441494af3bf9a7ffbbeef
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2020-10-09 11:52:00 +02:00
committed by sys_ocldev
parent 33ce6910c5
commit 27f9a95af2
10 changed files with 51 additions and 53 deletions

View File

@ -433,14 +433,9 @@ bool KernelInfo::createKernelAllocation(const Device &device) {
auto &hwInfo = device.getHardwareInfo();
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
bool status = false;
if (kernelAllocation->isAllocatedInLocalMemoryPool() && hwHelper.isBlitCopyRequiredForLocalMemory(hwInfo)) {
status = (BlitHelperFunctions::blitMemoryToAllocation(device, kernelAllocation, 0, heapInfo.pKernelHeap, {kernelIsaSize, 1, 1}) == BlitOperationResult::Success);
} else {
status = device.getMemoryManager()->copyMemoryToAllocation(kernelAllocation, 0, heapInfo.pKernelHeap, kernelIsaSize);
}
return status;
return MemoryTransferHelper::transferMemoryToAllocation(hwHelper.isBlitCopyRequiredForLocalMemory(hwInfo, *kernelAllocation),
device, kernelAllocation, 0, heapInfo.pKernelHeap,
static_cast<size_t>(kernelIsaSize));
}
void KernelInfo::apply(const DeviceInfoKernelPayloadConstants &constants) {

View File

@ -51,12 +51,10 @@ void PrintfHandler::prepareDispatch(const MultiDispatchInfo &multiDispatchInfo)
auto &hwInfo = device.getHardwareInfo();
auto &helper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
if (printfSurface->isAllocatedInLocalMemoryPool() && helper.isBlitCopyRequiredForLocalMemory(hwInfo)) {
BlitHelperFunctions::blitMemoryToAllocation(device.getDevice(), printfSurface, 0,
&printfSurfaceInitialDataSize, {sizeof(printfSurfaceInitialDataSize), 1, 1});
} else {
*reinterpret_cast<uint32_t *>(printfSurface->getUnderlyingBuffer()) = printfSurfaceInitialDataSize;
}
MemoryTransferHelper::transferMemoryToAllocation(helper.isBlitCopyRequiredForLocalMemory(hwInfo, *printfSurface),
device.getDevice(), printfSurface, 0, &printfSurfaceInitialDataSize,
sizeof(printfSurfaceInitialDataSize));
auto printfPatchAddress = ptrOffset(reinterpret_cast<uintptr_t *>(kernel->getCrossThreadData()),
kernel->getKernelInfo().patchInfo.pAllocateStatelessPrintfSurface->DataParamOffset);

View File

@ -908,18 +908,26 @@ HWTEST_F(HwHelperTest, whenGettingIsBlitCopyRequiredForLocalMemoryThenCorrectVal
HardwareInfo hwInfo = *defaultHwInfo;
hwInfo.capabilityTable.blitterOperationsSupported = true;
MockGraphicsAllocation graphicsAllocation;
graphicsAllocation.overrideMemoryPool(MemoryPool::LocalMemory);
auto expectedDefaultValue = (helper.getLocalMemoryAccessMode(hwInfo) == LocalMemoryAccessMode::CpuAccessDisallowed);
EXPECT_EQ(expectedDefaultValue, helper.isBlitCopyRequiredForLocalMemory(hwInfo));
EXPECT_EQ(expectedDefaultValue, helper.isBlitCopyRequiredForLocalMemory(hwInfo, graphicsAllocation));
DebugManager.flags.ForceLocalMemoryAccessMode.set(0);
EXPECT_FALSE(helper.isBlitCopyRequiredForLocalMemory(hwInfo));
EXPECT_FALSE(helper.isBlitCopyRequiredForLocalMemory(hwInfo, graphicsAllocation));
DebugManager.flags.ForceLocalMemoryAccessMode.set(1);
EXPECT_FALSE(helper.isBlitCopyRequiredForLocalMemory(hwInfo));
EXPECT_FALSE(helper.isBlitCopyRequiredForLocalMemory(hwInfo, graphicsAllocation));
DebugManager.flags.ForceLocalMemoryAccessMode.set(3);
EXPECT_TRUE(helper.isBlitCopyRequiredForLocalMemory(hwInfo));
EXPECT_TRUE(helper.isBlitCopyRequiredForLocalMemory(hwInfo, graphicsAllocation));
hwInfo.capabilityTable.blitterOperationsSupported = false;
EXPECT_FALSE(helper.isBlitCopyRequiredForLocalMemory(hwInfo));
EXPECT_FALSE(helper.isBlitCopyRequiredForLocalMemory(hwInfo, graphicsAllocation));
graphicsAllocation.overrideMemoryPool(MemoryPool::System64KBPages);
EXPECT_FALSE(helper.isBlitCopyRequiredForLocalMemory(hwInfo, graphicsAllocation));
hwInfo.capabilityTable.blitterOperationsSupported = true;
EXPECT_FALSE(helper.isBlitCopyRequiredForLocalMemory(hwInfo, graphicsAllocation));
}
HWTEST_F(HwHelperTest, whenPatchingGlobalBuffersThenDontForceBlitter) {
@ -954,7 +962,10 @@ HWTEST_F(HwHelperTest, givenVariousDebugKeyValuesWhenGettingLocalMemoryAccessMod
HWTEST2_F(HwHelperTest, givenDefaultHwHelperHwWhenGettingIsBlitCopyRequiredForLocalMemoryThenFalseIsReturned, IsAtMostGen11) {
auto &helper = HwHelper::get(renderCoreFamily);
EXPECT_FALSE(helper.isBlitCopyRequiredForLocalMemory(*defaultHwInfo));
MockGraphicsAllocation graphicsAllocation;
graphicsAllocation.overrideMemoryPool(MemoryPool::LocalMemory);
EXPECT_FALSE(helper.isBlitCopyRequiredForLocalMemory(*defaultHwInfo, graphicsAllocation));
}
HWCMDTEST_F(IGFX_GEN8_CORE, HwHelperTest, WhenIsFusedEuDispatchEnabledIsCalledThenFalseIsReturned) {