From bf1180753ddeac786adf67911fce3ba904a63133 Mon Sep 17 00:00:00 2001 From: Michal Mrozek Date: Fri, 20 Aug 2021 09:46:20 +0000 Subject: [PATCH] Improve private memory allocation. -allocate from single bank when only one sub device passed Signed-off-by: Michal Mrozek --- .../memory_manager/storage_info_tests.cpp | 22 ++++++++++--------- .../definitions/storage_info.cpp | 12 +++++++++- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/opencl/test/unit_test/memory_manager/storage_info_tests.cpp b/opencl/test/unit_test/memory_manager/storage_info_tests.cpp index 3683a4930b..0af2436509 100644 --- a/opencl/test/unit_test/memory_manager/storage_info_tests.cpp +++ b/opencl/test/unit_test/memory_manager/storage_info_tests.cpp @@ -108,22 +108,24 @@ TEST_F(MultiDeviceStorageInfoTest, givenDisabledFlagForMultiTileIsaPlacementWhen } } -TEST_F(MultiDeviceStorageInfoTest, whenCreatingStorageInfoForPrivateSurfaceThenAllMemoryBanksAreOnAndPageTableClonningIsNotRequired) { +TEST_F(MultiDeviceStorageInfoTest, whenCreatingStorageInfoForPrivateSurfaceWithOneTileThenOnlySingleBankIsUsed) { AllocationProperties properties{mockRootDeviceIndex, false, 0u, GraphicsAllocation::AllocationType::PRIVATE_SURFACE, false, false, singleTileMask}; auto storageInfo = memoryManager->createStorageInfoFromProperties(properties); EXPECT_FALSE(storageInfo.cloningOfPageTables); + EXPECT_EQ(singleTileMask, storageInfo.memoryBanks); + EXPECT_EQ(singleTileMask, storageInfo.pageTablesVisibility); + EXPECT_FALSE(storageInfo.tileInstanced); + EXPECT_EQ(1u, storageInfo.getNumBanks()); +} + +TEST_F(MultiDeviceStorageInfoTest, whenCreatingStorageInfoForPrivateSurfaceThenAllMemoryBanksAreOnAndPageTableClonningIsNotRequired) { + AllocationProperties properties{mockRootDeviceIndex, false, 0u, GraphicsAllocation::AllocationType::PRIVATE_SURFACE, false, false, allTilesMask}; + auto storageInfo = memoryManager->createStorageInfoFromProperties(properties); + EXPECT_FALSE(storageInfo.cloningOfPageTables); EXPECT_EQ(allTilesMask, storageInfo.memoryBanks); EXPECT_EQ(allTilesMask, storageInfo.pageTablesVisibility); EXPECT_TRUE(storageInfo.tileInstanced); - EXPECT_EQ(numDevices, storageInfo.getNumBanks()); - - properties.flags.multiOsContextCapable = true; - auto storageInfo2 = memoryManager->createStorageInfoFromProperties(properties); - EXPECT_FALSE(storageInfo2.cloningOfPageTables); - EXPECT_EQ(allTilesMask, storageInfo2.memoryBanks); - EXPECT_EQ(allTilesMask, storageInfo.pageTablesVisibility); - EXPECT_TRUE(storageInfo2.tileInstanced); - EXPECT_EQ(numDevices, storageInfo2.getNumBanks()); + EXPECT_EQ(4u, storageInfo.getNumBanks()); } TEST_F(MultiDeviceStorageInfoTest, givenMultiTileCsrWhenCreatingStorageInfoForInternalHeapThenSingleMemoryBankIsOnAndPageTableClonningIsRequired) { diff --git a/shared/source/memory_manager/definitions/storage_info.cpp b/shared/source/memory_manager/definitions/storage_info.cpp index 3b710ecc2b..d99ab0f515 100644 --- a/shared/source/memory_manager/definitions/storage_info.cpp +++ b/shared/source/memory_manager/definitions/storage_info.cpp @@ -66,12 +66,22 @@ StorageInfo MemoryManager::createStorageInfoFromProperties(const AllocationPrope } } break; case GraphicsAllocation::AllocationType::DEBUG_CONTEXT_SAVE_AREA: - case GraphicsAllocation::AllocationType::PRIVATE_SURFACE: case GraphicsAllocation::AllocationType::WORK_PARTITION_SURFACE: storageInfo.cloningOfPageTables = false; storageInfo.memoryBanks = allTilesValue; storageInfo.tileInstanced = true; break; + case GraphicsAllocation::AllocationType::PRIVATE_SURFACE: + storageInfo.cloningOfPageTables = false; + + if (properties.subDevicesBitfield.count() == 1) { + storageInfo.memoryBanks = preferredTile; + storageInfo.pageTablesVisibility = preferredTile; + } else { + storageInfo.memoryBanks = allTilesValue; + storageInfo.tileInstanced = true; + } + break; case GraphicsAllocation::AllocationType::COMMAND_BUFFER: case GraphicsAllocation::AllocationType::INTERNAL_HEAP: case GraphicsAllocation::AllocationType::LINEAR_STREAM: