Skip to content

Commit 5af3a46

Browse files
Add debug flag to disable cache flush
Related-To: NEO-5144 Change-Id: I29590d840a641dfcf3fc4d099ca84f196c8fdc1f Signed-off-by: Zbigniew Zdanowicz <[email protected]>
1 parent 78feb47 commit 5af3a46

File tree

10 files changed

+129
-19
lines changed

10 files changed

+129
-19
lines changed

opencl/source/helpers/hardware_commands_helper_bdw_plus.inl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include "opencl/source/helpers/hardware_commands_helper.h"
1212
#include "opencl/source/kernel/kernel.h"
1313

14+
#include "pipe_control_args.h"
15+
1416
namespace NEO {
1517

1618
template <typename GfxFamily>
@@ -153,12 +155,8 @@ void HardwareCommandsHelper<GfxFamily>::setInterfaceDescriptorOffset(
153155

154156
template <typename GfxFamily>
155157
void HardwareCommandsHelper<GfxFamily>::programCacheFlushAfterWalkerCommand(LinearStream *commandStream, const CommandQueue &commandQueue, const Kernel *kernel, uint64_t postSyncAddress) {
156-
using PIPE_CONTROL = typename GfxFamily::PIPE_CONTROL;
157-
auto pipeControl = commandStream->getSpaceForCmd<PIPE_CONTROL>();
158-
PIPE_CONTROL cmd = GfxFamily::cmdInitPipeControl;
159-
cmd.setCommandStreamerStallEnable(true);
160-
cmd.setDcFlushEnable(true);
161-
*pipeControl = cmd;
158+
PipeControlArgs args(true);
159+
MemorySynchronizationCommands<GfxFamily>::addPipeControl(*commandStream, args);
162160
}
163161

164162
} // namespace NEO

opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_2_tests.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,46 @@ HWTEST_F(UltCommandStreamReceiverTest, addPipeControlWithFlushAllCaches) {
894894
EXPECT_TRUE(pipeControl->getStateCacheInvalidationEnable());
895895
}
896896

897+
HWTEST_F(UltCommandStreamReceiverTest, givenDebugDisablingCacheFlushWhenAddingPipeControlWithCacheFlushThenOverrideRequestAndDisableCacheFlushFlags) {
898+
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
899+
DebugManagerStateRestore dbgRestorer;
900+
DebugManager.flags.DoNotFlushCaches.set(true);
901+
902+
char buff[sizeof(PIPE_CONTROL) * 3];
903+
LinearStream stream(buff, sizeof(PIPE_CONTROL) * 3);
904+
905+
PipeControlArgs args(true);
906+
args.constantCacheInvalidationEnable = true;
907+
args.instructionCacheInvalidateEnable = true;
908+
args.pipeControlFlushEnable = true;
909+
args.renderTargetCacheFlushEnable = true;
910+
args.stateCacheInvalidationEnable = true;
911+
args.textureCacheInvalidationEnable = true;
912+
args.vfCacheInvalidationEnable = true;
913+
914+
MemorySynchronizationCommands<FamilyType>::addPipeControl(stream, args);
915+
916+
parseCommands<FamilyType>(stream, 0);
917+
918+
PIPE_CONTROL *pipeControl = getCommand<PIPE_CONTROL>();
919+
920+
ASSERT_NE(nullptr, pipeControl);
921+
922+
// WA pipeControl added
923+
if (cmdList.size() == 2) {
924+
pipeControl++;
925+
}
926+
927+
EXPECT_FALSE(pipeControl->getDcFlushEnable());
928+
EXPECT_FALSE(pipeControl->getRenderTargetCacheFlushEnable());
929+
EXPECT_FALSE(pipeControl->getInstructionCacheInvalidateEnable());
930+
EXPECT_FALSE(pipeControl->getTextureCacheInvalidationEnable());
931+
EXPECT_FALSE(pipeControl->getPipeControlFlushEnable());
932+
EXPECT_FALSE(pipeControl->getVfCacheInvalidationEnable());
933+
EXPECT_FALSE(pipeControl->getConstantCacheInvalidationEnable());
934+
EXPECT_FALSE(pipeControl->getStateCacheInvalidationEnable());
935+
}
936+
897937
HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenEnabledPreemptionWhenFlushTaskCalledThenDontProgramMediaVfeStateAgain) {
898938
pDevice->setPreemptionMode(PreemptionMode::ThreadGroup);
899939
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();

opencl/test/unit_test/gen12lp/command_stream_receiver_hw_tests_gen12lp.inl

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,56 @@ GEN12LPTEST_F(UltCommandStreamReceiverTest, givenStateBaseAddressWhenItIsRequire
7272
EXPECT_TRUE(pipeControlCmd->getDcFlushEnable());
7373
EXPECT_TRUE(pipeControlCmd->getHdcPipelineFlush());
7474
}
75+
76+
using UltCommandStreamReceiverTestGen12Lp = UltCommandStreamReceiverTest;
77+
78+
GEN12LPTEST_F(UltCommandStreamReceiverTestGen12Lp, givenDebugEnablingCacheFlushWhenAddingPipeControlWithoutCacheFlushThenOverrideRequestAndEnableCacheFlushFlags) {
79+
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
80+
DebugManagerStateRestore dbgRestorer;
81+
DebugManager.flags.FlushAllCaches.set(true);
82+
83+
char buff[sizeof(PIPE_CONTROL) * 3];
84+
LinearStream stream(buff, sizeof(PIPE_CONTROL) * 3);
85+
86+
PipeControlArgs args;
87+
MemorySynchronizationCommands<FamilyType>::addPipeControl(stream, args);
88+
89+
parseCommands<FamilyType>(stream, 0);
90+
91+
PIPE_CONTROL *pipeControl = getCommand<PIPE_CONTROL>();
92+
93+
ASSERT_NE(nullptr, pipeControl);
94+
95+
// WA pipeControl added
96+
if (cmdList.size() == 2) {
97+
pipeControl++;
98+
}
99+
100+
EXPECT_TRUE(pipeControl->getHdcPipelineFlush());
101+
}
102+
103+
GEN12LPTEST_F(UltCommandStreamReceiverTestGen12Lp, givenDebugDisablingCacheFlushWhenAddingPipeControlWithCacheFlushThenOverrideRequestAndDisableCacheFlushFlags) {
104+
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
105+
DebugManagerStateRestore dbgRestorer;
106+
DebugManager.flags.DoNotFlushCaches.set(true);
107+
108+
char buff[sizeof(PIPE_CONTROL) * 3];
109+
LinearStream stream(buff, sizeof(PIPE_CONTROL) * 3);
110+
111+
PipeControlArgs args(true);
112+
args.hdcPipelineFlush = true;
113+
MemorySynchronizationCommands<FamilyType>::addPipeControl(stream, args);
114+
115+
parseCommands<FamilyType>(stream, 0);
116+
117+
PIPE_CONTROL *pipeControl = getCommand<PIPE_CONTROL>();
118+
119+
ASSERT_NE(nullptr, pipeControl);
120+
121+
// WA pipeControl added
122+
if (cmdList.size() == 2) {
123+
pipeControl++;
124+
}
125+
126+
EXPECT_FALSE(pipeControl->getHdcPipelineFlush());
127+
}

opencl/test/unit_test/gen12lp/hw_helper_tests_gen12lp.inl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,12 +338,12 @@ GEN12LPTEST_F(LriHelperTestsGen12Lp, whenProgrammingLriCommandThenExpectMmioRema
338338
using MemorySynchronizatiopCommandsTests = ::testing::Test;
339339

340340
GEN12LPTEST_F(MemorySynchronizatiopCommandsTests, whenSettingCacheFlushExtraFieldsThenExpectHdcFlushSet) {
341-
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
342-
PIPE_CONTROL pipeControl = FamilyType::cmdInitPipeControl;
343-
pipeControl.setConstantCacheInvalidationEnable(true);
344-
MemorySynchronizationCommands<FamilyType>::setCacheFlushExtraProperties(pipeControl);
345-
EXPECT_TRUE(pipeControl.getHdcPipelineFlush());
346-
EXPECT_FALSE(pipeControl.getConstantCacheInvalidationEnable());
341+
PipeControlArgs args;
342+
args.constantCacheInvalidationEnable = true;
343+
344+
MemorySynchronizationCommands<FamilyType>::setCacheFlushExtraProperties(args);
345+
EXPECT_TRUE(args.hdcPipelineFlush);
346+
EXPECT_FALSE(args.constantCacheInvalidationEnable);
347347
}
348348

349349
GEN12LPTEST_F(HwHelperTestGen12Lp, givenUnknownProductFamilyWhenGettingIsWorkaroundRequiredThenFalseIsReturned) {

opencl/test/unit_test/test_files/igdrcl.config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,5 @@ PerformImplicitFlushForNewResource = -1
196196
PerformImplicitFlushForIdleGpu = -1
197197
ProvideVerboseImplicitFlush = false
198198
PauseOnGpuMode = -1
199-
PrintTagAllocationAddress = 0
199+
PrintTagAllocationAddress = 0
200+
DoNotFlushCaches = false

shared/source/debug_settings/debug_variables_base.inl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ DECLARE_DEBUG_VARIABLE(bool, DisableTimestampPacketOptimizations, false, "Alloca
4040
DECLARE_DEBUG_VARIABLE(bool, DisableCachingForStatefulBufferAccess, false, "Disable caching for stateful buffer access")
4141
DECLARE_DEBUG_VARIABLE(bool, EnableDebugBreak, true, "Enable DEBUG_BREAKs")
4242
DECLARE_DEBUG_VARIABLE(bool, FlushAllCaches, false, "pipe controls between enqueues flush all possible caches")
43+
DECLARE_DEBUG_VARIABLE(bool, DoNotFlushCaches, false, "clear all possible cache flush flags from pipe controls between enqueue flush")
4344
DECLARE_DEBUG_VARIABLE(bool, MakeEachEnqueueBlocking, false, "equivalent of finish after each enqueue")
4445
DECLARE_DEBUG_VARIABLE(bool, DisableResourceRecycling, false, "when set to true disables resource recycling optimization")
4546
DECLARE_DEBUG_VARIABLE(bool, ForceDispatchScheduler, false, "dispatches scheduler kernel instead of kernel enqueued")

shared/source/gen12lp/hw_helper_gen12lp.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,19 @@ std::string HwHelperHw<Family>::getExtensions() const {
220220
template <>
221221
inline void MemorySynchronizationCommands<Family>::setPipeControlExtraProperties(PIPE_CONTROL &pipeControl, PipeControlArgs &args) {
222222
pipeControl.setHdcPipelineFlush(args.hdcPipelineFlush);
223+
224+
if (DebugManager.flags.FlushAllCaches.get()) {
225+
pipeControl.setHdcPipelineFlush(true);
226+
}
227+
if (DebugManager.flags.DoNotFlushCaches.get()) {
228+
pipeControl.setHdcPipelineFlush(false);
229+
}
223230
}
224231

225232
template <>
226-
void MemorySynchronizationCommands<Family>::setCacheFlushExtraProperties(Family::PIPE_CONTROL &pipeControl) {
227-
pipeControl.setHdcPipelineFlush(true);
228-
pipeControl.setConstantCacheInvalidationEnable(false);
233+
void MemorySynchronizationCommands<Family>::setCacheFlushExtraProperties(PipeControlArgs &args) {
234+
args.hdcPipelineFlush = true;
235+
args.constantCacheInvalidationEnable = false;
229236
}
230237

231238
template <>

shared/source/helpers/hw_helper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ struct MemorySynchronizationCommands {
362362
static void addPipeControlWithCSStallOnly(LinearStream &commandStream, PipeControlArgs &args);
363363

364364
static void addFullCacheFlush(LinearStream &commandStream);
365-
static void setCacheFlushExtraProperties(PIPE_CONTROL &pipeControl);
365+
static void setCacheFlushExtraProperties(PipeControlArgs &args);
366366

367367
static size_t getSizeForPipeControlWithPostSyncOperation(const HardwareInfo &hwInfo);
368368
static size_t getSizeForSinglePipeControl();

shared/source/helpers/hw_helper_base.inl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,16 @@ void MemorySynchronizationCommands<GfxFamily>::setPipeControl(typename GfxFamily
256256
pipeControl.setConstantCacheInvalidationEnable(true);
257257
pipeControl.setStateCacheInvalidationEnable(true);
258258
}
259+
if (DebugManager.flags.DoNotFlushCaches.get()) {
260+
pipeControl.setDcFlushEnable(false);
261+
pipeControl.setRenderTargetCacheFlushEnable(false);
262+
pipeControl.setInstructionCacheInvalidateEnable(false);
263+
pipeControl.setTextureCacheInvalidationEnable(false);
264+
pipeControl.setPipeControlFlushEnable(false);
265+
pipeControl.setVfCacheInvalidationEnable(false);
266+
pipeControl.setConstantCacheInvalidationEnable(false);
267+
pipeControl.setStateCacheInvalidationEnable(false);
268+
}
259269
}
260270

261271
template <typename GfxFamily>
@@ -456,8 +466,8 @@ void MemorySynchronizationCommands<GfxFamily>::addFullCacheFlush(LinearStream &c
456466
args.pipeControlFlushEnable = true;
457467
args.constantCacheInvalidationEnable = true;
458468
args.stateCacheInvalidationEnable = true;
469+
MemorySynchronizationCommands<GfxFamily>::setCacheFlushExtraProperties(args);
459470
MemorySynchronizationCommands<GfxFamily>::setPipeControl(cmd, args);
460-
MemorySynchronizationCommands<GfxFamily>::setCacheFlushExtraProperties(cmd);
461471
*pipeControl = cmd;
462472
}
463473

shared/source/helpers/hw_helper_bdw_plus.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ inline void MemorySynchronizationCommands<GfxFamily>::setPostSyncExtraProperties
103103
}
104104

105105
template <typename GfxFamily>
106-
inline void MemorySynchronizationCommands<GfxFamily>::setCacheFlushExtraProperties(PIPE_CONTROL &pipeControl) {
106+
inline void MemorySynchronizationCommands<GfxFamily>::setCacheFlushExtraProperties(PipeControlArgs &args) {
107107
}
108108

109109
template <typename GfxFamily>

0 commit comments

Comments
 (0)