From 6e0d04e25a6c8ed05ed12095baa0fcf481374bcb Mon Sep 17 00:00:00 2001 From: "Chodor, Jaroslaw" Date: Thu, 7 Feb 2019 20:39:26 +0100 Subject: [PATCH] Adding debug flag to disable DC flush in epilogue Change-Id: I1784be279ee9f837a0994997bec49c1925a68390 --- .../command_stream_receiver_hw.inl | 6 +- runtime/os_interface/debug_variables_base.inl | 1 + ...and_stream_receiver_flush_task_3_tests.cpp | 73 +++++++++++++++++++ unit_tests/test_files/igdrcl.config | 1 + 4 files changed, 80 insertions(+), 1 deletion(-) diff --git a/runtime/command_stream/command_stream_receiver_hw.inl b/runtime/command_stream/command_stream_receiver_hw.inl index f05e839a2dfa2..f738c0072e4cd 100644 --- a/runtime/command_stream/command_stream_receiver_hw.inl +++ b/runtime/command_stream/command_stream_receiver_hw.inl @@ -563,7 +563,11 @@ inline void CommandStreamReceiverHw::flushBatchedSubmissions() { //make sure we flush DC if needed if (epiloguePipeControlLocation) { - ((PIPE_CONTROL *)epiloguePipeControlLocation)->setDcFlushEnable(false == HwHelper::cacheFlushAfterWalkerSupported(this->hwInfo)); + bool flushDcInEpilogue = true; + if (DebugManager.flags.DisableDcFlushInEpilogue.get()) { + flushDcInEpilogue = false; + } + ((PIPE_CONTROL *)epiloguePipeControlLocation)->setDcFlushEnable(flushDcInEpilogue); } auto flushStamp = this->flush(primaryCmdBuffer->batchBuffer, surfacesForSubmit); diff --git a/runtime/os_interface/debug_variables_base.inl b/runtime/os_interface/debug_variables_base.inl index 6ec34020aa7ed..b99fb5fff43f1 100644 --- a/runtime/os_interface/debug_variables_base.inl +++ b/runtime/os_interface/debug_variables_base.inl @@ -80,6 +80,7 @@ DECLARE_DEBUG_VARIABLE(bool, UseNoRingFlushesKmdMode, true, "Windows only, passe DECLARE_DEBUG_VARIABLE(bool, DisableZeroCopyForUseHostPtr, false, "When active all buffer allocations created with CL_MEM_USE_HOST_PTR flag will not share memory with CPU.") DECLARE_DEBUG_VARIABLE(bool, DisableZeroCopyForBuffers, false, "When active all buffer allocations will not share memory with CPU.") DECLARE_DEBUG_VARIABLE(bool, EnableHostPtrTracking, true, "Enable host ptr tracking") +DECLARE_DEBUG_VARIABLE(bool, DisableDcFlushInEpilogue, false, "Disable DC flush in epilogue") /*FEATURE FLAGS*/ DECLARE_DEBUG_VARIABLE(bool, EnableNV12, true, "Enables NV12 extension") diff --git a/unit_tests/command_stream/command_stream_receiver_flush_task_3_tests.cpp b/unit_tests/command_stream/command_stream_receiver_flush_task_3_tests.cpp index 507012848452f..dfc196e4faa9a 100644 --- a/unit_tests/command_stream/command_stream_receiver_flush_task_3_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_flush_task_3_tests.cpp @@ -918,6 +918,79 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenDcFlushI EXPECT_NE(nullptr, cmdBuffer->epiloguePipeControlLocation); } +HWTEST_F(CommandStreamReceiverFlushTaskTests, givenEpiloguePipeControlThenDcFlushIsEnabled) { + using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; + + CommandQueueHw commandQueue(nullptr, pDevice, 0); + auto &commandStream = commandQueue.getCS(4096u); + + auto mockCsr = new MockCsrHw2(*platformDevices[0], *pDevice->executionEnvironment); + pDevice->resetCommandStreamReceiver(mockCsr); + + mockCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch); + + auto mockedSubmissionsAggregator = new mockSubmissionsAggregator(); + mockCsr->overrideSubmissionAggregator(mockedSubmissionsAggregator); + + DispatchFlags dispatchFlags; + dispatchFlags.guardCommandBufferWithPipeControl = true; + dispatchFlags.outOfOrderExecutionAllowed = false; + dispatchFlags.preemptionMode = PreemptionHelper::getDefaultPreemptionMode(pDevice->getHardwareInfo()); + mockCsr->flushTask(commandStream, + 0, + dsh, + ioh, + ssh, + taskLevel, + dispatchFlags, + *pDevice); + + auto cmdBuffer = mockedSubmissionsAggregator->peekCommandBuffers().peekHead(); + ASSERT_NE(nullptr, cmdBuffer->epiloguePipeControlLocation); + auto pipeControl = genCmdCast(cmdBuffer->epiloguePipeControlLocation); + ASSERT_NE(nullptr, pipeControl); + mockCsr->flushBatchedSubmissions(); + EXPECT_TRUE(pipeControl->getDcFlushEnable()); +} + +HWTEST_F(CommandStreamReceiverFlushTaskTests, givenEpiloguePipeControlWhendDcFlushDisabledByDebugFlagThenDcFlushIsDisabled) { + using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; + + DebugManagerStateRestore debugRestorer; + DebugManager.flags.DisableDcFlushInEpilogue.set(true); + + CommandQueueHw commandQueue(nullptr, pDevice, 0); + auto &commandStream = commandQueue.getCS(4096u); + + auto mockCsr = new MockCsrHw2(*platformDevices[0], *pDevice->executionEnvironment); + pDevice->resetCommandStreamReceiver(mockCsr); + + mockCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch); + + auto mockedSubmissionsAggregator = new mockSubmissionsAggregator(); + mockCsr->overrideSubmissionAggregator(mockedSubmissionsAggregator); + + DispatchFlags dispatchFlags; + dispatchFlags.guardCommandBufferWithPipeControl = true; + dispatchFlags.outOfOrderExecutionAllowed = false; + dispatchFlags.preemptionMode = PreemptionHelper::getDefaultPreemptionMode(pDevice->getHardwareInfo()); + mockCsr->flushTask(commandStream, + 0, + dsh, + ioh, + ssh, + taskLevel, + dispatchFlags, + *pDevice); + + auto cmdBuffer = mockedSubmissionsAggregator->peekCommandBuffers().peekHead(); + ASSERT_NE(nullptr, cmdBuffer->epiloguePipeControlLocation); + auto pipeControl = genCmdCast(cmdBuffer->epiloguePipeControlLocation); + ASSERT_NE(nullptr, pipeControl); + mockCsr->flushBatchedSubmissions(); + EXPECT_FALSE(pipeControl->getDcFlushEnable()); +} + HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeAndOoqFlagSetToFalseWhenTwoTasksArePassedWithTheSameLevelThenThereIsPipeControlBetweenThemAfterFlush) { CommandQueueHw commandQueue(nullptr, pDevice, 0); diff --git a/unit_tests/test_files/igdrcl.config b/unit_tests/test_files/igdrcl.config index 102f74919937e..272378f0ca837 100644 --- a/unit_tests/test_files/igdrcl.config +++ b/unit_tests/test_files/igdrcl.config @@ -106,3 +106,4 @@ AUBDumpAllocsOnEnqueueReadOnly = 0 AUBDumpForceAllToLocalMemory = 0 EnableCacheFlushAfterWalker = 0 EnableHostPtrTracking = 1 +DisableDcFlushInEpilogue = 0