From d7d6996464e1ddd709438f8512b321738e62bc9e Mon Sep 17 00:00:00 2001 From: Szymon Morek Date: Wed, 7 Aug 2024 11:01:37 +0000 Subject: [PATCH] performance: initialize timeout params once Currently this is done per each enqueue which is not really needed Signed-off-by: Szymon Morek --- .../command_stream/command_stream_receiver_hw_base.inl | 1 + .../source/os_interface/linux/drm_command_stream.inl | 2 -- .../windows/wddm_device_command_stream.inl | 2 -- .../command_stream/command_stream_receiver_tests.cpp | 10 +++++++++- .../windows/device_command_stream_tests.cpp | 6 ++---- 5 files changed, 12 insertions(+), 9 deletions(-) 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 f66abb0af1..2892effdc3 100644 --- a/shared/source/command_stream/command_stream_receiver_hw_base.inl +++ b/shared/source/command_stream/command_stream_receiver_hw_base.inl @@ -1404,6 +1404,7 @@ inline bool CommandStreamReceiverHw::initDirectSubmission() { if (directSubmissionController) { directSubmissionController->registerDirectSubmission(this); } + this->startControllingDirectSubmissions(); if (this->isUpdateTagFromWaitEnabled()) { this->overrideDispatchPolicy(DispatchMode::immediateDispatch); } diff --git a/shared/source/os_interface/linux/drm_command_stream.inl b/shared/source/os_interface/linux/drm_command_stream.inl index 84345d9798..ccfc8dce0a 100644 --- a/shared/source/os_interface/linux/drm_command_stream.inl +++ b/shared/source/os_interface/linux/drm_command_stream.inl @@ -140,7 +140,6 @@ SubmissionStatus DrmCommandStreamReceiver::flush(BatchBuffer &batchBu } if (this->directSubmission.get()) { - this->startControllingDirectSubmissions(); bool ret = this->directSubmission->dispatchCommandBuffer(batchBuffer, *this->flushStamp.get()); if (ret == false) { return Drm::getSubmissionStatusFromReturnCode(this->directSubmission->getDispatchErrorCode()); @@ -148,7 +147,6 @@ SubmissionStatus DrmCommandStreamReceiver::flush(BatchBuffer &batchBu return SubmissionStatus::success; } if (this->blitterDirectSubmission.get()) { - this->startControllingDirectSubmissions(); bool ret = this->blitterDirectSubmission->dispatchCommandBuffer(batchBuffer, *this->flushStamp.get()); if (ret == false) { return Drm::getSubmissionStatusFromReturnCode(this->blitterDirectSubmission->getDispatchErrorCode()); diff --git a/shared/source/os_interface/windows/wddm_device_command_stream.inl b/shared/source/os_interface/windows/wddm_device_command_stream.inl index 3c87db80a6..68059342d6 100644 --- a/shared/source/os_interface/windows/wddm_device_command_stream.inl +++ b/shared/source/os_interface/windows/wddm_device_command_stream.inl @@ -95,7 +95,6 @@ SubmissionStatus WddmCommandStreamReceiver::flush(BatchBuffer &batchB } if (this->directSubmission.get()) { - this->startControllingDirectSubmissions(); auto ret = this->directSubmission->dispatchCommandBuffer(batchBuffer, *(this->flushStamp.get())); if (ret == false) { return SubmissionStatus::failed; @@ -103,7 +102,6 @@ SubmissionStatus WddmCommandStreamReceiver::flush(BatchBuffer &batchB return SubmissionStatus::success; } if (this->blitterDirectSubmission.get()) { - this->startControllingDirectSubmissions(); auto ret = this->blitterDirectSubmission->dispatchCommandBuffer(batchBuffer, *(this->flushStamp.get())); if (ret == false) { return SubmissionStatus::failed; diff --git a/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp b/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp index b9de819860..a285b3fad2 100644 --- a/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp +++ b/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp @@ -1101,7 +1101,13 @@ class CommandStreamReceiverHwDirectSubmissionMock : public CommandStreamReceiver recursiveLockCounter++; return CommandStreamReceiverHw::obtainUniqueOwnership(); } + + void startControllingDirectSubmissions() override { + startControllingDirectSubmissionsCalled = true; + } + uint32_t recursiveLockCounter = 0; + bool startControllingDirectSubmissionsCalled = false; }; HWTEST_F(InitDirectSubmissionTest, whenCallInitDirectSubmissionAgainThenItIsNotReinitialized) { @@ -1132,7 +1138,7 @@ HWTEST_F(InitDirectSubmissionTest, whenCallInitDirectSubmissionAgainThenItIsNotR csr.reset(); } -HWTEST_F(InitDirectSubmissionTest, whenCallInitDirectSubmissionThenObtainLock) { +HWTEST_F(InitDirectSubmissionTest, whenCallInitDirectSubmissionThenObtainLockAndInitController) { auto csr = std::make_unique>(*device->executionEnvironment, device->getRootDeviceIndex(), device->getDeviceBitfield()); std::unique_ptr osContext(OsContext::create(device->getExecutionEnvironment()->rootDeviceEnvironments[0]->osInterface.get(), device->getRootDeviceIndex(), 0, EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_RCS, EngineUsage::regular}, @@ -1146,9 +1152,11 @@ HWTEST_F(InitDirectSubmissionTest, whenCallInitDirectSubmissionThenObtainLock) { csr->initializeTagAllocation(); csr->initDirectSubmission(); EXPECT_EQ(1u, csr->recursiveLockCounter); + EXPECT_TRUE(csr->startControllingDirectSubmissionsCalled); csr.reset(); } + HWTEST_F(InitDirectSubmissionTest, givenDirectSubmissionEnabledWhenPlatformNotSupportsRcsThenExpectFeatureNotAvailable) { auto csr = std::make_unique>(*device->executionEnvironment, device->getRootDeviceIndex(), device->getDeviceBitfield()); std::unique_ptr osContext(OsContext::create(device->getExecutionEnvironment()->rootDeviceEnvironments[0]->osInterface.get(), device->getRootDeviceIndex(), 0, diff --git a/shared/test/unit_test/os_interface/windows/device_command_stream_tests.cpp b/shared/test/unit_test/os_interface/windows/device_command_stream_tests.cpp index ffa388c0dc..6e9464801d 100644 --- a/shared/test/unit_test/os_interface/windows/device_command_stream_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/device_command_stream_tests.cpp @@ -1220,7 +1220,7 @@ HWTEST_TEMPLATED_F(WddmCommandStreamMockGdiTest, givenDirectSubmissionFailsThenF memoryManager->freeGraphicsMemory(commandBuffer); } -HWTEST_TEMPLATED_F(WddmCommandStreamMockGdiTest, givenDirectSubmissionEnabledOnRcsWhenFlushingCommandBufferThenExpectDirectSubmissionUsedAndDirectSubmissionControllerStarted) { +HWTEST_TEMPLATED_F(WddmCommandStreamMockGdiTest, givenDirectSubmissionEnabledOnRcsWhenFlushingCommandBufferThenExpectDirectSubmissionUsed) { using Dispatcher = RenderDispatcher; using MockSubmission = MockWddmDirectSubmission; @@ -1247,7 +1247,6 @@ HWTEST_TEMPLATED_F(WddmCommandStreamMockGdiTest, givenDirectSubmissionEnabledOnR batchBuffer.endCmdPtr = commandBuffer->getUnderlyingBuffer(); csr->flush(batchBuffer, csr->getResidencyAllocations()); - EXPECT_TRUE(mockCsr->directSubmissionControllerStarted); auto directSubmission = reinterpret_cast(mockCsr->directSubmission.get()); EXPECT_TRUE(directSubmission->ringStart); size_t actualDispatchSize = directSubmission->ringCommandStream.getUsed(); @@ -1267,7 +1266,7 @@ HWTEST_TEMPLATED_F(WddmCommandStreamMockGdiTest, givenDirectSubmissionEnabledOnR memoryManager->freeGraphicsMemory(commandBuffer); } -HWTEST_TEMPLATED_F(WddmCommandStreamMockGdiTest, givenDirectSubmissionEnabledOnBcsWhenFlushingCommandBufferThenExpectDirectSubmissionUsedAndDirectSubmissionControllerStarted) { +HWTEST_TEMPLATED_F(WddmCommandStreamMockGdiTest, givenDirectSubmissionEnabledOnBcsWhenFlushingCommandBufferThenExpectDirectSubmissionUsed) { using Dispatcher = BlitterDispatcher; using MockSubmission = MockWddmDirectSubmission; @@ -1295,7 +1294,6 @@ HWTEST_TEMPLATED_F(WddmCommandStreamMockGdiTest, givenDirectSubmissionEnabledOnB batchBuffer.endCmdPtr = commandBuffer->getUnderlyingBuffer(); csr->flush(batchBuffer, csr->getResidencyAllocations()); - EXPECT_TRUE(mockCsr->directSubmissionControllerStarted); auto directSubmission = reinterpret_cast(mockCsr->blitterDirectSubmission.get()); EXPECT_TRUE(directSubmission->ringStart); size_t actualDispatchSize = directSubmission->ringCommandStream.getUsed();