Skip to content

Commit be946ae

Browse files
performance: Optimize make resident for ULLS light
Do not check if ULLS light is active during every Csr::makeResident call. Store that information once during ULLS init. Related-To: NEO-13922 Signed-off-by: Lukasz Jobczyk <[email protected]>
1 parent 50e22ef commit be946ae

File tree

5 files changed

+20
-2
lines changed

5 files changed

+20
-2
lines changed

shared/source/command_stream/command_stream_receiver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ void CommandStreamReceiver::makeResident(GraphicsAllocation &gfxAllocation) {
156156
gfxAllocation.updateTaskCount(submissionTaskCount, osContext->getContextId());
157157

158158
if (gfxAllocation.isResidencyTaskCountBelow(submissionTaskCount, osContext->getContextId())) {
159-
auto pushAllocations = !this->osContext->isDirectSubmissionLightActive();
159+
auto pushAllocations = this->pushAllocationsForMakeResident;
160160

161161
if (debugManager.flags.MakeEachAllocationResident.get() != -1) {
162162
pushAllocations = !debugManager.flags.MakeEachAllocationResident.get();

shared/source/command_stream/command_stream_receiver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,7 @@ class CommandStreamReceiver : NEO::NonCopyableAndNonMovableClass {
688688
bool lastSystolicPipelineSelectMode = false;
689689
bool requiresInstructionCacheFlush = false;
690690
bool requiresDcFlush = false;
691+
bool pushAllocationsForMakeResident = true;
691692

692693
bool localMemoryEnabled = false;
693694
bool pageTableManagerInitialized = false;

shared/source/command_stream/command_stream_receiver_hw_base.inl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1411,8 +1411,11 @@ inline bool CommandStreamReceiverHw<GfxFamily>::initDirectSubmission() {
14111411
this->overrideDispatchPolicy(DispatchMode::immediateDispatch);
14121412
}
14131413
}
1414+
this->osContext->setDirectSubmissionActive();
1415+
if (this->osContext->isDirectSubmissionLightActive()) {
1416+
this->pushAllocationsForMakeResident = false;
1417+
}
14141418
}
1415-
this->osContext->setDirectSubmissionActive();
14161419
}
14171420
return ret;
14181421
}

shared/test/common/mocks/linux/mock_drm_command_stream_receiver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class TestedDrmCommandStreamReceiver : public DrmCommandStreamReceiver<GfxFamily
3636
using CommandStreamReceiver::immWritePostSyncWriteOffset;
3737
using CommandStreamReceiver::latestSentTaskCount;
3838
using CommandStreamReceiver::makeResident;
39+
using CommandStreamReceiver::pushAllocationsForMakeResident;
3940
using CommandStreamReceiver::tagAddress;
4041
using CommandStreamReceiver::taskCount;
4142
using CommandStreamReceiver::timeStampPostSyncWriteOffset;

shared/test/unit_test/os_interface/linux/drm_command_stream_tests_1.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,19 @@ HWTEST_TEMPLATED_F(DrmCommandStreamDirectSubmissionTest, givenDirectSubmissionLi
963963
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface.reset(oldMemoryOperationsInterface);
964964
}
965965

966+
HWTEST_TEMPLATED_F(DrmCommandStreamDirectSubmissionTest, givenDirectSubmissionLightWhenMakeResidentThenDoNotAddToCsrResidencyContainer) {
967+
auto testedCsr = static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr);
968+
testedCsr->directSubmission.reset();
969+
csr->initDirectSubmission();
970+
EXPECT_FALSE(testedCsr->pushAllocationsForMakeResident);
971+
EXPECT_EQ(testedCsr->getResidencyAllocations().size(), 0u);
972+
973+
DrmAllocation graphicsAllocation(0, 1u /*num gmms*/, AllocationType::unknown, nullptr, nullptr, 1024, static_cast<osHandle>(1u), MemoryPool::memoryNull);
974+
csr->makeResident(graphicsAllocation);
975+
976+
EXPECT_EQ(testedCsr->getResidencyAllocations().size(), 0u);
977+
}
978+
966979
template <typename GfxFamily>
967980
struct MockDrmDirectSubmission : public DrmDirectSubmission<GfxFamily, RenderDispatcher<GfxFamily>> {
968981
using DrmDirectSubmission<GfxFamily, RenderDispatcher<GfxFamily>>::currentTagData;

0 commit comments

Comments
 (0)