From 9981cdd9e24c945479eb5f95a3977ab4d01e202f Mon Sep 17 00:00:00 2001 From: Michal Mrozek Date: Thu, 17 Sep 2020 08:58:06 +0200 Subject: [PATCH] Add new debug key for implicit flushes Change-Id: Ifbf8903c383d16f62754655a5bc949f27d290c42 Signed-off-by: Michal Mrozek --- ...and_stream_receiver_flush_task_3_tests.cpp | 54 +++++++++++++++++++ .../test/unit_test/test_files/igdrcl.config | 3 +- .../command_stream_receiver_hw_base.inl | 15 +++--- .../debug_settings/debug_variables_base.inl | 1 + 4 files changed, 66 insertions(+), 7 deletions(-) diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_3_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_3_tests.cpp index 480bd67d12..7b110a7eeb 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_3_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_3_tests.cpp @@ -535,6 +535,60 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInDefaultModeWhenFlushTask EXPECT_EQ(1u, csr.peekLatestFlushedTaskCount()); } +HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenFlushTaskIsCalledGivenNumberOfTimesThenFlushIsCalled) { + DebugManagerStateRestore restorer; + DebugManager.flags.PerformImplicitFlushEveryEnqueueCount.set(2); + CommandQueueHw commandQueue(nullptr, pClDevice, 0, false); + auto &commandStream = commandQueue.getCS(4096u); + + DispatchFlags dispatchFlags = DispatchFlagsHelper::createDefaultDispatchFlags(); + dispatchFlags.preemptionMode = PreemptionHelper::getDefaultPreemptionMode(pDevice->getHardwareInfo()); + dispatchFlags.guardCommandBufferWithPipeControl = true; + + auto &csr = commandQueue.getGpgpuCommandStreamReceiver(); + csr.overrideDispatchPolicy(DispatchMode::BatchedDispatch); + dispatchFlags.implicitFlush = false; + + csr.flushTask(commandStream, + 0, + dsh, + ioh, + ssh, + taskLevel, + dispatchFlags, + *pDevice); + + EXPECT_EQ(1u, csr.peekLatestSentTaskCount()); + EXPECT_EQ(0u, csr.peekLatestFlushedTaskCount()); + dispatchFlags.implicitFlush = false; + + csr.flushTask(commandStream, + 0, + dsh, + ioh, + ssh, + taskLevel, + dispatchFlags, + *pDevice); + + EXPECT_EQ(2u, csr.peekLatestSentTaskCount()); + EXPECT_EQ(2u, csr.peekLatestFlushedTaskCount()); + + dispatchFlags.implicitFlush = false; + + csr.flushTask(commandStream, + 0, + dsh, + ioh, + ssh, + taskLevel, + dispatchFlags, + *pDevice); + + EXPECT_EQ(3u, csr.peekLatestSentTaskCount()); + EXPECT_EQ(2u, csr.peekLatestFlushedTaskCount()); +} + HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenWaitForTaskCountIsCalledWithTaskCountThatWasNotYetFlushedThenBatchedCommandBuffersAreSubmitted) { CommandQueueHw commandQueue(nullptr, pClDevice, 0, false); auto &commandStream = commandQueue.getCS(4096u); diff --git a/opencl/test/unit_test/test_files/igdrcl.config b/opencl/test/unit_test/test_files/igdrcl.config index 9d74edb746..d133817810 100644 --- a/opencl/test/unit_test/test_files/igdrcl.config +++ b/opencl/test/unit_test/test_files/igdrcl.config @@ -188,4 +188,5 @@ UseExternalAllocatorForSshAndDsh = 0 DirectSubmissionOverrideBlitterSupport = -1 DirectSubmissionOverrideRenderSupport = -1 DirectSubmissionOverrideComputeSupport = -1 -EnableUsmCompression = -1 \ No newline at end of file +EnableUsmCompression = -1 +PerformImplicitFlushEveryEnqueueCount = -1 \ No newline at end of file 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 b13a5faf5e..0f1b521b7d 100644 --- a/shared/source/command_stream/command_stream_receiver_hw_base.inl +++ b/shared/source/command_stream/command_stream_receiver_hw_base.inl @@ -179,6 +179,7 @@ CompletionStamp CommandStreamReceiverHw::flushTask( DBG_LOG(LogTaskCounts, __FUNCTION__, "Line: ", __LINE__, "taskLevel", taskLevel); auto levelClosed = false; + bool implicitFlush = dispatchFlags.implicitFlush || dispatchFlags.blocking || DebugManager.flags.ForceImplicitFlush.get(); void *currentPipeControlForNooping = nullptr; void *epiloguePipeControlLocation = nullptr; @@ -186,10 +187,6 @@ CompletionStamp CommandStreamReceiverHw::flushTask( flushBatchedSubmissions(); } - if (DebugManager.flags.ForceImplicitFlush.get()) { - dispatchFlags.implicitFlush = true; - } - if (detectInitProgrammingFlagsRequired(dispatchFlags)) { initProgrammingFlags(); } @@ -547,11 +544,17 @@ CompletionStamp CommandStreamReceiverHw::flushTask( //check if we are not over the budget, if we are do implicit flush if (getMemoryManager()->isMemoryBudgetExhausted()) { if (this->totalMemoryUsed >= device.getDeviceInfo().globalMemSize / 4) { - dispatchFlags.implicitFlush = true; + implicitFlush = true; } } - if (this->dispatchMode == DispatchMode::BatchedDispatch && (dispatchFlags.blocking || dispatchFlags.implicitFlush)) { + if (DebugManager.flags.PerformImplicitFlushEveryEnqueueCount.get() != -1) { + if ((taskCount + 1) % DebugManager.flags.PerformImplicitFlushEveryEnqueueCount.get() == 0) { + implicitFlush = true; + } + } + + if (this->dispatchMode == DispatchMode::BatchedDispatch && implicitFlush) { this->flushBatchedSubmissions(); } diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index 42667ecccf..bd9d781785 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -123,6 +123,7 @@ DECLARE_DEBUG_VARIABLE(bool, DisableZeroCopyForUseHostPtr, false, "When active a DECLARE_DEBUG_VARIABLE(int32_t, EnableHostPtrTracking, -1, "Enable host ptr tracking: -1 - default platform setting, 0 - disabled, 1 - enabled") DECLARE_DEBUG_VARIABLE(int32_t, MaxHwThreadsPercent, 0, "If not zero then maximum number of used HW threads is capped to max * MaxHwThreadsPercent / 100") DECLARE_DEBUG_VARIABLE(int32_t, MinHwThreadsUnoccupied, 0, "If not zero then maximum number of used HW threads is reduced by MinHwThreadsUnoccupied") +DECLARE_DEBUG_VARIABLE(int32_t, PerformImplicitFlushEveryEnqueueCount, -1, "If greater then 0, driver performs implicit flush every N submissions.") /*DIRECT SUBMISSION FLAGS*/ DECLARE_DEBUG_VARIABLE(int32_t, EnableDirectSubmission, -1, "-1: default (disabled), 0: disable, 1:enable. Enables direct submission of command buffers bypassing KMD")