From 595f374634a266ccdc6d6630440277704939c6e6 Mon Sep 17 00:00:00 2001 From: Bartosz Dunajski Date: Wed, 7 Oct 2020 13:39:45 +0200 Subject: [PATCH] Dont use blitter for local memory transfer if not available Change-Id: I5f43113498b59e3f1b8cb280c9feeccae8ff6140 Signed-off-by: Bartosz Dunajski --- opencl/source/program/kernel_info.cpp | 10 +++++----- opencl/test/unit_test/helpers/hw_helper_tests.cpp | 15 ++++++++++----- shared/source/helpers/hw_helper_base.inl | 2 +- .../program/program_initialization_tests.cpp | 1 + 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/opencl/source/program/kernel_info.cpp b/opencl/source/program/kernel_info.cpp index 3fb3793740..f9e715e7d6 100644 --- a/opencl/source/program/kernel_info.cpp +++ b/opencl/source/program/kernel_info.cpp @@ -433,14 +433,14 @@ 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)) { - auto status = BlitHelperFunctions::blitMemoryToAllocation(device, kernelAllocation, 0, heapInfo.pKernelHeap, {kernelIsaSize, 1, 1}); - if (status != BlitOperationResult::Unsupported) { - return status == BlitOperationResult::Success; - } + status = (BlitHelperFunctions::blitMemoryToAllocation(device, kernelAllocation, 0, heapInfo.pKernelHeap, {kernelIsaSize, 1, 1}) == BlitOperationResult::Success); + } else { + status = device.getMemoryManager()->copyMemoryToAllocation(kernelAllocation, heapInfo.pKernelHeap, kernelIsaSize); } - return device.getMemoryManager()->copyMemoryToAllocation(kernelAllocation, heapInfo.pKernelHeap, kernelIsaSize); + return status; } void KernelInfo::apply(const DeviceInfoKernelPayloadConstants &constants) { diff --git a/opencl/test/unit_test/helpers/hw_helper_tests.cpp b/opencl/test/unit_test/helpers/hw_helper_tests.cpp index 88f0e52d13..7b1f7dd18a 100644 --- a/opencl/test/unit_test/helpers/hw_helper_tests.cpp +++ b/opencl/test/unit_test/helpers/hw_helper_tests.cpp @@ -905,16 +905,21 @@ HWTEST_F(HwHelperTest, givenDefaultHwHelperHwWhenMinimalSIMDSizeIsQueriedThen8Is HWTEST_F(HwHelperTest, whenGettingIsBlitCopyRequiredForLocalMemoryThenCorrectValuesAreReturned) { DebugManagerStateRestore restore{}; auto &helper = HwHelper::get(renderCoreFamily); + HardwareInfo hwInfo = *defaultHwInfo; + hwInfo.capabilityTable.blitterOperationsSupported = true; - auto expectedDefaultValue = (helper.getLocalMemoryAccessMode(*defaultHwInfo) == LocalMemoryAccessMode::CpuAccessDisallowed); - EXPECT_EQ(expectedDefaultValue, helper.isBlitCopyRequiredForLocalMemory(*defaultHwInfo)); + auto expectedDefaultValue = (helper.getLocalMemoryAccessMode(hwInfo) == LocalMemoryAccessMode::CpuAccessDisallowed); + EXPECT_EQ(expectedDefaultValue, helper.isBlitCopyRequiredForLocalMemory(hwInfo)); DebugManager.flags.ForceLocalMemoryAccessMode.set(0); - EXPECT_FALSE(helper.isBlitCopyRequiredForLocalMemory(*defaultHwInfo)); + EXPECT_FALSE(helper.isBlitCopyRequiredForLocalMemory(hwInfo)); DebugManager.flags.ForceLocalMemoryAccessMode.set(1); - EXPECT_FALSE(helper.isBlitCopyRequiredForLocalMemory(*defaultHwInfo)); + EXPECT_FALSE(helper.isBlitCopyRequiredForLocalMemory(hwInfo)); + DebugManager.flags.ForceLocalMemoryAccessMode.set(3); - EXPECT_TRUE(helper.isBlitCopyRequiredForLocalMemory(*defaultHwInfo)); + EXPECT_TRUE(helper.isBlitCopyRequiredForLocalMemory(hwInfo)); + hwInfo.capabilityTable.blitterOperationsSupported = false; + EXPECT_FALSE(helper.isBlitCopyRequiredForLocalMemory(hwInfo)); } HWTEST_F(HwHelperTest, whenPatchingGlobalBuffersThenDontForceBlitter) { diff --git a/shared/source/helpers/hw_helper_base.inl b/shared/source/helpers/hw_helper_base.inl index f23e87fc9c..d95e7a63bd 100644 --- a/shared/source/helpers/hw_helper_base.inl +++ b/shared/source/helpers/hw_helper_base.inl @@ -422,7 +422,7 @@ inline bool HwHelperHw::allowRenderCompression(const HardwareInfo &hw template inline bool HwHelperHw::isBlitCopyRequiredForLocalMemory(const HardwareInfo &hwInfo) const { HwHelper &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily); - return (hwHelper.getLocalMemoryAccessMode(hwInfo) == LocalMemoryAccessMode::CpuAccessDisallowed); + return (hwHelper.getLocalMemoryAccessMode(hwInfo) == LocalMemoryAccessMode::CpuAccessDisallowed) && hwInfo.capabilityTable.blitterOperationsSupported; } template diff --git a/shared/test/unit_test/program/program_initialization_tests.cpp b/shared/test/unit_test/program/program_initialization_tests.cpp index 7d29f6548c..1f738b3182 100644 --- a/shared/test/unit_test/program/program_initialization_tests.cpp +++ b/shared/test/unit_test/program/program_initialization_tests.cpp @@ -235,6 +235,7 @@ TEST(AllocateGlobalSurfaceTest, GivenAllocationInLocalMemoryWhichRequiresBlitter for (auto isLocalMemorySupported : ::testing::Bool()) { DebugManager.flags.EnableLocalMemory.set(isLocalMemorySupported); MockDevice device; + device.getExecutionEnvironment()->rootDeviceEnvironments[0]->getMutableHardwareInfo()->capabilityTable.blitterOperationsSupported = true; MockSVMAllocsManager svmAllocsManager(device.getMemoryManager()); auto pAllocation = allocateGlobalsSurface(&svmAllocsManager, device, initData.size(), true /* constant */,