fix: Add experimental debug toggle to force 2M local memory size alignment

Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
Filip Hazubski 2024-06-27 14:13:43 +00:00 committed by Compute-Runtime-Automation
parent 940f23ddbf
commit 6992cb8aeb
6 changed files with 57 additions and 0 deletions

View File

@ -551,6 +551,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, ExperimentalSmallBufferPoolAllocator, -1, "Exper
DECLARE_DEBUG_VARIABLE(int32_t, ExperimentalCopyThroughLockWaitlistSizeThreshold, -1, "If less than given value, driver will wait for Waitlist on host, instead of sending appendBarrier. If 0, always use barrier.")
DECLARE_DEBUG_VARIABLE(bool, ExperimentalEnableL0DebuggerForOpenCL, false, "Experimentally enable debugging OCL with L0 Debug API. When enabled - Level Zero debugging is disabled.")
DECLARE_DEBUG_VARIABLE(bool, ExperimentalEnableTileAttach, true, "Experimentally enable attaching to tiles (subdevices).")
DECLARE_DEBUG_VARIABLE(bool, ExperimentalAlignLocalMemorySizeTo2MB, false, "Experimentally align all local memory allocations size to 2MB.")
/*DRIVER TOGGLES*/
DECLARE_DEBUG_VARIABLE(bool, UseMaxSimdSizeToDeduceMaxWorkgroupSize, false, "With this flag on, max workgroup size is deduced using SIMD32 instead of SIMD8, this causes the max wkg size to be 4 times bigger")

View File

@ -1872,6 +1872,9 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryInDevicePool(const A
} else {
sizeAligned = alignUp(allocationData.size, MemoryConstants::pageSize64k);
}
if (debugManager.flags.ExperimentalAlignLocalMemorySizeTo2MB.get()) {
sizeAligned = alignUp(sizeAligned, MemoryConstants::pageSize2M);
}
gmm = this->makeGmmIfSingleHandle(allocationData, sizeAligned);
}

View File

@ -1389,6 +1389,11 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryInDevicePool(const
alignment = alignmentSelector.selectAlignment(allocationData.size).alignment;
sizeAligned = alignUp(allocationData.size, alignment);
if (debugManager.flags.ExperimentalAlignLocalMemorySizeTo2MB.get()) {
alignment = alignUp(alignment, MemoryConstants::pageSize2M);
sizeAligned = alignUp(sizeAligned, MemoryConstants::pageSize2M);
}
if (singleBankAllocation) {
auto &productHelper = rootDeviceEnvironment.getHelper<ProductHelper>();

View File

@ -502,6 +502,7 @@ ForceImagesSupport = -1
RemoveUserFenceInCmdlistResetAndDestroy = -1
ForceCsrLockInBcsEnqueueOnlyForGpgpuSubmission = -1
ExperimentalEnableTileAttach = 1
ExperimentalAlignLocalMemorySizeTo2MB = 0
DirectSubmissionDisablePrefetcher = -1
ForceDefaultGrfCompilationMode = 0
ForceLargeGrfCompilationMode = 0

View File

@ -6674,6 +6674,42 @@ TEST_F(DrmMemoryManagerLocalMemoryAlignmentTest, givenCustomAlignmentWhenAllocat
}
}
TEST_F(DrmMemoryManagerLocalMemoryAlignmentTest, givenForced2MBSizeAlignmentWhenAllocatingAllocationThenUseProperAlignment) {
debugManager.flags.ExperimentalAlignLocalMemorySizeTo2MB.set(true);
AllocationData allocationData;
allocationData.allFlags = 0;
allocationData.flags.allocateMemory = true;
allocationData.rootDeviceIndex = rootDeviceIndex;
allocationData.type = AllocationType::buffer;
allocationData.flags.resource48Bit = true;
MemoryManager::AllocationStatus allocationStatus;
{
allocationData.size = 1;
auto memoryManager = createMemoryManager();
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocationData, allocationStatus);
ASSERT_NE(nullptr, allocation);
EXPECT_EQ(MemoryManager::AllocationStatus::Success, allocationStatus);
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::heapStandard2MB));
EXPECT_EQ(2 * MemoryConstants::megaByte, allocation->getUnderlyingBufferSize());
EXPECT_EQ(2 * MemoryConstants::megaByte, allocation->getReservedAddressSize());
memoryManager->freeGraphicsMemory(allocation);
}
{
allocationData.size = 2 * MemoryConstants::megaByte + 1;
auto memoryManager = createMemoryManager();
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocationData, allocationStatus);
ASSERT_NE(nullptr, allocation);
EXPECT_EQ(MemoryManager::AllocationStatus::Success, allocationStatus);
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::heapStandard2MB));
EXPECT_EQ(4 * MemoryConstants::megaByte, allocation->getUnderlyingBufferSize());
EXPECT_EQ(4 * MemoryConstants::megaByte, allocation->getReservedAddressSize());
memoryManager->freeGraphicsMemory(allocation);
}
}
TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenNotSetUseSystemMemoryWhenGraphicsAllocationInDevicePoolIsAllocatedForBufferThenLocalMemoryAllocationIsReturnedFromStandard64KbHeap) {
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
AllocationData allocData;

View File

@ -1941,6 +1941,17 @@ TEST_F(WddmMemoryManagerSimpleTest, givenCustomAlignmentBiggerThan2MbAndAllocati
testAlignment(size, expectedAlignment);
}
TEST_F(WddmMemoryManagerSimpleTest, givenForced2MBSizeAlignmentWhenAllocationInDevicePoolIsCreatedThenUseProperAlignment) {
debugManager.flags.ExperimentalAlignLocalMemorySizeTo2MB.set(true);
uint32_t size = 1;
uint32_t expectedAlignment = MemoryConstants::pageSize2M;
testAlignment(size, expectedAlignment);
size = 1 + MemoryConstants::pageSize2M;
testAlignment(size, expectedAlignment);
}
TEST_F(WddmMemoryManagerSimpleTest, givenAllocationLessThen2MbWhenAllocationInDevicePoolIsCreatedThenUse64KbAlignment) {
const uint32_t expectedAlignment = MemoryConstants::pageSize64k;
const uint32_t size = 2 * MemoryConstants::megaByte - 1;