diff --git a/level_zero/core/source/cmdlist/cmdlist_hw.inl b/level_zero/core/source/cmdlist/cmdlist_hw.inl index 9e35ecb849..4cb076fc02 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw.inl @@ -2256,10 +2256,9 @@ void CommandListCoreFamily::updateStreamProperties(Kernel &kernel finalStreamState.stateComputeMode.setProperties(false, kernelAttributes.numGrfRequired, kernel.getSchedulingHintExp(), hwInfo); if (finalStreamState.stateComputeMode.isDirty()) { - auto &neoDevice = *device->getNEODevice(); - NEO::EncodeWA::encodeAdditionalPipelineSelect(neoDevice, *commandContainer.getCommandStream(), true); - NEO::EncodeComputeMode::programComputeModeCommand(*commandContainer.getCommandStream(), finalStreamState.stateComputeMode, hwInfo); - NEO::EncodeWA::encodeAdditionalPipelineSelect(neoDevice, *commandContainer.getCommandStream(), false); + bool isRcs = (this->engineGroupType == NEO::EngineGroupType::RenderCompute); + NEO::EncodeComputeMode::programComputeModeCommandWithSynchronization( + *commandContainer.getCommandStream(), finalStreamState.stateComputeMode, {}, false, hwInfo, isRcs); } } diff --git a/level_zero/core/source/cmdqueue/cmdqueue_hw_base.inl b/level_zero/core/source/cmdqueue/cmdqueue_hw_base.inl index 8c9d0133c7..7906f6f3e4 100644 --- a/level_zero/core/source/cmdqueue/cmdqueue_hw_base.inl +++ b/level_zero/core/source/cmdqueue/cmdqueue_hw_base.inl @@ -42,7 +42,8 @@ void CommandQueueHw::programStateBaseAddress(uint64_t gsba, bool NEO::MemorySynchronizationCommands::addPipeControl(commandStream, pcArgs); NEO::Device *neoDevice = device->getNEODevice(); - NEO::EncodeWA::encodeAdditionalPipelineSelect(*neoDevice, commandStream, true); + bool isRcs = this->getCsr()->isRcs(); + NEO::EncodeWA::encodeAdditionalPipelineSelect(commandStream, {}, true, hwInfo, isRcs); auto pSbaCmd = static_cast(commandStream.getSpace(sizeof(STATE_BASE_ADDRESS))); STATE_BASE_ADDRESS sbaCmd; @@ -89,7 +90,7 @@ void CommandQueueHw::programStateBaseAddress(uint64_t gsba, bool device->getL0Debugger()->programSbaTrackingCommands(commandStream, sbaAddresses); } - NEO::EncodeWA::encodeAdditionalPipelineSelect(*device->getNEODevice(), commandStream, false); + NEO::EncodeWA::encodeAdditionalPipelineSelect(commandStream, {}, false, hwInfo, isRcs); } template diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_2.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_2.cpp index 427f89b6c6..d6cc59e53b 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_2.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_2.cpp @@ -481,6 +481,8 @@ HWTEST2_F(CommandListCreate, givenCommandListWhenMemoryCopyWithSignalEventsThenS auto event1 = std::unique_ptr(L0::Event::create(eventPool.get(), &eventDesc, device)); events.push_back(event1.get()); + result = commandList->appendMemoryCopy(dstPtr, srcPtr, 0x1001, nullptr, 2u, events.data()); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); result = commandList->appendMemoryCopy(dstPtr, srcPtr, 0x1001, nullptr, 2u, events.data()); EXPECT_EQ(ZE_RESULT_SUCCESS, result); @@ -494,6 +496,12 @@ HWTEST2_F(CommandListCreate, givenCommandListWhenMemoryCopyWithSignalEventsThenS itor = find(itor, cmdList.end()); EXPECT_NE(cmdList.end(), itor); itor++; + itor = find(itor, cmdList.end()); + EXPECT_NE(cmdList.end(), itor); + itor++; + itor = find(itor, cmdList.end()); + EXPECT_NE(cmdList.end(), itor); + itor++; itor = find(itor, cmdList.end()); if (MemorySynchronizationCommands::getDcFlushEnable(true, *defaultHwInfo)) { EXPECT_NE(cmdList.end(), itor); diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_1_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_1_tests.cpp index 39430a9c46..2030594a43 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_1_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_1_tests.cpp @@ -148,13 +148,14 @@ HWTEST_F(UltCommandStreamReceiverTest, givenPreambleSentAndThreadArbitrationPoli auto policyNotChangedFlush = commandStreamReceiver.getRequiredCmdStreamSize(flushTaskFlags, *pDevice); commandStreamReceiver.streamProperties.stateComputeMode.threadArbitrationPolicy.isDirty = true; + commandStreamReceiver.streamProperties.stateComputeMode.isCoherencyRequired.isDirty = true; auto policyChangedPreamble = commandStreamReceiver.getRequiredCmdSizeForPreamble(*pDevice); auto policyChangedFlush = commandStreamReceiver.getRequiredCmdStreamSize(flushTaskFlags, *pDevice); auto actualDifferenceForPreamble = policyChangedPreamble - policyNotChangedPreamble; auto actualDifferenceForFlush = policyChangedFlush - policyNotChangedFlush; auto expectedDifference = PreambleHelper::getThreadArbitrationCommandsSize() + - commandStreamReceiver.getCmdSizeForComputeMode(); + EncodeComputeMode::getCmdSizeForComputeMode(*defaultHwInfo, false, commandStreamReceiver.isRcs()); EXPECT_EQ(0u, actualDifferenceForPreamble); EXPECT_EQ(expectedDifference, actualDifferenceForFlush); } diff --git a/opencl/test/unit_test/gen11/coherency_tests_gen11.cpp b/opencl/test/unit_test/gen11/coherency_tests_gen11.cpp index 466e47ade5..5a625ed055 100644 --- a/opencl/test/unit_test/gen11/coherency_tests_gen11.cpp +++ b/opencl/test/unit_test/gen11/coherency_tests_gen11.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2021 Intel Corporation + * Copyright (C) 2019-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -46,19 +46,19 @@ struct Gen11CoherencyRequirements : public ::testing::Test { GEN11TEST_F(Gen11CoherencyRequirements, GivenSettingsWhenCoherencyRequestedThenProgrammingIsCorrect) { auto lriSize = sizeof(MI_LOAD_REGISTER_IMM); overrideCoherencyRequest(false, false); - auto retSize = csr->getCmdSizeForComputeMode(); - EXPECT_EQ(0u, retSize); + EXPECT_FALSE(csr->isComputeModeNeeded()); overrideCoherencyRequest(false, true); - retSize = csr->getCmdSizeForComputeMode(); - EXPECT_EQ(0u, retSize); + EXPECT_FALSE(csr->isComputeModeNeeded()); overrideCoherencyRequest(true, true); - retSize = csr->getCmdSizeForComputeMode(); + auto retSize = csr->getCmdSizeForComputeMode(); + EXPECT_TRUE(csr->isComputeModeNeeded()); EXPECT_EQ(lriSize, retSize); overrideCoherencyRequest(true, false); retSize = csr->getCmdSizeForComputeMode(); + EXPECT_TRUE(csr->isComputeModeNeeded()); EXPECT_EQ(lriSize, retSize); } diff --git a/opencl/test/unit_test/gen12lp/coherency_tests_gen12lp.inl b/opencl/test/unit_test/gen12lp/coherency_tests_gen12lp.inl index 906669a7ab..fc8f7b3fc3 100644 --- a/opencl/test/unit_test/gen12lp/coherency_tests_gen12lp.inl +++ b/opencl/test/unit_test/gen12lp/coherency_tests_gen12lp.inl @@ -72,19 +72,19 @@ GEN12LPTEST_F(Gen12LpCoherencyRequirements, GivenNoSharedHandlesWhenGettingCmdSi } overrideCoherencyRequest(false, false, false); - auto retSize = csr->getCmdSizeForComputeMode(); - EXPECT_EQ(0u, retSize); + EXPECT_FALSE(csr->isComputeModeNeeded()); overrideCoherencyRequest(false, true, false); - retSize = csr->getCmdSizeForComputeMode(); - EXPECT_EQ(0u, retSize); + EXPECT_FALSE(csr->isComputeModeNeeded()); overrideCoherencyRequest(true, true, false); - retSize = csr->getCmdSizeForComputeMode(); + auto retSize = csr->getCmdSizeForComputeMode(); + EXPECT_TRUE(csr->isComputeModeNeeded()); EXPECT_EQ(cmdsSize, retSize); overrideCoherencyRequest(true, false, false); retSize = csr->getCmdSizeForComputeMode(); + EXPECT_TRUE(csr->isComputeModeNeeded()); EXPECT_EQ(cmdsSize, retSize); } @@ -99,19 +99,19 @@ GEN12LPTEST_F(Gen12LpCoherencyRequirements, GivenSharedHandlesWhenGettingCmdSize } overrideCoherencyRequest(false, false, true); - auto retSize = csr->getCmdSizeForComputeMode(); - EXPECT_EQ(0u, retSize); + EXPECT_FALSE(csr->isComputeModeNeeded()); overrideCoherencyRequest(false, true, true); - retSize = csr->getCmdSizeForComputeMode(); - EXPECT_EQ(0u, retSize); + EXPECT_FALSE(csr->isComputeModeNeeded()); overrideCoherencyRequest(true, true, true); - retSize = csr->getCmdSizeForComputeMode(); + auto retSize = csr->getCmdSizeForComputeMode(); + EXPECT_TRUE(csr->isComputeModeNeeded()); EXPECT_EQ(cmdsSize, retSize); overrideCoherencyRequest(true, false, true); retSize = csr->getCmdSizeForComputeMode(); + EXPECT_TRUE(csr->isComputeModeNeeded()); EXPECT_EQ(cmdsSize, retSize); } diff --git a/opencl/test/unit_test/gen9/coherency_tests_gen9.cpp b/opencl/test/unit_test/gen9/coherency_tests_gen9.cpp index 5b35a00f5e..187bbdd784 100644 --- a/opencl/test/unit_test/gen9/coherency_tests_gen9.cpp +++ b/opencl/test/unit_test/gen9/coherency_tests_gen9.cpp @@ -1,29 +1,26 @@ /* - * Copyright (C) 2018-2021 Intel Corporation + * Copyright (C) 2018-2022 Intel Corporation * * SPDX-License-Identifier: MIT * */ -#include "shared/source/command_stream/command_stream_receiver_hw.h" -#include "shared/source/execution_environment/execution_environment.h" #include "shared/test/common/helpers/default_hw_info.h" #include "shared/test/common/helpers/dispatch_flags_helper.h" +#include "shared/test/common/libult/ult_command_stream_receiver.h" +#include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/mocks/ult_device_factory.h" #include "shared/test/common/test_macros/test.h" -#include "opencl/source/platform/platform.h" -#include "opencl/test/unit_test/mocks/mock_platform.h" - using namespace NEO; typedef ::testing::Test Gen9CoherencyRequirements; GEN9TEST_F(Gen9CoherencyRequirements, WhenMemoryManagerIsInitializedThenNoCoherencyProgramming) { - ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); - executionEnvironment->initializeMemoryManager(); - CommandStreamReceiverHw csr(*executionEnvironment, 0, 1); + UltDeviceFactory deviceFactory{1, 0}; LinearStream stream; DispatchFlags flags = DispatchFlagsHelper::createDefaultDispatchFlags(); + auto &csr = deviceFactory.rootDevices[0]->getUltCommandStreamReceiver(); auto retSize = csr.getCmdSizeForComputeMode(); EXPECT_EQ(0u, retSize); diff --git a/shared/source/command_container/command_encoder.h b/shared/source/command_container/command_encoder.h index 92770bf364..e36286259d 100644 --- a/shared/source/command_container/command_encoder.h +++ b/shared/source/command_container/command_encoder.h @@ -10,6 +10,7 @@ #include "shared/source/debugger/debugger.h" #include "shared/source/execution_environment/execution_environment.h" #include "shared/source/helpers/definitions/mi_flush_args.h" +#include "shared/source/helpers/pipe_control_args.h" #include "shared/source/helpers/register_offsets.h" #include "shared/source/helpers/simd_helper.h" #include "shared/source/helpers/vec.h" @@ -280,6 +281,10 @@ struct EncodeSurfaceState { template struct EncodeComputeMode { + static size_t getCmdSizeForComputeMode(const HardwareInfo &hwInfo, bool hasSharedHandles, bool isRcs); + static void programComputeModeCommandWithSynchronization(LinearStream &csr, StateComputeModeProperties &properties, + const PipelineSelectArgs &args, bool hasSharedHandles, + const HardwareInfo &hwInfo, bool isRcs); static void programComputeModeCommand(LinearStream &csr, StateComputeModeProperties &properties, const HardwareInfo &hwInfo); static void adjustPipelineSelect(CommandContainer &container, const NEO::KernelDescriptor &kernelDescriptor); @@ -287,8 +292,13 @@ struct EncodeComputeMode { template struct EncodeWA { - static void encodeAdditionalPipelineSelect(Device &device, LinearStream &stream, bool is3DPipeline); + static void encodeAdditionalPipelineSelect(LinearStream &stream, const PipelineSelectArgs &args, bool is3DPipeline, + const HardwareInfo &hwInfo, bool isRcs); static size_t getAdditionalPipelineSelectSize(Device &device); + + static void addPipeControlPriorToNonPipelinedStateCommand(LinearStream &commandStream, PipeControlArgs args, + const HardwareInfo &hwInfo, bool isRcs); + static void setAdditionalPipeControlFlagsForNonPipelineStateCommand(PipeControlArgs &args); }; template diff --git a/shared/source/command_container/command_encoder.inl b/shared/source/command_container/command_encoder.inl index c45db4731e..d56aa8d41f 100644 --- a/shared/source/command_container/command_encoder.inl +++ b/shared/source/command_container/command_encoder.inl @@ -848,4 +848,7 @@ inline void EncodeStoreMemory::programStoreDataImm(LinearStream &command template void EncodeEnableRayTracing::append3dStateBtd(void *ptr3dStateBtd) {} +template +inline void EncodeWA::setAdditionalPipeControlFlagsForNonPipelineStateCommand(PipeControlArgs &args) {} + } // namespace NEO diff --git a/shared/source/command_container/command_encoder_bdw_and_later.inl b/shared/source/command_container/command_encoder_bdw_and_later.inl index 6268637244..696286b0e1 100644 --- a/shared/source/command_container/command_encoder_bdw_and_later.inl +++ b/shared/source/command_container/command_encoder_bdw_and_later.inl @@ -355,11 +355,14 @@ void EncodeStateBaseAddress::encode(CommandContainer &container, STATE_B template void EncodeStateBaseAddress::encode(CommandContainer &container, STATE_BASE_ADDRESS &sbaCmd, uint32_t statelessMocsIndex, bool useGlobalAtomics, bool multiOsContextCapable) { + auto &device = *container.getDevice(); + auto &hwInfo = device.getHardwareInfo(); + auto isRcs = device.getDefaultEngine().commandStreamReceiver->isRcs(); if (container.isAnyHeapDirty()) { - EncodeWA::encodeAdditionalPipelineSelect(*container.getDevice(), *container.getCommandStream(), true); + EncodeWA::encodeAdditionalPipelineSelect(*container.getCommandStream(), {}, true, hwInfo, isRcs); } - auto gmmHelper = container.getDevice()->getGmmHelper(); + auto gmmHelper = device.getGmmHelper(); StateBaseAddressHelper::programStateBaseAddress( &sbaCmd, @@ -383,7 +386,7 @@ void EncodeStateBaseAddress::encode(CommandContainer &container, STATE_B auto pCmd = reinterpret_cast(container.getCommandStream()->getSpace(sizeof(STATE_BASE_ADDRESS))); *pCmd = sbaCmd; - EncodeWA::encodeAdditionalPipelineSelect(*container.getDevice(), *container.getCommandStream(), false); + EncodeWA::encodeAdditionalPipelineSelect(*container.getCommandStream(), {}, false, hwInfo, isRcs); } template @@ -410,13 +413,20 @@ size_t EncodeMiFlushDW::getMiFlushDwWaSize() { } template -inline void EncodeWA::encodeAdditionalPipelineSelect(Device &device, LinearStream &stream, bool is3DPipeline) {} +inline void EncodeWA::encodeAdditionalPipelineSelect(LinearStream &stream, const PipelineSelectArgs &args, bool is3DPipeline, + const HardwareInfo &hwInfo, bool isRcs) {} template inline size_t EncodeWA::getAdditionalPipelineSelectSize(Device &device) { return 0; } +template +inline void EncodeWA::addPipeControlPriorToNonPipelinedStateCommand(LinearStream &commandStream, PipeControlArgs args, + const HardwareInfo &hwInfo, bool isRcs) { + MemorySynchronizationCommands::addPipeControl(commandStream, args); +} + template inline void EncodeSurfaceState::encodeExtraBufferParams(EncodeSurfaceStateArgs &args) { auto surfaceState = reinterpret_cast(args.outMemory); diff --git a/shared/source/command_container/command_encoder_xe_hpg_core_and_later.inl b/shared/source/command_container/command_encoder_xe_hpg_core_and_later.inl index 2f237ef6fe..b2f1a7c589 100644 --- a/shared/source/command_container/command_encoder_xe_hpg_core_and_later.inl +++ b/shared/source/command_container/command_encoder_xe_hpg_core_and_later.inl @@ -30,4 +30,9 @@ void EncodeEnableRayTracing::programEnableRayTracing(LinearStream &co *commandStream.getSpaceForCmd() = cmd; } +template <> +inline void EncodeWA::setAdditionalPipeControlFlagsForNonPipelineStateCommand(PipeControlArgs &args) { + args.unTypedDataPortCacheFlush = true; +} + } // namespace NEO diff --git a/shared/source/command_container/command_encoder_xehp_and_later.inl b/shared/source/command_container/command_encoder_xehp_and_later.inl index 362372f630..1bff8f3175 100644 --- a/shared/source/command_container/command_encoder_xehp_and_later.inl +++ b/shared/source/command_container/command_encoder_xehp_and_later.inl @@ -644,12 +644,38 @@ void EncodeSempahore::programMiSemaphoreWait(MI_SEMAPHORE_WAIT *cmd, } template -inline void EncodeWA::encodeAdditionalPipelineSelect(Device &device, LinearStream &stream, bool is3DPipeline) {} +inline void EncodeWA::encodeAdditionalPipelineSelect(LinearStream &stream, const PipelineSelectArgs &args, bool is3DPipeline, + const HardwareInfo &hwInfo, bool isRcs) {} template inline size_t EncodeWA::getAdditionalPipelineSelectSize(Device &device) { return 0u; } +template +inline void EncodeWA::addPipeControlPriorToNonPipelinedStateCommand(LinearStream &commandStream, PipeControlArgs args, + const HardwareInfo &hwInfo, bool isRcs) { + auto &hwInfoConfig = (*HwInfoConfig::get(hwInfo.platform.eProductFamily)); + const auto &[isBasicWARequired, isExtendedWARequired] = hwInfoConfig.isPipeControlPriorToNonPipelinedStateCommandsWARequired(hwInfo, isRcs); + + if (isExtendedWARequired) { + args.textureCacheInvalidationEnable = true; + args.hdcPipelineFlush = true; + args.amfsFlushEnable = true; + args.instructionCacheInvalidateEnable = true; + args.constantCacheInvalidationEnable = true; + args.stateCacheInvalidationEnable = true; + + args.dcFlushEnable = false; + + NEO::EncodeWA::setAdditionalPipeControlFlagsForNonPipelineStateCommand(args); + } else if (isBasicWARequired) { + args.hdcPipelineFlush = true; + + NEO::EncodeWA::setAdditionalPipeControlFlagsForNonPipelineStateCommand(args); + } + + MemorySynchronizationCommands::addPipeControl(commandStream, args); +} template inline void EncodeStoreMemory::programStoreDataImm(MI_STORE_DATA_IMM *cmdBuffer, 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 27242b1c6f..6649af77a9 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 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 Intel Corporation + * Copyright (C) 2020-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -10,6 +10,18 @@ #include "shared/source/command_stream/linear_stream.h" namespace NEO { + +template +size_t EncodeComputeMode::getCmdSizeForComputeMode(const HardwareInfo &hwInfo, bool hasSharedHandles, bool isRcs) { + return 0u; +} + +template +inline void EncodeComputeMode::programComputeModeCommandWithSynchronization( + LinearStream &csr, StateComputeModeProperties &properties, const PipelineSelectArgs &args, + bool hasSharedHandles, const HardwareInfo &hwInfo, bool isRcs) { +} + 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 ec67a8e859..95542e7af7 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 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 Intel Corporation + * Copyright (C) 2020-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -10,6 +10,58 @@ #include "shared/source/command_stream/linear_stream.h" namespace NEO { + +template +size_t EncodeComputeMode::getCmdSizeForComputeMode(const HardwareInfo &hwInfo, bool hasSharedHandles, bool isRcs) { + size_t size = 0; + auto &hwInfoConfig = (*HwInfoConfig::get(hwInfo.platform.eProductFamily)); + const auto &[isBasicWARequired, isExtendedWARequired] = hwInfoConfig.isPipeControlPriorToNonPipelinedStateCommandsWARequired(hwInfo, isRcs); + std::ignore = isExtendedWARequired; + + if (isBasicWARequired) { + size += sizeof(typename Family::PIPE_CONTROL); + } + size += sizeof(typename Family::STATE_COMPUTE_MODE); + if (hasSharedHandles) { + size += sizeof(typename Family::PIPE_CONTROL); + } + if (hwInfoConfig.is3DPipelineSelectWARequired() && isRcs) { + size += (2 * PreambleHelper::getCmdSizeForPipelineSelect(hwInfo)); + } + return size; +} + +template +inline void EncodeComputeMode::programComputeModeCommandWithSynchronization( + LinearStream &csr, StateComputeModeProperties &properties, const PipelineSelectArgs &args, + bool hasSharedHandles, const HardwareInfo &hwInfo, bool isRcs) { + + using PIPE_CONTROL = typename Family::PIPE_CONTROL; + + NEO::EncodeWA::encodeAdditionalPipelineSelect(csr, args, true, hwInfo, isRcs); + + auto &hwInfoConfig = (*HwInfoConfig::get(hwInfo.platform.eProductFamily)); + const auto &[isBasicWARequired, isExtendedWARequired] = hwInfoConfig.isPipeControlPriorToNonPipelinedStateCommandsWARequired(hwInfo, isRcs); + std::ignore = isExtendedWARequired; + + if (isBasicWARequired) { + PipeControlArgs args; + args.dcFlushEnable = MemorySynchronizationCommands::getDcFlushEnable(true, hwInfo); + NEO::EncodeWA::addPipeControlPriorToNonPipelinedStateCommand(csr, args, hwInfo, isRcs); + } + + StreamProperties streamProperties{}; + streamProperties.stateComputeMode.setProperties(properties); + EncodeComputeMode::programComputeModeCommand(csr, streamProperties.stateComputeMode, hwInfo); + + if (hasSharedHandles) { + auto pc = csr.getSpaceForCmd(); + *pc = Family::cmdInitPipeControl; + } + + NEO::EncodeWA::encodeAdditionalPipelineSelect(csr, args, false, hwInfo, isRcs); +} + template inline void EncodeStoreMMIO::remapOffset(MI_STORE_REGISTER_MEM *pStoreRegMem) { pStoreRegMem->setMmioRemapEnable(true); diff --git a/shared/source/command_stream/command_stream_receiver_hw.h b/shared/source/command_stream/command_stream_receiver_hw.h index 8f6d688e4e..b26fdf2a92 100644 --- a/shared/source/command_stream/command_stream_receiver_hw.h +++ b/shared/source/command_stream/command_stream_receiver_hw.h @@ -65,7 +65,6 @@ class CommandStreamReceiverHw : public CommandStreamReceiver { size_t getCmdSizeForEpilogueCommands(const DispatchFlags &dispatchFlags) const; size_t getCmdSizeForL3Config() const; size_t getCmdSizeForPipelineSelect() const; - size_t getCmdSizeForComputeMode(); size_t getCmdSizeForMediaSampler(bool mediaSamplerRequired) const; size_t getCmdSizeForEngineMode(const DispatchFlags &dispatchFlags) const; size_t getCmdSizeForPerDssBackedBuffer(const HardwareInfo &hwInfo); @@ -73,6 +72,8 @@ class CommandStreamReceiverHw : public CommandStreamReceiver { size_t getCmdSizeForStallingCommands(const DispatchFlags &dispatchFlags) const; size_t getCmdSizeForStallingNoPostSyncCommands() const; size_t getCmdSizeForStallingPostSyncCommands() const; + size_t getCmdSizeForComputeMode(); + MOCKABLE_VIRTUAL bool hasSharedHandles(); bool isComputeModeNeeded() const; bool isPipelineSelectAlreadyProgrammed() const; @@ -148,7 +149,6 @@ class CommandStreamReceiverHw : public CommandStreamReceiver { void programL3(LinearStream &csr, uint32_t &newL3Config); void programPreamble(LinearStream &csr, Device &device, uint32_t &newL3Config); void programPipelineSelect(LinearStream &csr, PipelineSelectArgs &pipelineSelectArgs); - void programAdditionalPipelineSelect(LinearStream &csr, PipelineSelectArgs &pipelineSelectArgs, bool is3DPipeline); void programAdditionalStateBaseAddress(LinearStream &csr, typename GfxFamily::STATE_BASE_ADDRESS &cmd, Device &device); void programEpilogue(LinearStream &csr, Device &device, void **batchBufferEndLocation, DispatchFlags &dispatchFlags); void programEpliogueCommands(LinearStream &csr, const DispatchFlags &dispatchFlags); @@ -166,13 +166,10 @@ class CommandStreamReceiverHw : public CommandStreamReceiver { void programEnginePrologue(LinearStream &csr); size_t getCmdSizeForPrologue() const; - void setPipeControlPriorToNonPipelinedStateCommandExtraProperties(PipeControlArgs &args); - void addClearSLMWorkAround(typename GfxFamily::PIPE_CONTROL *pCmd); void addPipeControlBeforeStateBaseAddress(LinearStream &commandStream); void addPipeControlBeforeStateSip(LinearStream &commandStream, Device &device); void addPipeControlBefore3dState(LinearStream &commandStream, DispatchFlags &dispatchFlags); - void addPipeControlPriorToNonPipelinedStateCommand(LinearStream &commandStream, PipeControlArgs args); size_t getSshHeapSize(); bool are4GbHeapsAvailable() const; diff --git a/shared/source/command_stream/command_stream_receiver_hw_base.inl b/shared/source/command_stream/command_stream_receiver_hw_base.inl index c04d1b1a40..0aa208d4e8 100644 --- a/shared/source/command_stream/command_stream_receiver_hw_base.inl +++ b/shared/source/command_stream/command_stream_receiver_hw_base.inl @@ -400,7 +400,7 @@ CompletionStamp CommandStreamReceiverHw::flushTask( //Reprogram state base address if required if (isStateBaseAddressDirty || sourceLevelDebuggerActive) { addPipeControlBeforeStateBaseAddress(commandStreamCSR); - programAdditionalPipelineSelect(commandStreamCSR, dispatchFlags.pipelineSelectArgs, true); + EncodeWA::encodeAdditionalPipelineSelect(commandStreamCSR, dispatchFlags.pipelineSelectArgs, true, hwInfo, isRcs()); uint64_t newGSHbase = 0; GSBAFor32BitProgrammed = false; @@ -447,7 +447,7 @@ CompletionStamp CommandStreamReceiverHw::flushTask( bindingTableBaseAddressRequired = false; } - programAdditionalPipelineSelect(commandStreamCSR, dispatchFlags.pipelineSelectArgs, false); + EncodeWA::encodeAdditionalPipelineSelect(commandStreamCSR, dispatchFlags.pipelineSelectArgs, false, hwInfo, isRcs()); addPipeControlBeforeStateSip(commandStreamCSR, device); programStateSip(commandStreamCSR, device); @@ -809,7 +809,9 @@ size_t CommandStreamReceiverHw::getRequiredCmdStreamSize(const Dispat size += sizeof(typename GfxFamily::MI_BATCH_BUFFER_START); size += getCmdSizeForL3Config(); - size += getCmdSizeForComputeMode(); + if (isComputeModeNeeded()) { + size += getCmdSizeForComputeMode(); + } size += getCmdSizeForMediaSampler(dispatchFlags.pipelineSelectArgs.mediaSamplerRequired); size += getCmdSizeForPipelineSelect(); size += getCmdSizeForPreemption(dispatchFlags); @@ -1360,24 +1362,9 @@ inline void CommandStreamReceiverHw::updateTagFromWait() { } } -template -inline void CommandStreamReceiverHw::programAdditionalPipelineSelect(LinearStream &csr, PipelineSelectArgs &pipelineSelectArgs, bool is3DPipeline) { - const auto &hwInfoConfig = *HwInfoConfig::get(peekHwInfo().platform.eProductFamily); - if (hwInfoConfig.is3DPipelineSelectWARequired() && isRcs()) { - auto localPipelineSelectArgs = pipelineSelectArgs; - localPipelineSelectArgs.is3DPipelineRequired = is3DPipeline; - PreambleHelper::programPipelineSelect(&csr, localPipelineSelectArgs, peekHwInfo()); - } -} - template inline void CommandStreamReceiverHw::programAdditionalStateBaseAddress(LinearStream &csr, typename GfxFamily::STATE_BASE_ADDRESS &cmd, Device &device) {} -template -inline bool CommandStreamReceiverHw::isComputeModeNeeded() const { - return false; -} - template inline MemoryCompressionState CommandStreamReceiverHw::getMemoryCompressionState(bool auxTranslationRequired, const HardwareInfo &hwInfo) const { return MemoryCompressionState::NotApplicable; @@ -1502,4 +1489,22 @@ inline void CommandStreamReceiverHw::programActivePartitionConfigFlus } } +template +bool CommandStreamReceiverHw::hasSharedHandles() { + if (!csrSizeRequestFlags.hasSharedHandles) { + for (const auto &allocation : this->getResidencyAllocations()) { + if (allocation->peekSharedHandle()) { + csrSizeRequestFlags.hasSharedHandles = true; + break; + } + } + } + return csrSizeRequestFlags.hasSharedHandles; +} + +template +size_t CommandStreamReceiverHw::getCmdSizeForComputeMode() { + return EncodeComputeMode::getCmdSizeForComputeMode(this->peekHwInfo(), hasSharedHandles(), isRcs()); +} + } // namespace NEO diff --git a/shared/source/command_stream/command_stream_receiver_hw_bdw_and_later.inl b/shared/source/command_stream/command_stream_receiver_hw_bdw_and_later.inl index 5fea20da6a..babbb05961 100644 --- a/shared/source/command_stream/command_stream_receiver_hw_bdw_and_later.inl +++ b/shared/source/command_stream/command_stream_receiver_hw_bdw_and_later.inl @@ -90,21 +90,13 @@ bool CommandStreamReceiverHw::isMultiOsContextCapable() const { return false; } -template -inline void CommandStreamReceiverHw::setPipeControlPriorToNonPipelinedStateCommandExtraProperties(PipeControlArgs &args) {} - -template -inline void CommandStreamReceiverHw::addPipeControlPriorToNonPipelinedStateCommand(LinearStream &commandStream, PipeControlArgs args) { - MemorySynchronizationCommands::addPipeControl(commandStream, args); -} - template inline void CommandStreamReceiverHw::addPipeControlBeforeStateBaseAddress(LinearStream &commandStream) { PipeControlArgs args; args.dcFlushEnable = MemorySynchronizationCommands::getDcFlushEnable(true, peekHwInfo()); args.textureCacheInvalidationEnable = true; - addPipeControlPriorToNonPipelinedStateCommand(commandStream, args); + NEO::EncodeWA::addPipeControlPriorToNonPipelinedStateCommand(commandStream, args, peekHwInfo(), isRcs()); } template diff --git a/shared/source/command_stream/command_stream_receiver_hw_dg2_and_later.inl b/shared/source/command_stream/command_stream_receiver_hw_dg2_and_later.inl index 67c3f8df2d..a9d8d3da5c 100644 --- a/shared/source/command_stream/command_stream_receiver_hw_dg2_and_later.inl +++ b/shared/source/command_stream/command_stream_receiver_hw_dg2_and_later.inl @@ -16,11 +16,6 @@ using _3DSTATE_BTD = typename Family::_3DSTATE_BTD; using _3DSTATE_BTD_BODY = typename Family::_3DSTATE_BTD_BODY; using PIPE_CONTROL = typename Family::PIPE_CONTROL; -template -inline void CommandStreamReceiverHw::setPipeControlPriorToNonPipelinedStateCommandExtraProperties(PipeControlArgs &args) { - args.unTypedDataPortCacheFlush = true; -} - template <> void CommandStreamReceiverHw::programPerDssBackedBuffer(LinearStream &commandStream, Device &device, DispatchFlags &dispatchFlags) { if (dispatchFlags.usePerDssBackedBuffer && !isPerDssBackedBufferSent) { @@ -64,7 +59,7 @@ inline void CommandStreamReceiverHw::addPipeControlBefore3dState(Line if (isExtendedWARequired && dispatchFlags.usePerDssBackedBuffer && !isPerDssBackedBufferSent) { DEBUG_BREAK_IF(perDssBackedBuffer == nullptr); - addPipeControlPriorToNonPipelinedStateCommand(commandStream, args); + NEO::EncodeWA::addPipeControlPriorToNonPipelinedStateCommand(commandStream, args, hwInfo, isRcs()); } } 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 156f74d3c1..70e10e34bc 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 @@ -15,37 +15,17 @@ namespace NEO { template void CommandStreamReceiverHw::programComputeMode(LinearStream &stream, DispatchFlags &dispatchFlags, const HardwareInfo &hwInfo) { - using PIPE_CONTROL = typename GfxFamily::PIPE_CONTROL; if (isComputeModeNeeded()) { - programAdditionalPipelineSelect(stream, dispatchFlags.pipelineSelectArgs, true); - - auto hwInfoConfig = HwInfoConfig::get(hwInfo.platform.eProductFamily); - const auto &[isBasicWARequired, isExtendedWARequired] = hwInfoConfig->isPipeControlPriorToNonPipelinedStateCommandsWARequired(hwInfo, isRcs()); - std::ignore = isExtendedWARequired; - - if (isBasicWARequired) { - PipeControlArgs args; - args.dcFlushEnable = MemorySynchronizationCommands::getDcFlushEnable(true, hwInfo); - addPipeControlPriorToNonPipelinedStateCommand(stream, args); - } - - StreamProperties streamProperties{}; - streamProperties.stateComputeMode.setProperties(this->streamProperties.stateComputeMode); - EncodeComputeMode::programComputeModeCommand(stream, streamProperties.stateComputeMode, hwInfo); - - if (csrSizeRequestFlags.hasSharedHandles) { - auto pc = stream.getSpaceForCmd(); - *pc = GfxFamily::cmdInitPipeControl; - } - - programAdditionalPipelineSelect(stream, dispatchFlags.pipelineSelectArgs, false); + EncodeComputeMode::programComputeModeCommandWithSynchronization( + stream, this->streamProperties.stateComputeMode, dispatchFlags.pipelineSelectArgs, + hasSharedHandles(), hwInfo, isRcs()); } } -template <> -inline bool CommandStreamReceiverHw::isComputeModeNeeded() const { - return this->streamProperties.stateComputeMode.isDirty() || - StateComputeModeHelper::isStateComputeModeRequired(csrSizeRequestFlags, false); +template +inline bool CommandStreamReceiverHw::isComputeModeNeeded() const { + return StateComputeModeHelper::isStateComputeModeRequired(csrSizeRequestFlags, false) || + this->streamProperties.stateComputeMode.isDirty(); } template <> @@ -55,7 +35,7 @@ inline void CommandStreamReceiverHw::addPipeControlBeforeStateBaseAddres args.textureCacheInvalidationEnable = true; args.hdcPipelineFlush = true; - addPipeControlPriorToNonPipelinedStateCommand(commandStream, args); + NEO::EncodeWA::addPipeControlPriorToNonPipelinedStateCommand(commandStream, args, peekHwInfo(), isRcs()); } } // namespace NEO diff --git a/shared/source/command_stream/command_stream_receiver_hw_xehp_and_later.inl b/shared/source/command_stream/command_stream_receiver_hw_xehp_and_later.inl index d9e856451f..93a08aae05 100644 --- a/shared/source/command_stream/command_stream_receiver_hw_xehp_and_later.inl +++ b/shared/source/command_stream/command_stream_receiver_hw_xehp_and_later.inl @@ -44,36 +44,6 @@ size_t CommandStreamReceiverHw::getRequiredStateBaseAddressSize(const template size_t CommandStreamReceiverHw::getCmdSizeForL3Config() const { return 0; } -template -size_t CommandStreamReceiverHw::getCmdSizeForComputeMode() { - if (!csrSizeRequestFlags.hasSharedHandles) { - for (const auto &allocation : this->getResidencyAllocations()) { - if (allocation->peekSharedHandle()) { - csrSizeRequestFlags.hasSharedHandles = true; - break; - } - } - } - - size_t size = 0; - auto &hwInfo = peekHwInfo(); - if (isComputeModeNeeded()) { - auto hwInfoConfig = HwInfoConfig::get(hwInfo.platform.eProductFamily); - const auto &[isBasicWARequired, isExtendedWARequired] = hwInfoConfig->isPipeControlPriorToNonPipelinedStateCommandsWARequired(hwInfo, isRcs()); - std::ignore = isExtendedWARequired; - const auto isWARequired = isBasicWARequired; - - if (isWARequired) { - size += sizeof(typename GfxFamily::PIPE_CONTROL); - } - size += sizeof(typename GfxFamily::STATE_COMPUTE_MODE); - if (csrSizeRequestFlags.hasSharedHandles) { - size += sizeof(typename GfxFamily::PIPE_CONTROL); - } - } - return size; -} - template void CommandStreamReceiverHw::programPipelineSelect(LinearStream &commandStream, PipelineSelectArgs &pipelineSelectArgs) { if (csrSizeRequestFlags.mediaSamplerConfigChanged || csrSizeRequestFlags.specialPipelineSelectModeChanged || !isPreambleSent) { @@ -164,32 +134,6 @@ inline void CommandStreamReceiverHw::programActivePartitionConfig(Lin this->activePartitionsConfig = this->activePartitions; } -template -inline void CommandStreamReceiverHw::addPipeControlPriorToNonPipelinedStateCommand(LinearStream &commandStream, PipeControlArgs args) { - auto &hwInfo = peekHwInfo(); - auto hwInfoConfig = HwInfoConfig::get(hwInfo.platform.eProductFamily); - const auto &[isBasicWARequired, isExtendedWARequired] = hwInfoConfig->isPipeControlPriorToNonPipelinedStateCommandsWARequired(hwInfo, isRcs()); - - if (isExtendedWARequired) { - args.textureCacheInvalidationEnable = true; - args.hdcPipelineFlush = true; - args.amfsFlushEnable = true; - args.instructionCacheInvalidateEnable = true; - args.constantCacheInvalidationEnable = true; - args.stateCacheInvalidationEnable = true; - - args.dcFlushEnable = false; - - setPipeControlPriorToNonPipelinedStateCommandExtraProperties(args); - } else if (isBasicWARequired) { - args.hdcPipelineFlush = true; - - setPipeControlPriorToNonPipelinedStateCommandExtraProperties(args); - } - - MemorySynchronizationCommands::addPipeControl(commandStream, args); -} - template inline void CommandStreamReceiverHw::addPipeControlBeforeStateSip(LinearStream &commandStream, Device &device) { auto &hwInfo = peekHwInfo(); @@ -202,7 +146,7 @@ inline void CommandStreamReceiverHw::addPipeControlBeforeStateSip(Lin std::ignore = isExtendedWARequired; if (isBasicWARequired && debuggingEnabled && !hwHelper.isSipWANeeded(hwInfo)) { - addPipeControlPriorToNonPipelinedStateCommand(commandStream, args); + NEO::EncodeWA::addPipeControlPriorToNonPipelinedStateCommand(commandStream, args, hwInfo, isRcs()); } } diff --git a/shared/source/gen11/command_encoder_gen11.cpp b/shared/source/gen11/command_encoder_gen11.cpp index eebdc9dd61..aec1f3bee8 100644 --- a/shared/source/gen11/command_encoder_gen11.cpp +++ b/shared/source/gen11/command_encoder_gen11.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 Intel Corporation + * Copyright (C) 2020-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -18,6 +18,21 @@ using Family = NEO::ICLFamily; namespace NEO { +template <> +size_t EncodeComputeMode::getCmdSizeForComputeMode(const HardwareInfo &hwInfo, bool hasSharedHandles, bool isRcs) { + return sizeof(typename Family::MI_LOAD_REGISTER_IMM); +} + +template <> +void EncodeComputeMode::programComputeModeCommandWithSynchronization( + LinearStream &csr, StateComputeModeProperties &properties, const PipelineSelectArgs &args, + bool hasSharedHandles, const HardwareInfo &hwInfo, bool isRcs) { + LriHelper::program(&csr, + gen11HdcModeRegister::address, + DwordBuilder::build(gen11HdcModeRegister::forceNonCoherentEnableBit, true, !properties.isCoherencyRequired.value), + false); +} + template <> bool EncodeSurfaceState::doBindingTablePrefetch() { return false; diff --git a/shared/source/gen11/command_stream_receiver_hw_gen11.cpp b/shared/source/gen11/command_stream_receiver_hw_gen11.cpp index 07257fff6b..ba39d1c620 100644 --- a/shared/source/gen11/command_stream_receiver_hw_gen11.cpp +++ b/shared/source/gen11/command_stream_receiver_hw_gen11.cpp @@ -5,6 +5,7 @@ * */ +#include "shared/source/command_container/command_encoder.h" #include "shared/source/command_stream/command_stream_receiver_hw_bdw_and_later.inl" #include "shared/source/command_stream/device_command_stream.h" #include "shared/source/debug_settings/debug_settings_manager.h" @@ -17,21 +18,17 @@ typedef ICLFamily Family; static auto gfxCore = IGFX_GEN11_CORE; template <> -size_t CommandStreamReceiverHw::getCmdSizeForComputeMode() { - if (this->streamProperties.stateComputeMode.isDirty()) { - return sizeof(typename Family::MI_LOAD_REGISTER_IMM); +void CommandStreamReceiverHw::programComputeMode(LinearStream &stream, DispatchFlags &dispatchFlags, const HardwareInfo &hwInfo) { + if (this->isComputeModeNeeded()) { + EncodeComputeMode::programComputeModeCommandWithSynchronization( + stream, this->streamProperties.stateComputeMode, dispatchFlags.pipelineSelectArgs, + hasSharedHandles(), hwInfo, isRcs()); } - return 0; } -template <> -void CommandStreamReceiverHw::programComputeMode(LinearStream &stream, DispatchFlags &dispatchFlags, const HardwareInfo &hwInfo) { - if (this->streamProperties.stateComputeMode.isDirty()) { - LriHelper::program(&stream, - gen11HdcModeRegister::address, - DwordBuilder::build(gen11HdcModeRegister::forceNonCoherentEnableBit, true, !dispatchFlags.requiresCoherency), - false); - } +template +inline bool CommandStreamReceiverHw::isComputeModeNeeded() const { + return this->streamProperties.stateComputeMode.isCoherencyRequired.isDirty; } template <> diff --git a/shared/source/gen12lp/command_encoder_gen12lp.cpp b/shared/source/gen12lp/command_encoder_gen12lp.cpp index daf23bb8f8..9555a3cdb5 100644 --- a/shared/source/gen12lp/command_encoder_gen12lp.cpp +++ b/shared/source/gen12lp/command_encoder_gen12lp.cpp @@ -52,11 +52,13 @@ void EncodeComputeMode::programComputeModeCommand(LinearStream &csr, Sta } template <> -void EncodeWA::encodeAdditionalPipelineSelect(Device &device, LinearStream &stream, bool is3DPipeline) { - if (device.getDefaultEngine().commandStreamReceiver->isRcs()) { - PipelineSelectArgs args; - args.is3DPipelineRequired = is3DPipeline; - PreambleHelper::programPipelineSelect(&stream, args, device.getHardwareInfo()); +void EncodeWA::encodeAdditionalPipelineSelect(LinearStream &stream, const PipelineSelectArgs &args, + bool is3DPipeline, const HardwareInfo &hwInfo, bool isRcs) { + const auto &hwInfoConfig = *HwInfoConfig::get(hwInfo.platform.eProductFamily); + if (hwInfoConfig.is3DPipelineSelectWARequired() && isRcs) { + PipelineSelectArgs pipelineSelectArgs = args; + pipelineSelectArgs.is3DPipelineRequired = is3DPipeline; + PreambleHelper::programPipelineSelect(&stream, pipelineSelectArgs, hwInfo); } } diff --git a/shared/source/gen12lp/command_stream_receiver_hw_gen12lp.cpp b/shared/source/gen12lp/command_stream_receiver_hw_gen12lp.cpp index 04471d6f47..45af5acadb 100644 --- a/shared/source/gen12lp/command_stream_receiver_hw_gen12lp.cpp +++ b/shared/source/gen12lp/command_stream_receiver_hw_gen12lp.cpp @@ -27,33 +27,6 @@ size_t CommandStreamReceiverHw::getCmdSizeForL3Config() const { return 0; } -template <> -size_t CommandStreamReceiverHw::getCmdSizeForComputeMode() { - if (!csrSizeRequestFlags.hasSharedHandles) { - for (const auto &allocation : this->getResidencyAllocations()) { - if (allocation->peekSharedHandle()) { - csrSizeRequestFlags.hasSharedHandles = true; - break; - } - } - } - - size_t size = 0; - if (this->streamProperties.stateComputeMode.isDirty() || csrSizeRequestFlags.numGrfRequiredChanged) { - size += sizeof(typename Family::STATE_COMPUTE_MODE); - if (csrSizeRequestFlags.hasSharedHandles) { - size += sizeof(typename Family::PIPE_CONTROL); - } - - const auto &hwInfoConfig = *HwInfoConfig::get(peekHwInfo().platform.eProductFamily); - if (hwInfoConfig.is3DPipelineSelectWARequired() && isRcs()) { - size += (2 * PreambleHelper::getCmdSizeForPipelineSelect(peekHwInfo())); - } - } - - return size; -} - template <> void populateFactoryTable>() { extern CommandStreamReceiverCreateFunc commandStreamReceiverFactory[2 * IGFX_MAX_CORE]; diff --git a/shared/source/gen8/command_stream_receiver_hw_gen8.cpp b/shared/source/gen8/command_stream_receiver_hw_gen8.cpp index 651fa1c502..13567fa45e 100644 --- a/shared/source/gen8/command_stream_receiver_hw_gen8.cpp +++ b/shared/source/gen8/command_stream_receiver_hw_gen8.cpp @@ -16,12 +16,12 @@ typedef BDWFamily Family; static auto gfxCore = IGFX_GEN8_CORE; template <> -size_t CommandStreamReceiverHw::getCmdSizeForComputeMode() { - return 0; +void CommandStreamReceiverHw::programComputeMode(LinearStream &stream, DispatchFlags &dispatchFlags, const HardwareInfo &hwInfo) { } -template <> -void CommandStreamReceiverHw::programComputeMode(LinearStream &stream, DispatchFlags &dispatchFlags, const HardwareInfo &hwInfo) { +template +inline bool CommandStreamReceiverHw::isComputeModeNeeded() const { + return false; } template <> diff --git a/shared/source/gen9/command_stream_receiver_hw_gen9.cpp b/shared/source/gen9/command_stream_receiver_hw_gen9.cpp index 8da2a64e1d..ed2bcb0fa7 100644 --- a/shared/source/gen9/command_stream_receiver_hw_gen9.cpp +++ b/shared/source/gen9/command_stream_receiver_hw_gen9.cpp @@ -16,12 +16,12 @@ typedef SKLFamily Family; static auto gfxCore = IGFX_GEN9_CORE; template <> -size_t CommandStreamReceiverHw::getCmdSizeForComputeMode() { - return 0; +void CommandStreamReceiverHw::programComputeMode(LinearStream &stream, DispatchFlags &dispatchFlags, const HardwareInfo &hwInfo) { } -template <> -void CommandStreamReceiverHw::programComputeMode(LinearStream &stream, DispatchFlags &dispatchFlags, const HardwareInfo &hwInfo) { +template +inline bool CommandStreamReceiverHw::isComputeModeNeeded() const { + return false; } template <> 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 db1a20b5fa..7a142a6374 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 @@ -71,9 +71,6 @@ size_t CommandStreamReceiverHw::getCmdSizeForPerDssBackedBuffer(const Ha template <> void CommandStreamReceiverHw::addPipeControlBefore3dState(LinearStream &commandStream, DispatchFlags &dispatchFlags) {} -template <> -void CommandStreamReceiverHw::setPipeControlPriorToNonPipelinedStateCommandExtraProperties(PipeControlArgs &args) {} - template <> void BlitCommandsHelper::appendClearColor(const BlitProperties &blitProperties, typename Family::XY_BLOCK_COPY_BLT &blitCmd) { using XY_BLOCK_COPY_BLT = typename Family::XY_BLOCK_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 ae58451191..42dd2731b5 100644 --- a/shared/test/common/gen12lp/test_command_encoder_gen12lp.cpp +++ b/shared/test/common/gen12lp/test_command_encoder_gen12lp.cpp @@ -85,7 +85,11 @@ GEN12LPTEST_F(CommandEncoderTest, givenVariousEngineTypesWhenEncodeSBAThenAdditi GenCmdList commands; CmdParse::parseCommandBuffer(commands, ptrOffset(cmdContainer.getCommandStream()->getCpuBase(), 0), cmdContainer.getCommandStream()->getUsed()); auto itorLRI = find(commands.begin(), commands.end()); - EXPECT_NE(itorLRI, commands.end()); + if (HwInfoConfig::get(defaultHwInfo->platform.eProductFamily)->is3DPipelineSelectWARequired()) { + EXPECT_NE(itorLRI, commands.end()); + } else { + EXPECT_EQ(itorLRI, commands.end()); + } } cmdContainer.reset(); diff --git a/shared/test/unit_test/command_stream/compute_mode_tests.h b/shared/test/unit_test/command_stream/compute_mode_tests.h index 47375989d0..693c65f109 100644 --- a/shared/test/unit_test/command_stream/compute_mode_tests.h +++ b/shared/test/unit_test/command_stream/compute_mode_tests.h @@ -23,6 +23,13 @@ struct ComputeModeRequirements : public ::testing::Test { myCsr(ExecutionEnvironment &executionEnvironment, const DeviceBitfield deviceBitfield) : UltCommandStreamReceiver(executionEnvironment, 0, deviceBitfield){}; CsrSizeRequestFlags *getCsrRequestFlags() { return &this->csrSizeRequestFlags; } + bool hasSharedHandles() override { + if (hasSharedHandlesReturnValue) { + return *hasSharedHandlesReturnValue; + } + return UltCommandStreamReceiver::hasSharedHandles(); + }; + std::optional hasSharedHandlesReturnValue; }; void makeResidentSharedAlloc() { csr->getResidencyAllocations().push_back(alloc); @@ -48,7 +55,7 @@ struct ComputeModeRequirements : public ::testing::Test { bool numGrfRequiredChanged, uint32_t numGrfRequired) { auto csrHw = getCsrHw(); - csrHw->getCsrRequestFlags()->hasSharedHandles = hasSharedHandles; + csrHw->hasSharedHandlesReturnValue = hasSharedHandles; csrHw->getCsrRequestFlags()->numGrfRequiredChanged = numGrfRequiredChanged; flags.requiresCoherency = requireCoherency; flags.numGrfRequired = numGrfRequired; diff --git a/shared/test/unit_test/command_stream/compute_mode_tests_pvc_and_later.cpp b/shared/test/unit_test/command_stream/compute_mode_tests_pvc_and_later.cpp index a875580176..5c4d94929f 100644 --- a/shared/test/unit_test/command_stream/compute_mode_tests_pvc_and_later.cpp +++ b/shared/test/unit_test/command_stream/compute_mode_tests_pvc_and_later.cpp @@ -19,14 +19,15 @@ HWTEST2_F(ComputeModeRequirementsPvcAndLater, givenComputeModeCmdSizeWhenLargeGr auto cmdSize = sizeof(STATE_COMPUTE_MODE) + sizeof(PIPE_CONTROL); overrideComputeModeRequest(false, false, false, false, 128u); - auto retSize = getCsrHw()->getCmdSizeForComputeMode(); - EXPECT_EQ(0u, retSize); + EXPECT_FALSE(getCsrHw()->isComputeModeNeeded()); overrideComputeModeRequest(false, false, false, true, 256u); - retSize = getCsrHw()->getCmdSizeForComputeMode(); + auto retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->isComputeModeNeeded()); EXPECT_EQ(cmdSize, retSize); overrideComputeModeRequest(true, false, false, true, 256u); retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->isComputeModeNeeded()); EXPECT_EQ(cmdSize, retSize); } diff --git a/shared/test/unit_test/command_stream/compute_mode_tests_xehp_and_later.cpp b/shared/test/unit_test/command_stream/compute_mode_tests_xehp_and_later.cpp index f38e44b784..ffb57c3d70 100644 --- a/shared/test/unit_test/command_stream/compute_mode_tests_xehp_and_later.cpp +++ b/shared/test/unit_test/command_stream/compute_mode_tests_xehp_and_later.cpp @@ -32,19 +32,19 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, ComputeModeRequirements, givenCoherencyWithoutShare } overrideComputeModeRequest(false, false, false); - auto retSize = getCsrHw()->getCmdSizeForComputeMode(); - EXPECT_EQ(0u, retSize); + EXPECT_FALSE(getCsrHw()->isComputeModeNeeded()); overrideComputeModeRequest(false, true, false); - retSize = getCsrHw()->getCmdSizeForComputeMode(); - EXPECT_EQ(0u, retSize); + EXPECT_FALSE(getCsrHw()->isComputeModeNeeded()); overrideComputeModeRequest(true, true, false); - retSize = getCsrHw()->getCmdSizeForComputeMode(); + auto retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->isComputeModeNeeded()); EXPECT_EQ(cmdsSize, retSize); overrideComputeModeRequest(true, false, false); retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->isComputeModeNeeded()); EXPECT_EQ(cmdsSize, retSize); } @@ -56,27 +56,26 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, ComputeModeRequirements, givenCoherencyWithSharedHa const auto &hwInfoConfig = *HwInfoConfig::get(productFamily); const auto &[isBasicWARequired, isExtendedWARequired] = hwInfoConfig.isPipeControlPriorToNonPipelinedStateCommandsWARequired(*defaultHwInfo, csr->isRcs()); std::ignore = isExtendedWARequired; - auto cmdsSize = 0u; overrideComputeModeRequest(false, false, true); - auto retSize = getCsrHw()->getCmdSizeForComputeMode(); - EXPECT_EQ(cmdsSize, retSize); + EXPECT_FALSE(getCsrHw()->isComputeModeNeeded()); overrideComputeModeRequest(false, true, true); - retSize = getCsrHw()->getCmdSizeForComputeMode(); - EXPECT_EQ(cmdsSize, retSize); + EXPECT_FALSE(getCsrHw()->isComputeModeNeeded()); - cmdsSize = sizeof(STATE_COMPUTE_MODE) + sizeof(PIPE_CONTROL); + auto cmdsSize = sizeof(STATE_COMPUTE_MODE) + sizeof(PIPE_CONTROL); if (isBasicWARequired) { cmdsSize += +sizeof(PIPE_CONTROL); } overrideComputeModeRequest(true, true, true); - retSize = getCsrHw()->getCmdSizeForComputeMode(); + auto retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->isComputeModeNeeded()); EXPECT_EQ(cmdsSize, retSize); overrideComputeModeRequest(true, false, true); retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->isComputeModeNeeded()); EXPECT_EQ(cmdsSize, retSize); } @@ -340,27 +339,26 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, ComputeModeRequirements, givenComputeModeCmdSizeWhe using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE; using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; - auto cmdSize = 0u; - overrideComputeModeRequest(false, false, false, false, 128u); - auto retSize = getCsrHw()->getCmdSizeForComputeMode(); - EXPECT_EQ(cmdSize, retSize); + EXPECT_FALSE(getCsrHw()->isComputeModeNeeded()); const auto &hwInfoConfig = *HwInfoConfig::get(productFamily); const auto &[isBasicWARequired, isExtendedWARequired] = hwInfoConfig.isPipeControlPriorToNonPipelinedStateCommandsWARequired(*defaultHwInfo, csr->isRcs()); std::ignore = isExtendedWARequired; - cmdSize = sizeof(STATE_COMPUTE_MODE); + auto cmdSize = sizeof(STATE_COMPUTE_MODE); if (isBasicWARequired) { cmdSize += +sizeof(PIPE_CONTROL); } overrideComputeModeRequest(false, false, false, true, 256u); - retSize = getCsrHw()->getCmdSizeForComputeMode(); + auto retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->isComputeModeNeeded()); EXPECT_EQ(cmdSize, retSize); overrideComputeModeRequest(true, false, false, true, 256u); retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->isComputeModeNeeded()); EXPECT_EQ(cmdSize, retSize); } @@ -423,8 +421,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, ComputeModeRequirements, givenComputeModeProgrammin LinearStream stream(buff, 1024); overrideComputeModeRequest(false, false, false, false, 256u); - getCsrHw()->programComputeMode(stream, flags, *defaultHwInfo); - EXPECT_EQ(0u, stream.getUsed()); + EXPECT_FALSE(getCsrHw()->isComputeModeNeeded()); } HWTEST2_F(ComputeModeRequirements, givenComputeModeProgrammingWhenRequiredGRFNumberIsLowerThan128ThenSmallGRFModeIsProgrammed, ForceNonCoherentSupportedMatcher) { diff --git a/shared/test/unit_test/gen12lp/compute_mode_tests_gen12lp.inl b/shared/test/unit_test/gen12lp/compute_mode_tests_gen12lp.inl index fc63282a84..2c01294322 100644 --- a/shared/test/unit_test/gen12lp/compute_mode_tests_gen12lp.inl +++ b/shared/test/unit_test/gen12lp/compute_mode_tests_gen12lp.inl @@ -19,23 +19,22 @@ HWTEST2_F(ComputeModeRequirements, givenCsrRequestFlagsWithSharedHandlesWhenComm overrideComputeModeRequest(false, false, true); - auto retSize = getCsrHw()->getCmdSizeForComputeMode(); - EXPECT_EQ(0u, retSize); + EXPECT_FALSE(getCsrHw()->isComputeModeNeeded()); getCsrHw()->programComputeMode(stream, flags, *defaultHwInfo); EXPECT_EQ(0u, stream.getUsed()); stream.replaceBuffer(buff, 1024); overrideComputeModeRequest(false, true, true); - retSize = getCsrHw()->getCmdSizeForComputeMode(); - EXPECT_EQ(0u, retSize); + EXPECT_FALSE(getCsrHw()->isComputeModeNeeded()); getCsrHw()->programComputeMode(stream, flags, *defaultHwInfo); EXPECT_EQ(0u, stream.getUsed()); stream.replaceBuffer(buff, 1024); overrideComputeModeRequest(true, true, true); - retSize = getCsrHw()->getCmdSizeForComputeMode(); + auto retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->isComputeModeNeeded()); EXPECT_EQ(cmdsSize, retSize); getCsrHw()->programComputeMode(stream, flags, *defaultHwInfo); EXPECT_EQ(cmdsSize, stream.getUsed()); @@ -44,6 +43,7 @@ HWTEST2_F(ComputeModeRequirements, givenCsrRequestFlagsWithSharedHandlesWhenComm overrideComputeModeRequest(true, false, true); retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->isComputeModeNeeded()); EXPECT_EQ(cmdsSize, retSize); getCsrHw()->programComputeMode(stream, flags, *defaultHwInfo); EXPECT_EQ(cmdsSize, stream.getUsed()); @@ -52,6 +52,7 @@ HWTEST2_F(ComputeModeRequirements, givenCsrRequestFlagsWithSharedHandlesWhenComm overrideComputeModeRequest(false, false, true, true, 127u); retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->isComputeModeNeeded()); EXPECT_EQ(cmdsSize, retSize); getCsrHw()->programComputeMode(stream, flags, *defaultHwInfo); EXPECT_EQ(cmdsSize, stream.getUsed()); @@ -69,15 +70,15 @@ HWTEST2_F(ComputeModeRequirements, givenCsrRequestFlagsWithoutSharedHandlesWhenC overrideComputeModeRequest(false, false, false); - auto retSize = getCsrHw()->getCmdSizeForComputeMode(); - EXPECT_EQ(0u, retSize); + EXPECT_FALSE(getCsrHw()->isComputeModeNeeded()); getCsrHw()->programComputeMode(stream, flags, *defaultHwInfo); EXPECT_EQ(0u, stream.getUsed()); stream.replaceBuffer(buff, 1024); overrideComputeModeRequest(true, true, false); - retSize = getCsrHw()->getCmdSizeForComputeMode(); + auto retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->isComputeModeNeeded()); EXPECT_EQ(cmdsSize, retSize); getCsrHw()->programComputeMode(stream, flags, *defaultHwInfo); EXPECT_EQ(cmdsSize, stream.getUsed()); @@ -86,6 +87,7 @@ HWTEST2_F(ComputeModeRequirements, givenCsrRequestFlagsWithoutSharedHandlesWhenC overrideComputeModeRequest(true, false, false); retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->isComputeModeNeeded()); EXPECT_EQ(cmdsSize, retSize); getCsrHw()->programComputeMode(stream, flags, *defaultHwInfo); EXPECT_EQ(cmdsSize, stream.getUsed()); @@ -94,6 +96,7 @@ HWTEST2_F(ComputeModeRequirements, givenCsrRequestFlagsWithoutSharedHandlesWhenC overrideComputeModeRequest(false, false, false, true, 127u); retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->isComputeModeNeeded()); EXPECT_EQ(cmdsSize, retSize); getCsrHw()->programComputeMode(stream, flags, *defaultHwInfo); EXPECT_EQ(cmdsSize, stream.getUsed()); @@ -113,15 +116,15 @@ HWTEST2_F(ComputeModeRequirements, givenCsrRequestOnEngineCCSWhenCommandSizeIsCa overrideComputeModeRequest(false, false, false); - auto retSize = getCsrHw()->getCmdSizeForComputeMode(); - EXPECT_EQ(0u, retSize); + EXPECT_FALSE(getCsrHw()->isComputeModeNeeded()); getCsrHw()->programComputeMode(stream, flags, *defaultHwInfo); EXPECT_EQ(0u, stream.getUsed()); stream.replaceBuffer(buff, 1024); overrideComputeModeRequest(true, true, false); - retSize = getCsrHw()->getCmdSizeForComputeMode(); + auto retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->isComputeModeNeeded()); EXPECT_EQ(cmdsSize, retSize); getCsrHw()->programComputeMode(stream, flags, *defaultHwInfo); EXPECT_EQ(cmdsSize, stream.getUsed()); @@ -130,6 +133,7 @@ HWTEST2_F(ComputeModeRequirements, givenCsrRequestOnEngineCCSWhenCommandSizeIsCa overrideComputeModeRequest(true, false, false); retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->isComputeModeNeeded()); EXPECT_EQ(cmdsSize, retSize); getCsrHw()->programComputeMode(stream, flags, *defaultHwInfo); EXPECT_EQ(cmdsSize, stream.getUsed()); @@ -138,6 +142,7 @@ HWTEST2_F(ComputeModeRequirements, givenCsrRequestOnEngineCCSWhenCommandSizeIsCa overrideComputeModeRequest(false, false, false, true, 127u); retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->isComputeModeNeeded()); EXPECT_EQ(cmdsSize, retSize); getCsrHw()->programComputeMode(stream, flags, *defaultHwInfo); EXPECT_EQ(cmdsSize, stream.getUsed()); diff --git a/shared/test/unit_test/gen8/coherency_tests_gen8.cpp b/shared/test/unit_test/gen8/coherency_tests_gen8.cpp index 2e6b8abbd0..1557d578c7 100644 --- a/shared/test/unit_test/gen8/coherency_tests_gen8.cpp +++ b/shared/test/unit_test/gen8/coherency_tests_gen8.cpp @@ -1,15 +1,15 @@ /* - * Copyright (C) 2018-2021 Intel Corporation + * Copyright (C) 2018-2022 Intel Corporation * * SPDX-License-Identifier: MIT * */ -#include "shared/source/command_stream/command_stream_receiver_hw.h" -#include "shared/source/execution_environment/execution_environment.h" #include "shared/test/common/helpers/default_hw_info.h" #include "shared/test/common/helpers/dispatch_flags_helper.h" -#include "shared/test/common/mocks/mock_execution_environment.h" +#include "shared/test/common/libult/ult_command_stream_receiver.h" +#include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/mocks/ult_device_factory.h" #include "shared/test/common/test_macros/test.h" using namespace NEO; @@ -17,11 +17,10 @@ using namespace NEO; using Gen8CoherencyRequirements = ::testing::Test; GEN8TEST_F(Gen8CoherencyRequirements, WhenMemoryManagerIsInitializedThenNoCoherencyProgramming) { - auto executionEnvironment = std::make_unique(); - executionEnvironment->initializeMemoryManager(); - CommandStreamReceiverHw csr(*executionEnvironment, 0, 1); + UltDeviceFactory deviceFactory{1, 0}; LinearStream stream; DispatchFlags flags = DispatchFlagsHelper::createDefaultDispatchFlags(); + auto &csr = deviceFactory.rootDevices[0]->getUltCommandStreamReceiver(); auto retSize = csr.getCmdSizeForComputeMode(); EXPECT_EQ(0u, retSize); diff --git a/shared/test/unit_test/xe_hp_core/compute_mode_tests_xe_hp_core.cpp b/shared/test/unit_test/xe_hp_core/compute_mode_tests_xe_hp_core.cpp index 39ff3d4ee7..a0f0c32715 100644 --- a/shared/test/unit_test/xe_hp_core/compute_mode_tests_xe_hp_core.cpp +++ b/shared/test/unit_test/xe_hp_core/compute_mode_tests_xe_hp_core.cpp @@ -108,18 +108,18 @@ HWTEST2_F(ComputeModeRequirements, GivenProgramExtendedPipeControlPriorToNonPipe auto cmdsSize = sizeof(STATE_COMPUTE_MODE) + sizeof(PIPE_CONTROL); overrideComputeModeRequest(false, false, false); - auto retSize = getCsrHw()->getCmdSizeForComputeMode(); - EXPECT_EQ(0u, retSize); + EXPECT_FALSE(getCsrHw()->isComputeModeNeeded()); overrideComputeModeRequest(false, true, false); - retSize = getCsrHw()->getCmdSizeForComputeMode(); - EXPECT_EQ(0u, retSize); + EXPECT_FALSE(getCsrHw()->isComputeModeNeeded()); overrideComputeModeRequest(true, true, false); - retSize = getCsrHw()->getCmdSizeForComputeMode(); + auto retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->isComputeModeNeeded()); EXPECT_EQ(cmdsSize, retSize); overrideComputeModeRequest(true, false, false); retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->isComputeModeNeeded()); EXPECT_EQ(cmdsSize, retSize); } diff --git a/shared/test/unit_test/xe_hpc_core/compute_mode_tests_xe_hpc_core.cpp b/shared/test/unit_test/xe_hpc_core/compute_mode_tests_xe_hpc_core.cpp index 0aebce96ca..78708cd125 100644 --- a/shared/test/unit_test/xe_hpc_core/compute_mode_tests_xe_hpc_core.cpp +++ b/shared/test/unit_test/xe_hpc_core/compute_mode_tests_xe_hpc_core.cpp @@ -79,11 +79,11 @@ HWTEST2_F(XeHpcComputeModeRequirements, givenCoherencyWithoutSharedHandlesWhenCo auto cmdsSize = sizeof(STATE_COMPUTE_MODE) + sizeof(PIPE_CONTROL); overrideComputeModeRequest(false, false, false, false); - auto retSize = getCsrHw()->getCmdSizeForComputeMode(); - EXPECT_EQ(0u, retSize); + EXPECT_FALSE(getCsrHw()->isComputeModeNeeded()); overrideComputeModeRequest(false, false, false, true); - retSize = getCsrHw()->getCmdSizeForComputeMode(); + auto retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->isComputeModeNeeded()); EXPECT_EQ(cmdsSize, retSize); } @@ -96,10 +96,11 @@ HWTEST2_F(XeHpcComputeModeRequirements, givenNumGrfRequiredChangedWhenCommandSiz auto numGrfRequired = 128u; auto numGrfRequiredChanged = false; overrideComputeModeRequest(false, false, false, numGrfRequiredChanged, numGrfRequired); - EXPECT_EQ(0u, getCsrHw()->getCmdSizeForComputeMode()); + EXPECT_FALSE(getCsrHw()->isComputeModeNeeded()); numGrfRequiredChanged = true; overrideComputeModeRequest(false, false, false, numGrfRequiredChanged, numGrfRequired); + EXPECT_TRUE(getCsrHw()->isComputeModeNeeded()); EXPECT_EQ(sizeof(STATE_COMPUTE_MODE) + sizeof(PIPE_CONTROL), getCsrHw()->getCmdSizeForComputeMode()); } diff --git a/shared/test/unit_test/xe_hpg_core/compute_mode_tests_xe_hpg_core.cpp b/shared/test/unit_test/xe_hpg_core/compute_mode_tests_xe_hpg_core.cpp index 3da8c311db..d8005f1b07 100644 --- a/shared/test/unit_test/xe_hpg_core/compute_mode_tests_xe_hpg_core.cpp +++ b/shared/test/unit_test/xe_hpg_core/compute_mode_tests_xe_hpg_core.cpp @@ -103,20 +103,19 @@ XE_HPG_CORETEST_F(ComputeModeRequirementsXeHpgCore, givenComputeModeCmdSizeWhenL using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE; using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; - auto cmdSize = 0u; - overrideComputeModeRequest(false, false, false, false, 128u); - auto retSize = getCsrHw()->getCmdSizeForComputeMode(); - EXPECT_EQ(cmdSize, retSize); + EXPECT_FALSE(getCsrHw()->isComputeModeNeeded()); - cmdSize = sizeof(STATE_COMPUTE_MODE) + sizeof(PIPE_CONTROL); + auto cmdSize = sizeof(STATE_COMPUTE_MODE) + sizeof(PIPE_CONTROL); overrideComputeModeRequest(false, false, false, true, 256u); - retSize = getCsrHw()->getCmdSizeForComputeMode(); + auto retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->isComputeModeNeeded()); EXPECT_EQ(cmdSize, retSize); overrideComputeModeRequest(true, false, false, true, 256u); retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->isComputeModeNeeded()); EXPECT_EQ(cmdSize, retSize); } @@ -125,24 +124,22 @@ XE_HPG_CORETEST_F(ComputeModeRequirementsXeHpgCore, givenCoherencyWithSharedHand using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE; using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; - auto cmdsSize = 0u; - overrideComputeModeRequest(false, false, true); - auto retSize = getCsrHw()->getCmdSizeForComputeMode(); - EXPECT_EQ(cmdsSize, retSize); + EXPECT_FALSE(getCsrHw()->isComputeModeNeeded()); overrideComputeModeRequest(false, true, true); - retSize = getCsrHw()->getCmdSizeForComputeMode(); - EXPECT_EQ(cmdsSize, retSize); + EXPECT_FALSE(getCsrHw()->isComputeModeNeeded()); - cmdsSize = sizeof(STATE_COMPUTE_MODE) + (2 * sizeof(PIPE_CONTROL)); + auto cmdsSize = sizeof(STATE_COMPUTE_MODE) + (2 * sizeof(PIPE_CONTROL)); overrideComputeModeRequest(true, true, true); - retSize = getCsrHw()->getCmdSizeForComputeMode(); + auto retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->isComputeModeNeeded()); EXPECT_EQ(cmdsSize, retSize); overrideComputeModeRequest(true, false, true); retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->isComputeModeNeeded()); EXPECT_EQ(cmdsSize, retSize); } @@ -154,10 +151,10 @@ XE_HPG_CORETEST_F(ComputeModeRequirementsXeHpgCore, givenCoherencyWithoutSharedH auto cmdsSize = sizeof(STATE_COMPUTE_MODE) + sizeof(PIPE_CONTROL); overrideComputeModeRequest(false, false, false, false); - auto retSize = getCsrHw()->getCmdSizeForComputeMode(); - EXPECT_EQ(0u, retSize); + EXPECT_FALSE(getCsrHw()->isComputeModeNeeded()); overrideComputeModeRequest(false, false, false, true); - retSize = getCsrHw()->getCmdSizeForComputeMode(); + auto retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->isComputeModeNeeded()); EXPECT_EQ(cmdsSize, retSize); } diff --git a/shared/test/unit_test/xe_hpg_core/dg2/compute_mode_tests_dg2.cpp b/shared/test/unit_test/xe_hpg_core/dg2/compute_mode_tests_dg2.cpp index d368cdcd6b..2e75169471 100644 --- a/shared/test/unit_test/xe_hpg_core/dg2/compute_mode_tests_dg2.cpp +++ b/shared/test/unit_test/xe_hpg_core/dg2/compute_mode_tests_dg2.cpp @@ -173,18 +173,18 @@ HWTEST2_F(ComputeModeRequirements, GivenProgramExtendedPipeControlPriorToNonPipe auto cmdsSize = sizeof(STATE_COMPUTE_MODE) + sizeof(PIPE_CONTROL); overrideComputeModeRequest(false, false, false); - auto retSize = getCsrHw()->getCmdSizeForComputeMode(); - EXPECT_EQ(0u, retSize); + EXPECT_FALSE(getCsrHw()->isComputeModeNeeded()); overrideComputeModeRequest(false, true, false); - retSize = getCsrHw()->getCmdSizeForComputeMode(); - EXPECT_EQ(0u, retSize); + EXPECT_FALSE(getCsrHw()->isComputeModeNeeded()); overrideComputeModeRequest(true, true, false); - retSize = getCsrHw()->getCmdSizeForComputeMode(); + auto retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->isComputeModeNeeded()); EXPECT_EQ(cmdsSize, retSize); overrideComputeModeRequest(true, false, false); retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->isComputeModeNeeded()); EXPECT_EQ(cmdsSize, retSize); }