From 55723d0b18c3cc0c09330986baab93fa68a134f4 Mon Sep 17 00:00:00 2001 From: Filip Hazubski Date: Mon, 6 Sep 2021 19:28:20 +0000 Subject: [PATCH] Remove redundant functions Remove EncodeStates::adjustStateComputeMode function. Unify CommandStreamReceiverHw::programComputeMode functions. Related-To: NEO-5995 Signed-off-by: Filip Hazubski --- .../command_container/command_encoder.h | 3 -- .../encode_compute_mode_bdw_and_later.inl | 5 ---- .../encode_compute_mode_tgllp_and_later.inl | 8 ----- ...and_stream_receiver_hw_tgllp_and_later.inl | 22 ++++++++++++-- .../command_stream_receiver_hw_xe_hp_core.cpp | 30 ------------------- .../gen12lp/test_command_encoder_gen12lp.cpp | 7 +++-- .../unit_test/encoders/test_encode_states.cpp | 4 ++- 7 files changed, 28 insertions(+), 51 deletions(-) diff --git a/shared/source/command_container/command_encoder.h b/shared/source/command_container/command_encoder.h index 8f899e8f7e..9264850555 100644 --- a/shared/source/command_container/command_encoder.h +++ b/shared/source/command_container/command_encoder.h @@ -105,9 +105,6 @@ struct EncodeStates { BindlessHeapsHelper *bindlessHeapHelper, const HardwareInfo &hwInfo); - static void adjustStateComputeMode(LinearStream &csr, uint32_t numGrfRequired, void *const stateComputeModePtr, - bool requiresCoherency, uint32_t threadArbitrationPolicy, const HardwareInfo &hwInfo); - static size_t getAdjustStateComputeModeSize(); }; diff --git a/shared/source/command_container/encode_compute_mode_bdw_and_later.inl b/shared/source/command_container/encode_compute_mode_bdw_and_later.inl index 1b464c6577..27242b1c6f 100644 --- a/shared/source/command_container/encode_compute_mode_bdw_and_later.inl +++ b/shared/source/command_container/encode_compute_mode_bdw_and_later.inl @@ -10,11 +10,6 @@ #include "shared/source/command_stream/linear_stream.h" namespace NEO { -template -inline void EncodeStates::adjustStateComputeMode(LinearStream &csr, uint32_t numGrfRequired, void *const stateComputeModePtr, - bool requiresCoherency, uint32_t threadArbitrationPolicy, const HardwareInfo &hwInfo) { -} - template inline void EncodeStoreMMIO::remapOffset(MI_STORE_REGISTER_MEM *pStoreRegMem) { } diff --git a/shared/source/command_container/encode_compute_mode_tgllp_and_later.inl b/shared/source/command_container/encode_compute_mode_tgllp_and_later.inl index 20ff666a9f..ec67a8e859 100644 --- a/shared/source/command_container/encode_compute_mode_tgllp_and_later.inl +++ b/shared/source/command_container/encode_compute_mode_tgllp_and_later.inl @@ -10,14 +10,6 @@ #include "shared/source/command_stream/linear_stream.h" namespace NEO { -template -void EncodeStates::adjustStateComputeMode(LinearStream &csr, uint32_t numGrfRequired, void *const stateComputeModePtr, - bool requiresCoherency, uint32_t threadArbitrationPolicy, const HardwareInfo &hwInfo) { - StreamProperties properties{}; - properties.stateComputeMode.setProperties(requiresCoherency, numGrfRequired, threadArbitrationPolicy); - EncodeComputeMode::adjustComputeMode(csr, stateComputeModePtr, properties.stateComputeMode, hwInfo); -} - template inline void EncodeStoreMMIO::remapOffset(MI_STORE_REGISTER_MEM *pStoreRegMem) { pStoreRegMem->setMmioRemapEnable(true); diff --git a/shared/source/command_stream/command_stream_receiver_hw_tgllp_and_later.inl b/shared/source/command_stream/command_stream_receiver_hw_tgllp_and_later.inl index 7f76800555..b4280c53ab 100644 --- a/shared/source/command_stream/command_stream_receiver_hw_tgllp_and_later.inl +++ b/shared/source/command_stream/command_stream_receiver_hw_tgllp_and_later.inl @@ -19,9 +19,27 @@ void CommandStreamReceiverHw::programComputeMode(LinearStream &stream programAdditionalPipelineSelect(stream, dispatchFlags.pipelineSelectArgs, true); this->lastSentCoherencyRequest = static_cast(dispatchFlags.requiresCoherency); + if (DebugManager.flags.ProgramAdditionalPipeControlBeforeStateComputeModeCommand.get()) { + auto pPipeControlSpace = stream.getSpaceForCmd(); + + auto pipeControl = GfxFamily::cmdInitPipeControl; + pipeControl.setHdcPipelineFlush(true); + pipeControl.setAmfsFlushEnable(true); + pipeControl.setCommandStreamerStallEnable(true); + pipeControl.setInstructionCacheInvalidateEnable(true); + pipeControl.setTextureCacheInvalidationEnable(true); + pipeControl.setDcFlushEnable(true); + pipeControl.setConstantCacheInvalidationEnable(true); + pipeControl.setStateCacheInvalidationEnable(true); + + *pPipeControlSpace = pipeControl; + } + auto stateComputeMode = GfxFamily::cmdInitStateComputeMode; - EncodeStates::adjustStateComputeMode(stream, dispatchFlags.numGrfRequired, &stateComputeMode, - dispatchFlags.requiresCoherency, this->requiredThreadArbitrationPolicy, hwInfo); + StreamProperties properties{}; + properties.stateComputeMode.setProperties(dispatchFlags.requiresCoherency, dispatchFlags.numGrfRequired, + this->requiredThreadArbitrationPolicy); + EncodeComputeMode::adjustComputeMode(stream, &stateComputeMode, properties.stateComputeMode, hwInfo); if (csrSizeRequestFlags.hasSharedHandles) { auto pc = stream.getSpaceForCmd(); diff --git a/shared/source/xe_hp_core/command_stream_receiver_hw_xe_hp_core.cpp b/shared/source/xe_hp_core/command_stream_receiver_hw_xe_hp_core.cpp index 811803fdb2..50abb337a3 100644 --- a/shared/source/xe_hp_core/command_stream_receiver_hw_xe_hp_core.cpp +++ b/shared/source/xe_hp_core/command_stream_receiver_hw_xe_hp_core.cpp @@ -73,36 +73,6 @@ inline bool CommandStreamReceiverHw::isAdditionalPipeControlNeeded() con return DebugManager.flags.ProgramAdditionalPipeControlBeforeStateComputeModeCommand.get(); } -template <> -void CommandStreamReceiverHw::programComputeMode(LinearStream &stream, DispatchFlags &dispatchFlags, const HardwareInfo &hwInfo) { - using PIPE_CONTROL = typename Family::PIPE_CONTROL; - if (isComputeModeNeeded()) { - this->lastSentCoherencyRequest = static_cast(dispatchFlags.requiresCoherency); - - if (DebugManager.flags.ProgramAdditionalPipeControlBeforeStateComputeModeCommand.get()) { - auto pc = stream.getSpaceForCmd(); - *pc = Family::cmdInitPipeControl; - pc->setHdcPipelineFlush(true); - pc->setAmfsFlushEnable(true); - pc->setCommandStreamerStallEnable(true); - pc->setInstructionCacheInvalidateEnable(true); - pc->setTextureCacheInvalidationEnable(true); - pc->setDcFlushEnable(true); - pc->setConstantCacheInvalidationEnable(true); - pc->setStateCacheInvalidationEnable(true); - } - - auto stateComputeMode = Family::cmdInitStateComputeMode; - EncodeStates::adjustStateComputeMode(stream, dispatchFlags.numGrfRequired, &stateComputeMode, - dispatchFlags.requiresCoherency, this->requiredThreadArbitrationPolicy, hwInfo); - - if (csrSizeRequestFlags.hasSharedHandles) { - auto pc = stream.getSpaceForCmd(); - *pc = Family::cmdInitPipeControl; - } - } -} - template <> void BlitCommandsHelper::appendClearColor(const BlitProperties &blitProperties, typename Family::XY_COPY_BLT &blitCmd) { using XY_COPY_BLT = typename Family::XY_COPY_BLT; diff --git a/shared/test/common/gen12lp/test_command_encoder_gen12lp.cpp b/shared/test/common/gen12lp/test_command_encoder_gen12lp.cpp index 9b482659b9..fe8c3242f2 100644 --- a/shared/test/common/gen12lp/test_command_encoder_gen12lp.cpp +++ b/shared/test/common/gen12lp/test_command_encoder_gen12lp.cpp @@ -20,7 +20,7 @@ using namespace NEO; using CommandEncoderTest = Test; -GEN12LPTEST_F(CommandEncoderTest, givenAdjustStateComputeModeThenStateComputeModeShowsNonCoherencySet) { +GEN12LPTEST_F(CommandEncoderTest, WhenAdjustComputeModeIsCalledThenStateComputeModeShowsNonCoherencySet) { using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE; using FORCE_NON_COHERENT = typename STATE_COMPUTE_MODE::FORCE_NON_COHERENT; @@ -32,7 +32,10 @@ GEN12LPTEST_F(CommandEncoderTest, givenAdjustStateComputeModeThenStateComputeMod auto usedSpaceBefore = cmdContainer.getCommandStream()->getUsed(); // Adjust the State Compute Mode which sets FORCE_NON_COHERENT_FORCE_GPU_NON_COHERENT - EncodeStates::adjustStateComputeMode(*cmdContainer.getCommandStream(), cmdContainer.lastSentNumGrfRequired, nullptr, false, 0, *defaultHwInfo); + StreamProperties properties{}; + properties.stateComputeMode.setProperties(false, cmdContainer.lastSentNumGrfRequired, 0); + NEO::EncodeComputeMode::adjustComputeMode(*cmdContainer.getCommandStream(), nullptr, + properties.stateComputeMode, *defaultHwInfo); auto usedSpaceAfter = cmdContainer.getCommandStream()->getUsed(); ASSERT_GT(usedSpaceAfter, usedSpaceBefore); diff --git a/shared/test/unit_test/encoders/test_encode_states.cpp b/shared/test/unit_test/encoders/test_encode_states.cpp index 508228f7f9..82d56d62ee 100644 --- a/shared/test/unit_test/encoders/test_encode_states.cpp +++ b/shared/test/unit_test/encoders/test_encode_states.cpp @@ -327,6 +327,8 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandEncodeStatesTest, whenAdjustPipelineSelectIsC HWTEST2_F(CommandEncodeStatesTest, whenAdjustStateComputeModeIsCalledThenNothingHappens, IsAtMostGen11) { using PIPELINE_SELECT = typename FamilyType::PIPELINE_SELECT; auto initialUsed = cmdContainer->getCommandStream()->getUsed(); - NEO::EncodeStates::adjustStateComputeMode(*cmdContainer->getCommandStream(), 0, nullptr, false, 0, *defaultHwInfo); + StreamProperties emptyProperties{}; + NEO::EncodeComputeMode::adjustComputeMode(*cmdContainer->getCommandStream(), nullptr, + emptyProperties.stateComputeMode, *defaultHwInfo); EXPECT_EQ(initialUsed, cmdContainer->getCommandStream()->getUsed()); }