diff --git a/core/helpers/hw_helper.h b/core/helpers/hw_helper.h index 89fffa6775..4a6d9b5ad8 100644 --- a/core/helpers/hw_helper.h +++ b/core/helpers/hw_helper.h @@ -244,6 +244,10 @@ struct PipeControlHelper { static size_t getSizeForPipeControlWithPostSyncOperation(const HardwareInfo &hwInfo); static size_t getSizeForSinglePipeControl(); + static PIPE_CONTROL *addFullCacheFlush(LinearStream &commandStream); + static size_t getSizeForFullCacheFlush(); + static void setExtraCacheFlushFields(PIPE_CONTROL *pipeControl); + protected: static size_t getSizeForAdditonalSynchronization(const HardwareInfo &hwInfo); static PIPE_CONTROL *obtainPipeControl(LinearStream &commandStream, bool dcFlush); diff --git a/core/helpers/hw_helper_base.inl b/core/helpers/hw_helper_base.inl index a35a4ee139..1c555d0f92 100644 --- a/core/helpers/hw_helper_base.inl +++ b/core/helpers/hw_helper_base.inl @@ -287,4 +287,26 @@ template uint32_t HwHelperHw::getMaxThreadsForWorkgroup(const HardwareInfo &hwInfo, uint32_t maxNumEUsPerSubSlice) const { return HwHelper::getMaxThreadsForWorkgroup(hwInfo, maxNumEUsPerSubSlice); } + +template +size_t PipeControlHelper::getSizeForFullCacheFlush() { + return sizeof(typename GfxFamily::PIPE_CONTROL); +} + +template +typename GfxFamily::PIPE_CONTROL *PipeControlHelper::addFullCacheFlush(LinearStream &commandStream) { + auto pipeControl = PipeControlHelper::obtainPipeControl(commandStream, true); + + pipeControl->setRenderTargetCacheFlushEnable(true); + pipeControl->setInstructionCacheInvalidateEnable(true); + pipeControl->setTextureCacheInvalidationEnable(true); + pipeControl->setPipeControlFlushEnable(true); + pipeControl->setConstantCacheInvalidationEnable(true); + pipeControl->setStateCacheInvalidationEnable(true); + + PipeControlHelper::setExtraCacheFlushFields(pipeControl); + + return pipeControl; +} + } // namespace NEO diff --git a/core/helpers/hw_helper_bdw_plus.inl b/core/helpers/hw_helper_bdw_plus.inl index 63360d8c06..4b5d1514e9 100644 --- a/core/helpers/hw_helper_bdw_plus.inl +++ b/core/helpers/hw_helper_bdw_plus.inl @@ -80,4 +80,8 @@ template void PipeControlHelper::setExtraPipeControlProperties(PIPE_CONTROL &pipeControl, const HardwareInfo &hwInfo) { } +template +void PipeControlHelper::setExtraCacheFlushFields(PIPE_CONTROL *pipeControl) { +} + } // namespace NEO diff --git a/runtime/gen12lp/hw_helper_gen12lp.cpp b/runtime/gen12lp/hw_helper_gen12lp.cpp index 969e1317df..383928b8ee 100644 --- a/runtime/gen12lp/hw_helper_gen12lp.cpp +++ b/runtime/gen12lp/hw_helper_gen12lp.cpp @@ -122,6 +122,11 @@ std::string HwHelperHw::getExtensions() const { return "cl_intel_subgroup_local_block_io "; } +template <> +void PipeControlHelper::setExtraCacheFlushFields(Family::PIPE_CONTROL *pipeControl) { + pipeControl->setHdcPipelineFlush(true); +} + template class AubHelperHw; template class HwHelperHw; template class FlatBatchBufferHelperHw; diff --git a/unit_tests/gen12lp/hw_helper_tests_gen12lp.inl b/unit_tests/gen12lp/hw_helper_tests_gen12lp.inl index 23f3c68d8c..e37cd0c4e8 100644 --- a/unit_tests/gen12lp/hw_helper_tests_gen12lp.inl +++ b/unit_tests/gen12lp/hw_helper_tests_gen12lp.inl @@ -166,3 +166,13 @@ GEN12LPTEST_F(LriHelperTestsGen12Lp, whenProgrammingLriCommandThenExpectMmioRema EXPECT_EQ(lri, stream.getCpuBase()); EXPECT_TRUE(memcmp(lri, &expectedLri, sizeof(MI_LOAD_REGISTER_IMM)) == 0); } + +using PipeControlHelperTests = ::testing::Test; + +GEN12LPTEST_F(PipeControlHelperTests, whenSettingCacheFlushExtraFieldsThenExpectHdcFlushSet) { + using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; + PIPE_CONTROL pipeControl = FamilyType::cmdInitPipeControl; + + PipeControlHelper::setExtraCacheFlushFields(&pipeControl); + EXPECT_TRUE(pipeControl.getHdcPipelineFlush()); +} diff --git a/unit_tests/helpers/hw_helper_tests.cpp b/unit_tests/helpers/hw_helper_tests.cpp index a95199f246..dfdfec3fe1 100644 --- a/unit_tests/helpers/hw_helper_tests.cpp +++ b/unit_tests/helpers/hw_helper_tests.cpp @@ -810,3 +810,27 @@ HWTEST_F(HwHelperTest, givenDefaultHwHelperHwWhenMinimalSIMDSizeIsQueriedThen8Is auto &helper = HwHelper::get(renderCoreFamily); EXPECT_EQ(8u, helper.getMinimalSIMDSize()); } + +HWTEST_F(PipeControlHelperTests, WhenGettingPipeControSizeForCacheFlushThenReturnCorrectValue) { + using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; + size_t actualSize = PipeControlHelper::getSizeForFullCacheFlush(); + EXPECT_EQ(sizeof(PIPE_CONTROL), actualSize); +} + +HWTEST_F(PipeControlHelperTests, WhenProgrammingCacheFlushThenExpectBasicFieldsSet) { + using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; + std::unique_ptr buffer(new uint8_t[128]); + + LinearStream stream(buffer.get(), 128); + + PIPE_CONTROL *pipeControl = PipeControlHelper::addFullCacheFlush(stream); + EXPECT_TRUE(pipeControl->getCommandStreamerStallEnable()); + EXPECT_TRUE(pipeControl->getDcFlushEnable()); + + EXPECT_TRUE(pipeControl->getRenderTargetCacheFlushEnable()); + EXPECT_TRUE(pipeControl->getInstructionCacheInvalidateEnable()); + EXPECT_TRUE(pipeControl->getTextureCacheInvalidationEnable()); + EXPECT_TRUE(pipeControl->getPipeControlFlushEnable()); + EXPECT_TRUE(pipeControl->getConstantCacheInvalidationEnable()); + EXPECT_TRUE(pipeControl->getStateCacheInvalidationEnable()); +}