Skip to content

Commit 95e4dc4

Browse files
Delete unneeded residency/eviction allocations mutators
Change-Id: Ic73ea4c4e3ebf422f935a440a1b4789fe1c15494 Signed-off-by: Maciej Dziuban <[email protected]>
1 parent b774e9c commit 95e4dc4

File tree

8 files changed

+18
-81
lines changed

8 files changed

+18
-81
lines changed

runtime/command_stream/aub_command_stream_receiver_hw.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ void AUBCommandStreamReceiverHw<GfxFamily>::processResidency(ResidencyContainer
668668
template <typename GfxFamily>
669669
void AUBCommandStreamReceiverHw<GfxFamily>::makeNonResident(GraphicsAllocation &gfxAllocation) {
670670
if (gfxAllocation.residencyTaskCount[this->deviceIndex] != ObjectNotResident) {
671-
this->pushAllocationForEviction(&gfxAllocation);
671+
this->getEvictionAllocations().push_back(&gfxAllocation);
672672
gfxAllocation.residencyTaskCount[this->deviceIndex] = ObjectNotResident;
673673
}
674674
}

runtime/command_stream/command_stream_receiver.cpp

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ CommandStreamReceiver::~CommandStreamReceiver() {
5555
void CommandStreamReceiver::makeResident(GraphicsAllocation &gfxAllocation) {
5656
auto submissionTaskCount = this->taskCount + 1;
5757
if (gfxAllocation.residencyTaskCount[deviceIndex] < (int)submissionTaskCount) {
58-
this->pushAllocationForResidency(&gfxAllocation);
58+
this->getResidencyAllocations().push_back(&gfxAllocation);
5959
gfxAllocation.taskCount = submissionTaskCount;
6060
if (gfxAllocation.residencyTaskCount[deviceIndex] == ObjectNotResident) {
6161
this->totalMemoryUsed += gfxAllocation.getUnderlyingBufferSize();
@@ -65,14 +65,14 @@ void CommandStreamReceiver::makeResident(GraphicsAllocation &gfxAllocation) {
6565
}
6666

6767
void CommandStreamReceiver::processEviction() {
68-
this->clearEvictionAllocations();
68+
this->getEvictionAllocations().clear();
6969
}
7070

7171
void CommandStreamReceiver::makeNonResident(GraphicsAllocation &gfxAllocation) {
7272
if (gfxAllocation.residencyTaskCount[deviceIndex] != ObjectNotResident) {
7373
makeCoherent(gfxAllocation);
7474
if (gfxAllocation.peekEvictable()) {
75-
this->pushAllocationForEviction(&gfxAllocation);
75+
this->getEvictionAllocations().push_back(&gfxAllocation);
7676
} else {
7777
gfxAllocation.setEvictable(true);
7878
}
@@ -88,11 +88,7 @@ void CommandStreamReceiver::makeSurfacePackNonResident(ResidencyContainer *alloc
8888
for (auto &surface : residencyAllocations) {
8989
this->makeNonResident(*surface);
9090
}
91-
if (allocationsForResidency) {
92-
residencyAllocations.clear();
93-
} else {
94-
this->clearResidencyAllocations();
95-
}
91+
residencyAllocations.clear();
9692
this->processEviction();
9793
}
9894

@@ -255,26 +251,10 @@ ResidencyContainer &CommandStreamReceiver::getResidencyAllocations() {
255251
return this->residencyAllocations;
256252
}
257253

258-
void CommandStreamReceiver::pushAllocationForResidency(GraphicsAllocation *gfxAllocation) {
259-
this->residencyAllocations.push_back(gfxAllocation);
260-
}
261-
262-
void CommandStreamReceiver::clearResidencyAllocations() {
263-
this->residencyAllocations.clear();
264-
}
265-
266254
ResidencyContainer &CommandStreamReceiver::getEvictionAllocations() {
267255
return this->evictionAllocations;
268256
}
269257

270-
void CommandStreamReceiver::pushAllocationForEviction(GraphicsAllocation *gfxAllocation) {
271-
this->evictionAllocations.push_back(gfxAllocation);
272-
}
273-
274-
void CommandStreamReceiver::clearEvictionAllocations() {
275-
this->evictionAllocations.clear();
276-
}
277-
278258
void CommandStreamReceiver::activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) {}
279259

280260
GraphicsAllocation *CommandStreamReceiver::allocateDebugSurface(size_t size) {

runtime/command_stream/command_stream_receiver.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,7 @@ class CommandStreamReceiver {
7575
void setMemoryManager(MemoryManager *mm);
7676

7777
ResidencyContainer &getResidencyAllocations();
78-
void pushAllocationForResidency(GraphicsAllocation *gfxAllocation);
79-
void clearResidencyAllocations();
80-
8178
ResidencyContainer &getEvictionAllocations();
82-
void pushAllocationForEviction(GraphicsAllocation *gfxAllocation);
83-
void clearEvictionAllocations();
8479

8580
virtual GmmPageTableMngr *createPageTableManager() { return nullptr; }
8681

runtime/os_interface/windows/wddm_device_command_stream.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ void WddmCommandStreamReceiver<GfxFamily>::processResidency(ResidencyContainer &
145145
template <typename GfxFamily>
146146
void WddmCommandStreamReceiver<GfxFamily>::processEviction() {
147147
getMemoryManager()->makeNonResidentEvictionAllocations(this->getEvictionAllocations());
148-
this->clearEvictionAllocations();
148+
this->getEvictionAllocations().clear();
149149
}
150150

151151
template <typename GfxFamily>

unit_tests/command_stream/command_stream_receiver_tests.cpp

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -41,44 +41,6 @@ struct CommandStreamReceiverTest : public DeviceFixture,
4141
CommandStreamReceiver *commandStreamReceiver;
4242
};
4343

44-
TEST_F(CommandStreamReceiverTest, givenValidCsrWhenPushingAllocationForResidencyThanAllocationsCountIsIncreated) {
45-
ASSERT_EQ(0u, commandStreamReceiver->getResidencyAllocations().size());
46-
47-
GraphicsAllocation allocation(nullptr, 0);
48-
commandStreamReceiver->pushAllocationForResidency(&allocation);
49-
EXPECT_EQ(1u, commandStreamReceiver->getResidencyAllocations().size());
50-
}
51-
52-
TEST_F(CommandStreamReceiverTest, givenValidCsrWhenClearingAllocationsForResidencyThenAllAllocationsAreRemoved) {
53-
GraphicsAllocation allocation1(nullptr, 0);
54-
GraphicsAllocation allocation2(nullptr, 0);
55-
commandStreamReceiver->pushAllocationForResidency(&allocation1);
56-
commandStreamReceiver->pushAllocationForResidency(&allocation2);
57-
ASSERT_EQ(2u, commandStreamReceiver->getResidencyAllocations().size());
58-
59-
commandStreamReceiver->clearResidencyAllocations();
60-
EXPECT_EQ(0u, commandStreamReceiver->getResidencyAllocations().size());
61-
}
62-
63-
TEST_F(CommandStreamReceiverTest, givenValidCsrWhenPushingAllocationForEvictionThanAllocationsCountIsIncreated) {
64-
ASSERT_EQ(0u, commandStreamReceiver->getResidencyAllocations().size());
65-
66-
GraphicsAllocation allocation(nullptr, 0);
67-
commandStreamReceiver->pushAllocationForEviction(&allocation);
68-
EXPECT_EQ(1u, commandStreamReceiver->getEvictionAllocations().size());
69-
}
70-
71-
TEST_F(CommandStreamReceiverTest, givenValidCsrWhenClearingAllocationsForEvictionThenAllAllocationsAreRemoved) {
72-
GraphicsAllocation allocation1(nullptr, 0);
73-
GraphicsAllocation allocation2(nullptr, 0);
74-
commandStreamReceiver->pushAllocationForEviction(&allocation1);
75-
commandStreamReceiver->pushAllocationForEviction(&allocation2);
76-
ASSERT_EQ(2u, commandStreamReceiver->getEvictionAllocations().size());
77-
78-
commandStreamReceiver->clearEvictionAllocations();
79-
EXPECT_EQ(0u, commandStreamReceiver->getEvictionAllocations().size());
80-
}
81-
8244
HWTEST_F(CommandStreamReceiverTest, testCtor) {
8345
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
8446
EXPECT_EQ(0u, csr.peekTaskLevel());

unit_tests/command_stream/tbx_command_stream_tests.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ TEST(TbxCommandStreamReceiverTest, givenTbxCommandStreamReceiverWhenTypeIsChecke
160160
EXPECT_EQ(CommandStreamReceiverType::CSR_TBX, csr->getType());
161161
}
162162

163-
HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenMakeResidentIsCalledForGraphicsAllocationThenItShouldPushAllocationForResidencyToMemoryManager) {
163+
HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenMakeResidentIsCalledForGraphicsAllocationThenItShouldPushAllocationForResidencyToCsr) {
164164
TbxCommandStreamReceiverHw<FamilyType> *tbxCsr = (TbxCommandStreamReceiverHw<FamilyType> *)pCommandStreamReceiver;
165165
TbxMemoryManager *memoryManager = tbxCsr->getMemoryManager();
166166
ASSERT_NE(nullptr, memoryManager);
@@ -177,7 +177,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenMakeResidentIsC
177177
memoryManager->freeGraphicsMemory(graphicsAllocation);
178178
}
179179

180-
HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenMakeResidentHasAlreadyBeenCalledForGraphicsAllocationThenItShouldNotPushAllocationForResidencyAgainToMemoryManager) {
180+
HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenMakeResidentHasAlreadyBeenCalledForGraphicsAllocationThenItShouldNotPushAllocationForResidencyAgainToCsr) {
181181
TbxCommandStreamReceiverHw<FamilyType> *tbxCsr = (TbxCommandStreamReceiverHw<FamilyType> *)pCommandStreamReceiver;
182182
TbxMemoryManager *memoryManager = tbxCsr->getMemoryManager();
183183
ASSERT_NE(nullptr, memoryManager);
@@ -228,8 +228,8 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenProcessResidenc
228228

229229
EXPECT_EQ(ObjectNotResident, graphicsAllocation->residencyTaskCount[0u]);
230230

231-
tbxCsr->pushAllocationForResidency(graphicsAllocation);
232-
tbxCsr->processResidency(tbxCsr->getResidencyAllocations(), *pDevice->getOsContext());
231+
ResidencyContainer allocationsForResidency = {graphicsAllocation};
232+
tbxCsr->processResidency(allocationsForResidency, *pDevice->getOsContext());
233233

234234
EXPECT_NE(ObjectNotResident, graphicsAllocation->residencyTaskCount[0u]);
235235
EXPECT_EQ((int)tbxCsr->peekTaskCount() + 1, graphicsAllocation->residencyTaskCount[0u]);

unit_tests/os_interface/linux/drm_command_stream_tests.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,7 @@ TEST_F(DrmCommandStreamLeaksTest, makeResidentTwice) {
11761176
EXPECT_EQ(buffer, bo1);
11771177
EXPECT_EQ(1u, bo1->getRefCount());
11781178

1179-
csr->clearResidencyAllocations();
1179+
csr->getResidencyAllocations().clear();
11801180
csr->makeResident(*allocation);
11811181
csr->processResidency(csr->getResidencyAllocations(), *osContext);
11821182

@@ -1368,7 +1368,7 @@ TEST_F(DrmCommandStreamLeaksTest, GivenAllocationsContainingDifferentCountOfFrag
13681368
EXPECT_EQ(1u, bo->getRefCount());
13691369
}
13701370
mm->freeGraphicsMemory(allocation);
1371-
csr->clearResidencyAllocations();
1371+
csr->getResidencyAllocations().clear();
13721372

13731373
EXPECT_EQ(0u, hostPtrManager.getFragmentCount());
13741374

@@ -1423,7 +1423,7 @@ TEST_F(DrmCommandStreamLeaksTest, GivenTwoAllocationsWhenBackingStorageIsTheSame
14231423

14241424
mm->freeGraphicsMemory(allocation);
14251425
mm->freeGraphicsMemory(allocation2);
1426-
csr->clearResidencyAllocations();
1426+
csr->getResidencyAllocations().clear();
14271427
}
14281428

14291429
TEST_F(DrmCommandStreamLeaksTest, GivenTwoAllocationsWhenBackingStorageIsDifferentThenMakeResidentShouldAddTwoLocations) {
@@ -1446,7 +1446,7 @@ TEST_F(DrmCommandStreamLeaksTest, GivenTwoAllocationsWhenBackingStorageIsDiffere
14461446

14471447
mm->freeGraphicsMemory(allocation);
14481448
mm->freeGraphicsMemory(allocation2);
1449-
csr->clearResidencyAllocations();
1449+
csr->getResidencyAllocations().clear();
14501450
}
14511451

14521452
TEST_F(DrmCommandStreamLeaksTest, makeResidentSizeZero) {
@@ -1616,7 +1616,7 @@ TEST_F(DrmCommandStreamLeaksTest, CheckDrmFree) {
16161616
mm->freeGraphicsMemory(allocation);
16171617
}
16181618

1619-
TEST_F(DrmCommandStreamLeaksTest, MakeResidentClearResidencyAllocationsInMemoryManager) {
1619+
TEST_F(DrmCommandStreamLeaksTest, MakeResidentClearResidencyAllocationsInCommandStreamReceiver) {
16201620
auto allocation1 = mm->allocateGraphicsMemory(1024);
16211621
auto allocation2 = mm->allocateGraphicsMemory(1024);
16221622

unit_tests/os_interface/windows/device_command_stream_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,8 @@ TEST_F(WddmCommandStreamTest, processEvictionPlacesAllAllocationsOnTrimCandidate
547547
ASSERT_NE(nullptr, allocation);
548548
ASSERT_NE(nullptr, allocation2);
549549

550-
csr->pushAllocationForEviction(allocation);
551-
csr->pushAllocationForEviction(allocation2);
550+
csr->getEvictionAllocations().push_back(allocation);
551+
csr->getEvictionAllocations().push_back(allocation2);
552552

553553
EXPECT_EQ(2u, csr->getEvictionAllocations().size());
554554

@@ -566,7 +566,7 @@ TEST_F(WddmCommandStreamTest, processEvictionClearsEvictionAllocations) {
566566
GraphicsAllocation *allocation = memManager->allocateGraphicsMemory(4096);
567567
ASSERT_NE(nullptr, allocation);
568568

569-
csr->pushAllocationForEviction(allocation);
569+
csr->getEvictionAllocations().push_back(allocation);
570570

571571
EXPECT_EQ(1u, csr->getEvictionAllocations().size());
572572

0 commit comments

Comments
 (0)