diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index 8446a3dbdc..1743740f8e 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -396,6 +396,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, EnableCopyWithStagingBuffers, -1, "Enable copy w DECLARE_DEBUG_VARIABLE(int32_t, StagingBufferSize, -1, "Size of single staging buffer. -1: default (2MB), >0: size in KB") DECLARE_DEBUG_VARIABLE(int32_t, ForcePostSyncL1Flush, -1, "-1: default (do nothing), 0: L1 flush disabled in post sync, 1: L1 flush enabled in post sync") DECLARE_DEBUG_VARIABLE(int32_t, AllowNotZeroForCompressedOnWddm, -1, "-1: default (do nothing), 0: do not set AllowNotZeroed for compressed resources, 1: set AllowNotZeroed for compressed resources"); +DECLARE_DEBUG_VARIABLE(int64_t, ForceGmmSystemMemoryBufferForAllocations, 0, "0: default, >0: (bitmask) for given Allocation Types, force GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER gmm resource type"); /*DIRECT SUBMISSION FLAGS*/ DECLARE_DEBUG_VARIABLE(int32_t, EnableDirectSubmission, -1, "-1: default (disabled), 0: disable, 1:enable. Enables direct submission of command buffers bypassing KMD") diff --git a/shared/source/gmm_helper/cache_settings_helper.cpp b/shared/source/gmm_helper/cache_settings_helper.cpp index d073889baa..2675d713df 100644 --- a/shared/source/gmm_helper/cache_settings_helper.cpp +++ b/shared/source/gmm_helper/cache_settings_helper.cpp @@ -51,6 +51,13 @@ GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getDefaultUsageTypeWithCaching return getDefaultUsageTypeWithCachingDisabled(allocationType, productHelper); } + if (debugManager.flags.ForceGmmSystemMemoryBufferForAllocations.get()) { + UNRECOVERABLE_IF(allocationType == AllocationType::unknown); + if ((1llu << (static_cast(allocationType))) & debugManager.flags.ForceGmmSystemMemoryBufferForAllocations.get()) { + return GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER; + } + } + switch (allocationType) { case AllocationType::image: return GMM_RESOURCE_USAGE_OCL_IMAGE; diff --git a/shared/test/common/test_files/igdrcl.config b/shared/test/common/test_files/igdrcl.config index 2c18058bc6..9551b01772 100644 --- a/shared/test/common/test_files/igdrcl.config +++ b/shared/test/common/test_files/igdrcl.config @@ -619,4 +619,5 @@ OverrideNumHighPriorityContexts = -1 ForceScratchAndMTPBufferSizeMode = -1 ForcePostSyncL1Flush = -1 AllowNotZeroForCompressedOnWddm = -1 +ForceGmmSystemMemoryBufferForAllocations = 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 c0b067c4df..bc61bfa4b6 100644 --- a/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp +++ b/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp @@ -901,6 +901,31 @@ TEST(GmmTest, givenUncachedDebugFlagMaskSetWhenAskingForUsageTypeThenReturnUncac CacheSettingsHelper::getGmmUsageType(AllocationType::bufferHostMemory, false, productHelper)); } +TEST(GmmTest, givenFlagForceGmmSystemMemoryBufferForAllocationsWhenCallGetGmmUsageTypeThenReturnSystemMemoryBuffer) { + DebugManagerStateRestore restore; + + MockExecutionEnvironment mockExecutionEnvironment{}; + const auto &productHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper(); + + constexpr int64_t bufferMask = 1ll << static_cast(AllocationType::buffer); + constexpr int64_t globalFence = 1ll << static_cast(AllocationType::globalFence); + + auto defaultGmmUsageType = GMM_RESOURCE_USAGE_OCL_BUFFER; + + EXPECT_EQ(defaultGmmUsageType, + CacheSettingsHelper::getGmmUsageType(AllocationType::buffer, false, productHelper)); + EXPECT_EQ(defaultGmmUsageType, + CacheSettingsHelper::getGmmUsageType(AllocationType::globalFence, false, productHelper)); + + debugManager.flags.ForceGmmSystemMemoryBufferForAllocations.set(bufferMask | globalFence); + auto expectedGmmUsageTypeAfterForcingFlag = GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER; + + EXPECT_EQ(expectedGmmUsageTypeAfterForcingFlag, + CacheSettingsHelper::getGmmUsageType(AllocationType::buffer, false, productHelper)); + EXPECT_EQ(expectedGmmUsageTypeAfterForcingFlag, + CacheSettingsHelper::getGmmUsageType(AllocationType::globalFence, false, productHelper)); +} + TEST(GmmTest, givenAllocationForStatefulAccessWhenDebugFlagIsSetThenReturnUncachedType) { DebugManagerStateRestore restore; debugManager.flags.DisableCachingForStatefulBufferAccess.set(true);