diff --git a/opencl/test/unit_test/context/context_tests.cpp b/opencl/test/unit_test/context/context_tests.cpp index 5a0e0598cb..2a4d209a42 100644 --- a/opencl/test/unit_test/context/context_tests.cpp +++ b/opencl/test/unit_test/context/context_tests.cpp @@ -557,7 +557,12 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, ContextCreateTests, givenLocalMemoryAllocationWhenB auto executionEnv = testedDevice->getExecutionEnvironment(); executionEnv->rootDeviceEnvironments[0]->getMutableHardwareInfo()->capabilityTable.blitterOperationsSupported = false; - EXPECT_EQ(BlitOperationResult::Unsupported, BlitHelper::blitMemoryToAllocation(buffer->getContext()->getDevice(0)->getDevice(), memory, buffer->getOffset(), hostMemory, {1, 1, 1})); + const auto &hwInfo = testedDevice->getHardwareInfo(); + auto isBlitterRequired = HwHelper::get(hwInfo.platform.eRenderCoreFamily).isBlitCopyRequiredForLocalMemory(hwInfo, *memory); + + auto expectedStatus = isBlitterRequired ? BlitOperationResult::Success : BlitOperationResult::Unsupported; + + EXPECT_EQ(expectedStatus, BlitHelper::blitMemoryToAllocation(buffer->getContext()->getDevice(0)->getDevice(), memory, buffer->getOffset(), hostMemory, {1, 1, 1})); executionEnv->rootDeviceEnvironments[0]->getMutableHardwareInfo()->capabilityTable.blitterOperationsSupported = true; EXPECT_EQ(BlitOperationResult::Success, BlitHelper::blitMemoryToAllocation(buffer->getContext()->getDevice(0)->getDevice(), memory, buffer->getOffset(), hostMemory, {1, 1, 1})); diff --git a/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp b/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp index 35be2f5d1b..84230b3687 100644 --- a/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp +++ b/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp @@ -3017,6 +3017,26 @@ TEST(MemoryTransferHelperTest, givenBlitOperationSupportedWhenBcsEngineNotAvaila EXPECT_EQ(BlitOperationResult::Unsupported, BlitHelperFunctions::blitMemoryToAllocation(*device, &graphicsAllocation, 0, srcData, {dataSize, 1, 1})); } +TEST(MemoryTransferHelperTest, givenBlitOperationSupportedDisabledWhenBlitMemoryToAllocationThenReturnUnsupported) { + DebugManagerStateRestore restorer; + constexpr uint32_t dataSize = 16; + uint8_t destData[dataSize] = {}; + uint8_t srcData[dataSize] = {}; + + MockGraphicsAllocation graphicsAllocation{destData, sizeof(destData)}; + graphicsAllocation.storageInfo.memoryBanks = 1; + graphicsAllocation.setAllocationType(GraphicsAllocation::AllocationType::BUFFER); + + auto hwInfo = *defaultHwInfo; + hwInfo.capabilityTable.blitterOperationsSupported = true; + hwInfo.featureTable.ftrBcsInfo = 1; + DebugManager.flags.EnableBlitterOperationsSupport.set(false); + + auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(&hwInfo)); + + EXPECT_EQ(BlitOperationResult::Unsupported, BlitHelperFunctions::blitMemoryToAllocation(*device, &graphicsAllocation, 0, srcData, {dataSize, 1, 1})); +} + TEST(MemoryManagerTest, givenMemoryManagerWithLocalMemoryWhenCreatingMultiGraphicsAllocationInSystemMemoryThenForceSystemMemoryPlacement) { MockExecutionEnvironment executionEnvironment(defaultHwInfo.get()); executionEnvironment.initGmm(); diff --git a/shared/source/helpers/blit_commands_helper.cpp b/shared/source/helpers/blit_commands_helper.cpp index a3c54e7187..ec4b9f1968 100644 --- a/shared/source/helpers/blit_commands_helper.cpp +++ b/shared/source/helpers/blit_commands_helper.cpp @@ -174,7 +174,11 @@ BlitOperationResult BlitHelper::blitMemoryToAllocation(const Device &device, Gra BlitOperationResult BlitHelper::blitMemoryToAllocationBanks(const Device &device, GraphicsAllocation *memory, size_t offset, const void *hostPtr, const Vec3 &size, DeviceBitfield memoryBanks) { const auto &hwInfo = device.getHardwareInfo(); - if (!hwInfo.capabilityTable.blitterOperationsSupported) { + auto isBlitterRequired = HwHelper::get(hwInfo.platform.eRenderCoreFamily).isBlitCopyRequiredForLocalMemory(hwInfo, *memory); + if (!hwInfo.capabilityTable.blitterOperationsSupported && !isBlitterRequired) { + return BlitOperationResult::Unsupported; + } + if (0 == DebugManager.flags.EnableBlitterOperationsSupport.get()) { return BlitOperationResult::Unsupported; } diff --git a/shared/source/memory_manager/memory_manager.cpp b/shared/source/memory_manager/memory_manager.cpp index 896eaf1f44..69ab681808 100644 --- a/shared/source/memory_manager/memory_manager.cpp +++ b/shared/source/memory_manager/memory_manager.cpp @@ -684,9 +684,6 @@ bool MemoryManager::copyMemoryToAllocation(GraphicsAllocation *graphicsAllocatio for (auto i = 0u; i < graphicsAllocation->storageInfo.getNumBanks(); ++i) { memcpy_s(ptrOffset(static_cast(graphicsAllocation->getUnderlyingBuffer()) + i * graphicsAllocation->getUnderlyingBufferSize(), destinationOffset), (graphicsAllocation->getUnderlyingBufferSize() - destinationOffset), memoryToCopy, sizeToCopy); - if (graphicsAllocation->getAllocationType() != GraphicsAllocation::AllocationType::DEBUG_CONTEXT_SAVE_AREA) { - break; - } } return true; }