From 1e1d675606644702e4b4241f23e46e8cf63f2760 Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Fri, 15 Mar 2024 15:54:44 +0000 Subject: [PATCH] fix: disable passing FtrTile64Optimization to gmmlib add debug key to control if the value should be passed Related-To: NEO-10785 Signed-off-by: Mateusz Jablonski --- .../debug_settings/debug_variables_base.inl | 1 + .../client_context/gmm_client_context.cpp | 4 ++ shared/test/common/test_files/igdrcl.config | 1 + .../unit_test/gmm_helper/gmm_helper_tests.cpp | 29 +++++++++++ .../windows/os_interface_win_tests.cpp | 50 ++++++++++++++++++- 5 files changed, 84 insertions(+), 1 deletion(-) diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index bd221548e6..3bf8eab9c2 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -507,6 +507,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, SignalAllEventPackets, -1, "All packets of event DECLARE_DEBUG_VARIABLE(int32_t, EnableBcsSwControlWa, -1, "Enable BCS WA via BCSSWCONTROL MMIO. -1: default, 0: disabled, 1: if src in system mem, 2: if dst in system mem, 3: if src and dst in system mem, 4: always") DECLARE_DEBUG_VARIABLE(bool, EnableHostAllocationMemPolicy, false, "Enables Memory Policy for host allocation") DECLARE_DEBUG_VARIABLE(int32_t, OverrideHostAllocationMemPolicyMode, -1, "Override Memory Policy mode for host allocation -1: default (use the system configuration), 0: MPOL_DEFAULT, 1: MPOL_PREFERRED, 2: MPOL_BIND, 3: MPOL_INTERLEAVED, 4: MPOL_LOCAL, 5: MPOL_PREFERRED_MANY") +DECLARE_DEBUG_VARIABLE(int32_t, EnableFtrTile64Optimization, 0, "Control feature Tile64 Optimization flag passed to gmmlib. -1: pass as-is, 0: disable flag(default due to NEO-10623), 1: enable flag"); /* IMPLICIT SCALING */ DECLARE_DEBUG_VARIABLE(int32_t, EnableWalkerPartition, -1, "-1: default, 0: disable, 1: enable, Enables Walker Partitioning via WPARID.") diff --git a/shared/source/gmm_helper/client_context/gmm_client_context.cpp b/shared/source/gmm_helper/client_context/gmm_client_context.cpp index 583b1f7fd9..07804ba694 100644 --- a/shared/source/gmm_helper/client_context/gmm_client_context.cpp +++ b/shared/source/gmm_helper/client_context/gmm_client_context.cpp @@ -7,6 +7,7 @@ #include "shared/source/gmm_helper/client_context/gmm_client_context.h" +#include "shared/source/debug_settings/debug_settings_manager.h" #include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/gmm_helper/client_context/gmm_handle_allocator.h" #include "shared/source/gmm_helper/gmm_interface.h" @@ -37,6 +38,9 @@ GmmClientContext::GmmClientContext(const RootDeviceEnvironment &rootDeviceEnviro if (osInterface && osInterface->getDriverModel()) { osInterface->getDriverModel()->setGmmInputArgs(&inArgs); } + if (debugManager.flags.EnableFtrTile64Optimization.get() != -1) { + reinterpret_cast<_SKU_FEATURE_TABLE *>(inArgs.pSkuTable)->FtrTile64Optimization = debugManager.flags.EnableFtrTile64Optimization.get(); + } auto ret = GmmInterface::initialize(&inArgs, &outArgs); diff --git a/shared/test/common/test_files/igdrcl.config b/shared/test/common/test_files/igdrcl.config index d0e6fe4d60..988c717932 100644 --- a/shared/test/common/test_files/igdrcl.config +++ b/shared/test/common/test_files/igdrcl.config @@ -592,4 +592,5 @@ EnableWaitOnUserFenceAfterBindAndUnbind = -1 UseGemCreateExtInAllocateMemoryByKMD = -1 PrintMmapAndMunMapCalls = -1 UseLocalPreferredForCacheableBuffers = -1 +EnableFtrTile64Optimization = 0 # Please don't edit below this line diff --git a/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp b/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp index 9f43742329..956554ed85 100644 --- a/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp +++ b/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp @@ -941,6 +941,35 @@ TEST(GmmHelperTest, givenValidGmmFunctionsWhenCreateGmmHelperWithoutOsInterfaceT EXPECT_EQ(0, memcmp(&expectedWaTable, &passedWaTable, sizeof(WA_TABLE))); EXPECT_EQ(GMM_CLIENT::GMM_OCL_VISTA, passedInputArgs.ClientType); } +TEST(GmmHelperTest, givenEnableFtrTile64OptimizationDebugKeyWhenSetThenProperValueIsPassedToGmmlib) { + DebugManagerStateRestore restorer; + VariableBackup passedInputArgsBackup(&passedInputArgs); + VariableBackup passedFtrTableBackup(&passedFtrTable); + VariableBackup passedGtSystemInfoBackup(&passedGtSystemInfo); + VariableBackup passedWaTableBackup(&passedWaTable); + VariableBackup copyInputArgsBackup(©InputArgs, true); + + auto hwInfo = defaultHwInfo.get(); + { + MockExecutionEnvironment executionEnvironment{hwInfo}; + EXPECT_EQ(0u, passedFtrTable.FtrTile64Optimization); + } + { + debugManager.flags.EnableFtrTile64Optimization.set(-1); + MockExecutionEnvironment executionEnvironment{hwInfo}; + EXPECT_EQ(0u, passedFtrTable.FtrTile64Optimization); + } + { + debugManager.flags.EnableFtrTile64Optimization.set(0); + MockExecutionEnvironment executionEnvironment{hwInfo}; + EXPECT_EQ(0u, passedFtrTable.FtrTile64Optimization); + } + { + debugManager.flags.EnableFtrTile64Optimization.set(1); + MockExecutionEnvironment executionEnvironment{hwInfo}; + EXPECT_EQ(1u, passedFtrTable.FtrTile64Optimization); + } +} TEST(GmmHelperTest, givenGmmHelperAndL3CacheDisabledForDebugThenCorrectMOCSIsReturned) { decltype(GmmHelper::createGmmContextWrapperFunc) createGmmContextSave = GmmHelper::createGmmContextWrapperFunc; diff --git a/shared/test/unit_test/os_interface/windows/os_interface_win_tests.cpp b/shared/test/unit_test/os_interface/windows/os_interface_win_tests.cpp index cde2fe3679..dba05eb437 100644 --- a/shared/test/unit_test/os_interface/windows/os_interface_win_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/os_interface_win_tests.cpp @@ -11,6 +11,7 @@ #include "shared/source/gmm_helper/gmm_helper.h" #include "shared/source/os_interface/windows/os_context_win.h" #include "shared/source/os_interface/windows/sys_calls.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/engine_descriptor_helper.h" #include "shared/test/common/mocks/mock_execution_environment.h" #include "shared/test/common/os_interface/windows/wddm_fixture.h" @@ -99,4 +100,51 @@ TEST_F(OsInterfaceTest, whenOsInterfaceSetupGmmInputArgsThenArgsAreSet) { EXPECT_EQ(wddm->gfxFeatureTable.get(), passedInputArgs.pSkuTable); EXPECT_EQ(wddm->gfxWorkaroundTable.get(), passedInputArgs.pWaTable); EXPECT_EQ(&rootDeviceEnvironment.getHardwareInfo()->gtSystemInfo, passedInputArgs.pGtSysInfo); -} \ No newline at end of file +} + +TEST_F(OsInterfaceTest, givenEnableFtrTile64OptimizationDebugKeyWhenSetThenProperValueIsPassedToGmmlib) { + MockExecutionEnvironment executionEnvironment; + auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0]; + auto wddm = new WddmMock(rootDeviceEnvironment); + EXPECT_EQ(nullptr, rootDeviceEnvironment.osInterface.get()); + wddm->init(); + EXPECT_NE(nullptr, rootDeviceEnvironment.osInterface.get()); + + VariableBackup passedInputArgsBackup(&passedInputArgs); + VariableBackup passedFtrTableBackup(&passedFtrTable); + VariableBackup passedGtSystemInfoBackup(&passedGtSystemInfo); + VariableBackup passedWaTableBackup(&passedWaTable); + VariableBackup copyInputArgsBackup(©InputArgs, true); + DebugManagerStateRestore restorer; + { + wddm->gfxFeatureTable->FtrTile64Optimization = 1; + auto gmmHelper = std::make_unique(rootDeviceEnvironment); + EXPECT_EQ(0u, passedFtrTable.FtrTile64Optimization); + } + { + debugManager.flags.EnableFtrTile64Optimization.set(-1); + wddm->gfxFeatureTable->FtrTile64Optimization = 1; + auto gmmHelper = std::make_unique(rootDeviceEnvironment); + EXPECT_EQ(1u, passedFtrTable.FtrTile64Optimization); + } + { + debugManager.flags.EnableFtrTile64Optimization.set(-1); + wddm->gfxFeatureTable->FtrTile64Optimization = 0; + auto gmmHelper = std::make_unique(rootDeviceEnvironment); + EXPECT_EQ(0u, passedFtrTable.FtrTile64Optimization); + } + + { + debugManager.flags.EnableFtrTile64Optimization.set(0); + wddm->gfxFeatureTable->FtrTile64Optimization = 1; + auto gmmHelper = std::make_unique(rootDeviceEnvironment); + EXPECT_EQ(0u, passedFtrTable.FtrTile64Optimization); + } + + { + debugManager.flags.EnableFtrTile64Optimization.set(1); + wddm->gfxFeatureTable->FtrTile64Optimization = 0; + auto gmmHelper = std::make_unique(rootDeviceEnvironment); + EXPECT_EQ(1u, passedFtrTable.FtrTile64Optimization); + } +}