From b6e3817f31e88cc9092cf94f57fabb6eb5574761 Mon Sep 17 00:00:00 2001 From: Bartosz Dunajski Date: Wed, 31 Mar 2021 13:46:34 +0000 Subject: [PATCH] Dont program dcFlush when not allowed Signed-off-by: Bartosz Dunajski --- .../core/source/cmdqueue/cmdqueue_hw_base.inl | 13 ++++------ .../sources/cmdlist/test_cmdlist_2.cpp | 8 +++--- .../test_cmdlist_append_event_reset.cpp | 2 +- .../test_cmdlist_append_signal_event.cpp | 2 +- .../test_cmdlist_append_wait_on_events.cpp | 4 +-- .../command_queue/dispatch_walker_tests.cpp | 4 +-- .../command_queue/enqueue_kernel_1_tests.cpp | 26 +++++++++++-------- ...and_stream_receiver_flush_task_1_tests.cpp | 8 +++--- ...and_stream_receiver_flush_task_2_tests.cpp | 6 ++--- ...and_stream_receiver_flush_task_3_tests.cpp | 8 +++--- .../unit_test/helpers/hw_helper_tests.cpp | 23 +++++++++++++++- .../unit_test/mem_obj/buffer_bcs_tests.cpp | 4 +-- .../command_stream_receiver_hw_base.inl | 3 ++- shared/source/helpers/hw_helper.h | 2 ++ shared/source/helpers/hw_helper_base.inl | 10 ++++++- 15 files changed, 78 insertions(+), 45 deletions(-) diff --git a/level_zero/core/source/cmdqueue/cmdqueue_hw_base.inl b/level_zero/core/source/cmdqueue/cmdqueue_hw_base.inl index f8b7b9cfc3..34a45332fd 100644 --- a/level_zero/core/source/cmdqueue/cmdqueue_hw_base.inl +++ b/level_zero/core/source/cmdqueue/cmdqueue_hw_base.inl @@ -12,6 +12,7 @@ #include "shared/source/command_stream/linear_stream.h" #include "shared/source/device/device.h" #include "shared/source/helpers/api_specific_config.h" +#include "shared/source/helpers/hw_helper.h" #include "shared/source/helpers/hw_info.h" #include "shared/source/helpers/interlocked_max.h" #include "shared/source/helpers/preamble.h" @@ -32,16 +33,12 @@ template void CommandQueueHw::programStateBaseAddress(uint64_t gsba, bool useLocalMemoryForIndirectHeap, NEO::LinearStream &commandStream) { using GfxFamily = typename NEO::GfxFamilyMapper::GfxFamily; using STATE_BASE_ADDRESS = typename GfxFamily::STATE_BASE_ADDRESS; - using PIPE_CONTROL = typename GfxFamily::PIPE_CONTROL; - PIPE_CONTROL *pcCmd = commandStream.getSpaceForCmd(); - PIPE_CONTROL cmd = GfxFamily::cmdInitPipeControl; + NEO::PipeControlArgs pcArgs; + pcArgs.dcFlushEnable = true; + pcArgs.textureCacheInvalidationEnable = true; - cmd.setTextureCacheInvalidationEnable(true); - cmd.setDcFlushEnable(true); - cmd.setCommandStreamerStallEnable(true); - - *pcCmd = cmd; + NEO::MemorySynchronizationCommands::addPipeControl(commandStream, pcArgs); NEO::Device *neoDevice = device->getNEODevice(); auto &hwInfo = neoDevice->getHardwareInfo(); diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_2.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_2.cpp index 2932135946..76dc0963d8 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_2.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_2.cpp @@ -403,7 +403,7 @@ HWTEST2_F(AppendMemoryCopy, givenCommandListAndHostPointersWhenMemoryCopyRegionC cmd = genCmdCast(*itor); itor = find(++itor, genCmdList.end()); } - EXPECT_TRUE(cmd->getDcFlushEnable()); + EXPECT_EQ(MemorySynchronizationCommands::isDcFlushAllowed(), cmd->getDcFlushEnable()); } HWTEST2_F(AppendMemoryCopy, givenCommandListAndHostPointersWhenMemoryCopyCalledThenPipeControlWithDcFlushAdded, Platforms) { @@ -426,7 +426,7 @@ HWTEST2_F(AppendMemoryCopy, givenCommandListAndHostPointersWhenMemoryCopyCalledT cmd = genCmdCast(*itor); itor = find(++itor, genCmdList.end()); } - EXPECT_TRUE(cmd->getDcFlushEnable()); + EXPECT_EQ(MemorySynchronizationCommands::isDcFlushAllowed(), cmd->getDcFlushEnable()); } HWTEST2_F(CommandListCreate, givenCommandListAnd2DWhbufferenMemoryCopyRegionCalledThenCopyKernel2DCalled, Platforms) { @@ -596,7 +596,7 @@ HWTEST2_F(CommandListCreate, givenCommandListWhenMemoryCopyWithSignalEventScopeS auto it = *(iterator.end() - 1); auto cmd1 = genCmdCast(*it); - EXPECT_TRUE(cmd1->getDcFlushEnable()); + EXPECT_EQ(MemorySynchronizationCommands::isDcFlushAllowed(), cmd1->getDcFlushEnable()); } using ImageSupport = IsWithinProducts; @@ -1234,7 +1234,7 @@ HWTEST2_F(CommandListCreate, givenCommandListWhenTimestampPassedToMemoryCopyThen EXPECT_NE(cmdList.end(), itor); { auto cmd = genCmdCast(*itor); - EXPECT_TRUE(cmd->getDcFlushEnable()); + EXPECT_EQ(MemorySynchronizationCommands::isDcFlushAllowed(), cmd->getDcFlushEnable()); } } } // namespace ult diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_event_reset.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_event_reset.cpp index 459318f986..2c07fa62d8 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_event_reset.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_event_reset.cpp @@ -196,7 +196,7 @@ HWTEST2_F(CommandListAppendEventReset, givenEventWithHostScopeUsedInResetThenPip EXPECT_TRUE(cmd->getCommandStreamerStallEnable()); EXPECT_EQ(cmd->getAddressHigh(), gpuAddress >> 32u); EXPECT_EQ(cmd->getAddress(), uint32_t(gpuAddress)); - EXPECT_TRUE(cmd->getDcFlushEnable()); + EXPECT_EQ(MemorySynchronizationCommands::isDcFlushAllowed(), cmd->getDcFlushEnable()); postSyncFound = true; } } diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_signal_event.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_signal_event.cpp index 3e99f51f5c..31f88fd5a1 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_signal_event.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_signal_event.cpp @@ -132,7 +132,7 @@ HWTEST_F(CommandListAppendSignalEvent, givenEventWithScopeFlagDeviceWhenAppendin if (cmd->getPostSyncOperation() == POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA) { EXPECT_EQ(cmd->getImmediateData(), Event::STATE_SIGNALED); EXPECT_TRUE(cmd->getCommandStreamerStallEnable()); - EXPECT_TRUE(cmd->getDcFlushEnable()); + EXPECT_EQ(MemorySynchronizationCommands::isDcFlushAllowed(), cmd->getDcFlushEnable()); postSyncFound = true; } } diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_wait_on_events.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_wait_on_events.cpp index 40bf629263..95a7149702 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_wait_on_events.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_wait_on_events.cpp @@ -132,7 +132,7 @@ HWTEST_F(CommandListAppendWaitOnEvent, givenEventWithWaitScopeFlagDeviceWhenAppe ASSERT_NE(cmd, nullptr); EXPECT_TRUE(cmd->getCommandStreamerStallEnable()); - EXPECT_TRUE(cmd->getDcFlushEnable()); + EXPECT_EQ(MemorySynchronizationCommands::isDcFlushAllowed(), cmd->getDcFlushEnable()); } } @@ -188,4 +188,4 @@ HWTEST2_F(CommandListAppendWaitOnEvent, givenCommandListWhenAppendWriteGlobalTim } } // namespace ult -} // namespace L0 \ No newline at end of file +} // namespace L0 diff --git a/opencl/test/unit_test/command_queue/dispatch_walker_tests.cpp b/opencl/test/unit_test/command_queue/dispatch_walker_tests.cpp index f573410d28..957d09e983 100644 --- a/opencl/test/unit_test/command_queue/dispatch_walker_tests.cpp +++ b/opencl/test/unit_test/command_queue/dispatch_walker_tests.cpp @@ -1369,7 +1369,7 @@ HWTEST_P(DispatchWalkerTestForAuxTranslation, givenKernelWhenAuxToNonAuxWhenTran ASSERT_EQ(2u, pipeControls.size()); auto beginPipeControl = genCmdCast(*(pipeControls[0])); - EXPECT_TRUE(beginPipeControl->getDcFlushEnable()); + EXPECT_EQ(MemorySynchronizationCommands::isDcFlushAllowed(), beginPipeControl->getDcFlushEnable()); EXPECT_TRUE(beginPipeControl->getCommandStreamerStallEnable()); auto endPipeControl = genCmdCast(*(pipeControls[1])); @@ -1425,7 +1425,7 @@ HWTEST_P(DispatchWalkerTestForAuxTranslation, givenKernelWhenNonAuxToAuxWhenTran bool dcFlushRequired = (pClDevice->getHardwareInfo().platform.eRenderCoreFamily == IGFX_GEN8_CORE); auto beginPipeControl = genCmdCast(*(pipeControls[0])); - EXPECT_TRUE(beginPipeControl->getDcFlushEnable()); + EXPECT_EQ(MemorySynchronizationCommands::isDcFlushAllowed(), beginPipeControl->getDcFlushEnable()); EXPECT_TRUE(beginPipeControl->getCommandStreamerStallEnable()); auto endPipeControl = genCmdCast(*(pipeControls[1])); diff --git a/opencl/test/unit_test/command_queue/enqueue_kernel_1_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_kernel_1_tests.cpp index 88d75d3693..4ea6e77ce2 100644 --- a/opencl/test/unit_test/command_queue/enqueue_kernel_1_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_kernel_1_tests.cpp @@ -1415,8 +1415,10 @@ struct PauseOnGpuTests : public EnqueueKernelTest { return false; } - template + template bool verifyPipeControl(const GenCmdList::iterator &iterator, uint64_t debugPauseStateAddress, DebugPauseState requiredDebugPauseState) { + using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; + auto pipeControlCmd = genCmdCast(*iterator); if ((static_cast(requiredDebugPauseState) == pipeControlCmd->getImmediateData()) && @@ -1424,7 +1426,8 @@ struct PauseOnGpuTests : public EnqueueKernelTest { (static_cast(debugPauseStateAddress >> 32) == pipeControlCmd->getAddressHigh())) { EXPECT_TRUE(pipeControlCmd->getCommandStreamerStallEnable()); - EXPECT_TRUE(pipeControlCmd->getDcFlushEnable()); + + EXPECT_EQ(MemorySynchronizationCommands::isDcFlushAllowed(), pipeControlCmd->getDcFlushEnable()); EXPECT_EQ(PIPE_CONTROL::POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA, pipeControlCmd->getPostSyncOperation()); @@ -1466,16 +1469,17 @@ struct PauseOnGpuTests : public EnqueueKernelTest { } } - template + template void findPipeControls(GenCmdList &cmdList) { + using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; auto pipeControl = find(cmdList.begin(), cmdList.end()); while (pipeControl != cmdList.end()) { - if (verifyPipeControl(pipeControl, debugPauseStateAddress, DebugPauseState::waitingForUserStartConfirmation)) { + if (verifyPipeControl(pipeControl, debugPauseStateAddress, DebugPauseState::waitingForUserStartConfirmation)) { pipeControlBeforeWalkerFound++; } - if (verifyPipeControl(pipeControl, debugPauseStateAddress, DebugPauseState::waitingForUserEndConfirmation)) { + if (verifyPipeControl(pipeControl, debugPauseStateAddress, DebugPauseState::waitingForUserEndConfirmation)) { pipeControlAfterWalkerFound++; } @@ -1530,7 +1534,7 @@ HWTEST_F(PauseOnGpuTests, givenPauseOnEnqueueFlagSetWhenDispatchWalkersThenInser EXPECT_EQ(1u, semaphoreBeforeWalkerFound); EXPECT_EQ(1u, semaphoreAfterWalkerFound); - findPipeControls(hwParser.cmdList); + findPipeControls(hwParser.cmdList); EXPECT_EQ(1u, pipeControlBeforeWalkerFound); EXPECT_EQ(1u, pipeControlAfterWalkerFound); @@ -1552,7 +1556,7 @@ HWTEST_F(PauseOnGpuTests, givenPauseOnEnqueueFlagSetToMinusTwoWhenDispatchWalker findSemaphores(hwParser.cmdList); - findPipeControls(hwParser.cmdList); + findPipeControls(hwParser.cmdList); EXPECT_EQ(2u, semaphoreBeforeWalkerFound); EXPECT_EQ(2u, semaphoreAfterWalkerFound); @@ -1576,7 +1580,7 @@ HWTEST_F(PauseOnGpuTests, givenPauseModeSetToBeforeOnlyWhenDispatchingThenInsert findSemaphores(hwParser.cmdList); - findPipeControls(hwParser.cmdList); + findPipeControls(hwParser.cmdList); EXPECT_EQ(1u, semaphoreBeforeWalkerFound); EXPECT_EQ(0u, semaphoreAfterWalkerFound); @@ -1600,7 +1604,7 @@ HWTEST_F(PauseOnGpuTests, givenPauseModeSetToAfterOnlyWhenDispatchingThenInsertP findSemaphores(hwParser.cmdList); - findPipeControls(hwParser.cmdList); + findPipeControls(hwParser.cmdList); EXPECT_EQ(0u, semaphoreBeforeWalkerFound); EXPECT_EQ(1u, semaphoreAfterWalkerFound); @@ -1624,7 +1628,7 @@ HWTEST_F(PauseOnGpuTests, givenPauseModeSetToBeforeAndAfterWhenDispatchingThenIn findSemaphores(hwParser.cmdList); - findPipeControls(hwParser.cmdList); + findPipeControls(hwParser.cmdList); EXPECT_EQ(1u, semaphoreBeforeWalkerFound); EXPECT_EQ(1u, semaphoreAfterWalkerFound); @@ -1649,7 +1653,7 @@ HWTEST_F(PauseOnGpuTests, givenPauseOnEnqueueFlagSetWhenDispatchWalkersThenDontI findSemaphores(hwParser.cmdList); - findPipeControls(hwParser.cmdList); + findPipeControls(hwParser.cmdList); EXPECT_EQ(0u, semaphoreBeforeWalkerFound); EXPECT_EQ(0u, semaphoreAfterWalkerFound); diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_1_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_1_tests.cpp index 88e2c299ca..768e6822c5 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_1_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_1_tests.cpp @@ -545,7 +545,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenStateBaseAddressWhenItIsRequi EXPECT_NE(stateBaseAddressItor, pipeControlItor); auto pipeControlCmd = (typename FamilyType::PIPE_CONTROL *)*pipeControlItor; EXPECT_TRUE(pipeControlCmd->getTextureCacheInvalidationEnable()); - EXPECT_TRUE(pipeControlCmd->getDcFlushEnable()); + EXPECT_EQ(MemorySynchronizationCommands::isDcFlushAllowed(), pipeControlCmd->getDcFlushEnable()); } HWTEST_F(CommandStreamReceiverFlushTaskTests, givenNotApplicableL3ConfigWhenFlushingTaskThenDontReloadSba) { @@ -1185,11 +1185,11 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, GivenBlockingWh // Verify that the dcFlushEnabled bit is not set in PC auto pCmd = reinterpret_cast(pipeControlTask); - EXPECT_TRUE(pCmd->getDcFlushEnable()); + EXPECT_EQ(MemorySynchronizationCommands::isDcFlushAllowed(), pCmd->getDcFlushEnable()); } } else { auto pCmd = reinterpret_cast(*itorPC); - EXPECT_TRUE(pCmd->getDcFlushEnable()); + EXPECT_EQ(MemorySynchronizationCommands::isDcFlushAllowed(), pCmd->getDcFlushEnable()); } } @@ -1233,7 +1233,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, GivenBlockedKernelRequiringDCFlush // Verify that the dcFlushEnabled bit is set in PC auto pCmdWA = reinterpret_cast(*itorPC); - EXPECT_TRUE(pCmdWA->getDcFlushEnable()); + EXPECT_EQ(MemorySynchronizationCommands::isDcFlushAllowed(), pCmdWA->getDcFlushEnable()); buffer->release(); } diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_2_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_2_tests.cpp index 46f1c06933..5a2ea79869 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_2_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_2_tests.cpp @@ -74,7 +74,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, GivenBlockedKernelNotRequiringDCFl // Verify that the dcFlushEnabled bit is set in PC auto pCmdWA = reinterpret_cast(*itorPC); - EXPECT_TRUE(pCmdWA->getDcFlushEnable()); + EXPECT_EQ(MemorySynchronizationCommands::isDcFlushAllowed(), pCmdWA->getDcFlushEnable()); buffer->release(); } @@ -347,10 +347,10 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, EXPECT_NE(cmdList.end(), itorCmdP); auto itorCmd2 = find(itorCmdP, cmdList.end()); cmdPC = (PIPE_CONTROL *)*itorCmd2; - EXPECT_TRUE(cmdPC->getDcFlushEnable()); + EXPECT_EQ(MemorySynchronizationCommands::isDcFlushAllowed(), cmdPC->getDcFlushEnable()); } else { // single PIPE_CONTROL following GPGPU_WALKER has DcFlush and Write HwTag - EXPECT_TRUE(cmdPC->getDcFlushEnable()); + EXPECT_EQ(MemorySynchronizationCommands::isDcFlushAllowed(), cmdPC->getDcFlushEnable()); } retVal = clReleaseEvent(event); 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 d5ad1dd8db..31d12b4b84 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 @@ -952,7 +952,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenCommandA auto pipeControl = genCmdCast(*itorPipeControl); mockCsr->flushBatchedSubmissions(); - EXPECT_TRUE(pipeControl->getDcFlushEnable()); + EXPECT_EQ(MemorySynchronizationCommands::isDcFlushAllowed(), pipeControl->getDcFlushEnable()); } HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWithOutOfOrderModeFisabledWhenCommandAreSubmittedThenDcFlushIsAdded) { @@ -984,7 +984,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWithOutOfOrd auto pipeControl = genCmdCast(*itorPipeControl); mockCsr->flushBatchedSubmissions(); - EXPECT_TRUE(pipeControl->getDcFlushEnable()); + EXPECT_EQ(MemorySynchronizationCommands::isDcFlushAllowed(), pipeControl->getDcFlushEnable()); } HWTEST_F(CommandStreamReceiverFlushTaskTests, givenUpdateTaskCountFromWaitSetWhenFlushTaskThenThereIsNoPipeControlForUpdateTaskCount) { @@ -1136,7 +1136,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenEpiloguePipeControlThenDcFlus auto pipeControl = genCmdCast(cmdBuffer->epiloguePipeControlLocation); ASSERT_NE(nullptr, pipeControl); mockCsr->flushBatchedSubmissions(); - EXPECT_TRUE(pipeControl->getDcFlushEnable()); + EXPECT_EQ(MemorySynchronizationCommands::isDcFlushAllowed(), pipeControl->getDcFlushEnable()); } HWTEST_F(CommandStreamReceiverFlushTaskTests, givenEpiloguePipeControlWhendDcFlushDisabledByDebugFlagThenDcFlushIsDisabled) { @@ -1742,7 +1742,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenDcFlushArgumentIsTrueWhenCall PIPE_CONTROL *pipeControl = genCmdCast(buffer.get()); ASSERT_NE(nullptr, pipeControl); - EXPECT_TRUE(pipeControl->getDcFlushEnable()); + EXPECT_EQ(MemorySynchronizationCommands::isDcFlushAllowed(), pipeControl->getDcFlushEnable()); EXPECT_TRUE(pipeControl->getCommandStreamerStallEnable()); } diff --git a/opencl/test/unit_test/helpers/hw_helper_tests.cpp b/opencl/test/unit_test/helpers/hw_helper_tests.cpp index cfde22904a..1861b099c4 100644 --- a/opencl/test/unit_test/helpers/hw_helper_tests.cpp +++ b/opencl/test/unit_test/helpers/hw_helper_tests.cpp @@ -279,6 +279,27 @@ HWTEST_F(PipeControlHelperTests, givenPostSyncWriteTimestampModeWhenHelperIsUsed EXPECT_TRUE(memcmp(pipeControl, &expectedPipeControl, sizeof(PIPE_CONTROL)) == 0); } +HWTEST_F(PipeControlHelperTests, givenHwHelperwhenAskingForDcFlushThenReturnTrue) { + EXPECT_TRUE(MemorySynchronizationCommands::isDcFlushAllowed()); +} + +HWTEST_F(PipeControlHelperTests, givenDcFlushNotAllowedWhenProgrammingPipeControlThenDontSetDcFlush) { + using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; + std::unique_ptr buffer(new uint8_t[128]); + + LinearStream stream(buffer.get(), 128); + + PipeControlArgs args; + args.dcFlushEnable = true; + + MemorySynchronizationCommands::addPipeControl(stream, args); + + auto pipeControl = genCmdCast(stream.getCpuBase()); + ASSERT_NE(nullptr, pipeControl); + + EXPECT_EQ(MemorySynchronizationCommands::isDcFlushAllowed(), pipeControl->getDcFlushEnable()); +} + HWTEST_F(PipeControlHelperTests, givenPostSyncWriteImmediateDataModeWhenHelperIsUsedThenProperFieldsAreProgrammed) { using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; std::unique_ptr buffer(new uint8_t[128]); @@ -1007,7 +1028,7 @@ HWTEST_F(PipeControlHelperTests, WhenProgrammingCacheFlushThenExpectBasicFieldsS ASSERT_NE(nullptr, pipeControl); EXPECT_TRUE(pipeControl->getCommandStreamerStallEnable()); - EXPECT_TRUE(pipeControl->getDcFlushEnable()); + EXPECT_EQ(MemorySynchronizationCommands::isDcFlushAllowed(), pipeControl->getDcFlushEnable()); EXPECT_TRUE(pipeControl->getRenderTargetCacheFlushEnable()); EXPECT_TRUE(pipeControl->getInstructionCacheInvalidateEnable()); diff --git a/opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp b/opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp index 39e860a816..d98005cb0c 100644 --- a/opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp +++ b/opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp @@ -612,7 +612,7 @@ void BcsBufferTests::waitForCacheFlushFromBcsTest(MockCommandQueueHw uint64_t addressLow = pipeControlCmd->getAddress(); cacheFlushWriteAddress = addressHigh | addressLow; if (cacheFlushWriteAddress != 0) { - EXPECT_TRUE(pipeControlCmd->getDcFlushEnable()); + EXPECT_EQ(MemorySynchronizationCommands::isDcFlushAllowed(), pipeControlCmd->getDcFlushEnable()); EXPECT_TRUE(pipeControlCmd->getCommandStreamerStallEnable()); EXPECT_EQ(isCacheFlushForBcsRequired, 0u == pipeControlCmd->getImmediateData()); break; @@ -728,7 +728,7 @@ HWTEST_TEMPLATED_F(BcsBufferTests, givenBarrierWhenReleasingMultipleBlockedEnque stallingPipeControlFound = true; EXPECT_TRUE(pipeControlCmd->getCommandStreamerStallEnable()); - EXPECT_TRUE(pipeControlCmd->getDcFlushEnable()); + EXPECT_EQ(MemorySynchronizationCommands::isDcFlushAllowed(), pipeControlCmd->getDcFlushEnable()); break; } } 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 dbf4c68a9f..c2f7351dcf 100644 --- a/shared/source/command_stream/command_stream_receiver_hw_base.inl +++ b/shared/source/command_stream/command_stream_receiver_hw_base.inl @@ -739,7 +739,8 @@ inline bool CommandStreamReceiverHw::flushBatchedSubmissions() { //make sure we flush DC if needed if (epiloguePipeControlLocation) { - bool flushDcInEpilogue = true; + bool flushDcInEpilogue = MemorySynchronizationCommands::isDcFlushAllowed(); + if (DebugManager.flags.DisableDcFlushInEpilogue.get()) { flushDcInEpilogue = false; } diff --git a/shared/source/helpers/hw_helper.h b/shared/source/helpers/hw_helper.h index 570937a5eb..252901c6ed 100644 --- a/shared/source/helpers/hw_helper.h +++ b/shared/source/helpers/hw_helper.h @@ -401,6 +401,8 @@ struct MemorySynchronizationCommands { static void addPipeControl(LinearStream &commandStream, PipeControlArgs &args); static void addPipeControlWithCSStallOnly(LinearStream &commandStream, PipeControlArgs &args); + static bool isDcFlushAllowed(); + static void addFullCacheFlush(LinearStream &commandStream); static void setCacheFlushExtraProperties(PipeControlArgs &args); diff --git a/shared/source/helpers/hw_helper_base.inl b/shared/source/helpers/hw_helper_base.inl index a3b4ecc069..d3e980624c 100644 --- a/shared/source/helpers/hw_helper_base.inl +++ b/shared/source/helpers/hw_helper_base.inl @@ -234,7 +234,6 @@ void MemorySynchronizationCommands::addPipeControlWithPostSync( template void MemorySynchronizationCommands::setPipeControl(typename GfxFamily::PIPE_CONTROL &pipeControl, PipeControlArgs &args) { pipeControl.setCommandStreamerStallEnable(true); - pipeControl.setDcFlushEnable(args.dcFlushEnable); pipeControl.setConstantCacheInvalidationEnable(args.constantCacheInvalidationEnable); pipeControl.setInstructionCacheInvalidateEnable(args.instructionCacheInvalidateEnable); pipeControl.setPipeControlFlushEnable(args.pipeControlFlushEnable); @@ -245,6 +244,10 @@ void MemorySynchronizationCommands::setPipeControl(typename GfxFamily pipeControl.setGenericMediaStateClear(args.genericMediaStateClear); pipeControl.setTlbInvalidate(args.tlbInvalidation); + if (isDcFlushAllowed()) { + pipeControl.setDcFlushEnable(args.dcFlushEnable); + } + setPipeControlExtraProperties(pipeControl, args); if (DebugManager.flags.FlushAllCaches.get()) { @@ -270,6 +273,11 @@ void MemorySynchronizationCommands::setPipeControl(typename GfxFamily } } +template +bool MemorySynchronizationCommands::isDcFlushAllowed() { + return true; +} + template void MemorySynchronizationCommands::addPipeControl(LinearStream &commandStream, PipeControlArgs &args) { using PIPE_CONTROL = typename GfxFamily::PIPE_CONTROL;