Add debug flag to enable calling freeMemory in memory Manager
Change-Id: I61a3c6e768bd9a479731f9e3e000069c9b677c33 Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
This commit is contained in:
parent
827b3aa9dc
commit
832814cefa
|
@ -215,7 +215,7 @@ void OsAgnosticMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllo
|
||||||
}
|
}
|
||||||
|
|
||||||
auto aubCenter = executionEnvironment.aubCenter.get();
|
auto aubCenter = executionEnvironment.aubCenter.get();
|
||||||
if (aubCenter && aubCenter->getAubManager()) {
|
if (aubCenter && aubCenter->getAubManager() && DebugManager.flags.EnableFreeMemory.get()) {
|
||||||
aubCenter->getAubManager()->freeMemory(gfxAllocation->getGpuAddress(), gfxAllocation->getUnderlyingBufferSize());
|
aubCenter->getAubManager()->freeMemory(gfxAllocation->getGpuAddress(), gfxAllocation->getUnderlyingBufferSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ void OsAgnosticMemoryManager::cleanOsHandles(OsHandleStorage &handleStorage) {
|
||||||
for (unsigned int i = 0; i < maxFragmentsCount; i++) {
|
for (unsigned int i = 0; i < maxFragmentsCount; i++) {
|
||||||
if (handleStorage.fragmentStorageData[i].freeTheFragment) {
|
if (handleStorage.fragmentStorageData[i].freeTheFragment) {
|
||||||
auto aubCenter = executionEnvironment.aubCenter.get();
|
auto aubCenter = executionEnvironment.aubCenter.get();
|
||||||
if (aubCenter && aubCenter->getAubManager()) {
|
if (aubCenter && aubCenter->getAubManager() && DebugManager.flags.EnableFreeMemory.get()) {
|
||||||
aubCenter->getAubManager()->freeMemory((uint64_t)handleStorage.fragmentStorageData[i].cpuPtr, handleStorage.fragmentStorageData[i].fragmentSize);
|
aubCenter->getAubManager()->freeMemory((uint64_t)handleStorage.fragmentStorageData[i].cpuPtr, handleStorage.fragmentStorageData[i].fragmentSize);
|
||||||
}
|
}
|
||||||
delete handleStorage.fragmentStorageData[i].osHandleStorage;
|
delete handleStorage.fragmentStorageData[i].osHandleStorage;
|
||||||
|
|
|
@ -103,6 +103,7 @@ DECLARE_DEBUG_VARIABLE(bool, EnablePassInlineData, false, "Enable passing of inl
|
||||||
DECLARE_DEBUG_VARIABLE(bool, EnableFormatQuery, false, "Enable sharing format querying")
|
DECLARE_DEBUG_VARIABLE(bool, EnableFormatQuery, false, "Enable sharing format querying")
|
||||||
DECLARE_DEBUG_VARIABLE(bool, AllowOpenFdOperations, false, "When enabled driver is allowed to call DRM_IOCTL_PRIME_HANDLE_TO_FD.")
|
DECLARE_DEBUG_VARIABLE(bool, AllowOpenFdOperations, false, "When enabled driver is allowed to call DRM_IOCTL_PRIME_HANDLE_TO_FD.")
|
||||||
DECLARE_DEBUG_VARIABLE(bool, EnableBlitterOperationsForReadWriteBuffers, false, "Use Blitter engine for Read/Write Buffers operations")
|
DECLARE_DEBUG_VARIABLE(bool, EnableBlitterOperationsForReadWriteBuffers, false, "Use Blitter engine for Read/Write Buffers operations")
|
||||||
|
DECLARE_DEBUG_VARIABLE(bool, EnableFreeMemory, false, "Enable freeMemory in memory manager")
|
||||||
DECLARE_DEBUG_VARIABLE(int32_t, EnableCacheFlushAfterWalker, 0, "-1: platform behavior, 0: disabled, 1: enabled. Adds dedicated cache flush command after WALKER command when surfaces used by kernel require to flush the cache")
|
DECLARE_DEBUG_VARIABLE(int32_t, EnableCacheFlushAfterWalker, 0, "-1: platform behavior, 0: disabled, 1: enabled. Adds dedicated cache flush command after WALKER command when surfaces used by kernel require to flush the cache")
|
||||||
DECLARE_DEBUG_VARIABLE(int32_t, EnableLocalMemory, -1, "-1: default behavior, 0: disabled, 1: enabled, Allows allocating graphics memory in Local Memory")
|
DECLARE_DEBUG_VARIABLE(int32_t, EnableLocalMemory, -1, "-1: default behavior, 0: disabled, 1: enabled, Allows allocating graphics memory in Local Memory")
|
||||||
DECLARE_DEBUG_VARIABLE(int32_t, EnableStatelessToStatefulBufferOffsetOpt, -1, "-1: dont override, 0: disable, 1: enable, Enables buffer-offset improvement of the stateless to stateful optimization")
|
DECLARE_DEBUG_VARIABLE(int32_t, EnableStatelessToStatefulBufferOffsetOpt, -1, "-1: dont override, 0: disable, 1: enable, Enables buffer-offset improvement of the stateless to stateful optimization")
|
||||||
|
|
|
@ -303,7 +303,9 @@ TEST_F(MemoryAllocatorTest, givenOsHandleStorageWhenOsHandlesAreCleanedAndAubMan
|
||||||
EXPECT_EQ(nullptr, mockAubCenter->aubManager);
|
EXPECT_EQ(nullptr, mockAubCenter->aubManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MemoryAllocatorTest, givenOsHandleStorageWhenOsHandlesAreCleanedAndAubManagerIsAvailableThenFreeMemoryIsCalledOnAubManager) {
|
TEST_F(MemoryAllocatorTest, givenOsHandleStorageAndFreeMemoryEnabledWhenOsHandlesAreCleanedAndAubManagerIsAvailableThenFreeMemoryIsCalledOnAubManager) {
|
||||||
|
DebugManagerStateRestore dbgRestore;
|
||||||
|
DebugManager.flags.EnableFreeMemory.set(true);
|
||||||
MockExecutionEnvironment mockExecutionEnvironment(*platformDevices);
|
MockExecutionEnvironment mockExecutionEnvironment(*platformDevices);
|
||||||
MockMemoryManager mockMemoryManager(mockExecutionEnvironment);
|
MockMemoryManager mockMemoryManager(mockExecutionEnvironment);
|
||||||
auto mockManager = new MockAubManager();
|
auto mockManager = new MockAubManager();
|
||||||
|
@ -1155,7 +1157,9 @@ INSTANTIATE_TEST_CASE_P(OsAgnosticMemoryManagerWithParams,
|
||||||
OsAgnosticMemoryManagerWithParams,
|
OsAgnosticMemoryManagerWithParams,
|
||||||
::testing::Values(false, true));
|
::testing::Values(false, true));
|
||||||
|
|
||||||
TEST(OsAgnosticMemoryManager, givenOsAgnosticMemoryManagerWhenGraphicsAllocationIsDestroyedThenFreeMemoryOnAubManagerShouldBeCalled) {
|
TEST(OsAgnosticMemoryManager, givenOsAgnosticMemoryManagerAndFreeMemoryEnabledWhenGraphicsAllocationIsDestroyedThenFreeMemoryOnAubManagerShouldBeCalled) {
|
||||||
|
DebugManagerStateRestore dbgRestore;
|
||||||
|
DebugManager.flags.EnableFreeMemory.set(true);
|
||||||
MockExecutionEnvironment executionEnvironment;
|
MockExecutionEnvironment executionEnvironment;
|
||||||
OsAgnosticMemoryManager memoryManager(executionEnvironment);
|
OsAgnosticMemoryManager memoryManager(executionEnvironment);
|
||||||
MockAubManager *mockManager = new MockAubManager();
|
MockAubManager *mockManager = new MockAubManager();
|
||||||
|
@ -1169,6 +1173,22 @@ TEST(OsAgnosticMemoryManager, givenOsAgnosticMemoryManagerWhenGraphicsAllocation
|
||||||
EXPECT_TRUE(mockManager->freeMemoryCalled);
|
EXPECT_TRUE(mockManager->freeMemoryCalled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(OsAgnosticMemoryManager, givenOsAgnosticMemoryManagerAndFreeMemoryDisabledWhenGraphicsAllocationIsDestroyedThenFreeMemoryOnAubManagerShouldBeCalled) {
|
||||||
|
DebugManagerStateRestore dbgRestore;
|
||||||
|
DebugManager.flags.EnableFreeMemory.set(false);
|
||||||
|
MockExecutionEnvironment executionEnvironment;
|
||||||
|
OsAgnosticMemoryManager memoryManager(executionEnvironment);
|
||||||
|
MockAubManager *mockManager = new MockAubManager();
|
||||||
|
MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "file_name.aub", CommandStreamReceiverType::CSR_AUB);
|
||||||
|
mockAubCenter->aubManager = std::unique_ptr<MockAubManager>(mockManager);
|
||||||
|
executionEnvironment.aubCenter.reset(mockAubCenter);
|
||||||
|
|
||||||
|
auto gfxAllocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
||||||
|
EXPECT_FALSE(mockManager->freeMemoryCalled);
|
||||||
|
memoryManager.freeGraphicsMemory(gfxAllocation);
|
||||||
|
EXPECT_FALSE(mockManager->freeMemoryCalled);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(MemoryManager, givenSharedResourceCopyWhenAllocatingGraphicsMemoryThenAllocateGraphicsMemoryForImageIsCalled) {
|
TEST(MemoryManager, givenSharedResourceCopyWhenAllocatingGraphicsMemoryThenAllocateGraphicsMemoryForImageIsCalled) {
|
||||||
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||||
MockMemoryManager memoryManager(false, true, *executionEnvironment);
|
MockMemoryManager memoryManager(false, true, *executionEnvironment);
|
||||||
|
|
|
@ -113,3 +113,4 @@ EnableFormatQuery = 0
|
||||||
AllowOpenFdOperations = 0
|
AllowOpenFdOperations = 0
|
||||||
EnableBlitterOperationsForReadWriteBuffers = 0
|
EnableBlitterOperationsForReadWriteBuffers = 0
|
||||||
DisableAuxTranslation = 0
|
DisableAuxTranslation = 0
|
||||||
|
EnableFreeMemory = 0
|
||||||
|
|
Loading…
Reference in New Issue