1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
|
/*
* Copyright (C) 2019-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/command_stream/preemption.h"
#include "shared/source/command_stream/stream_properties.h"
#include "shared/test/common/fixtures/preamble_fixture.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "reg_configs_common.h"
using namespace NEO;
using TglLpSlm = PreambleFixture;
HWTEST2_F(TglLpSlm, givenTglLpWhenPreambleIsBeingProgrammedThenThreadArbitrationPolicyIsIgnored, IsTGLLP) {
DebugManagerStateRestore dbgRestore;
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::Disabled));
typedef Gen12LpFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
LinearStream &cs = linearStream;
uint32_t l3Config = PreambleHelper<Gen12LpFamily>::getL3Config(pDevice->getHardwareInfo(), true);
MockDevice mockDevice;
PreambleHelper<Gen12LpFamily>::programPreamble(&linearStream, mockDevice, l3Config,
nullptr, nullptr);
parseCommands<Gen12LpFamily>(cs);
// parse through commands and ensure that 0xE404 is not being programmed
EXPECT_EQ(0U, countMmio<FamilyType>(cmdList.begin(), cmdList.end(), 0xE404));
}
HWTEST2_F(TglLpSlm, WhenCheckingL3IsConfigurableThenExpectItToBeFalse, IsTGLLP) {
bool isL3Programmable =
PreambleHelper<Gen12LpFamily>::isL3Configurable(*defaultHwInfo);
EXPECT_FALSE(isL3Programmable);
}
HWTEST2_F(TglLpSlm, WhenPreambleIsCreatedThenSlmIsDisabled, IsTGLLP) {
typedef Gen12LpFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
LinearStream &cs = linearStream;
uint32_t l3Config = PreambleHelper<FamilyType>::getL3Config(pDevice->getHardwareInfo(), true);
PreambleHelper<FamilyType>::programL3(&cs, l3Config);
parseCommands<Gen12LpFamily>(cs);
auto itorLRI = find<MI_LOAD_REGISTER_IMM *>(cmdList.begin(), cmdList.end());
ASSERT_EQ(cmdList.end(), itorLRI);
}
using Gen12LpUrbEntryAllocationSize = PreambleFixture;
HWTEST2_F(Gen12LpUrbEntryAllocationSize, WhenPreambleIsCreatedThenUrbEntryAllocationSizeIsCorrect, IsTGLLP) {
uint32_t actualVal = PreambleHelper<FamilyType>::getUrbEntryAllocationSize();
EXPECT_EQ(1024u, actualVal);
}
using Gen12LpPreambleVfeState = PreambleVfeState;
HWTEST2_F(Gen12LpPreambleVfeState, GivenWaOffWhenProgrammingVfeStateThenProgrammingIsCorrect, IsTGLLP) {
typedef typename FamilyType::PIPE_CONTROL PIPE_CONTROL;
testWaTable->flags.waSendMIFLUSHBeforeVFE = 0;
LinearStream &cs = linearStream;
auto vfeCmd = PreambleHelper<FamilyType>::getSpaceForVfeState(&linearStream, pDevice->getHardwareInfo(), EngineGroupType::RenderCompute);
StreamProperties emptyProperties{};
PreambleHelper<FamilyType>::programVfeState(vfeCmd, pDevice->getHardwareInfo(), 0u, 0, 672u, emptyProperties, nullptr);
parseCommands<FamilyType>(cs);
auto itorPC = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
ASSERT_NE(cmdList.end(), itorPC);
const auto &pc = *reinterpret_cast<PIPE_CONTROL *>(*itorPC);
EXPECT_FALSE(pc.getRenderTargetCacheFlushEnable());
EXPECT_FALSE(pc.getDepthCacheFlushEnable());
EXPECT_FALSE(pc.getDepthStallEnable());
EXPECT_FALSE(pc.getDcFlushEnable());
EXPECT_EQ(1u, pc.getCommandStreamerStallEnable());
}
HWTEST2_F(Gen12LpPreambleVfeState, givenCcsEngineWhenWaIsSetThenAppropriatePipeControlFlushesAreSet, IsTGLLP) {
typedef typename FamilyType::PIPE_CONTROL PIPE_CONTROL;
testWaTable->flags.waSendMIFLUSHBeforeVFE = 1;
LinearStream &cs = linearStream;
auto vfeCmd = PreambleHelper<FamilyType>::getSpaceForVfeState(&linearStream, pDevice->getHardwareInfo(), EngineGroupType::Compute);
StreamProperties emptyProperties{};
PreambleHelper<FamilyType>::programVfeState(vfeCmd, pDevice->getHardwareInfo(), 0u, 0, 672u, emptyProperties, nullptr);
parseCommands<FamilyType>(cs);
auto itorPC = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
ASSERT_NE(cmdList.end(), itorPC);
const auto &pc = *reinterpret_cast<PIPE_CONTROL *>(*itorPC);
EXPECT_FALSE(pc.getRenderTargetCacheFlushEnable());
EXPECT_FALSE(pc.getDepthCacheFlushEnable());
EXPECT_TRUE(pc.getDcFlushEnable());
EXPECT_EQ(1u, pc.getCommandStreamerStallEnable());
}
HWTEST2_F(Gen12LpPreambleVfeState, givenRcsEngineWhenWaIsSetThenAppropriatePipeControlFlushesAreSet, IsTGLLP) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
testWaTable->flags.waSendMIFLUSHBeforeVFE = 1;
LinearStream &cs = linearStream;
auto vfeCmd = PreambleHelper<FamilyType>::getSpaceForVfeState(&linearStream, pDevice->getHardwareInfo(), EngineGroupType::RenderCompute);
StreamProperties emptyProperties{};
PreambleHelper<FamilyType>::programVfeState(vfeCmd, pDevice->getHardwareInfo(), 0u, 0, 672u, emptyProperties, nullptr);
parseCommands<FamilyType>(cs);
auto itorPC = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
ASSERT_NE(cmdList.end(), itorPC);
const auto &pc = *reinterpret_cast<PIPE_CONTROL *>(*itorPC);
EXPECT_TRUE(pc.getRenderTargetCacheFlushEnable());
EXPECT_TRUE(pc.getDepthCacheFlushEnable());
EXPECT_TRUE(pc.getDepthStallEnable());
EXPECT_TRUE(pc.getDcFlushEnable());
EXPECT_EQ(1u, pc.getCommandStreamerStallEnable());
}
HWTEST2_F(Gen12LpPreambleVfeState, givenDefaultPipeControlWhenItIsProgrammedThenCsStallBitIsSet, IsTGLLP) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
PIPE_CONTROL *pipeControl = static_cast<PIPE_CONTROL *>(linearStream.getSpace(sizeof(PIPE_CONTROL)));
*pipeControl = FamilyType::cmdInitPipeControl;
EXPECT_EQ(1u, pipeControl->getCommandStreamerStallEnable());
}
HWTEST2_F(Gen12LpPreambleVfeState, givenCfeFusedEuDispatchFlagsWhenprogramAdditionalFieldsInVfeStateIsCalledThenGetDisableSlice0Subslice2ReturnsCorrectValues, IsTGLLP) {
using MEDIA_VFE_STATE = typename FamilyType::MEDIA_VFE_STATE;
DebugManagerStateRestore restorer;
auto hwInfo = pDevice->getRootDeviceEnvironment().getMutableHardwareInfo();
auto &waTable = hwInfo->workaroundTable;
void *cmdSpace = linearStream.getSpace(sizeof(MEDIA_VFE_STATE));
auto mediaVfeState = reinterpret_cast<MEDIA_VFE_STATE *>(cmdSpace);
*mediaVfeState = FamilyType::cmdInitMediaVfeState;
std::tuple<bool, bool, int32_t> testParams[]{
{false, false, 0},
{false, true, 0},
{false, false, -1},
{true, false, 1},
{true, true, -1},
{true, true, 1}};
StreamProperties streamProperties = {};
streamProperties.frontEndState.disableEUFusion.value = 0;
for (auto &[expectedValue, waDisableFusedThreadScheduling, debugKeyValue] : testParams) {
waTable.flags.waDisableFusedThreadScheduling = waDisableFusedThreadScheduling;
DebugManager.flags.CFEFusedEUDispatch.set(debugKeyValue);
PreambleHelper<FamilyType>::appendProgramVFEState(*hwInfo, streamProperties, cmdSpace);
EXPECT_EQ(expectedValue, mediaVfeState->getDisableSlice0Subslice2());
}
}
HWTEST2_F(Gen12LpPreambleVfeState, givenMaxNumberOfDssDebugVariableWhenMediaVfeStateIsProgrammedThenFieldIsSet, IsTGLLP) {
using MEDIA_VFE_STATE = typename FamilyType::MEDIA_VFE_STATE;
DebugManagerStateRestore restorer;
DebugManager.flags.MediaVfeStateMaxSubSlices.set(2);
auto hwInfo = pDevice->getRootDeviceEnvironment().getMutableHardwareInfo();
void *cmdSpace = linearStream.getSpace(sizeof(MEDIA_VFE_STATE));
auto mediaVfeState = reinterpret_cast<MEDIA_VFE_STATE *>(cmdSpace);
*mediaVfeState = FamilyType::cmdInitMediaVfeState;
StreamProperties streamProperties = {};
streamProperties.frontEndState.disableEUFusion.value = 0;
PreambleHelper<FamilyType>::appendProgramVFEState(*hwInfo, streamProperties, cmdSpace);
EXPECT_EQ(2u, mediaVfeState->getMaximumNumberOfDualSubslices());
}
HWTEST2_F(Gen12LpPreambleVfeState, givenDisableEUFusionWhenProgramAdditionalFieldsInVfeStateThenCorrectFieldIsSet, IsTGLLP) {
using MEDIA_VFE_STATE = typename FamilyType::MEDIA_VFE_STATE;
auto hwInfo = pDevice->getRootDeviceEnvironment().getMutableHardwareInfo();
void *cmdSpace = linearStream.getSpace(sizeof(MEDIA_VFE_STATE));
auto mediaVfeState = reinterpret_cast<MEDIA_VFE_STATE *>(cmdSpace);
*mediaVfeState = FamilyType::cmdInitMediaVfeState;
StreamProperties streamProperties = {};
streamProperties.frontEndState.disableEUFusion.value = 1;
PreambleHelper<FamilyType>::appendProgramVFEState(*hwInfo, streamProperties, cmdSpace);
EXPECT_TRUE(mediaVfeState->getDisableSlice0Subslice2());
}
HWTEST2_F(Gen12LpPreambleVfeState, givenDisableEUFusionAndCFEFusedEUDispatchWhenProgramAdditionalFieldsInVfeStateThenCorrectFieldIsSet, IsTGLLP) {
using MEDIA_VFE_STATE = typename FamilyType::MEDIA_VFE_STATE;
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.CFEFusedEUDispatch.set(0);
auto hwInfo = pDevice->getRootDeviceEnvironment().getMutableHardwareInfo();
void *cmdSpace = linearStream.getSpace(sizeof(MEDIA_VFE_STATE));
auto mediaVfeState = reinterpret_cast<MEDIA_VFE_STATE *>(cmdSpace);
*mediaVfeState = FamilyType::cmdInitMediaVfeState;
StreamProperties streamProperties = {};
streamProperties.frontEndState.disableEUFusion.value = 1;
PreambleHelper<FamilyType>::appendProgramVFEState(*hwInfo, streamProperties, cmdSpace);
EXPECT_FALSE(mediaVfeState->getDisableSlice0Subslice2());
}
using ThreadArbitrationGen12Lp = PreambleFixture;
GEN12LPTEST_F(ThreadArbitrationGen12Lp, whenGetDefaultThreadArbitrationPolicyIsCalledThenCorrectPolicyIsReturned) {
EXPECT_EQ(ThreadArbitrationPolicy::AgeBased, HwHelperHw<FamilyType>::get().getDefaultThreadArbitrationPolicy());
}
GEN12LPTEST_F(ThreadArbitrationGen12Lp, whenGetSupportThreadArbitrationPoliciesIsCalledThenEmptyVectorIsReturned) {
auto supportedPolicies = PreambleHelper<FamilyType>::getSupportedThreadArbitrationPolicies();
EXPECT_EQ(0u, supportedPolicies.size());
}
using PreemptionWatermarkGen12Lp = PreambleFixture;
GEN12LPTEST_F(PreemptionWatermarkGen12Lp, WhenPreambleIsCreatedThenPreambleWorkAroundsIsNotProgrammed) {
PreambleHelper<FamilyType>::programGenSpecificPreambleWorkArounds(&linearStream, pDevice->getHardwareInfo());
parseCommands<FamilyType>(linearStream);
auto cmd = findMmioCmd<FamilyType>(cmdList.begin(), cmdList.end(), FfSliceCsChknReg2::address);
ASSERT_EQ(nullptr, cmd);
MockDevice mockDevice;
mockDevice.setDebuggerActive(false);
size_t expectedSize = PreemptionHelper::getRequiredPreambleSize<FamilyType>(mockDevice);
EXPECT_EQ(expectedSize, PreambleHelper<FamilyType>::getAdditionalCommandsSize(mockDevice));
mockDevice.setDebuggerActive(true);
expectedSize += PreambleHelper<FamilyType>::getKernelDebuggingCommandsSize(mockDevice.isDebuggerActive());
EXPECT_EQ(expectedSize, PreambleHelper<FamilyType>::getAdditionalCommandsSize(mockDevice));
}
using PreambleFixtureGen12lp = PreambleFixture;
GEN12LPTEST_F(PreambleFixtureGen12lp, whenKernelDebuggingCommandsAreProgrammedThenCorrectRegisterAddressesAndValuesAreSet) {
typedef typename FamilyType::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
auto bufferSize = PreambleHelper<FamilyType>::getKernelDebuggingCommandsSize(true);
auto buffer = std::unique_ptr<char[]>(new char[bufferSize]);
LinearStream stream(buffer.get(), bufferSize);
PreambleHelper<FamilyType>::programKernelDebugging(&stream);
HardwareParse hwParser;
hwParser.parseCommands<FamilyType>(stream);
auto cmdList = hwParser.getCommandsList<MI_LOAD_REGISTER_IMM>();
ASSERT_EQ(2u, cmdList.size());
auto it = cmdList.begin();
MI_LOAD_REGISTER_IMM *cmd = reinterpret_cast<MI_LOAD_REGISTER_IMM *>(*it);
EXPECT_EQ(0x20d8u, cmd->getRegisterOffset());
EXPECT_EQ((1u << 5) | (1u << 21), cmd->getDataDword());
it++;
cmd = reinterpret_cast<MI_LOAD_REGISTER_IMM *>(*it);
EXPECT_EQ(0xe400u, cmd->getRegisterOffset());
EXPECT_EQ((1u << 7) | (1u << 4), cmd->getDataDword());
}
|