diff --git a/opencl/test/unit_test/memory_manager/memory_manager_allocate_in_preferred_pool_tests.inl b/opencl/test/unit_test/memory_manager/memory_manager_allocate_in_preferred_pool_tests.inl index d8b31993fd..a0f320ce31 100644 --- a/opencl/test/unit_test/memory_manager/memory_manager_allocate_in_preferred_pool_tests.inl +++ b/opencl/test/unit_test/memory_manager/memory_manager_allocate_in_preferred_pool_tests.inl @@ -134,32 +134,35 @@ TEST(MemoryManagerGetAlloctionDataTest, givenDebugModeWhenCertainAllocationTypes DebugManagerStateRestore restorer; auto allocationType = GraphicsAllocation::AllocationType::BUFFER; auto mask = 1llu << (static_cast(allocationType) - 1); - DebugManager.flags.ForceSystemMemoryPlacement.set(mask); AllocationData allocData; AllocationProperties properties(0, 0, allocationType); - MockMemoryManager mockMemoryManager; - MockMemoryManager::getAllocationData(allocData, properties, nullptr, mockMemoryManager.createStorageInfoFromProperties(properties)); + allocData.flags.useSystemMemory = false; + MockMemoryManager::overrideAllocationData(allocData, properties); EXPECT_TRUE(allocData.flags.useSystemMemory); + allocData.flags.useSystemMemory = false; allocationType = GraphicsAllocation::AllocationType::WRITE_COMBINED; mask |= 1llu << (static_cast(allocationType) - 1); DebugManager.flags.ForceSystemMemoryPlacement.set(mask); AllocationProperties properties2(0, 0, allocationType); - MockMemoryManager::getAllocationData(allocData, properties2, nullptr, mockMemoryManager.createStorageInfoFromProperties(properties2)); - - EXPECT_TRUE(allocData.flags.useSystemMemory); - allocData.flags.useSystemMemory = false; - - MockMemoryManager::getAllocationData(allocData, properties, nullptr, mockMemoryManager.createStorageInfoFromProperties(properties)); + MockMemoryManager::overrideAllocationData(allocData, properties2); EXPECT_TRUE(allocData.flags.useSystemMemory); allocData.flags.useSystemMemory = false; - DebugManager.flags.ForceSystemMemoryPlacement.set(8llu); - MockMemoryManager::getAllocationData(allocData, properties, nullptr, mockMemoryManager.createStorageInfoFromProperties(properties)); + + MockMemoryManager::overrideAllocationData(allocData, properties); + EXPECT_TRUE(allocData.flags.useSystemMemory); + + allocData.flags.useSystemMemory = false; + allocationType = GraphicsAllocation::AllocationType::IMAGE; + mask = 1llu << (static_cast(allocationType) - 1); + DebugManager.flags.ForceSystemMemoryPlacement.set(mask); + + MockMemoryManager::overrideAllocationData(allocData, properties); EXPECT_FALSE(allocData.flags.useSystemMemory); } @@ -865,6 +868,32 @@ TEST(MemoryManagerTest, givenDirectSemaphoreAddressingDefaultWhenNoOverrideThenE EXPECT_EQ(1u, allocationData.flags.resource48Bit); } +TEST(MemoryManagerTest, givenForceNonSystemMaskWhenAllocationTypeMatchesMaskThenExpectSystemFlagFalse) { + DebugManagerStateRestore restorer; + auto allocationType = GraphicsAllocation::AllocationType::BUFFER; + auto mask = 1llu << (static_cast(allocationType) - 1); + DebugManager.flags.ForceNonSystemMemoryPlacement.set(mask); + + AllocationData allocationData; + AllocationProperties properties(0, 0x1000, GraphicsAllocation::AllocationType::BUFFER); + allocationData.flags.useSystemMemory = 1; + MockMemoryManager::overrideAllocationData(allocationData, properties); + EXPECT_EQ(0u, allocationData.flags.useSystemMemory); +} + +TEST(MemoryManagerTest, givenForceNonSystemMaskWhenAllocationTypeNotMatchesMaskThenExpectSystemFlagTrue) { + DebugManagerStateRestore restorer; + auto allocationType = GraphicsAllocation::AllocationType::BUFFER; + auto mask = 1llu << (static_cast(allocationType) - 1); + DebugManager.flags.ForceNonSystemMemoryPlacement.set(mask); + + AllocationData allocationData; + AllocationProperties properties(0, 0x1000, GraphicsAllocation::AllocationType::COMMAND_BUFFER); + allocationData.flags.useSystemMemory = 1; + MockMemoryManager::overrideAllocationData(allocationData, properties); + EXPECT_EQ(1u, allocationData.flags.useSystemMemory); +} + using MemoryManagerGetAlloctionDataHaveToBeForcedTo48BitTest = testing::TestWithParam>; TEST_P(MemoryManagerGetAlloctionDataHaveToBeForcedTo48BitTest, givenAllocationTypesHaveToBeForcedTo48BitThenAllocationDataResource48BitIsSet) { diff --git a/opencl/test/unit_test/test_files/igdrcl.config b/opencl/test/unit_test/test_files/igdrcl.config index aa7151cfb8..3545a39ed7 100644 --- a/opencl/test/unit_test/test_files/igdrcl.config +++ b/opencl/test/unit_test/test_files/igdrcl.config @@ -139,6 +139,7 @@ EnableSharedSystemUsmSupport = -1 EnablePassInlineData = -1 ForceFineGrainedSVMSupport = -1 ForceSystemMemoryPlacement = 0 +ForceNonSystemMemoryPlacement = 0 ForceOCLVersion = 0 ForcePreemptionMode = -1 NodeOrdinal = -1 diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index 53bc4f5b71..b2d85fa115 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -161,6 +161,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, ForceFineGrainedSVMSupport, -1, "-1: default, 0: /*DRIVER TOGGLES*/ DECLARE_DEBUG_VARIABLE(int64_t, ForceSystemMemoryPlacement, 0, "0: default, >0: (bitmask) for given Graphics Allocation Type, force system memory placement") +DECLARE_DEBUG_VARIABLE(int64_t, ForceNonSystemMemoryPlacement, 0, "0: default, >0: (bitmask) for given Graphics Allocation Type, force non-system memory placement") DECLARE_DEBUG_VARIABLE(int32_t, ForceOCLVersion, 0, "Force specific OpenCL API version") DECLARE_DEBUG_VARIABLE(int32_t, ForcePreemptionMode, -1, "Keep this variable in sync with PreemptionMode enum. -1 - devices default mode, 1 - disable, 2 - midBatch, 3 - threadGroup, 4 - midThread") DECLARE_DEBUG_VARIABLE(int32_t, NodeOrdinal, -1, "-1: default do not override, 0: ENGINE_RCS") diff --git a/shared/source/memory_manager/memory_manager.cpp b/shared/source/memory_manager/memory_manager.cpp index c410136010..888da115ad 100644 --- a/shared/source/memory_manager/memory_manager.cpp +++ b/shared/source/memory_manager/memory_manager.cpp @@ -300,12 +300,6 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo break; } - if (DebugManager.flags.ForceSystemMemoryPlacement.get()) { - if ((1llu << (static_cast(properties.allocationType) - 1)) & DebugManager.flags.ForceSystemMemoryPlacement.get()) { - allocationData.flags.useSystemMemory = true; - } - } - if (properties.allocationType == GraphicsAllocation::AllocationType::COMMAND_BUFFER && properties.flags.multiOsContextCapable) { allocationData.flags.useSystemMemory = false; } @@ -598,6 +592,18 @@ bool MemoryManager::isCopyRequired(ImageInfo &imgInfo, const void *hostPtr) { } void MemoryManager::overrideAllocationData(AllocationData &allocationData, const AllocationProperties &properties) { + if (DebugManager.flags.ForceSystemMemoryPlacement.get()) { + if ((1llu << (static_cast(properties.allocationType) - 1)) & DebugManager.flags.ForceSystemMemoryPlacement.get()) { + allocationData.flags.useSystemMemory = true; + } + } + + if (DebugManager.flags.ForceNonSystemMemoryPlacement.get()) { + if ((1llu << (static_cast(properties.allocationType) - 1)) & DebugManager.flags.ForceNonSystemMemoryPlacement.get()) { + allocationData.flags.useSystemMemory = false; + } + } + int32_t directRingPlacement = DebugManager.flags.DirectSubmissionBufferPlacement.get(); int32_t directRingAddressing = DebugManager.flags.DirectSubmissionBufferAddressing.get(); if (properties.allocationType == GraphicsAllocation::AllocationType::RING_BUFFER) {