From be946ae56c693fed9c240b1fde7b353241ea17a7 Mon Sep 17 00:00:00 2001 From: Lukasz Jobczyk Date: Mon, 24 Feb 2025 10:50:20 +0000 Subject: [PATCH] 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 --- .../command_stream/command_stream_receiver.cpp | 2 +- .../source/command_stream/command_stream_receiver.h | 1 + .../command_stream_receiver_hw_base.inl | 5 ++++- .../mocks/linux/mock_drm_command_stream_receiver.h | 1 + .../linux/drm_command_stream_tests_1.cpp | 13 +++++++++++++ 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/shared/source/command_stream/command_stream_receiver.cpp b/shared/source/command_stream/command_stream_receiver.cpp index f716fd4e3b..3a8f31b0c1 100644 --- a/shared/source/command_stream/command_stream_receiver.cpp +++ b/shared/source/command_stream/command_stream_receiver.cpp @@ -156,7 +156,7 @@ void CommandStreamReceiver::makeResident(GraphicsAllocation &gfxAllocation) { gfxAllocation.updateTaskCount(submissionTaskCount, osContext->getContextId()); if (gfxAllocation.isResidencyTaskCountBelow(submissionTaskCount, osContext->getContextId())) { - auto pushAllocations = !this->osContext->isDirectSubmissionLightActive(); + auto pushAllocations = this->pushAllocationsForMakeResident; if (debugManager.flags.MakeEachAllocationResident.get() != -1) { pushAllocations = !debugManager.flags.MakeEachAllocationResident.get(); diff --git a/shared/source/command_stream/command_stream_receiver.h b/shared/source/command_stream/command_stream_receiver.h index d04c3b5be0..6f7b4a52d6 100644 --- a/shared/source/command_stream/command_stream_receiver.h +++ b/shared/source/command_stream/command_stream_receiver.h @@ -688,6 +688,7 @@ class CommandStreamReceiver : NEO::NonCopyableAndNonMovableClass { bool lastSystolicPipelineSelectMode = false; bool requiresInstructionCacheFlush = false; bool requiresDcFlush = false; + bool pushAllocationsForMakeResident = true; bool localMemoryEnabled = false; bool pageTableManagerInitialized = false; diff --git a/shared/source/command_stream/command_stream_receiver_hw_base.inl b/shared/source/command_stream/command_stream_receiver_hw_base.inl index 294ce0f354..4dfe38c9ac 100644 --- a/shared/source/command_stream/command_stream_receiver_hw_base.inl +++ b/shared/source/command_stream/command_stream_receiver_hw_base.inl @@ -1411,8 +1411,11 @@ inline bool CommandStreamReceiverHw::initDirectSubmission() { this->overrideDispatchPolicy(DispatchMode::immediateDispatch); } } + this->osContext->setDirectSubmissionActive(); + if (this->osContext->isDirectSubmissionLightActive()) { + this->pushAllocationsForMakeResident = false; + } } - this->osContext->setDirectSubmissionActive(); } return ret; } diff --git a/shared/test/common/mocks/linux/mock_drm_command_stream_receiver.h b/shared/test/common/mocks/linux/mock_drm_command_stream_receiver.h index 8b8f2f5696..0c6d3fe293 100644 --- a/shared/test/common/mocks/linux/mock_drm_command_stream_receiver.h +++ b/shared/test/common/mocks/linux/mock_drm_command_stream_receiver.h @@ -36,6 +36,7 @@ class TestedDrmCommandStreamReceiver : public DrmCommandStreamReceiverrootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface.reset(oldMemoryOperationsInterface); } +HWTEST_TEMPLATED_F(DrmCommandStreamDirectSubmissionTest, givenDirectSubmissionLightWhenMakeResidentThenDoNotAddToCsrResidencyContainer) { + auto testedCsr = static_cast *>(csr); + testedCsr->directSubmission.reset(); + csr->initDirectSubmission(); + EXPECT_FALSE(testedCsr->pushAllocationsForMakeResident); + EXPECT_EQ(testedCsr->getResidencyAllocations().size(), 0u); + + DrmAllocation graphicsAllocation(0, 1u /*num gmms*/, AllocationType::unknown, nullptr, nullptr, 1024, static_cast(1u), MemoryPool::memoryNull); + csr->makeResident(graphicsAllocation); + + EXPECT_EQ(testedCsr->getResidencyAllocations().size(), 0u); +} + template struct MockDrmDirectSubmission : public DrmDirectSubmission> { using DrmDirectSubmission>::currentTagData;