From 7b5778c04806a65b59fc07f577ebbd878e5ceb1d Mon Sep 17 00:00:00 2001 From: Michal Mrozek Date: Mon, 6 Apr 2020 18:47:34 +0200 Subject: [PATCH] Add debug flag to force system memory placement. -remove not needed Report64BitIdentifier Signed-off-by: Michal Mrozek Change-Id: Ic6ae96e2a575a088742f3b08eb40c5b400f93088 --- ...nager_allocate_in_preferred_pool_tests.inl | 33 +++++++++++++++++++ .../debug_settings/debug_settings_manager.cpp | 4 --- .../debug_settings/debug_variables_base.inl | 2 +- .../source/memory_manager/memory_manager.cpp | 6 ++++ .../debug_settings_manager_tests.cpp | 11 ------- 5 files changed, 40 insertions(+), 16 deletions(-) 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 a1ac7554ec..bd088e857a 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 @@ -127,6 +127,39 @@ TEST(MemoryManagerGetAlloctionDataTest, givenDebugModeToForceBuffersToSystemMemo EXPECT_FALSE(allocData.flags.useSystemMemory); } +TEST(MemoryManagerGetAlloctionDataTest, givenDebugModeWhenCertainAllocationTypesAreSelectedThenSystemPlacementIsChoosen) { + DebugManagerStateRestore restorer; + auto allocationType = GraphicsAllocation::AllocationType::BUFFER; + auto mask = 1llu << (static_cast(allocationType) - 1); + + DebugManager.flags.ForceSystemMemoryPlacement.set(mask); + + AllocationData allocData; + AllocationProperties properties(0, true, 0, allocationType, false); + MockMemoryManager mockMemoryManager; + MockMemoryManager::getAllocationData(allocData, properties, nullptr, mockMemoryManager.createStorageInfoFromProperties(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, true, 0, allocationType, false); + 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)); + EXPECT_TRUE(allocData.flags.useSystemMemory); + + allocData.flags.useSystemMemory = false; + DebugManager.flags.ForceSystemMemoryPlacement.set(8llu); + MockMemoryManager::getAllocationData(allocData, properties, nullptr, mockMemoryManager.createStorageInfoFromProperties(properties)); + EXPECT_FALSE(allocData.flags.useSystemMemory); +} + typedef MemoryManagerGetAlloctionDataTest MemoryManagerGetAlloctionData32BitAnd64kbPagesAllowedTest; TEST_P(MemoryManagerGetAlloctionData32BitAnd64kbPagesAllowedTest, givenAllocationTypesWith32BitAnd64kbPagesAllowedWhenAllocationDataIsQueriedThenProperFlagsAreSet) { diff --git a/shared/source/debug_settings/debug_settings_manager.cpp b/shared/source/debug_settings/debug_settings_manager.cpp index 4d3cd8c8c9..3bf62568f9 100644 --- a/shared/source/debug_settings/debug_settings_manager.cpp +++ b/shared/source/debug_settings/debug_settings_manager.cpp @@ -60,10 +60,6 @@ void DebugSettingsManager::dumpNonDefaultFlag(const char *variableNa template void DebugSettingsManager::dumpFlags() const { - if (flags.Report64BitIdentifier.get()) { - std::cout << "Report64BitIdentifier flag value = " << flags.Report64BitIdentifier.get() << std::endl; - } - if (flags.PrintDebugSettings.get() == false) { return; } diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index 5bb3973db1..101cb33409 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -151,9 +151,9 @@ DECLARE_DEBUG_VARIABLE(int32_t, RenderCompressedBuffersEnabled, -1, "-1: default DECLARE_DEBUG_VARIABLE(int32_t, EnableSharedSystemUsmSupport, -1, "-1: default, 0: shared system memory disabled, 1: shared system memory enabled") DECLARE_DEBUG_VARIABLE(int32_t, EnablePassInlineData, -1, "-1: default, 0: Do not allow to pass inline data 1: Enable passing of inline data") DECLARE_DEBUG_VARIABLE(int32_t, ForceFineGrainedSVMSupport, -1, "-1: default, 0: Do not report Fine Grained SVM capabilties 1: Report SVM Fine Grained capabilities if device supports SVM") -DECLARE_DEBUG_VARIABLE(int64_t, Report64BitIdentifier, 0, ">0: print this value during initialization to ensure that 64 bit debug variables are working properly.") /*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(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 3fdbb7cc6b..14cf248a73 100644 --- a/shared/source/memory_manager/memory_manager.cpp +++ b/shared/source/memory_manager/memory_manager.cpp @@ -305,6 +305,12 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo } } + if (DebugManager.flags.ForceSystemMemoryPlacement.get()) { + if ((1llu << (static_cast(properties.allocationType) - 1)) & DebugManager.flags.ForceSystemMemoryPlacement.get()) { + allocationData.flags.useSystemMemory = true; + } + } + switch (properties.allocationType) { case GraphicsAllocation::AllocationType::COMMAND_BUFFER: case GraphicsAllocation::AllocationType::DEVICE_QUEUE_BUFFER: diff --git a/shared/test/unit_test/debug_settings/debug_settings_manager_tests.cpp b/shared/test/unit_test/debug_settings/debug_settings_manager_tests.cpp index bccaf3b284..6baa534fe8 100644 --- a/shared/test/unit_test/debug_settings/debug_settings_manager_tests.cpp +++ b/shared/test/unit_test/debug_settings/debug_settings_manager_tests.cpp @@ -112,17 +112,6 @@ TEST(DebugSettingsManager, givenReaderImplInDebugManagerWhenSettingDifferentRead EXPECT_EQ(readerImpl2, debugManager.getReaderImpl()); } -TEST(DebugSettingsManager, givenReport64BitIdetntifierFlagWhenDumpFlagsThen64BitValueIsPrinted) { - testing::internal::CaptureStdout(); - FullyEnabledTestDebugManager debugManager; - debugManager.flags.Report64BitIdentifier.set(0xffffffffeeeeeeee); - - debugManager.dumpFlags(); - - std::string output = testing::internal::GetCapturedStdout(); - EXPECT_FALSE(output.compare("Report64BitIdentifier flag value = -286331154\n")); -} - TEST(DebugSettingsManager, givenPrintDebugSettingsEnabledWhenCallingDumpFlagsThenFlagsAreWrittenToDumpFile) { testing::internal::CaptureStdout(); FullyEnabledTestDebugManager debugManager;