Add debug flag to disable cache flush

Related-To: NEO-5144

Change-Id: I29590d840a641dfcf3fc4d099ca84f196c8fdc1f
Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2020-09-30 15:06:42 +02:00
committed by sys_ocldev
parent 78feb47d6c
commit 5af3a46662
10 changed files with 129 additions and 19 deletions

View File

@@ -11,6 +11,8 @@
#include "opencl/source/helpers/hardware_commands_helper.h" #include "opencl/source/helpers/hardware_commands_helper.h"
#include "opencl/source/kernel/kernel.h" #include "opencl/source/kernel/kernel.h"
#include "pipe_control_args.h"
namespace NEO { namespace NEO {
template <typename GfxFamily> template <typename GfxFamily>
@@ -153,12 +155,8 @@ void HardwareCommandsHelper<GfxFamily>::setInterfaceDescriptorOffset(
template <typename GfxFamily> template <typename GfxFamily>
void HardwareCommandsHelper<GfxFamily>::programCacheFlushAfterWalkerCommand(LinearStream *commandStream, const CommandQueue &commandQueue, const Kernel *kernel, uint64_t postSyncAddress) { void HardwareCommandsHelper<GfxFamily>::programCacheFlushAfterWalkerCommand(LinearStream *commandStream, const CommandQueue &commandQueue, const Kernel *kernel, uint64_t postSyncAddress) {
using PIPE_CONTROL = typename GfxFamily::PIPE_CONTROL; PipeControlArgs args(true);
auto pipeControl = commandStream->getSpaceForCmd<PIPE_CONTROL>(); MemorySynchronizationCommands<GfxFamily>::addPipeControl(*commandStream, args);
PIPE_CONTROL cmd = GfxFamily::cmdInitPipeControl;
cmd.setCommandStreamerStallEnable(true);
cmd.setDcFlushEnable(true);
*pipeControl = cmd;
} }
} // namespace NEO } // namespace NEO

View File

@@ -894,6 +894,46 @@ HWTEST_F(UltCommandStreamReceiverTest, addPipeControlWithFlushAllCaches) {
EXPECT_TRUE(pipeControl->getStateCacheInvalidationEnable()); EXPECT_TRUE(pipeControl->getStateCacheInvalidationEnable());
} }
HWTEST_F(UltCommandStreamReceiverTest, givenDebugDisablingCacheFlushWhenAddingPipeControlWithCacheFlushThenOverrideRequestAndDisableCacheFlushFlags) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.DoNotFlushCaches.set(true);
char buff[sizeof(PIPE_CONTROL) * 3];
LinearStream stream(buff, sizeof(PIPE_CONTROL) * 3);
PipeControlArgs args(true);
args.constantCacheInvalidationEnable = true;
args.instructionCacheInvalidateEnable = true;
args.pipeControlFlushEnable = true;
args.renderTargetCacheFlushEnable = true;
args.stateCacheInvalidationEnable = true;
args.textureCacheInvalidationEnable = true;
args.vfCacheInvalidationEnable = true;
MemorySynchronizationCommands<FamilyType>::addPipeControl(stream, args);
parseCommands<FamilyType>(stream, 0);
PIPE_CONTROL *pipeControl = getCommand<PIPE_CONTROL>();
ASSERT_NE(nullptr, pipeControl);
// WA pipeControl added
if (cmdList.size() == 2) {
pipeControl++;
}
EXPECT_FALSE(pipeControl->getDcFlushEnable());
EXPECT_FALSE(pipeControl->getRenderTargetCacheFlushEnable());
EXPECT_FALSE(pipeControl->getInstructionCacheInvalidateEnable());
EXPECT_FALSE(pipeControl->getTextureCacheInvalidationEnable());
EXPECT_FALSE(pipeControl->getPipeControlFlushEnable());
EXPECT_FALSE(pipeControl->getVfCacheInvalidationEnable());
EXPECT_FALSE(pipeControl->getConstantCacheInvalidationEnable());
EXPECT_FALSE(pipeControl->getStateCacheInvalidationEnable());
}
HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenEnabledPreemptionWhenFlushTaskCalledThenDontProgramMediaVfeStateAgain) { HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenEnabledPreemptionWhenFlushTaskCalledThenDontProgramMediaVfeStateAgain) {
pDevice->setPreemptionMode(PreemptionMode::ThreadGroup); pDevice->setPreemptionMode(PreemptionMode::ThreadGroup);
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>(); auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();

View File

@@ -72,3 +72,56 @@ GEN12LPTEST_F(UltCommandStreamReceiverTest, givenStateBaseAddressWhenItIsRequire
EXPECT_TRUE(pipeControlCmd->getDcFlushEnable()); EXPECT_TRUE(pipeControlCmd->getDcFlushEnable());
EXPECT_TRUE(pipeControlCmd->getHdcPipelineFlush()); EXPECT_TRUE(pipeControlCmd->getHdcPipelineFlush());
} }
using UltCommandStreamReceiverTestGen12Lp = UltCommandStreamReceiverTest;
GEN12LPTEST_F(UltCommandStreamReceiverTestGen12Lp, givenDebugEnablingCacheFlushWhenAddingPipeControlWithoutCacheFlushThenOverrideRequestAndEnableCacheFlushFlags) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.FlushAllCaches.set(true);
char buff[sizeof(PIPE_CONTROL) * 3];
LinearStream stream(buff, sizeof(PIPE_CONTROL) * 3);
PipeControlArgs args;
MemorySynchronizationCommands<FamilyType>::addPipeControl(stream, args);
parseCommands<FamilyType>(stream, 0);
PIPE_CONTROL *pipeControl = getCommand<PIPE_CONTROL>();
ASSERT_NE(nullptr, pipeControl);
// WA pipeControl added
if (cmdList.size() == 2) {
pipeControl++;
}
EXPECT_TRUE(pipeControl->getHdcPipelineFlush());
}
GEN12LPTEST_F(UltCommandStreamReceiverTestGen12Lp, givenDebugDisablingCacheFlushWhenAddingPipeControlWithCacheFlushThenOverrideRequestAndDisableCacheFlushFlags) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.DoNotFlushCaches.set(true);
char buff[sizeof(PIPE_CONTROL) * 3];
LinearStream stream(buff, sizeof(PIPE_CONTROL) * 3);
PipeControlArgs args(true);
args.hdcPipelineFlush = true;
MemorySynchronizationCommands<FamilyType>::addPipeControl(stream, args);
parseCommands<FamilyType>(stream, 0);
PIPE_CONTROL *pipeControl = getCommand<PIPE_CONTROL>();
ASSERT_NE(nullptr, pipeControl);
// WA pipeControl added
if (cmdList.size() == 2) {
pipeControl++;
}
EXPECT_FALSE(pipeControl->getHdcPipelineFlush());
}

View File

@@ -338,12 +338,12 @@ GEN12LPTEST_F(LriHelperTestsGen12Lp, whenProgrammingLriCommandThenExpectMmioRema
using MemorySynchronizatiopCommandsTests = ::testing::Test; using MemorySynchronizatiopCommandsTests = ::testing::Test;
GEN12LPTEST_F(MemorySynchronizatiopCommandsTests, whenSettingCacheFlushExtraFieldsThenExpectHdcFlushSet) { GEN12LPTEST_F(MemorySynchronizatiopCommandsTests, whenSettingCacheFlushExtraFieldsThenExpectHdcFlushSet) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; PipeControlArgs args;
PIPE_CONTROL pipeControl = FamilyType::cmdInitPipeControl; args.constantCacheInvalidationEnable = true;
pipeControl.setConstantCacheInvalidationEnable(true);
MemorySynchronizationCommands<FamilyType>::setCacheFlushExtraProperties(pipeControl); MemorySynchronizationCommands<FamilyType>::setCacheFlushExtraProperties(args);
EXPECT_TRUE(pipeControl.getHdcPipelineFlush()); EXPECT_TRUE(args.hdcPipelineFlush);
EXPECT_FALSE(pipeControl.getConstantCacheInvalidationEnable()); EXPECT_FALSE(args.constantCacheInvalidationEnable);
} }
GEN12LPTEST_F(HwHelperTestGen12Lp, givenUnknownProductFamilyWhenGettingIsWorkaroundRequiredThenFalseIsReturned) { GEN12LPTEST_F(HwHelperTestGen12Lp, givenUnknownProductFamilyWhenGettingIsWorkaroundRequiredThenFalseIsReturned) {

View File

@@ -196,4 +196,5 @@ PerformImplicitFlushForNewResource = -1
PerformImplicitFlushForIdleGpu = -1 PerformImplicitFlushForIdleGpu = -1
ProvideVerboseImplicitFlush = false ProvideVerboseImplicitFlush = false
PauseOnGpuMode = -1 PauseOnGpuMode = -1
PrintTagAllocationAddress = 0 PrintTagAllocationAddress = 0
DoNotFlushCaches = false

View File

@@ -40,6 +40,7 @@ DECLARE_DEBUG_VARIABLE(bool, DisableTimestampPacketOptimizations, false, "Alloca
DECLARE_DEBUG_VARIABLE(bool, DisableCachingForStatefulBufferAccess, false, "Disable caching for stateful buffer access") DECLARE_DEBUG_VARIABLE(bool, DisableCachingForStatefulBufferAccess, false, "Disable caching for stateful buffer access")
DECLARE_DEBUG_VARIABLE(bool, EnableDebugBreak, true, "Enable DEBUG_BREAKs") DECLARE_DEBUG_VARIABLE(bool, EnableDebugBreak, true, "Enable DEBUG_BREAKs")
DECLARE_DEBUG_VARIABLE(bool, FlushAllCaches, false, "pipe controls between enqueues flush all possible caches") DECLARE_DEBUG_VARIABLE(bool, FlushAllCaches, false, "pipe controls between enqueues flush all possible caches")
DECLARE_DEBUG_VARIABLE(bool, DoNotFlushCaches, false, "clear all possible cache flush flags from pipe controls between enqueue flush")
DECLARE_DEBUG_VARIABLE(bool, MakeEachEnqueueBlocking, false, "equivalent of finish after each enqueue") DECLARE_DEBUG_VARIABLE(bool, MakeEachEnqueueBlocking, false, "equivalent of finish after each enqueue")
DECLARE_DEBUG_VARIABLE(bool, DisableResourceRecycling, false, "when set to true disables resource recycling optimization") DECLARE_DEBUG_VARIABLE(bool, DisableResourceRecycling, false, "when set to true disables resource recycling optimization")
DECLARE_DEBUG_VARIABLE(bool, ForceDispatchScheduler, false, "dispatches scheduler kernel instead of kernel enqueued") DECLARE_DEBUG_VARIABLE(bool, ForceDispatchScheduler, false, "dispatches scheduler kernel instead of kernel enqueued")

View File

@@ -220,12 +220,19 @@ std::string HwHelperHw<Family>::getExtensions() const {
template <> template <>
inline void MemorySynchronizationCommands<Family>::setPipeControlExtraProperties(PIPE_CONTROL &pipeControl, PipeControlArgs &args) { inline void MemorySynchronizationCommands<Family>::setPipeControlExtraProperties(PIPE_CONTROL &pipeControl, PipeControlArgs &args) {
pipeControl.setHdcPipelineFlush(args.hdcPipelineFlush); pipeControl.setHdcPipelineFlush(args.hdcPipelineFlush);
if (DebugManager.flags.FlushAllCaches.get()) {
pipeControl.setHdcPipelineFlush(true);
}
if (DebugManager.flags.DoNotFlushCaches.get()) {
pipeControl.setHdcPipelineFlush(false);
}
} }
template <> template <>
void MemorySynchronizationCommands<Family>::setCacheFlushExtraProperties(Family::PIPE_CONTROL &pipeControl) { void MemorySynchronizationCommands<Family>::setCacheFlushExtraProperties(PipeControlArgs &args) {
pipeControl.setHdcPipelineFlush(true); args.hdcPipelineFlush = true;
pipeControl.setConstantCacheInvalidationEnable(false); args.constantCacheInvalidationEnable = false;
} }
template <> template <>

View File

@@ -362,7 +362,7 @@ struct MemorySynchronizationCommands {
static void addPipeControlWithCSStallOnly(LinearStream &commandStream, PipeControlArgs &args); static void addPipeControlWithCSStallOnly(LinearStream &commandStream, PipeControlArgs &args);
static void addFullCacheFlush(LinearStream &commandStream); static void addFullCacheFlush(LinearStream &commandStream);
static void setCacheFlushExtraProperties(PIPE_CONTROL &pipeControl); static void setCacheFlushExtraProperties(PipeControlArgs &args);
static size_t getSizeForPipeControlWithPostSyncOperation(const HardwareInfo &hwInfo); static size_t getSizeForPipeControlWithPostSyncOperation(const HardwareInfo &hwInfo);
static size_t getSizeForSinglePipeControl(); static size_t getSizeForSinglePipeControl();

View File

@@ -256,6 +256,16 @@ void MemorySynchronizationCommands<GfxFamily>::setPipeControl(typename GfxFamily
pipeControl.setConstantCacheInvalidationEnable(true); pipeControl.setConstantCacheInvalidationEnable(true);
pipeControl.setStateCacheInvalidationEnable(true); pipeControl.setStateCacheInvalidationEnable(true);
} }
if (DebugManager.flags.DoNotFlushCaches.get()) {
pipeControl.setDcFlushEnable(false);
pipeControl.setRenderTargetCacheFlushEnable(false);
pipeControl.setInstructionCacheInvalidateEnable(false);
pipeControl.setTextureCacheInvalidationEnable(false);
pipeControl.setPipeControlFlushEnable(false);
pipeControl.setVfCacheInvalidationEnable(false);
pipeControl.setConstantCacheInvalidationEnable(false);
pipeControl.setStateCacheInvalidationEnable(false);
}
} }
template <typename GfxFamily> template <typename GfxFamily>
@@ -456,8 +466,8 @@ void MemorySynchronizationCommands<GfxFamily>::addFullCacheFlush(LinearStream &c
args.pipeControlFlushEnable = true; args.pipeControlFlushEnable = true;
args.constantCacheInvalidationEnable = true; args.constantCacheInvalidationEnable = true;
args.stateCacheInvalidationEnable = true; args.stateCacheInvalidationEnable = true;
MemorySynchronizationCommands<GfxFamily>::setCacheFlushExtraProperties(args);
MemorySynchronizationCommands<GfxFamily>::setPipeControl(cmd, args); MemorySynchronizationCommands<GfxFamily>::setPipeControl(cmd, args);
MemorySynchronizationCommands<GfxFamily>::setCacheFlushExtraProperties(cmd);
*pipeControl = cmd; *pipeControl = cmd;
} }

View File

@@ -103,7 +103,7 @@ inline void MemorySynchronizationCommands<GfxFamily>::setPostSyncExtraProperties
} }
template <typename GfxFamily> template <typename GfxFamily>
inline void MemorySynchronizationCommands<GfxFamily>::setCacheFlushExtraProperties(PIPE_CONTROL &pipeControl) { inline void MemorySynchronizationCommands<GfxFamily>::setCacheFlushExtraProperties(PipeControlArgs &args) {
} }
template <typename GfxFamily> template <typename GfxFamily>