Skip to content

Commit

Permalink
Debug mask support to force uncached Gmm usage type
Browse files Browse the repository at this point in the history
Signed-off-by: Bartosz Dunajski <[email protected]>
  • Loading branch information
BartoszDunajski authored and Compute-Runtime-Automation committed May 18, 2022
1 parent 5f38555 commit 56a164f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
18 changes: 18 additions & 0 deletions opencl/test/unit_test/gmm_helper/gmm_helper_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int64_t>(AllocationType::BUFFER) - 1);
constexpr int64_t imageMask = 1 << (static_cast<int64_t>(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);
Expand Down
3 changes: 2 additions & 1 deletion opencl/test/unit_test/test_files/igdrcl.config
Original file line number Diff line number Diff line change
Expand Up @@ -422,4 +422,5 @@ DirectSubmissionInsertSfenceInstructionPriorToSubmission = -1
EnableTimestampWaitForEvents = -1
ForceWddmLowPriorityContextValue = -1
EnableDebuggerMmapMemoryAccess = 0
FailBuildProgramWithStatefulAccess = -1
FailBuildProgramWithStatefulAccess = -1
ForceUncachedGmmUsageType = 0
1 change: 1 addition & 0 deletions shared/source/debug_settings/debug_variables_base.inl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 6 additions & 0 deletions shared/source/gmm_helper/cache_settings_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int64_t>(allocationType) - 1)) & DebugManager.flags.ForceUncachedGmmUsageType.get()) {
forceUncached = true;
}
}

if (forceUncached || DebugManager.flags.ForceAllResourcesUncached.get()) {
return getDefaultUsageTypeWithCachingDisabled(allocationType);
} else {
Expand Down

0 comments on commit 56a164f

Please sign in to comment.