mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Create buffer object with multiple lmem regions for kmd-migrated buffers
This commit enables cross-tile kmd migration for buffers in local memory Related-To: NEO-6977 Signed-off-by: Milczarek, Slawomir <slawomir.milczarek@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
f2bbd63d37
commit
30071599df
@ -83,6 +83,15 @@ struct MockedMemoryInfo : public NEO::MemoryInfo {
|
||||
handle = 1u;
|
||||
return 0u;
|
||||
}
|
||||
uint32_t createGemExtWithMultipleRegions(Drm *drm, uint32_t memoryBanks, size_t allocSize, uint32_t &handle) override {
|
||||
if (allocSize == 0) {
|
||||
return EINVAL;
|
||||
}
|
||||
handle = 1u;
|
||||
banks = memoryBanks;
|
||||
return 0u;
|
||||
}
|
||||
uint32_t banks = 0;
|
||||
};
|
||||
|
||||
class DrmMemoryManagerFixtureWithoutQuietIoctlExpectation {
|
||||
|
@ -505,3 +505,44 @@ TEST(MemoryInfo, givenMemoryInfoWithRegionsAndPrivateBOSupportedAndIsPerContextV
|
||||
ASSERT_TRUE(createExt);
|
||||
EXPECT_EQ(std::nullopt, createExt->vmPrivateExt.vmId);
|
||||
}
|
||||
|
||||
TEST(MemoryInfo, givenMemoryInfoWithRegionsWhenCreatingGemExtWithMultipleRegionsThenReturnCorrectValues) {
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.EnableLocalMemory.set(1);
|
||||
|
||||
std::vector<MemoryRegion> regionInfo(5);
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[0].probedSize = 8 * GB;
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
regionInfo[1].probedSize = 16 * GB;
|
||||
regionInfo[2].region = {I915_MEMORY_CLASS_DEVICE, 1};
|
||||
regionInfo[2].probedSize = 16 * GB;
|
||||
regionInfo[3].region = {I915_MEMORY_CLASS_DEVICE, 2};
|
||||
regionInfo[3].probedSize = 16 * GB;
|
||||
regionInfo[4].region = {I915_MEMORY_CLASS_DEVICE, 3};
|
||||
regionInfo[4].probedSize = 16 * GB;
|
||||
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo);
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
auto drm = std::make_unique<DrmQueryMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
uint32_t handle = 0;
|
||||
uint32_t memoryRegions = 0b1011;
|
||||
auto ret = memoryInfo->createGemExtWithMultipleRegions(drm.get(), memoryRegions, 1024, handle);
|
||||
EXPECT_EQ(1u, handle);
|
||||
EXPECT_EQ(0u, ret);
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
|
||||
const auto &createExt = drm->context.receivedCreateGemExt;
|
||||
ASSERT_TRUE(createExt);
|
||||
ASSERT_EQ(3u, createExt->memoryRegions.size());
|
||||
EXPECT_EQ(I915_MEMORY_CLASS_DEVICE, createExt->memoryRegions[0].memoryClass);
|
||||
EXPECT_EQ(0u, createExt->memoryRegions[0].memoryInstance);
|
||||
EXPECT_EQ(I915_MEMORY_CLASS_DEVICE, createExt->memoryRegions[1].memoryClass);
|
||||
EXPECT_EQ(1u, createExt->memoryRegions[1].memoryInstance);
|
||||
EXPECT_EQ(I915_MEMORY_CLASS_DEVICE, createExt->memoryRegions[2].memoryClass);
|
||||
EXPECT_EQ(3u, createExt->memoryRegions[2].memoryInstance);
|
||||
EXPECT_EQ(1024u, drm->context.receivedCreateGemExt->size);
|
||||
}
|
||||
|
@ -4140,6 +4140,26 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenDrmMemor
|
||||
EXPECT_EQ(nullptr, bo);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenUseKmdMigrationForBuffersWhenGraphicsAllocationInDevicePoolIsAllocatedForBufferWithSeveralMemoryBanksThenCreateGemObjectWithMultipleRegions) {
|
||||
DebugManager.flags.UseKmdMigrationForBuffers.set(1);
|
||||
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
|
||||
AllocationData allocData;
|
||||
allocData.allFlags = 0;
|
||||
allocData.size = MemoryConstants::pageSize;
|
||||
allocData.type = AllocationType::BUFFER;
|
||||
allocData.rootDeviceIndex = rootDeviceIndex;
|
||||
allocData.storageInfo.memoryBanks = 0b11;
|
||||
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
EXPECT_EQ(MemoryManager::AllocationStatus::Success, status);
|
||||
|
||||
EXPECT_EQ(allocData.storageInfo.memoryBanks, static_cast<MockedMemoryInfo *>(mock->getMemoryInfo())->banks);
|
||||
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenUseSystemMemoryFlagWhenGraphicsAllocationInDevicePoolIsAllocatedThenNullptrIsReturned) {
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
|
||||
AllocationData allocData;
|
||||
|
Reference in New Issue
Block a user