Simplify memory manager API [1/n]

pass struct with properties to allocate graphics memory methods:
for protected methods use AllocationData
for public methods use AllocationProperties

Change-Id: Ie1c3cb6b5e330bc4adac2ca8b0bf02d30ec76065
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2018-11-30 11:01:33 +01:00
committed by sys_ocldev
parent ace20aba5b
commit c8748b77a0
30 changed files with 235 additions and 163 deletions

View File

@@ -236,7 +236,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWhenMakeResidentC
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true, *pDevice->executionEnvironment));
memoryManager.reset(aubCsr->createMemoryManager(false, false));
aubCsr->setOsContext(*pDevice->getDefaultEngine().osContext);
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t));
auto osContextId = aubCsr->getOsContext().getContextId();
@@ -540,7 +540,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
auto commandBuffer = aubExecutionEnvironment->commandBuffer;
LinearStream cs(commandBuffer);
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t));
ASSERT_NE(nullptr, gfxAllocation);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
@@ -574,7 +574,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNonStanda
auto commandBuffer = aubExecutionEnvironment->commandBuffer;
LinearStream cs(commandBuffer);
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t));
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
@@ -611,7 +611,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
aubCsr->subCaptureManager.reset(aubSubCaptureManagerMock);
ASSERT_TRUE(aubCsr->subCaptureManager->isSubCaptureEnabled());
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t));
ASSERT_NE(nullptr, gfxAllocation);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
@@ -642,7 +642,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphic
auto aubExecutionEnvironment = getEnvironment<AUBCommandStreamReceiverHw<FamilyType>>(false, false, true);
auto memoryManager = aubExecutionEnvironment->executionEnvironment->memoryManager.get();
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t));
EXPECT_TRUE(gfxAllocation->isAubWritable());
@@ -654,7 +654,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcess
auto aubCsr = aubExecutionEnvironment->template getCsr<AUBCommandStreamReceiverHw<FamilyType>>();
auto memoryManager = aubExecutionEnvironment->executionEnvironment->memoryManager.get();
auto gfxDefaultAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
auto gfxDefaultAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t));
ResidencyContainer allocationsForResidency = {gfxDefaultAllocation};
aubCsr->processResidency(allocationsForResidency);
@@ -669,7 +669,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenWriteMe
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true, *pDevice->executionEnvironment));
memoryManager.reset(aubCsr->createMemoryManager(false, false));
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t));
GraphicsAllocation::AllocationType onlyOneTimeAubWritableTypes[] = {
GraphicsAllocation::AllocationType::BUFFER,
@@ -694,10 +694,10 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcess
memoryManager.reset(aubCsr->createMemoryManager(false, false));
aubCsr->setOsContext(*pDevice->getDefaultEngine().osContext);
auto gfxBufferAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
auto gfxBufferAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t));
gfxBufferAllocation->setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
auto gfxImageAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
auto gfxImageAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t));
gfxImageAllocation->setAllocationType(GraphicsAllocation::AllocationType::IMAGE);
ResidencyContainer allocationsForResidency = {gfxBufferAllocation, gfxImageAllocation};
@@ -717,11 +717,11 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptur
memoryManager.reset(aubCsr->createMemoryManager(false, false));
aubCsr->setOsContext(*pDevice->getDefaultEngine().osContext);
auto gfxBufferAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
auto gfxBufferAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t));
gfxBufferAllocation->setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
gfxBufferAllocation->setAubWritable(false);
auto gfxImageAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
auto gfxImageAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t));
gfxImageAllocation->setAllocationType(GraphicsAllocation::AllocationType::IMAGE);
gfxImageAllocation->setAubWritable(false);
@@ -744,11 +744,11 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcess
memoryManager.reset(aubCsr->createMemoryManager(false, false));
aubCsr->setOsContext(*pDevice->getDefaultEngine().osContext);
auto gfxBufferAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
auto gfxBufferAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t));
gfxBufferAllocation->setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
gfxBufferAllocation->setAubWritable(false);
auto gfxImageAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
auto gfxImageAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t));
gfxImageAllocation->setAllocationType(GraphicsAllocation::AllocationType::IMAGE);
gfxImageAllocation->setAubWritable(false);
@@ -769,7 +769,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphic
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true, *pDevice->executionEnvironment));
memoryManager.reset(aubCsr->createMemoryManager(false, false));
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t));
EXPECT_TRUE(aubCsr->writeMemory(*gfxAllocation));
@@ -781,7 +781,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphic
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true, *pDevice->executionEnvironment));
memoryManager.reset(aubCsr->createMemoryManager(false, false));
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t));
gfxAllocation->setAubWritable(false);
EXPECT_FALSE(aubCsr->writeMemory(*gfxAllocation));

View File

@@ -48,8 +48,8 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedB
auto flatBatchBufferHelper = new FlatBatchBufferHelperHw<FamilyType>(*pDevice->executionEnvironment);
aubCsr->overwriteFlatBatchBufferHelper(flatBatchBufferHelper);
auto chainedBatchBuffer = memoryManager->allocateGraphicsMemory(128u, 64u, false, false);
auto otherAllocation = memoryManager->allocateGraphicsMemory(128u, 64u, false, false);
auto chainedBatchBuffer = memoryManager->allocateGraphicsMemory(128u);
auto otherAllocation = memoryManager->allocateGraphicsMemory(128u);
ASSERT_NE(nullptr, chainedBatchBuffer);
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
@@ -102,8 +102,8 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedB
auto flatBatchBufferHelper = new FlatBatchBufferHelperHw<FamilyType>(*pDevice->executionEnvironment);
aubCsr->overwriteFlatBatchBufferHelper(flatBatchBufferHelper);
auto chainedBatchBuffer = memoryManager->allocateGraphicsMemory(128u, 64u, false, false);
auto otherAllocation = memoryManager->allocateGraphicsMemory(128u, 64u, false, false);
auto chainedBatchBuffer = memoryManager->allocateGraphicsMemory(128u);
auto otherAllocation = memoryManager->allocateGraphicsMemory(128u);
ASSERT_NE(nullptr, chainedBatchBuffer);
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
@@ -278,7 +278,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedF
auto mockHelper = new MockFlatBatchBufferHelper<FamilyType>(*aubExecutionEnvironment->executionEnvironment);
aubCsr->overwriteFlatBatchBufferHelper(mockHelper);
auto chainedBatchBuffer = aubExecutionEnvironment->executionEnvironment->memoryManager->allocateGraphicsMemory(128u, 64u, false, false);
auto chainedBatchBuffer = aubExecutionEnvironment->executionEnvironment->memoryManager->allocateGraphicsMemory(128u);
ASSERT_NE(nullptr, chainedBatchBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 128u, chainedBatchBuffer, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
@@ -286,7 +286,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedF
aubCsr->makeResident(*chainedBatchBuffer);
std::unique_ptr<GraphicsAllocation, std::function<void(GraphicsAllocation *)>> ptr(
aubExecutionEnvironment->executionEnvironment->memoryManager->allocateGraphicsMemory(4096, 4096, false, false),
aubExecutionEnvironment->executionEnvironment->memoryManager->allocateGraphicsMemory(4096),
[&](GraphicsAllocation *ptr) { aubExecutionEnvironment->executionEnvironment->memoryManager->freeGraphicsMemory(ptr); });
auto expectedAllocation = ptr.get();
@@ -663,7 +663,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenWriteMe
aubCsr->ppgtt.reset(ppgttMock);
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t));
gfxAllocation->setAubWritable(true);
auto gmm = new Gmm(nullptr, 1, false);

View File

@@ -175,7 +175,7 @@ HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAub
}
HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenMakeResidentIsCalledThenBaseCsrMakeResidentIsCalled) {
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t));
ASSERT_NE(nullptr, gfxAllocation);
csrWithAubDump->makeResident(*gfxAllocation);
@@ -197,7 +197,7 @@ HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAub
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t));
ASSERT_NE(nullptr, gfxAllocation);
ResidencyContainer allocationsForResidency = {gfxAllocation};
@@ -217,7 +217,7 @@ HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAub
}
HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenMakeNonResidentIsCalledThenBothBaseAndAubCsrMakeNonResidentIsCalled) {
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t));
ASSERT_NE(nullptr, gfxAllocation);
csrWithAubDump->makeResident(*gfxAllocation);

View File

@@ -263,7 +263,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenFlushIsCalledTh
TbxMemoryManager *memoryManager = tbxCsr->getMemoryManager();
ASSERT_NE(nullptr, memoryManager);
auto graphicsAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
auto graphicsAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t));
ASSERT_NE(nullptr, graphicsAllocation);
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);