performance: align alloc size to 2MB on XeKMD/iGPU

Related-To: NEO-15905

Signed-off-by: Szymon Morek <szymon.morek@intel.com>
This commit is contained in:
Szymon Morek
2025-08-25 13:22:55 +00:00
committed by Compute-Runtime-Automation
parent b2ea1d98e6
commit 228da24b38
9 changed files with 101 additions and 3 deletions

View File

@@ -9211,4 +9211,49 @@ TEST_F(DrmMemoryManagerTest, givenMmapAlignmentLessOrEqual2MBWhenAllocatingGraph
EXPECT_NE(nullptr, allocation);
EXPECT_EQ(2 * MemoryConstants::megaByte, memoryManager->passedAlignment);
memoryManager->freeGraphicsMemory(allocation);
}
HWTEST_TEMPLATED_F(DrmMemoryManagerTest, given2MBAlignmentRequiredWhenUnalignedSizePassedToAllocateWithAlignmentThenSizeAlignedTo2MB) {
mock->ioctlExpected.gemUserptr = 1;
mock->ioctlExpected.gemWait = 1;
mock->ioctlExpected.gemClose = 1;
auto mockIoctlHelper = new MockIoctlHelper(*mock);
auto &drm = static_cast<DrmMockCustom &>(memoryManager->getDrm(mockRootDeviceIndex));
drm.ioctlHelper.reset(mockIoctlHelper);
AllocationData allocationData;
allocationData.size = 4 * MemoryConstants::megaByte + 1 * MemoryConstants::megaByte;
allocationData.alignment = MemoryConstants::pageSize64k;
allocationData.type = AllocationType::buffer;
allocationData.rootDeviceIndex = mockRootDeviceIndex;
mockIoctlHelper->is2MBSizeAlignmentRequiredResult = true;
auto allocation = memoryManager->allocateGraphicsMemoryWithAlignmentImpl(allocationData);
EXPECT_NE(nullptr, allocation);
EXPECT_EQ(2 * MemoryConstants::megaByte, memoryManager->passedAlignment);
EXPECT_EQ(6 * MemoryConstants::megaByte, allocation->getReservedAddressSize());
memoryManager->freeGraphicsMemory(allocation);
}
HWTEST_TEMPLATED_F(DrmMemoryManagerTest, given2MBAlignmentRequiredWhenUnalignedSizePassedToAllocateByKmdThenSizeAlignedTo2MB) {
mock->ioctlExpected.gemCreate = 1;
mock->ioctlExpected.gemWait = 1;
mock->ioctlExpected.gemClose = 1;
auto mockIoctlHelper = new MockIoctlHelper(*mock);
auto &drm = static_cast<DrmMockCustom &>(memoryManager->getDrm(mockRootDeviceIndex));
drm.ioctlHelper.reset(mockIoctlHelper);
AllocationData allocationData;
allocationData.size = 4 * MemoryConstants::megaByte + 1 * MemoryConstants::megaByte;
allocationData.alignment = MemoryConstants::pageSize64k;
allocationData.type = AllocationType::buffer;
allocationData.rootDeviceIndex = mockRootDeviceIndex;
mockIoctlHelper->is2MBSizeAlignmentRequiredResult = true;
auto allocation = memoryManager->allocateMemoryByKMD(allocationData);
EXPECT_NE(nullptr, allocation);
EXPECT_EQ(6 * MemoryConstants::megaByte, allocation->getReservedAddressSize());
memoryManager->freeGraphicsMemory(allocation);
}

View File

@@ -3093,3 +3093,28 @@ TEST_F(IoctlHelperXeTest, givenXeIoctlHelperWhenCallingOverrideMaxSlicesSupporte
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(drm);
EXPECT_FALSE(xeIoctlHelper->overrideMaxSlicesSupported());
}
TEST_F(IoctlHelperXeTest, givenXeIoctlHelperWhenCallingIs2MBSizeAlignmentRequiredThenProperValueReturned) {
DebugManagerStateRestore restorer{};
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto &rootDeviceEnvironment = *executionEnvironment->rootDeviceEnvironments[0];
rootDeviceEnvironment.osInterface = std::make_unique<OSInterface>();
rootDeviceEnvironment.osInterface->setDriverModel(std::make_unique<DrmMockTime>(mockFd, rootDeviceEnvironment));
auto drm = DrmMockXe::create(rootDeviceEnvironment);
auto xeIoctlHelper = static_cast<MockIoctlHelperXe *>(drm->getIoctlHelper());
xeIoctlHelper->initialize();
executionEnvironment->memoryManager.reset(new TestedDrmMemoryManager{*executionEnvironment});
auto hwInfo = drm->getRootDeviceEnvironment().getMutableHardwareInfo();
hwInfo->capabilityTable.isIntegratedDevice = true;
EXPECT_TRUE(xeIoctlHelper->is2MBSizeAlignmentRequired(AllocationType::buffer));
EXPECT_FALSE(xeIoctlHelper->is2MBSizeAlignmentRequired(AllocationType::linearStream));
hwInfo->capabilityTable.isIntegratedDevice = false;
EXPECT_FALSE(xeIoctlHelper->is2MBSizeAlignmentRequired(AllocationType::buffer));
EXPECT_FALSE(xeIoctlHelper->is2MBSizeAlignmentRequired(AllocationType::linearStream));
hwInfo->capabilityTable.isIntegratedDevice = true;
debugManager.flags.Disable2MBSizeAlignment.set(true);
EXPECT_FALSE(xeIoctlHelper->is2MBSizeAlignmentRequired(AllocationType::buffer));
}