Delegate MemoryManager residency and eviction calls through CSR

MemoryManager::getEvictonAllocations()
MemoryManager::pushAllocationForEviction()
MemoryManager::clearEvictionAllocations()
MemoryManager::clearResidencyAllocations()

Change-Id: Iaa3051965bc9dfc09384e2bd5e9e0c372b5e722a
Signed-off-by: Maciej Dziuban <maciej.dziuban@intel.com>
This commit is contained in:
Maciej Dziuban
2018-09-12 10:44:35 +02:00
committed by sys_ocldev
parent 7aa70248e8
commit da5a292e54
9 changed files with 46 additions and 25 deletions

View File

@ -610,7 +610,7 @@ void AUBCommandStreamReceiverHw<GfxFamily>::processResidency(ResidencyContainer
template <typename GfxFamily>
void AUBCommandStreamReceiverHw<GfxFamily>::makeNonResident(GraphicsAllocation &gfxAllocation) {
if (gfxAllocation.residencyTaskCount != ObjectNotResident) {
this->getMemoryManager()->pushAllocationForEviction(&gfxAllocation);
this->pushAllocationForEviction(&gfxAllocation);
gfxAllocation.residencyTaskCount = ObjectNotResident;
}
}

View File

@ -78,14 +78,14 @@ void CommandStreamReceiver::makeResident(GraphicsAllocation &gfxAllocation) {
}
void CommandStreamReceiver::processEviction() {
getMemoryManager()->clearEvictionAllocations();
this->clearEvictionAllocations();
}
void CommandStreamReceiver::makeNonResident(GraphicsAllocation &gfxAllocation) {
if (gfxAllocation.residencyTaskCount != ObjectNotResident) {
makeCoherent(gfxAllocation);
if (gfxAllocation.peekEvictable()) {
getMemoryManager()->pushAllocationForEviction(&gfxAllocation);
this->pushAllocationForEviction(&gfxAllocation);
} else {
gfxAllocation.setEvictable(true);
}
@ -104,7 +104,7 @@ void CommandStreamReceiver::makeSurfacePackNonResident(ResidencyContainer *alloc
if (allocationsForResidency) {
residencyAllocations.clear();
} else {
this->getMemoryManager()->clearResidencyAllocations();
this->clearResidencyAllocations();
}
this->processEviction();
}
@ -272,6 +272,22 @@ void CommandStreamReceiver::pushAllocationForResidency(GraphicsAllocation *gfxAl
this->memoryManager->pushAllocationForResidency(gfxAllocation);
}
void CommandStreamReceiver::clearResidencyAllocations() {
this->memoryManager->clearResidencyAllocations();
}
ResidencyContainer &CommandStreamReceiver::getEvictionAllocations() {
return this->memoryManager->getEvictionAllocations();
}
void CommandStreamReceiver::pushAllocationForEviction(GraphicsAllocation *gfxAllocation) {
this->memoryManager->pushAllocationForEviction(gfxAllocation);
}
void CommandStreamReceiver::clearEvictionAllocations() {
this->memoryManager->clearEvictionAllocations();
}
void CommandStreamReceiver::activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) {}
GraphicsAllocation *CommandStreamReceiver::allocateDebugSurface(size_t size) {

View File

@ -91,6 +91,11 @@ class CommandStreamReceiver {
ResidencyContainer &getResidencyAllocations();
void pushAllocationForResidency(GraphicsAllocation *gfxAllocation);
void clearResidencyAllocations();
ResidencyContainer &getEvictionAllocations();
void pushAllocationForEviction(GraphicsAllocation *gfxAllocation);
void clearEvictionAllocations();
virtual GmmPageTableMngr *createPageTableManager() { return nullptr; }

View File

@ -159,8 +159,8 @@ void WddmCommandStreamReceiver<GfxFamily>::processResidency(ResidencyContainer *
template <typename GfxFamily>
void WddmCommandStreamReceiver<GfxFamily>::processEviction() {
getMemoryManager()->makeNonResidentEvictionAllocations();
getMemoryManager()->clearEvictionAllocations();
getMemoryManager()->makeNonResidentEvictionAllocations(this->getEvictionAllocations());
this->clearEvictionAllocations();
}
template <typename GfxFamily>

View File

@ -547,7 +547,7 @@ bool WddmMemoryManager::makeResidentResidencyAllocations(ResidencyContainer *all
return result;
}
void WddmMemoryManager::makeNonResidentEvictionAllocations() {
void WddmMemoryManager::makeNonResidentEvictionAllocations(ResidencyContainer &evictionAllocations) {
acquireResidencyLock();

View File

@ -65,7 +65,7 @@ class WddmMemoryManager : public MemoryManager {
void unlockResource(GraphicsAllocation *graphicsAllocation) override;
bool makeResidentResidencyAllocations(ResidencyContainer *allocationsForResidency, OsContext &osContext);
void makeNonResidentEvictionAllocations();
void makeNonResidentEvictionAllocations(ResidencyContainer &evictionAllocations);
AllocationStatus populateOsHandles(OsHandleStorage &handleStorage) override;
void cleanOsHandles(OsHandleStorage &handleStorage) override;

View File

@ -287,12 +287,12 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWhenMakeResidentC
// First makeNonResident marks the allocation as nonresident
aubCsr->makeNonResident(*gfxAllocation);
EXPECT_EQ(ObjectNotResident, gfxAllocation->residencyTaskCount);
EXPECT_EQ(1u, memoryManager->getEvictionAllocations().size());
EXPECT_EQ(1u, aubCsr->getEvictionAllocations().size());
// Second makeNonResident should have no impact
aubCsr->makeNonResident(*gfxAllocation);
EXPECT_EQ(ObjectNotResident, gfxAllocation->residencyTaskCount);
EXPECT_EQ(1u, memoryManager->getEvictionAllocations().size());
EXPECT_EQ(1u, aubCsr->getEvictionAllocations().size());
memoryManager->freeGraphicsMemoryImpl(gfxAllocation);
}

View File

@ -1191,7 +1191,7 @@ TEST_F(DrmCommandStreamLeaksTest, makeResidentTwice) {
EXPECT_EQ(buffer, bo1);
EXPECT_EQ(1u, bo1->getRefCount());
csr->getMemoryManager()->clearResidencyAllocations();
csr->clearResidencyAllocations();
csr->makeResident(*allocation);
csr->processResidency(&csr->getResidencyAllocations(), *osContext);
@ -1383,7 +1383,7 @@ TEST_F(DrmCommandStreamLeaksTest, GivenAllocationsContainingDifferentCountOfFrag
EXPECT_EQ(1u, bo->getRefCount());
}
mm->freeGraphicsMemory(allocation);
mm->clearResidencyAllocations();
csr->clearResidencyAllocations();
EXPECT_EQ(0u, hostPtrManager.getFragmentCount());
@ -1438,7 +1438,7 @@ TEST_F(DrmCommandStreamLeaksTest, GivenTwoAllocationsWhenBackingStorageIsTheSame
mm->freeGraphicsMemory(allocation);
mm->freeGraphicsMemory(allocation2);
mm->clearResidencyAllocations();
csr->clearResidencyAllocations();
}
TEST_F(DrmCommandStreamLeaksTest, GivenTwoAllocationsWhenBackingStorageIsDifferentThenMakeResidentShouldAddTwoLocations) {
@ -1461,7 +1461,7 @@ TEST_F(DrmCommandStreamLeaksTest, GivenTwoAllocationsWhenBackingStorageIsDiffere
mm->freeGraphicsMemory(allocation);
mm->freeGraphicsMemory(allocation2);
mm->clearResidencyAllocations();
csr->clearResidencyAllocations();
}
TEST_F(DrmCommandStreamLeaksTest, makeResidentSizeZero) {
@ -1682,7 +1682,7 @@ TEST_F(DrmCommandStreamLeaksTest, makeNonResidentOnMemObjectCallsDrmCSMakeNonRes
EXPECT_TRUE(tCsr->makeNonResidentResult.called);
EXPECT_EQ(allocation1, tCsr->makeNonResidentResult.allocation);
EXPECT_EQ(0u, mm->getEvictionAllocations().size());
EXPECT_EQ(0u, tCsr->getEvictionAllocations().size());
mm->freeGraphicsMemory(allocation1);
}

View File

@ -549,7 +549,7 @@ TEST_F(WddmCommandStreamTest, makeNonResidentPutsAllocationInEvictionAllocations
csr->makeNonResident(*commandBuffer);
EXPECT_EQ(1u, memManager->getEvictionAllocations().size());
EXPECT_EQ(1u, csr->getEvictionAllocations().size());
memManager->freeGraphicsMemory(commandBuffer);
}
@ -562,10 +562,10 @@ TEST_F(WddmCommandStreamTest, processEvictionPlacesAllAllocationsOnTrimCandidate
ASSERT_NE(nullptr, allocation);
ASSERT_NE(nullptr, allocation2);
memManager->pushAllocationForEviction(allocation);
memManager->pushAllocationForEviction(allocation2);
csr->pushAllocationForEviction(allocation);
csr->pushAllocationForEviction(allocation2);
EXPECT_EQ(2u, memManager->getEvictionAllocations().size());
EXPECT_EQ(2u, csr->getEvictionAllocations().size());
csr->processEviction();
@ -581,13 +581,13 @@ TEST_F(WddmCommandStreamTest, processEvictionClearsEvictionAllocations) {
GraphicsAllocation *allocation = memManager->allocateGraphicsMemory(4096);
ASSERT_NE(nullptr, allocation);
memManager->pushAllocationForEviction(allocation);
csr->pushAllocationForEviction(allocation);
EXPECT_EQ(1u, memManager->getEvictionAllocations().size());
EXPECT_EQ(1u, csr->getEvictionAllocations().size());
csr->processEviction();
EXPECT_EQ(0u, memManager->getEvictionAllocations().size());
EXPECT_EQ(0u, csr->getEvictionAllocations().size());
memManager->freeGraphicsMemory(allocation);
}
@ -603,7 +603,7 @@ TEST_F(WddmCommandStreamTest, makeResidentNonResidentMemObj) {
EXPECT_EQ(gfxAllocation, csr->getResidencyAllocations()[0]);
csr->makeNonResident(*buffer->getGraphicsAllocation());
EXPECT_EQ(gfxAllocation, memManager->getEvictionAllocations()[0]);
EXPECT_EQ(gfxAllocation, csr->getEvictionAllocations()[0]);
delete buffer;
memManager->freeGraphicsMemory(gfxAllocation);
@ -709,7 +709,7 @@ TEST_F(WddmCommandStreamMockGdiTest, makeResidentClearsResidencyAllocations) {
csr->makeResident(*commandBuffer);
EXPECT_EQ(1u, csr->getResidencyAllocations().size());
EXPECT_EQ(0u, memManager->getEvictionAllocations().size());
EXPECT_EQ(0u, csr->getEvictionAllocations().size());
EXPECT_EQ(trimListUnusedPosition, ((WddmAllocation *)commandBuffer)->getTrimCandidateListPosition());
@ -718,7 +718,7 @@ TEST_F(WddmCommandStreamMockGdiTest, makeResidentClearsResidencyAllocations) {
csr->makeSurfacePackNonResident(nullptr);
EXPECT_EQ(0u, csr->getResidencyAllocations().size());
EXPECT_EQ(0u, memManager->getEvictionAllocations().size());
EXPECT_EQ(0u, csr->getEvictionAllocations().size());
EXPECT_EQ(0u, ((WddmAllocation *)commandBuffer)->getTrimCandidateListPosition());