From 118bad16dfe523724dfaf8016bfa6fbe6896348b Mon Sep 17 00:00:00 2001 From: "Dunajski, Bartosz" Date: Thu, 30 Aug 2018 11:05:18 +0200 Subject: [PATCH] Dont add PIPE_CONTROL between Walkers for TimestampPacket writes Change-Id: I6216a0926678c7f7a997cb37ce4eb59f914b518e Signed-off-by: Dunajski, Bartosz --- .../command_stream_receiver_hw.inl | 10 +++- ...mmand_stream_receiver_flush_task_tests.cpp | 57 +++++++++++++++++++ 2 files changed, 64 insertions(+), 3 deletions(-) diff --git a/runtime/command_stream/command_stream_receiver_hw.inl b/runtime/command_stream/command_stream_receiver_hw.inl index 014c2adff6..d2bbaae908 100644 --- a/runtime/command_stream/command_stream_receiver_hw.inl +++ b/runtime/command_stream/command_stream_receiver_hw.inl @@ -175,7 +175,8 @@ CompletionStamp CommandStreamReceiverHw::flushTask( epiloguePipeControlLocation = ptrOffset(commandStreamTask.getCpuBase(), commandStreamTask.getUsed()); - if (dispatchFlags.outOfOrderExecutionAllowed && !dispatchFlags.dcFlush) { + if ((dispatchFlags.outOfOrderExecutionAllowed || DebugManager.flags.EnableTimestampPacket.get()) && + !dispatchFlags.dcFlush) { currentPipeControlForNooping = epiloguePipeControlLocation; } @@ -348,7 +349,9 @@ CompletionStamp CommandStreamReceiverHw::flushTask( // Add a PC if we have a dependency on a previous walker to avoid concurrency issues. if (taskLevel > this->taskLevel) { - addPipeControl(commandStreamCSR, false); + if (!DebugManager.flags.EnableTimestampPacket.get()) { + addPipeControl(commandStreamCSR, false); + } this->taskLevel = taskLevel; DBG_LOG(LogTaskCounts, __FUNCTION__, "Line: ", __LINE__, "this->taskCount", this->taskCount); } @@ -615,7 +618,8 @@ size_t CommandStreamReceiverHw::getRequiredCmdStreamSizeAligned(const return alignUp(size, MemoryConstants::cacheLineSize); } -template size_t CommandStreamReceiverHw::getRequiredStateBaseAddressSize() const { +template +size_t CommandStreamReceiverHw::getRequiredStateBaseAddressSize() const { return sizeof(typename GfxFamily::STATE_BASE_ADDRESS) + sizeof(PIPE_CONTROL); } diff --git a/unit_tests/command_stream/command_stream_receiver_flush_task_tests.cpp b/unit_tests/command_stream/command_stream_receiver_flush_task_tests.cpp index 7e12f5c544..5e98705b3b 100644 --- a/unit_tests/command_stream/command_stream_receiver_flush_task_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_flush_task_tests.cpp @@ -297,6 +297,23 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, higherTaskLevelShouldSendAPipeCont EXPECT_NE(cmdList.end(), itorPC); } +HWTEST_F(CommandStreamReceiverFlushTaskTests, givenHigherTaskLevelWhenDebugVariableIsEnabledThenDontAddPipeControl) { + DebugManagerStateRestore restore; + DebugManager.flags.EnableTimestampPacket.set(true); + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + commandStreamReceiver.isPreambleSent = true; + configureCSRtoNonDirtyState(); + commandStreamReceiver.taskLevel = taskLevel; + taskLevel++; // submit with higher taskLevel + + flushTask(commandStreamReceiver); + + parseCommands(commandStreamReceiver.commandStream, 0); + + auto itorPC = find(cmdList.begin(), cmdList.end()); + EXPECT_EQ(cmdList.end(), itorPC); +} + HWTEST_F(CommandStreamReceiverFlushTaskTests, whenSamplerCacheFlushNotRequiredThenDontSendPipecontrol) { auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); OCLRT::WorkaroundTable *waTable = nullptr; @@ -2902,6 +2919,46 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenCsrInBatch EXPECT_NE(itorPipeControl, itorBatchBufferStartSecond); } +HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeAndOoqFlagSetToFalseWhenDebugVariableIsSetThenNoopPipeControl) { + DebugManagerStateRestore restore; + 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; + + auto taskLevelPriorToSubmission = mockCsr->peekTaskLevel(); + + DebugManager.flags.EnableTimestampPacket.set(false); + mockCsr->flushTask(commandStream, 0, dsh, ioh, ssh, taskLevelPriorToSubmission, dispatchFlags, *pDevice); + mockCsr->flushTask(commandStream, 0, dsh, ioh, ssh, taskLevelPriorToSubmission, dispatchFlags, *pDevice); + + auto firstCmdBuffer = mockedSubmissionsAggregator->peekCommandBuffers().peekHead(); + EXPECT_EQ(nullptr, firstCmdBuffer->pipeControlThatMayBeErasedLocation); + auto secondCmdBuffer = firstCmdBuffer->next; + EXPECT_EQ(nullptr, secondCmdBuffer->pipeControlThatMayBeErasedLocation); + + mockCsr->flushBatchedSubmissions(); + + DebugManager.flags.EnableTimestampPacket.set(true); + mockCsr->flushTask(commandStream, 0, dsh, ioh, ssh, taskLevelPriorToSubmission, dispatchFlags, *pDevice); + mockCsr->flushTask(commandStream, 0, dsh, ioh, ssh, taskLevelPriorToSubmission, dispatchFlags, *pDevice); + + firstCmdBuffer = mockedSubmissionsAggregator->peekCommandBuffers().peekHead(); + EXPECT_NE(nullptr, firstCmdBuffer->pipeControlThatMayBeErasedLocation); + secondCmdBuffer = firstCmdBuffer->next; + EXPECT_NE(nullptr, secondCmdBuffer->pipeControlThatMayBeErasedLocation); +} + HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenPipeControlForNoopAddressIsNullThenPipeControlIsNotNooped) { CommandQueueHw commandQueue(nullptr, pDevice, 0); auto &commandStream = commandQueue.getCS(4096u);