diff --git a/runtime/command_stream/command_stream_receiver_hw_bdw_plus.inl b/runtime/command_stream/command_stream_receiver_hw_bdw_plus.inl index 74c8c3978f..d64fe6d463 100644 --- a/runtime/command_stream/command_stream_receiver_hw_bdw_plus.inl +++ b/runtime/command_stream/command_stream_receiver_hw_bdw_plus.inl @@ -48,7 +48,7 @@ inline size_t CommandStreamReceiverHw::getCmdSizeForL3Config() const template void CommandStreamReceiverHw::programPipelineSelect(LinearStream &commandStream, DispatchFlags &dispatchFlags) { if (csrSizeRequestFlags.mediaSamplerConfigChanged || !isPreambleSent) { - PreambleHelper::programPipelineSelect(&commandStream, dispatchFlags); + PreambleHelper::programPipelineSelect(&commandStream, dispatchFlags, peekHwInfo()); this->lastMediaSamplerConfig = dispatchFlags.mediaSamplerRequired; } } diff --git a/runtime/gen11/preamble_gen11.cpp b/runtime/gen11/preamble_gen11.cpp index b90e77b5c8..eae2dc5fdd 100644 --- a/runtime/gen11/preamble_gen11.cpp +++ b/runtime/gen11/preamble_gen11.cpp @@ -28,13 +28,19 @@ uint32_t PreambleHelper::getL3Config(const HardwareInfo &hwInfo, bool } template <> -void PreambleHelper::programPipelineSelect(LinearStream *pCommandStream, const DispatchFlags &dispatchFlags) { +void PreambleHelper::programPipelineSelect(LinearStream *pCommandStream, + const DispatchFlags &dispatchFlags, + const HardwareInfo &hwInfo) { + typedef typename ICLFamily::PIPELINE_SELECT PIPELINE_SELECT; auto pCmd = (PIPELINE_SELECT *)pCommandStream->getSpace(sizeof(PIPELINE_SELECT)); *pCmd = ICLFamily::cmdInitPipelineSelect; - auto mask = pipelineSelectEnablePipelineSelectMaskBits | pipelineSelectMediaSamplerDopClockGateMaskBits | pipelineSelectMediaSamplerPowerClockGateMaskBits; + auto mask = pipelineSelectEnablePipelineSelectMaskBits | + pipelineSelectMediaSamplerDopClockGateMaskBits | + pipelineSelectMediaSamplerPowerClockGateMaskBits; + pCmd->setMaskBits(mask); pCmd->setPipelineSelection(PIPELINE_SELECT::PIPELINE_SELECTION_GPGPU); pCmd->setMediaSamplerDopClockGateEnable(!dispatchFlags.mediaSamplerRequired); diff --git a/runtime/gen8/preamble_gen8.cpp b/runtime/gen8/preamble_gen8.cpp index 28cac70bae..f4b84c3595 100644 --- a/runtime/gen8/preamble_gen8.cpp +++ b/runtime/gen8/preamble_gen8.cpp @@ -32,7 +32,10 @@ uint32_t PreambleHelper::getL3Config(const HardwareInfo &hwInfo, bool } template <> -void PreambleHelper::programPipelineSelect(LinearStream *pCommandStream, const DispatchFlags &dispatchFlags) { +void PreambleHelper::programPipelineSelect(LinearStream *pCommandStream, + const DispatchFlags &dispatchFlags, + const HardwareInfo &hwInfo) { + typedef typename BDWFamily::PIPELINE_SELECT PIPELINE_SELECT; auto pCmd = (PIPELINE_SELECT *)pCommandStream->getSpace(sizeof(PIPELINE_SELECT)); *pCmd = BDWFamily::cmdInitPipelineSelect; diff --git a/runtime/gen9/preamble_gen9.cpp b/runtime/gen9/preamble_gen9.cpp index 287441843d..9bf85e8807 100644 --- a/runtime/gen9/preamble_gen9.cpp +++ b/runtime/gen9/preamble_gen9.cpp @@ -28,7 +28,10 @@ uint32_t PreambleHelper::getL3Config(const HardwareInfo &hwInfo, bool } template <> -void PreambleHelper::programPipelineSelect(LinearStream *pCommandStream, const DispatchFlags &dispatchFlags) { +void PreambleHelper::programPipelineSelect(LinearStream *pCommandStream, + const DispatchFlags &dispatchFlags, + const HardwareInfo &hwInfo) { + typedef typename SKLFamily::PIPELINE_SELECT PIPELINE_SELECT; auto pCmd = (PIPELINE_SELECT *)pCommandStream->getSpace(sizeof(PIPELINE_SELECT)); diff --git a/runtime/helpers/hardware_commands_helper.h b/runtime/helpers/hardware_commands_helper.h index 329e14ac2d..6ec823c9da 100644 --- a/runtime/helpers/hardware_commands_helper.h +++ b/runtime/helpers/hardware_commands_helper.h @@ -143,6 +143,7 @@ struct HardwareCommandsHelper : public PerThreadDataHelper { static size_t getSizeRequiredCS(const Kernel *kernel); static size_t getSizeRequiredForCacheFlush(const CommandQueue &commandQueue, const Kernel *kernel, uint64_t postSyncAddress); static bool isPipeControlWArequired(const HardwareInfo &hwInfo); + static bool isPipeControlPriorToPipelineSelectWArequired(const HardwareInfo &hwInfo); static size_t getSizeRequiredDSH( const Kernel &kernel); static size_t getSizeRequiredIOH( diff --git a/runtime/helpers/hardware_commands_helper.inl b/runtime/helpers/hardware_commands_helper.inl index dbfcb941cd..969f29c0d0 100644 --- a/runtime/helpers/hardware_commands_helper.inl +++ b/runtime/helpers/hardware_commands_helper.inl @@ -25,6 +25,11 @@ namespace NEO { template bool HardwareCommandsHelper::isPipeControlWArequired(const HardwareInfo &hwInfo) { return false; } +template +bool HardwareCommandsHelper::isPipeControlPriorToPipelineSelectWArequired(const HardwareInfo &hwInfo) { + return false; +} + template uint32_t HardwareCommandsHelper::computeSlmValues(uint32_t valueIn) { auto value = std::max(valueIn, 1024u); diff --git a/runtime/helpers/preamble.h b/runtime/helpers/preamble.h index 359a6f6471..caeb028286 100644 --- a/runtime/helpers/preamble.h +++ b/runtime/helpers/preamble.h @@ -27,7 +27,9 @@ struct PreambleHelper { using PIPE_CONTROL = typename GfxFamily::PIPE_CONTROL; static void programL3(LinearStream *pCommandStream, uint32_t l3Config); - static void programPipelineSelect(LinearStream *pCommandStream, const DispatchFlags &dispatchFlags); + static void programPipelineSelect(LinearStream *pCommandStream, + const DispatchFlags &dispatchFlags, + const HardwareInfo &hwInfo); static uint32_t getDefaultThreadArbitrationPolicy(); static void programThreadArbitration(LinearStream *pCommandStream, uint32_t requiredThreadArbitrationPolicy); static void programPreemption(LinearStream *pCommandStream, Device &device, GraphicsAllocation *preemptionCsr); diff --git a/unit_tests/command_stream/command_stream_receiver_flush_task_2_tests.cpp b/unit_tests/command_stream/command_stream_receiver_flush_task_2_tests.cpp index a5e7fe3685..5ff35e74b4 100644 --- a/unit_tests/command_stream/command_stream_receiver_flush_task_2_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_flush_task_2_tests.cpp @@ -9,6 +9,7 @@ #include "runtime/command_stream/csr_definitions.h" #include "runtime/command_stream/scratch_space_controller.h" #include "runtime/gmm_helper/gmm_helper.h" +#include "runtime/helpers/hardware_commands_helper.h" #include "runtime/helpers/hw_helper.h" #include "runtime/helpers/state_base_address.h" #include "runtime/memory_manager/internal_allocation_storage.h" @@ -983,8 +984,29 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrWhenPreambleNotSentThenReq EXPECT_EQ(mediaSamplerConfigChangedSize, mediaSamplerConfigNotChangedSize); } +HWTEST_F(CommandStreamReceiverFlushTaskTests, givenSpecialPipelineSelectModeChangedWhenGetCmdSizeForPielineSelectIsCalledThenCorrectSizeIsReturned) { + using PIPELINE_SELECT = typename FamilyType::PIPELINE_SELECT; + using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; + + UltCommandStreamReceiver &commandStreamReceiver = (UltCommandStreamReceiver &)pDevice->getGpgpuCommandStreamReceiver(); + + CsrSizeRequestFlags csrSizeRequest = {}; + DispatchFlags flags; + csrSizeRequest.specialPipelineSelectModeChanged = true; + commandStreamReceiver.overrideCsrSizeReqFlags(csrSizeRequest); + size_t size = commandStreamReceiver.getCmdSizeForPipelineSelect(); + + size_t expectedSize = sizeof(PIPELINE_SELECT); + if (HardwareCommandsHelper::isPipeControlPriorToPipelineSelectWArequired(pDevice->getHardwareInfo())) { + expectedSize += sizeof(PIPE_CONTROL); + } + EXPECT_EQ(expectedSize, size); +} + HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrWhenPreambleSentThenRequiredCsrSizeDependsOnmediaSamplerConfigChanged) { - typedef typename FamilyType::PIPELINE_SELECT PIPELINE_SELECT; + using PIPELINE_SELECT = typename FamilyType::PIPELINE_SELECT; + using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; + UltCommandStreamReceiver &commandStreamReceiver = (UltCommandStreamReceiver &)pDevice->getGpgpuCommandStreamReceiver(); CsrSizeRequestFlags csrSizeRequest = {}; DispatchFlags flags; @@ -1000,7 +1022,13 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrWhenPreambleSentThenRequir EXPECT_NE(mediaSamplerConfigChangedSize, mediaSamplerConfigNotChangedSize); auto difference = mediaSamplerConfigChangedSize - mediaSamplerConfigNotChangedSize; - EXPECT_EQ(sizeof(PIPELINE_SELECT), difference); + + size_t expectedDifference = sizeof(PIPELINE_SELECT); + if (HardwareCommandsHelper::isPipeControlPriorToPipelineSelectWArequired(pDevice->getHardwareInfo())) { + expectedDifference += sizeof(PIPE_CONTROL); + } + + EXPECT_EQ(expectedDifference, difference); } HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrWhenSamplerCacheFlushSentThenRequiredCsrSizeContainsPipecontrolSize) {