Disable cross-tile kmd migration for usm allocations

Ensure KMD migrations for USM allocations to occur between smem and lmem only

Related-To: NEO-6969

Signed-off-by: Milczarek, Slawomir <slawomir.milczarek@intel.com>
This commit is contained in:
Milczarek, Slawomir
2022-05-16 08:29:09 +00:00
committed by Compute-Runtime-Automation
parent e32738ee4a
commit 9d31d36491
3 changed files with 81 additions and 1 deletions

View File

@@ -485,7 +485,7 @@ TEST_F(DrmMemoryManagerLocalMemoryPrelimTest, givenSetVmAdviseAtomicAttributeWhe
}
}
TEST_F(DrmMemoryManagerLocalMemoryPrelimTest, givenUseKmdMigrationAndUsmInitialPlacementSetWhenCreateSharedUnifiedMemoryAllocationWithDevicesThenKmdMigratedAllocationIsCreatedWithCorrectRegionsOrder) {
TEST_F(DrmMemoryManagerLocalMemoryPrelimTest, givenUseKmdMigrationAndUsmInitialPlacementSetWhenCreateSharedUnifiedMemoryAllocationThenKmdMigratedAllocationIsCreatedWithCorrectRegionsOrder) {
DebugManagerStateRestore restorer;
DebugManager.flags.UseKmdMigration.set(1);
DebugManager.flags.UsmInitialPlacement.set(1);
@@ -517,6 +517,49 @@ TEST_F(DrmMemoryManagerLocalMemoryPrelimTest, givenUseKmdMigrationAndUsmInitialP
auto allocation = unifiedMemoryManager.getSVMAlloc(ptr)->gpuAllocations.getDefaultGraphicsAllocation();
EXPECT_NE(allocation, nullptr);
const auto memRegions = mock->context.receivedCreateGemExt.value().memoryRegions;
EXPECT_EQ(memRegions.size(), 2u);
EXPECT_EQ(memRegions[0].memoryClass, I915_MEMORY_CLASS_DEVICE);
EXPECT_EQ(memRegions[0].memoryInstance, regionInfo[1].region.memoryInstance);
EXPECT_EQ(memRegions[1].memoryClass, I915_MEMORY_CLASS_SYSTEM);
EXPECT_EQ(memRegions[1].memoryInstance, 1u);
unifiedMemoryManager.freeSVMAlloc(ptr);
}
TEST_F(DrmMemoryManagerLocalMemoryPrelimTest, givenUseKmdMigrationAndUsmInitialPlacementSetWhenCreateSharedUnifiedMemoryAllocationWithMultiStoragePlacementThenKmdMigratedAllocationIsCreatedWithCorrectRegionsOrder) {
DebugManagerStateRestore restorer;
DebugManager.flags.UseKmdMigration.set(1);
DebugManager.flags.UsmInitialPlacement.set(1);
DebugManager.flags.OverrideMultiStoragePlacement.set(0xF);
RootDeviceIndicesContainer rootDeviceIndices = {mockRootDeviceIndex};
std::map<uint32_t, DeviceBitfield> deviceBitfields{{mockRootDeviceIndex, mockDeviceBitfield}};
std::vector<MemoryRegion> regionInfo(5);
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 1};
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, DrmMockHelper::getEngineOrMemoryInstanceValue(0, 0)};
regionInfo[2].region = {I915_MEMORY_CLASS_DEVICE, DrmMockHelper::getEngineOrMemoryInstanceValue(1, 0)};
regionInfo[3].region = {I915_MEMORY_CLASS_DEVICE, DrmMockHelper::getEngineOrMemoryInstanceValue(2, 0)};
regionInfo[4].region = {I915_MEMORY_CLASS_DEVICE, DrmMockHelper::getEngineOrMemoryInstanceValue(3, 0)};
auto hwInfo = mock->getRootDeviceEnvironment().getMutableHardwareInfo();
hwInfo->gtSystemInfo.MultiTileArchInfo.IsValid = 1;
hwInfo->gtSystemInfo.MultiTileArchInfo.TileCount = 4;
mock->memoryInfo.reset(new MemoryInfo(regionInfo));
mock->queryEngineInfo();
SVMAllocsManager unifiedMemoryManager(memoryManager, false);
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::SHARED_UNIFIED_MEMORY, rootDeviceIndices, deviceBitfields);
unifiedMemoryProperties.device = device.get();
auto ptr = unifiedMemoryManager.createSharedUnifiedMemoryAllocation(MemoryConstants::pageSize64k, unifiedMemoryProperties, nullptr);
EXPECT_NE(ptr, nullptr);
auto allocation = unifiedMemoryManager.getSVMAlloc(ptr)->gpuAllocations.getDefaultGraphicsAllocation();
EXPECT_NE(allocation, nullptr);
const auto memRegions = mock->context.receivedCreateGemExt.value().memoryRegions;
EXPECT_EQ(memRegions.size(), 5u);
EXPECT_EQ(memRegions[0].memoryClass, I915_MEMORY_CLASS_DEVICE);

View File

@@ -150,6 +150,12 @@ StorageInfo MemoryManager::createStorageInfoFromProperties(const AllocationPrope
}
case AllocationType::UNIFIED_SHARED_MEMORY:
storageInfo.memoryBanks = allTilesValue;
if (DebugManager.flags.UseKmdMigration.get() != -1) {
storageInfo.memoryBanks = preferredTile;
}
if (DebugManager.flags.OverrideMultiStoragePlacement.get() != -1) {
storageInfo.memoryBanks = DebugManager.flags.OverrideMultiStoragePlacement.get();
}
break;
default:
break;

View File

@@ -378,6 +378,37 @@ TEST_F(MultiDeviceStorageInfoTest, givenReadOnlyBufferToBeCopiedAcrossTilesWhenD
EXPECT_EQ(3u, storageInfo.getNumBanks());
}
TEST_F(MultiDeviceStorageInfoTest, givenUnifiedSharedMemoryWhenMultiStoragePlacementIsOverridenThenSpecifiedBanksAreUsed) {
DebugManagerStateRestore restorer;
auto proposedTiles = allTilesMask;
proposedTiles[0] = 0;
DebugManager.flags.OverrideMultiStoragePlacement.set(proposedTiles.to_ulong());
AllocationProperties properties{mockRootDeviceIndex, false, 512 * KB, AllocationType::UNIFIED_SHARED_MEMORY, true, allTilesMask};
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
EXPECT_EQ(proposedTiles, storageInfo.memoryBanks);
}
TEST_F(MultiDeviceStorageInfoTest, givenUnifiedSharedMemoryWhenKmdMigrationIsUsedThenPreferredTileIsUsed) {
DebugManagerStateRestore restorer;
DebugManager.flags.UseKmdMigration.set(1);
AllocationProperties properties{mockRootDeviceIndex, false, 512 * KB, AllocationType::UNIFIED_SHARED_MEMORY, true, allTilesMask};
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
DeviceBitfield preferredTile;
EXPECT_TRUE(properties.subDevicesBitfield.count() > 1);
const auto leastOccupiedBank = memoryManager->getLocalMemoryUsageBankSelector(properties.allocationType, properties.rootDeviceIndex)->getLeastOccupiedBank(properties.subDevicesBitfield);
UNRECOVERABLE_IF(!properties.subDevicesBitfield.test(leastOccupiedBank));
preferredTile.set(leastOccupiedBank);
EXPECT_EQ(preferredTile, storageInfo.memoryBanks);
}
TEST_F(MultiDeviceStorageInfoTest, givenLeastOccupiedBankAndOtherBitsEnabledInSubDeviceBitfieldWhenCreateStorageInfoThenTakeLeastOccupiedBankAsMemoryBank) {
AllocationProperties properties{mockRootDeviceIndex, false, 1u, AllocationType::UNKNOWN, false, singleTileMask};
auto leastOccupiedBank = memoryManager->getLocalMemoryUsageBankSelector(properties.allocationType, properties.rootDeviceIndex)->getLeastOccupiedBank(properties.subDevicesBitfield);