From 56a164ffcdaca9ba2fd950e85d4961b7bcc20d44 Mon Sep 17 00:00:00 2001 From: Bartosz Dunajski Date: Wed, 18 May 2022 11:22:39 +0000 Subject: [PATCH] Debug mask support to force uncached Gmm usage type Signed-off-by: Bartosz Dunajski --- .../unit_test/gmm_helper/gmm_helper_tests.cpp | 18 ++++++++++++++++++ opencl/test/unit_test/test_files/igdrcl.config | 3 ++- .../debug_settings/debug_variables_base.inl | 1 + .../gmm_helper/cache_settings_helper.cpp | 6 ++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/opencl/test/unit_test/gmm_helper/gmm_helper_tests.cpp b/opencl/test/unit_test/gmm_helper/gmm_helper_tests.cpp index 1a23bbfaf28c6..1d899c23103db 100644 --- a/opencl/test/unit_test/gmm_helper/gmm_helper_tests.cpp +++ b/opencl/test/unit_test/gmm_helper/gmm_helper_tests.cpp @@ -939,6 +939,24 @@ TEST(GmmTest, givenConstSurfaceWhenDebugFlagIsSetThenReturnUncachedType) { CacheSettingsHelper::getGmmUsageType(AllocationType::CONSTANT_SURFACE, false, *defaultHwInfo)); } +TEST(GmmTest, givenUncachedDebugFlagMaskSetWhenAskingForUsageTypeThenReturnUncached) { + DebugManagerStateRestore restore; + + constexpr int64_t bufferMask = 1 << (static_cast(AllocationType::BUFFER) - 1); + constexpr int64_t imageMask = 1 << (static_cast(AllocationType::IMAGE) - 1); + + DebugManager.flags.ForceUncachedGmmUsageType.set(bufferMask | imageMask); + + EXPECT_EQ(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED, + CacheSettingsHelper::getGmmUsageType(AllocationType::BUFFER, false, *defaultHwInfo)); + + EXPECT_EQ(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED, + CacheSettingsHelper::getGmmUsageType(AllocationType::IMAGE, false, *defaultHwInfo)); + + EXPECT_NE(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED, + CacheSettingsHelper::getGmmUsageType(AllocationType::BUFFER_HOST_MEMORY, false, *defaultHwInfo)); +} + TEST(GmmTest, givenAllocationForStatefulAccessWhenDebugFlagIsSetThenReturnUncachedType) { DebugManagerStateRestore restore; DebugManager.flags.DisableCachingForStatefulBufferAccess.set(true); diff --git a/opencl/test/unit_test/test_files/igdrcl.config b/opencl/test/unit_test/test_files/igdrcl.config index 5b3dece9259a0..8c0c0825d2b50 100644 --- a/opencl/test/unit_test/test_files/igdrcl.config +++ b/opencl/test/unit_test/test_files/igdrcl.config @@ -422,4 +422,5 @@ DirectSubmissionInsertSfenceInstructionPriorToSubmission = -1 EnableTimestampWaitForEvents = -1 ForceWddmLowPriorityContextValue = -1 EnableDebuggerMmapMemoryAccess = 0 -FailBuildProgramWithStatefulAccess = -1 \ No newline at end of file +FailBuildProgramWithStatefulAccess = -1 +ForceUncachedGmmUsageType = 0 \ No newline at end of file diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index d842c047acf80..ddd0883009a7d 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -417,6 +417,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, ForceDefaultHeapSize, -1, "-1: no force (64kb), DECLARE_DEBUG_VARIABLE(int32_t, PreferCopyEngineForCopyBufferToBuffer, -1, "-1: default, 0: prefer EUs, 1: prefer blitter") 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(int64_t, ForceUncachedGmmUsageType, 0, "0: default, >0: (bitmask) for given Graphics Allocation Type, force uncached gmm resource type") DECLARE_DEBUG_VARIABLE(int64_t, DisableIndirectAccess, -1, "0: default, 0: Use indirect access settings provided by application, 1: Disable indirect access and ignore settings provided by application") DECLARE_DEBUG_VARIABLE(int32_t, UseVmBind, -1, "Use new residency model on Linux (requires kernel support), -1: default, 0: disabled, 1: enabled") DECLARE_DEBUG_VARIABLE(int32_t, PassBoundBOToExec, -1, "Pass bound BOs to exec call to keep dependencies") diff --git a/shared/source/gmm_helper/cache_settings_helper.cpp b/shared/source/gmm_helper/cache_settings_helper.cpp index 6266c864e64be..10be17acc08d0 100644 --- a/shared/source/gmm_helper/cache_settings_helper.cpp +++ b/shared/source/gmm_helper/cache_settings_helper.cpp @@ -15,6 +15,12 @@ namespace NEO { GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getGmmUsageType(AllocationType allocationType, bool forceUncached, const HardwareInfo &hwInfo) { + if (DebugManager.flags.ForceUncachedGmmUsageType.get()) { + if ((1llu << (static_cast(allocationType) - 1)) & DebugManager.flags.ForceUncachedGmmUsageType.get()) { + forceUncached = true; + } + } + if (forceUncached || DebugManager.flags.ForceAllResourcesUncached.get()) { return getDefaultUsageTypeWithCachingDisabled(allocationType); } else {