Program PIPE CONTROL before STATE_SIP

Related-To: NEO-6056

Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
Krzysztof Gibala
2021-10-01 11:47:49 +00:00
committed by Compute-Runtime-Automation
parent d88b730daa
commit 6736454f85
9 changed files with 152 additions and 19 deletions

View File

@ -9,6 +9,7 @@
#include "shared/source/helpers/state_base_address.h"
#include "shared/test/common/cmd_parse/hw_parse.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/mocks/mock_debugger.h"
#include "opencl/test/unit_test/fixtures/ult_command_stream_receiver_fixture.h"
#include "opencl/test/unit_test/libult/ult_command_stream_receiver.h"
@ -121,6 +122,94 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverFlushTaskXeHPAndLaterTests, gi
EXPECT_TRUE(pipeControlCmd->getHdcPipelineFlush());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverFlushTaskXeHPAndLaterTests, givenProgramAdditionalPipeControlBeforeStateComputeModeCommandDebugKeyAndStateSipWhenItIsRequiredThenThereIsPipeControlPriorToIt) {
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.ProgramAdditionalPipeControlBeforeStateComputeModeCommand.set(true);
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
using STATE_SIP = typename FamilyType::STATE_SIP;
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
pDevice->executionEnvironment->rootDeviceEnvironments[0]->debugger.reset(new MockDebugger);
auto sipType = SipKernel::getSipKernelType(*pDevice);
SipKernel::initSipKernel(sipType, *pDevice);
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
configureCSRtoNonDirtyState<FamilyType>(false);
ioh.replaceBuffer(ptrOffset(ioh.getCpuBase(), +1u), ioh.getMaxAvailableSpace() + MemoryConstants::pageSize * 3);
flushTask(commandStreamReceiver);
parseCommands<FamilyType>(commandStreamReceiver.getCS(0));
auto pipeControlIterator = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
auto pipeControlCmd = genCmdCast<PIPE_CONTROL *>(*pipeControlIterator);
EXPECT_TRUE(pipeControlCmd->getHdcPipelineFlush());
EXPECT_TRUE(pipeControlCmd->getAmfsFlushEnable());
EXPECT_TRUE(pipeControlCmd->getCommandStreamerStallEnable());
EXPECT_TRUE(pipeControlCmd->getInstructionCacheInvalidateEnable());
EXPECT_TRUE(pipeControlCmd->getTextureCacheInvalidationEnable());
EXPECT_EQ(MemorySynchronizationCommands<FamilyType>::isDcFlushAllowed(), pipeControlCmd->getDcFlushEnable());
EXPECT_TRUE(pipeControlCmd->getConstantCacheInvalidationEnable());
EXPECT_TRUE(pipeControlCmd->getStateCacheInvalidationEnable());
auto sipIterator = find<STATE_SIP *>(cmdList.begin(), cmdList.end());
auto sipCmd = genCmdCast<STATE_SIP *>(*sipIterator);
auto sipAllocation = SipKernel::getSipKernel(*pDevice).getSipAllocation();
EXPECT_EQ(sipAllocation->getGpuAddressToPatch(), sipCmd->getSystemInstructionPointer());
}
HWTEST2_F(CommandStreamReceiverFlushTaskXeHPAndLaterTests, givenProgramAdditionalPipeControlBeforeStateComputeModeCommandDebugKeyAndStateSipWhenA0SteppingIsActivatedThenOnlyGlobalSipIsProgrammed, IsXEHP) {
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.ProgramAdditionalPipeControlBeforeStateComputeModeCommand.set(true);
using STATE_SIP = typename FamilyType::STATE_SIP;
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
const auto &hwInfoConfig = *HwInfoConfig::get(productFamily);
hardwareInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 1;
hardwareInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_A0, hardwareInfo);
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hardwareInfo, 0u));
auto &commandStreamReceiver = mockDevice->getUltCommandStreamReceiver<FamilyType>();
mockDevice->executionEnvironment->rootDeviceEnvironments[0]->debugger.reset(new MockDebugger);
auto sipType = SipKernel::getSipKernelType(*mockDevice);
SipKernel::initSipKernel(sipType, *mockDevice);
configureCSRtoNonDirtyState<FamilyType>(false);
ioh.replaceBuffer(ptrOffset(ioh.getCpuBase(), +1u), ioh.getMaxAvailableSpace() + MemoryConstants::pageSize * 3);
flushTaskFlags.preemptionMode = PreemptionHelper::getDefaultPreemptionMode(mockDevice->getHardwareInfo());
commandStreamReceiver.flushTask(
commandStream,
0,
dsh,
ioh,
ssh,
taskLevel,
flushTaskFlags,
*mockDevice);
parseCommands<FamilyType>(commandStreamReceiver.getCS(0));
auto itorLRI = findMmio<FamilyType>(cmdList.begin(), cmdList.end(), 0xE42C);
EXPECT_NE(cmdList.end(), itorLRI);
auto cmdLRI = genCmdCast<MI_LOAD_REGISTER_IMM *>(*itorLRI);
auto sipAddress = cmdLRI->getDataDword() & 0xfffffff8;
auto sipAllocation = SipKernel::getSipKernel(*mockDevice).getSipAllocation();
EXPECT_EQ(sipAllocation->getGpuAddressToPatch(), sipAddress);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverFlushTaskXeHPAndLaterTests, whenNotReprogrammingSshButInitProgrammingFlagsThenBindingTablePoolIsProgrammed) {
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();

View File

@ -13,3 +13,4 @@ HWTEST_EXCLUDE_PRODUCT(HwInfoConfigTest, WhenAllowRenderCompressionIsCalledThenT
HWTEST_EXCLUDE_PRODUCT(HwInfoConfigTest, givenHardwareInfoWhenCallingIsMaxThreadsForWorkgroupWARequiredThenFalseIsReturned, IGFX_XE_HP_CORE);
HWTEST_EXCLUDE_PRODUCT(HwInfoConfigTest, whenCallingGetDeviceMemoryNameThenDdrIsReturned, IGFX_XE_HP_CORE);
HWTEST_EXCLUDE_PRODUCT(HwInfoConfigTest, givenHwInfoConfigWhenAskedIfExtraParametersAreInvalidThenFalseIsReturned, IGFX_XE_HP_CORE);
HWTEST_EXCLUDE_PRODUCT(CommandStreamReceiverFlushTaskXeHPAndLaterTests, givenProgramAdditionalPipeControlBeforeStateComputeModeCommandDebugKeyAndStateSipWhenItIsRequiredThenThereIsPipeControlPriorToIt, IGFX_XE_HP_CORE);

View File

@ -158,6 +158,8 @@ class CommandStreamReceiverHw : public CommandStreamReceiver {
void addClearSLMWorkAround(typename GfxFamily::PIPE_CONTROL *pCmd);
void addPipeControlCmd(LinearStream &commandStream, PipeControlArgs &args);
void addPipeControlBeforeStateBaseAddress(LinearStream &commandStream);
void addPipeControlBeforeStateSip(LinearStream &commandStream, Device &device);
void addPipeControlPriorToNonPipelinedStateCommand(LinearStream &commandStream, PipeControlArgs args);
size_t getSshHeapSize();
bool are4GbHeapsAvailable() const;

View File

@ -451,6 +451,7 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
}
programAdditionalPipelineSelect(commandStreamCSR, dispatchFlags.pipelineSelectArgs, false);
addPipeControlBeforeStateSip(commandStreamCSR, device);
programStateSip(commandStreamCSR, device);
if (DebugManager.flags.AddPatchInfoCommentsForAUBDump.get()) {

View File

@ -90,13 +90,22 @@ bool CommandStreamReceiverHw<GfxFamily>::isMultiOsContextCapable() const {
return false;
}
template <typename GfxFamily>
inline void CommandStreamReceiverHw<GfxFamily>::addPipeControlPriorToNonPipelinedStateCommand(LinearStream &commandStream, PipeControlArgs args) {
addPipeControlCmd(commandStream, args);
}
template <typename GfxFamily>
inline void CommandStreamReceiverHw<GfxFamily>::addPipeControlBeforeStateBaseAddress(LinearStream &commandStream) {
PipeControlArgs args(true);
args.textureCacheInvalidationEnable = true;
addPipeControlCmd(commandStream, args);
addPipeControlPriorToNonPipelinedStateCommand(commandStream, args);
}
template <typename GfxFamily>
inline void CommandStreamReceiverHw<GfxFamily>::addPipeControlBeforeStateSip(LinearStream &commandStream, Device &device) {}
template <typename GfxFamily>
bool CommandStreamReceiverHw<GfxFamily>::checkPlatformSupportsNewResourceImplicitFlush() const {
return false;

View File

@ -7,6 +7,7 @@
#include "shared/source/command_container/command_encoder.h"
#include "shared/source/command_stream/command_stream_receiver_hw.h"
#include "shared/source/device/device.h"
#include "shared/source/helpers/state_compute_mode_helper.h"
#include "shared/source/os_interface/hw_info_config.h"
@ -62,18 +63,7 @@ inline void CommandStreamReceiverHw<Family>::addPipeControlBeforeStateBaseAddres
args.textureCacheInvalidationEnable = true;
args.hdcPipelineFlush = true;
auto hwInfo = peekHwInfo();
auto hwInfoConfig = HwInfoConfig::get(hwInfo.platform.eProductFamily);
if (hwInfoConfig->isPipeControlPriorToNonPipelinedStateCommandsWARequired(hwInfo)) {
args.hdcPipelineFlush = true;
args.amfsFlushEnable = true;
args.instructionCacheInvalidateEnable = true;
args.dcFlushEnable = true;
args.constantCacheInvalidationEnable = true;
args.stateCacheInvalidationEnable = true;
}
addPipeControlCmd(commandStream, args);
addPipeControlPriorToNonPipelinedStateCommand(commandStream, args);
}
} // namespace NEO

View File

@ -166,4 +166,36 @@ void CommandStreamReceiverHw<GfxFamily>::programActivePartitionConfig() {
}
}
template <typename GfxFamily>
inline void CommandStreamReceiverHw<GfxFamily>::addPipeControlPriorToNonPipelinedStateCommand(LinearStream &commandStream, PipeControlArgs args) {
auto hwInfo = peekHwInfo();
auto hwInfoConfig = HwInfoConfig::get(hwInfo.platform.eProductFamily);
if (hwInfoConfig->isPipeControlPriorToNonPipelinedStateCommandsWARequired(hwInfo)) {
args.textureCacheInvalidationEnable = true;
args.hdcPipelineFlush = true;
args.amfsFlushEnable = true;
args.instructionCacheInvalidateEnable = true;
args.dcFlushEnable = true;
args.constantCacheInvalidationEnable = true;
args.stateCacheInvalidationEnable = true;
}
addPipeControlCmd(commandStream, args);
}
template <typename GfxFamily>
inline void CommandStreamReceiverHw<GfxFamily>::addPipeControlBeforeStateSip(LinearStream &commandStream, Device &device) {
auto hwInfo = peekHwInfo();
HwHelper &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
auto hwInfoConfig = HwInfoConfig::get(hwInfo.platform.eProductFamily);
bool debuggingEnabled = device.getDebugger() != nullptr;
PipeControlArgs args(true);
if (hwInfoConfig->isPipeControlPriorToNonPipelinedStateCommandsWARequired(hwInfo) && debuggingEnabled &&
!hwHelper.isSipWANeeded(hwInfo)) {
addPipeControlPriorToNonPipelinedStateCommand(commandStream, args);
}
}
} // namespace NEO

View File

@ -9,6 +9,7 @@
#include "shared/source/command_stream/linear_stream.h"
#include "shared/source/command_stream/preemption_mode.h"
#include "shared/source/helpers/hw_info.h"
#include "shared/source/os_interface/hw_info_config.h"
#include "sku_info.h"

View File

@ -13,13 +13,15 @@ template <>
void PreemptionHelper::programStateSip<GfxFamily>(LinearStream &preambleCmdStream, Device &device) {
using STATE_SIP = typename GfxFamily::STATE_SIP;
using MI_LOAD_REGISTER_IMM = typename GfxFamily::MI_LOAD_REGISTER_IMM;
auto hwInfo = device.getHardwareInfo();
bool debuggingEnabled = device.getDebugger() != nullptr;
if (debuggingEnabled) {
HwHelper &hwHelper = HwHelper::get(device.getHardwareInfo().platform.eRenderCoreFamily);
HwHelper &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
auto sipAllocation = SipKernel::getSipKernel(device).getSipAllocation();
if (hwHelper.isSipWANeeded(device.getHardwareInfo())) {
if (hwHelper.isSipWANeeded(hwInfo)) {
auto mmio = reinterpret_cast<MI_LOAD_REGISTER_IMM *>(preambleCmdStream.getSpace(sizeof(MI_LOAD_REGISTER_IMM)));
MI_LOAD_REGISTER_IMM cmd = GfxFamily::cmdInitLoadRegisterImm;
@ -71,13 +73,19 @@ template <>
size_t PreemptionHelper::getRequiredStateSipCmdSize<GfxFamily>(const Device &device) {
size_t size = 0;
bool debuggingEnabled = device.getDebugger() != nullptr || device.isDebuggerActive();
if (debuggingEnabled) {
HwHelper &hwHelper = HwHelper::get(device.getHardwareInfo().platform.eRenderCoreFamily);
auto hwInfo = device.getHardwareInfo();
if (hwHelper.isSipWANeeded(device.getHardwareInfo())) {
if (debuggingEnabled) {
HwHelper &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
if (hwHelper.isSipWANeeded(hwInfo)) {
size += sizeof(typename GfxFamily::PIPE_CONTROL);
size += 2 * sizeof(typename GfxFamily::MI_LOAD_REGISTER_IMM);
} else {
auto hwInfoConfig = HwInfoConfig::get(hwInfo.platform.eProductFamily);
if (hwInfoConfig->isPipeControlPriorToNonPipelinedStateCommandsWARequired(hwInfo)) {
size += sizeof(typename GfxFamily::PIPE_CONTROL);
}
size += sizeof(typename GfxFamily::STATE_SIP);
}
}