Skip to content

Commit b0a6d91

Browse files
Making DSH and IOH always resident
Change-Id: Ib114b92cb5ee153f213c15c935f8f1d1cfeb46eb
1 parent d516cd6 commit b0a6d91

File tree

5 files changed

+51
-3
lines changed

5 files changed

+51
-3
lines changed

runtime/command_stream/command_stream_receiver.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ void CommandStreamReceiver::processEviction() {
6767
void CommandStreamReceiver::makeNonResident(GraphicsAllocation &gfxAllocation) {
6868
if (gfxAllocation.residencyTaskCount != ObjectNotResident) {
6969
makeCoherent(gfxAllocation);
70-
getMemoryManager()->pushAllocationForEviction(&gfxAllocation);
70+
if (gfxAllocation.peekEvictable()) {
71+
getMemoryManager()->pushAllocationForEviction(&gfxAllocation);
72+
} else {
73+
gfxAllocation.setEvictable(true);
74+
}
7175
}
7276

7377
gfxAllocation.residencyTaskCount = ObjectNotResident;

runtime/command_stream/command_stream_receiver_hw.inl

+2
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,10 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
299299
auto sshAllocation = ssh.getGraphicsAllocation();
300300

301301
this->makeResident(*dshAllocation);
302+
dshAllocation->setEvictable(false);
302303
this->makeResident(*iohAllocation);
303304
this->makeResident(*sshAllocation);
305+
iohAllocation->setEvictable(false);
304306

305307
this->makeResident(*tagAllocation);
306308

runtime/memory_manager/graphics_allocation.h

+4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
5050
osHandle sharedHandle;
5151
bool locked = false;
5252
uint32_t reuseCount = 0; // GraphicsAllocation can be reused by shared resources
53+
bool evictable = true;
5354

5455
public:
5556
enum AllocationType {
@@ -126,6 +127,9 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
126127

127128
int residencyTaskCount = ObjectNotResident;
128129

130+
void setEvictable(bool evictable) { this->evictable = evictable; }
131+
bool peekEvictable() const { return evictable; }
132+
129133
bool isResident() const { return residencyTaskCount != ObjectNotResident; }
130134
void setLocked(bool locked) { this->locked = locked; }
131135
bool isLocked() const { return locked; }

unit_tests/command_stream/command_stream_receiver_hw_tests.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,29 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenTaskIsSu
315315
EXPECT_EQ(expectedUsedSize, commandStream.getUsed());
316316
}
317317

318+
HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrWhenflushTaskThenDshAndIohNotEvictable) {
319+
auto mockCsr = new MockCsrHw2<FamilyType>(*platformDevices[0]);
320+
pDevice->resetCommandStreamReceiver(mockCsr);
321+
DispatchFlags dispatchFlags;
322+
323+
mockCsr->flushTask(commandStream,
324+
0,
325+
dsh,
326+
ioh,
327+
ssh,
328+
taskLevel,
329+
dispatchFlags);
330+
331+
EXPECT_EQ(dsh.getGraphicsAllocation()->peekEvictable(), true);
332+
EXPECT_EQ(ssh.getGraphicsAllocation()->peekEvictable(), true);
333+
EXPECT_EQ(ioh.getGraphicsAllocation()->peekEvictable(), true);
334+
335+
dsh.getGraphicsAllocation()->setEvictable(false);
336+
EXPECT_EQ(dsh.getGraphicsAllocation()->peekEvictable(), false);
337+
dsh.getGraphicsAllocation()->setEvictable(true);
338+
EXPECT_EQ(dsh.getGraphicsAllocation()->peekEvictable(), true);
339+
}
340+
318341
HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeAndMidThreadPreemptionWhenFlushTaskIsCalledThenSipKernelIsMadeResident) {
319342
auto mockCsr = new MockCsrHw2<FamilyType>(*platformDevices[0]);
320343
pDevice->resetCommandStreamReceiver(mockCsr);

unit_tests/os_interface/windows/device_command_stream_tests.cpp

+17-2
Original file line numberDiff line numberDiff line change
@@ -668,15 +668,21 @@ HWTEST_F(WddmCommandStreamMockGdiTest, givenRecordedCommandBufferWhenItIsSubmitt
668668
mockCsr->overrideSubmissionAggregator(mockedSubmissionsAggregator);
669669

670670
auto commandBuffer = memManager->allocateGraphicsMemory(1024, 4096);
671+
auto dshAlloc = memManager->allocateGraphicsMemory(1024, 4096);
672+
auto iohAlloc = memManager->allocateGraphicsMemory(1024, 4096);
673+
auto sshAlloc = memManager->allocateGraphicsMemory(1024, 4096);
671674

672675
mockCsr->setTagAllocation(tagAllocation);
673676

674677
LinearStream cs(commandBuffer);
678+
LinearStream dsh(dshAlloc);
679+
LinearStream ioh(iohAlloc);
680+
LinearStream ssh(sshAlloc);
675681

676682
DispatchFlags dispatchFlags;
677683
dispatchFlags.guardCommandBufferWithPipeControl = true;
678684
dispatchFlags.requiresCoherency = true;
679-
mockCsr->flushTask(cs, 0u, cs, cs, cs, 0u, dispatchFlags);
685+
mockCsr->flushTask(cs, 0u, dsh, ioh, ssh, 0u, dispatchFlags);
680686

681687
auto &cmdBuffers = mockedSubmissionsAggregator->peekCommandBuffers();
682688
auto storedCommandBuffer = cmdBuffers.peekHead();
@@ -692,11 +698,14 @@ HWTEST_F(WddmCommandStreamMockGdiTest, givenRecordedCommandBufferWhenItIsSubmitt
692698
auto csrCommandStream = mockCsr->commandStream.getGraphicsAllocation();
693699
EXPECT_EQ(reinterpret_cast<uint64_t>(csrCommandStream->getUnderlyingBuffer()), mockWddm->submitResult.commandBufferSubmitted);
694700
EXPECT_TRUE(((COMMAND_BUFFER_HEADER *)mockWddm->submitResult.commandHeaderSubmitted)->RequiresCoherency);
695-
EXPECT_EQ(3u, mockWddm->makeResidentResult.handleCount);
701+
EXPECT_EQ(6u, mockWddm->makeResidentResult.handleCount);
696702

697703
std::vector<D3DKMT_HANDLE> expectedHandles;
698704
expectedHandles.push_back(((WddmAllocation *)tagAllocation)->handle);
699705
expectedHandles.push_back(((WddmAllocation *)commandBuffer)->handle);
706+
expectedHandles.push_back(((WddmAllocation *)dshAlloc)->handle);
707+
expectedHandles.push_back(((WddmAllocation *)iohAlloc)->handle);
708+
expectedHandles.push_back(((WddmAllocation *)sshAlloc)->handle);
700709
expectedHandles.push_back(((WddmAllocation *)csrCommandStream)->handle);
701710

702711
for (auto i = 0u; i < mockWddm->makeResidentResult.handleCount; i++) {
@@ -712,8 +721,14 @@ HWTEST_F(WddmCommandStreamMockGdiTest, givenRecordedCommandBufferWhenItIsSubmitt
712721

713722
EXPECT_NE(trimListUnusedPosition, ((WddmAllocation *)tagAllocation)->getTrimCandidateListPosition());
714723
EXPECT_NE(trimListUnusedPosition, ((WddmAllocation *)commandBuffer)->getTrimCandidateListPosition());
724+
EXPECT_EQ(trimListUnusedPosition, ((WddmAllocation *)dshAlloc)->getTrimCandidateListPosition());
725+
EXPECT_EQ(trimListUnusedPosition, ((WddmAllocation *)iohAlloc)->getTrimCandidateListPosition());
726+
EXPECT_NE(trimListUnusedPosition, ((WddmAllocation *)sshAlloc)->getTrimCandidateListPosition());
715727
EXPECT_NE(trimListUnusedPosition, ((WddmAllocation *)csrCommandStream)->getTrimCandidateListPosition());
716728

729+
memManager->freeGraphicsMemory(dshAlloc);
730+
memManager->freeGraphicsMemory(iohAlloc);
731+
memManager->freeGraphicsMemory(sshAlloc);
717732
memManager->freeGraphicsMemory(commandBuffer);
718733
}
719734

0 commit comments

Comments
 (0)