From 2166f7cbccc88c0678505ac1e78b23a759c5ca7c Mon Sep 17 00:00:00 2001 From: John Falkowski Date: Thu, 31 Aug 2023 06:14:14 +0000 Subject: [PATCH] fix: Disable 1-tile chunking dev mem Disable chunking for device memory allocation if only 1Tile Related-To: NEO-8098 Signed-off-by: John Falkowski --- .../os_interface/linux/drm_memory_manager.cpp | 6 +++-- .../linux/drm_memory_manager_tests.cpp | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/shared/source/os_interface/linux/drm_memory_manager.cpp b/shared/source/os_interface/linux/drm_memory_manager.cpp index 3eadb85c55..14dc64d55d 100644 --- a/shared/source/os_interface/linux/drm_memory_manager.cpp +++ b/shared/source/os_interface/linux/drm_memory_manager.cpp @@ -1881,9 +1881,11 @@ bool DrmMemoryManager::createDrmAllocation(Drm *drm, DrmAllocation *allocation, uint32_t numOfChunks = DebugManager.flags.NumberOfBOChunks.get(); size_t chunkingSize = boTotalChunkSize / numOfChunks; - // Dont chunk for sizes less than chunkThreshold + // Do not chunk for sizes less than chunkThreshold + // Do not chunk for single tile device memory if (boTotalChunkSize >= drm->getMinimalSizeForChunking() && - !(chunkingSize & (MemoryConstants::chunkThreshold - 1))) { + !(chunkingSize & (MemoryConstants::chunkThreshold - 1)) && + (allocation->storageInfo.subDeviceBitfield.count() > 1)) { handles = 1; allocation->resizeBufferObjects(handles); diff --git a/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp index 5cfef53146..3dce29b7c7 100644 --- a/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp @@ -5319,6 +5319,7 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, allocData.type = AllocationType::BUFFER; allocData.rootDeviceIndex = rootDeviceIndex; allocData.storageInfo.memoryBanks = 0b11; + allocData.storageInfo.subDeviceBitfield = 0b11; auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocData, status); EXPECT_NE(nullptr, allocation); @@ -5351,6 +5352,29 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, memoryManager->freeGraphicsMemory(allocation); } +TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, + givenDeviceMemoryAllocationWithChunkingModeSetToDeviceAndOnlyOneTileThenChunkingIsNotUsed) { + VariableBackup backupChunkingCallParent{&mock->getChunkingAvailableCall.callParent, false}; + VariableBackup backupChunkingReturnValue{&mock->getChunkingAvailableCall.returnValue, true}; + VariableBackup backupChunkingModeCallParent{&mock->getChunkingModeCall.callParent, false}; + VariableBackup backupChunkingModeReturnValue{&mock->getChunkingModeCall.returnValue, 0x2}; + + MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success; + AllocationData allocData; + allocData.allFlags = 0; + allocData.size = MemoryConstants::pageSize2M; + allocData.type = AllocationType::BUFFER; + allocData.rootDeviceIndex = rootDeviceIndex; + allocData.storageInfo.memoryBanks = 0b11; + allocData.storageInfo.subDeviceBitfield = 0b01; + + auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocData, status); + EXPECT_NE(nullptr, allocation); + EXPECT_FALSE(allocation->storageInfo.isChunked); + + memoryManager->freeGraphicsMemory(allocation); +} + TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenDeviceMemoryAllocationWithChunkingModeSetToDeviceThenChunkingIsUsed) { VariableBackup backupChunkingCallParent{&mock->getChunkingAvailableCall.callParent, false}; @@ -5365,6 +5389,7 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, allocData.type = AllocationType::BUFFER; allocData.rootDeviceIndex = rootDeviceIndex; allocData.storageInfo.memoryBanks = 0b11; + allocData.storageInfo.subDeviceBitfield = 0b11; auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocData, status); EXPECT_NE(nullptr, allocation); @@ -5460,6 +5485,7 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, allocData.type = AllocationType::BUFFER; allocData.rootDeviceIndex = rootDeviceIndex; allocData.storageInfo.memoryBanks = 0b11; + allocData.storageInfo.subDeviceBitfield = 0b11; static_cast(mock->getMemoryInfo())->failOnCreateGemExtWithMultipleRegions = true; auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocData, status);