Enable MemoryInfo for platforms without local mem

Query for memory regions on all platforms.
Fix createPaddedAllocation when input allocation
was made by KMD

Resolves: NEO-6472

Signed-off-by: Szymon Morek <szymon.morek@intel.com>
This commit is contained in:
Szymon Morek
2021-12-21 14:17:26 +00:00
committed by Compute-Runtime-Automation
parent 3599e7aeda
commit 962d98a2d8
5 changed files with 62 additions and 38 deletions

View File

@ -18,23 +18,6 @@
using namespace NEO;
TEST(MemoryInfo, givenNotSupportedLocalMemoryQueryingMemoryInfoThenMemoryInfoIsNotCreated) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableLocalMemory.set(0);
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
ASSERT_NE(nullptr, drm);
auto ret = drm->queryMemoryInfo();
auto memoryInfo = drm->getMemoryInfo();
EXPECT_EQ(0u, drm->ioctlCallsCount);
EXPECT_TRUE(ret);
EXPECT_EQ(nullptr, memoryInfo);
}
TEST(MemoryInfo, givenMemoryRegionQuerySupportedWhenQueryingMemoryInfoThenMemoryInfoIsCreatedWithRegions) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableLocalMemory.set(1);

View File

@ -865,17 +865,6 @@ TEST_F(DrmMemoryManagerTestImpl, givenDrmMemoryManagerWhenGetLocalMemorySizeIsCa
EXPECT_EQ(memoryInfo->getMemoryRegionSize(MemoryBanks::getBankForLocalMemory(0)), memoryManager.getLocalMemorySize(0u, 0xF));
}
TEST_F(DrmMemoryManagerTestImpl, givenLocalMemoryDisabledWhenQueryMemoryInfoThenReturnTrueAndDontCreateMemoryInfo) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableLocalMemory.set(0);
MockExecutionEnvironment executionEnvironment;
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
auto drm = std::make_unique<DrmMock>(*executionEnvironment.rootDeviceEnvironments[0]);
auto ret = drm->queryMemoryInfo();
EXPECT_TRUE(ret);
EXPECT_EQ(nullptr, drm->memoryInfo);
}
TEST_F(DrmMemoryManagerTestImpl, givenDrmMemoryManagerWhenGetLocalMemorySizeIsCalledForMemoryInfoAndInvalidDeviceBitfieldThenReturnZero) {
MockExecutionEnvironment executionEnvironment;
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();

View File

@ -5710,4 +5710,49 @@ TEST_F(DrmMemoryManagerTest, givenDrmWhenRetrieveMmapOffsetForBufferObjectIsCall
}
}
TEST_F(DrmMemoryManagerTest, whenCallPaddedAllocationWithoutMmapPtrThenOnlyUserptrCalled) {
mock->ioctl_expected.gemUserptr = 1;
mock->ioctl_expected.gemClose = 1;
void *cpuPtr = (void *)0x30000;
size_t size = 0x1000;
DrmAllocation gfxAllocation(rootDeviceIndex, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, cpuPtr, size, (osHandle)1u, MemoryPool::MemoryNull);
auto gfxPaddedAllocation = memoryManager->createPaddedAllocation(&gfxAllocation, size);
ASSERT_NE(nullptr, gfxPaddedAllocation);
memoryManager->freeGraphicsMemoryImpl(gfxPaddedAllocation);
}
TEST_F(DrmMemoryManagerTest, whenCallPaddedAllocationWithMmapPtrThenMmapCalled) {
mock->ioctl_expected.gemMmap = 1;
mock->ioctl_expected.gemUserptr = 1;
mock->ioctl_expected.gemClose = 1;
BufferObject bo(mock, 1, 1024, 0);
void *cpuPtr = (void *)0x30000;
size_t size = 0x1000;
DrmAllocation gfxAllocation(rootDeviceIndex, GraphicsAllocation::AllocationType::UNKNOWN, &bo, cpuPtr, size, (osHandle)1u, MemoryPool::MemoryNull);
gfxAllocation.setMmapPtr(cpuPtr);
gfxAllocation.setMmapSize(size);
auto gfxPaddedAllocation = memoryManager->createPaddedAllocation(&gfxAllocation, size);
ASSERT_NE(nullptr, gfxPaddedAllocation);
EXPECT_TRUE(gfxAllocation.isLocked());
memoryManager->freeGraphicsMemoryImpl(gfxPaddedAllocation);
}
TEST_F(DrmMemoryManagerTest, whenCallPaddedAllocationWithMmapPtrAndFailedMmapCalledThenReturnNullptr) {
mock->ioctl_expected.gemMmap = 1;
mock->ioctl_res = -1;
BufferObject bo(mock, 1, 1024, 0);
void *cpuPtr = (void *)0x30000;
size_t size = 0x1000;
DrmAllocation gfxAllocation(rootDeviceIndex, GraphicsAllocation::AllocationType::UNKNOWN, &bo, cpuPtr, size, (osHandle)1u, MemoryPool::MemoryNull);
gfxAllocation.setMmapPtr(cpuPtr);
gfxAllocation.setMmapSize(size);
auto gfxPaddedAllocation = memoryManager->createPaddedAllocation(&gfxAllocation, size);
ASSERT_EQ(nullptr, gfxPaddedAllocation);
mock->ioctl_res = 0;
}
} // namespace NEO