mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 14:02:58 +08:00
feature: track used memory by allocations
Track memory used by memory allocations. System and local per device. Will be used for heuristics in memory pooling. Related-To: NEO-11356 Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
6103ab1dae
commit
26428d5af3
@@ -413,6 +413,36 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenSmallSizeAndGpuAddress
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenMemoryManagerWhenAllocateGraphicsMemoryIsCalledThenAllocationSizeIsRegistered) {
|
||||
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(true, false, false, *executionEnvironment);
|
||||
auto osContext = device->getDefaultEngine().osContext;
|
||||
|
||||
const auto allocationSize = MemoryConstants::pageSize;
|
||||
auto allocationProperties = MockAllocationProperties{device->getRootDeviceIndex(), allocationSize};
|
||||
allocationProperties.osContext = osContext;
|
||||
allocationProperties.allocationType = AllocationType::buffer;
|
||||
EXPECT_EQ(0u, memoryManager->getUsedLocalMemorySize(device->getRootDeviceIndex()));
|
||||
EXPECT_EQ(0u, memoryManager->getUsedSystemMemorySize());
|
||||
auto localAllocation = memoryManager->allocateGraphicsMemoryWithProperties(allocationProperties);
|
||||
EXPECT_NE(nullptr, localAllocation);
|
||||
EXPECT_EQ(localAllocation->getUnderlyingBufferSize(), memoryManager->getUsedLocalMemorySize(device->getRootDeviceIndex()));
|
||||
EXPECT_EQ(0u, memoryManager->getUsedSystemMemorySize());
|
||||
|
||||
allocationProperties.allocationType = AllocationType::bufferHostMemory;
|
||||
auto systemAllocation = memoryManager->allocateGraphicsMemoryWithProperties(allocationProperties);
|
||||
EXPECT_NE(nullptr, systemAllocation);
|
||||
EXPECT_EQ(localAllocation->getUnderlyingBufferSize(), memoryManager->getUsedLocalMemorySize(device->getRootDeviceIndex()));
|
||||
EXPECT_EQ(systemAllocation->getUnderlyingBufferSize(), memoryManager->getUsedSystemMemorySize());
|
||||
|
||||
memoryManager->freeGraphicsMemory(localAllocation);
|
||||
EXPECT_EQ(0u, memoryManager->getUsedLocalMemorySize(device->getRootDeviceIndex()));
|
||||
EXPECT_EQ(systemAllocation->getUnderlyingBufferSize(), memoryManager->getUsedSystemMemorySize());
|
||||
|
||||
memoryManager->freeGraphicsMemory(systemAllocation);
|
||||
EXPECT_EQ(0u, memoryManager->getUsedLocalMemorySize(device->getRootDeviceIndex()));
|
||||
EXPECT_EQ(0u, memoryManager->getUsedSystemMemorySize());
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTest, givenInjectedFailuresWhenGraphicsMemoryWithGpuVaIsAllocatedThenNullptrIsReturned) {
|
||||
mock->ioctlExpected.total = -1; // don't care
|
||||
|
||||
|
||||
@@ -747,6 +747,34 @@ TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWhenAllocateGraphicsMemory
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWhenAllocateGraphicsMemoryIsCalledThenAllocationSizeIsRegistered) {
|
||||
memoryManager.reset(new MockWddmMemoryManager(false, true, executionEnvironment));
|
||||
|
||||
const auto allocationSize = MemoryConstants::pageSize;
|
||||
auto allocationProperties = MockAllocationProperties{csr->getRootDeviceIndex(), allocationSize};
|
||||
allocationProperties.allocationType = AllocationType::buffer;
|
||||
EXPECT_EQ(0u, memoryManager->getUsedLocalMemorySize(csr->getRootDeviceIndex()));
|
||||
EXPECT_EQ(0u, memoryManager->getUsedSystemMemorySize());
|
||||
auto localAllocation = memoryManager->allocateGraphicsMemoryWithProperties(allocationProperties);
|
||||
EXPECT_NE(nullptr, localAllocation);
|
||||
EXPECT_EQ(localAllocation->getUnderlyingBufferSize(), memoryManager->getUsedLocalMemorySize(csr->getRootDeviceIndex()));
|
||||
EXPECT_EQ(0u, memoryManager->getUsedSystemMemorySize());
|
||||
|
||||
allocationProperties.allocationType = AllocationType::bufferHostMemory;
|
||||
auto systemAllocation = memoryManager->allocateGraphicsMemoryWithProperties(allocationProperties);
|
||||
EXPECT_NE(nullptr, systemAllocation);
|
||||
EXPECT_EQ(localAllocation->getUnderlyingBufferSize(), memoryManager->getUsedLocalMemorySize(csr->getRootDeviceIndex()));
|
||||
EXPECT_EQ(systemAllocation->getUnderlyingBufferSize(), memoryManager->getUsedSystemMemorySize());
|
||||
|
||||
memoryManager->freeGraphicsMemory(localAllocation);
|
||||
EXPECT_EQ(0u, memoryManager->getUsedLocalMemorySize(csr->getRootDeviceIndex()));
|
||||
EXPECT_EQ(systemAllocation->getUnderlyingBufferSize(), memoryManager->getUsedSystemMemorySize());
|
||||
|
||||
memoryManager->freeGraphicsMemory(systemAllocation);
|
||||
EXPECT_EQ(0u, memoryManager->getUsedLocalMemorySize(csr->getRootDeviceIndex()));
|
||||
EXPECT_EQ(0u, memoryManager->getUsedSystemMemorySize());
|
||||
}
|
||||
|
||||
class MockCreateWddmAllocationMemoryManager : public MockWddmMemoryManager {
|
||||
public:
|
||||
MockCreateWddmAllocationMemoryManager(NEO::ExecutionEnvironment &execEnv) : MockWddmMemoryManager(execEnv) {}
|
||||
|
||||
Reference in New Issue
Block a user