refactor: add debug flag to not set 2way coherency

Signed-off-by: Szymon Morek <szymon.morek@intel.com>
This commit is contained in:
Szymon Morek
2025-09-19 09:58:49 +00:00
committed by Compute-Runtime-Automation
parent d8177828ef
commit 4d64ec8aaa
5 changed files with 51 additions and 0 deletions

View File

@@ -89,6 +89,7 @@ DECLARE_DEBUG_VARIABLE(bool, AbortHostSyncOnNonHostVisibleEvent, false, "Aborts
DECLARE_DEBUG_VARIABLE(bool, IgnoreProductSpecificIoctlHelper, false, "When set then product specific ioctl helper is not created even if available, generic one is used")
DECLARE_DEBUG_VARIABLE(bool, EnableDdiHandlesExtension, true, "Enable L0 Driver Direct Device Interface (DDI) Handles Extension")
DECLARE_DEBUG_VARIABLE(bool, BlockingEventRelease, false, "Makes clReleaseEvent blocking")
DECLARE_DEBUG_VARIABLE(bool, Disable2WayCoherencyOverride, false, "Disable 2-way coherency override for misaligned user ptr allocations")
DECLARE_DEBUG_VARIABLE(std::string, ForceDeviceId, std::string("unk"), "Override device id in AUB/TBX mode")
DECLARE_DEBUG_VARIABLE(std::string, FilterDeviceId, std::string("unk"), "Device id filter, adapter matching device id will be opened; ignored when unk")
DECLARE_DEBUG_VARIABLE(std::string, FilterBdfPath, std::string("unk"), "Linux-only, BDF path filter, only matching paths will be opened; ignored when unk")

View File

@@ -125,6 +125,10 @@ GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getDefaultUsageTypeWithCaching
// Set 2-way coherency for allocations which are not aligned to cacheline
GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getGmmUsageTypeForUserPtr(bool isCacheFlushRequired, const void *userPtr, size_t size, const ProductHelper &productHelper) {
if (debugManager.flags.Disable2WayCoherencyOverride.get()) {
return GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER;
}
if (isCacheFlushRequired && !isL3Capable(userPtr, size) && productHelper.isMisalignedUserPtr2WayCoherent()) {
return GMM_RESOURCE_USAGE_HW_CONTEXT;
} else {

View File

@@ -50,6 +50,7 @@ AbortHostSyncOnNonHostVisibleEvent = 0
IgnoreProductSpecificIoctlHelper = 0
PrintMclData = 0
BlockingEventRelease = 0
Disable2WayCoherencyOverride = 0
ForceL1Caching = -1
UseKmdMigration = -1
CreateKmdMigratedSharedAllocationWithMultipleBOs = -1

View File

@@ -3986,6 +3986,28 @@ TEST_F(DrmMemoryManagerBasic, givenUnalignedHostPtrWithFlushL3RequiredWhenAlloca
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(DrmMemoryManagerBasic, givenUnalignedHostPtrWithFlushL3RequiredAndDebugFlagWhenAllocateGraphicsMemoryThenSetCorrectPatIndex) {
DebugManagerStateRestore restorer;
debugManager.flags.Disable2WayCoherencyOverride.set(true);
AllocationData allocationData;
std::unique_ptr<TestedDrmMemoryManager> memoryManager(new (std::nothrow) TestedDrmMemoryManager(false, false, false, executionEnvironment));
memoryManager->forceLimitedRangeAllocator(MemoryConstants::max48BitAddress);
allocationData.size = 13;
allocationData.hostPtr = reinterpret_cast<const void *>(0x5001);
allocationData.rootDeviceIndex = rootDeviceIndex;
allocationData.flags.flushL3 = true;
auto allocation = static_cast<DrmAllocation *>(memoryManager->allocateGraphicsMemoryForNonSvmHostPtr(allocationData));
EXPECT_NE(nullptr, allocation);
EXPECT_EQ(0x5001u, reinterpret_cast<uint64_t>(allocation->getUnderlyingBuffer()));
EXPECT_EQ(13u, allocation->getUnderlyingBufferSize());
EXPECT_EQ(1u, allocation->getAllocationOffset());
EXPECT_EQ(MockGmmClientContextBase::MockPatIndex::cached, allocation->getBO()->peekPatIndex());
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(DrmMemoryManagerBasic, givenUnalignedHostPtrWithFlushL3NotRequiredWhenAllocateGraphicsMemoryThenSetCorrectPatIndex) {
AllocationData allocationData;
std::unique_ptr<TestedDrmMemoryManager> memoryManager(new (std::nothrow) TestedDrmMemoryManager(false, false, false, executionEnvironment));

View File

@@ -1098,6 +1098,29 @@ TEST_F(WddmMemoryManagerSimpleTest, givenAllocateGraphicsMemoryForNonSvmHostPtrI
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(WddmMemoryManagerSimpleTest, givenDebugFlagSetWhenNotAlignedPtrIsPassedAndFlushL3RequiredThenSetCorrectGmmResource) {
DebugManagerStateRestore restorer;
debugManager.flags.Disable2WayCoherencyOverride.set(true);
memoryManager.reset(new MockWddmMemoryManager(false, false, executionEnvironment));
auto size = 13u;
auto hostPtr = reinterpret_cast<const void *>(0x10001);
AllocationData allocationData;
allocationData.size = size;
allocationData.hostPtr = hostPtr;
allocationData.flags.flushL3 = true;
auto allocation = memoryManager->allocateGraphicsMemoryForNonSvmHostPtr(allocationData);
EXPECT_NE(nullptr, allocation);
EXPECT_EQ(hostPtr, allocation->getUnderlyingBuffer());
EXPECT_EQ(size, allocation->getUnderlyingBufferSize());
EXPECT_EQ(1u, allocation->getAllocationOffset());
auto expectedUsage = GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER;
EXPECT_EQ(expectedUsage, allocation->getGmm(0)->resourceParams.Usage);
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(WddmMemoryManagerSimpleTest, givenAllocateGraphicsMemoryForNonSvmHostPtrIsCalledWhenNotAlignedPtrIsPassedAndFlushL3NotRequiredThenSetCorrectGmmResource) {
memoryManager.reset(new MockWddmMemoryManager(false, false, executionEnvironment));
auto size = 13u;