2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2023-01-06 00:57:56 +08:00
|
|
|
* Copyright (C) 2018-2023 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2022-03-26 05:04:08 +08:00
|
|
|
#include "shared/source/command_container/command_encoder.h"
|
2021-05-18 10:46:21 +08:00
|
|
|
#include "shared/source/command_stream/stream_properties.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/command_stream/thread_arbitration_policy.h"
|
2020-03-03 18:59:49 +08:00
|
|
|
#include "shared/source/gen8/reg_configs.h"
|
2022-12-06 19:19:36 +08:00
|
|
|
#include "shared/source/helpers/hw_helper.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/helpers/preamble.h"
|
2022-08-11 23:58:56 +08:00
|
|
|
#include "shared/test/common/fixtures/preamble_fixture.h"
|
2023-01-06 00:57:56 +08:00
|
|
|
#include "shared/test/common/mocks/mock_execution_environment.h"
|
2020-02-24 17:22:30 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
using namespace NEO;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
typedef PreambleFixture BdwSlm;
|
|
|
|
|
2020-10-21 15:49:11 +08:00
|
|
|
BDWTEST_F(BdwSlm, WhenL3ConfigIsDispatchedThenProperRegisterAddressAndValueAreProgrammed) {
|
2022-07-25 23:30:11 +08:00
|
|
|
typedef Gen8Family::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
|
2017-12-21 07:45:38 +08:00
|
|
|
LinearStream &cs = linearStream;
|
2022-07-25 23:30:11 +08:00
|
|
|
uint32_t l3Config = PreambleHelper<Gen8Family>::getL3Config(*defaultHwInfo, true);
|
|
|
|
PreambleHelper<Gen8Family>::programL3(&cs, l3Config);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2022-07-25 23:30:11 +08:00
|
|
|
parseCommands<Gen8Family>(cs);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
auto itorLRI = find<MI_LOAD_REGISTER_IMM *>(cmdList.begin(), cmdList.end());
|
|
|
|
ASSERT_NE(cmdList.end(), itorLRI);
|
|
|
|
|
|
|
|
const auto &lri = *reinterpret_cast<MI_LOAD_REGISTER_IMM *>(*itorLRI);
|
2022-07-25 23:30:11 +08:00
|
|
|
auto registerOffset = L3CNTLRegisterOffset<Gen8Family>::registerOffset;
|
2022-05-16 23:15:59 +08:00
|
|
|
EXPECT_EQ(registerOffset, lri.getRegisterOffset());
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_EQ(1u, lri.getDataDword() & 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef PreambleFixture Gen8L3Config;
|
|
|
|
|
2020-10-21 15:49:11 +08:00
|
|
|
BDWTEST_F(Gen8L3Config, GivenNoSlmWhenProgrammingL3ThenProgrammingIsCorrect) {
|
2017-12-21 07:45:38 +08:00
|
|
|
bool slmUsed = false;
|
|
|
|
uint32_t l3Config = 0;
|
|
|
|
|
|
|
|
l3Config = getL3ConfigHelper<IGFX_BROADWELL>(slmUsed);
|
2019-02-18 20:43:10 +08:00
|
|
|
EXPECT_EQ(0x80000340u, l3Config);
|
|
|
|
|
|
|
|
uint32_t errorDetectionBehaviorControlBit = 1 << 9;
|
|
|
|
EXPECT_TRUE((l3Config & errorDetectionBehaviorControlBit) != 0);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2020-10-21 15:49:11 +08:00
|
|
|
BDWTEST_F(Gen8L3Config, GivenlmWhenProgrammingL3ThenProgrammingIsCorrect) {
|
2017-12-21 07:45:38 +08:00
|
|
|
bool slmUsed = true;
|
|
|
|
uint32_t l3Config = 0;
|
|
|
|
|
|
|
|
l3Config = getL3ConfigHelper<IGFX_BROADWELL>(slmUsed);
|
2019-02-18 20:43:10 +08:00
|
|
|
EXPECT_EQ(0x60000321u, l3Config);
|
|
|
|
|
|
|
|
uint32_t errorDetectionBehaviorControlBit = 1 << 9;
|
|
|
|
EXPECT_TRUE((l3Config & errorDetectionBehaviorControlBit) != 0);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef PreambleFixture ThreadArbitrationGen8;
|
2018-02-20 15:11:24 +08:00
|
|
|
BDWTEST_F(ThreadArbitrationGen8, givenPolicyWhenThreadArbitrationProgrammedThenDoNothing) {
|
2022-07-25 23:30:11 +08:00
|
|
|
typedef Gen8Family::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
|
2017-12-21 07:45:38 +08:00
|
|
|
LinearStream &cs = linearStream;
|
2023-01-06 00:57:56 +08:00
|
|
|
MockExecutionEnvironment mockExecutionEnvironment{};
|
|
|
|
auto &rootDeviceEnvironment = *mockExecutionEnvironment.rootDeviceEnvironments[0];
|
2022-03-08 22:18:31 +08:00
|
|
|
StreamProperties streamProperties{};
|
|
|
|
streamProperties.stateComputeMode.threadArbitrationPolicy.set(ThreadArbitrationPolicy::RoundRobin);
|
2023-01-06 00:57:56 +08:00
|
|
|
EncodeComputeMode<FamilyType>::programComputeModeCommand(linearStream, streamProperties.stateComputeMode, rootDeviceEnvironment, nullptr);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-02-20 15:11:24 +08:00
|
|
|
EXPECT_EQ(0u, cs.getUsed());
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-05-06 18:33:44 +08:00
|
|
|
MockDevice device;
|
2022-07-25 23:30:11 +08:00
|
|
|
EXPECT_EQ(0u, PreambleHelper<Gen8Family>::getAdditionalCommandsSize(device));
|
2022-12-08 20:22:35 +08:00
|
|
|
EXPECT_EQ(ThreadArbitrationPolicy::AgeBased, GfxCoreHelperHw<Gen8Family>::get().getDefaultThreadArbitrationPolicy());
|
2021-09-09 16:32:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
BDWTEST_F(ThreadArbitrationGen8, whenGetSupportThreadArbitrationPoliciesIsCalledThenEmptyVectorIsReturned) {
|
2022-07-25 23:30:11 +08:00
|
|
|
auto supportedPolicies = PreambleHelper<Gen8Family>::getSupportedThreadArbitrationPolicies();
|
2021-09-09 16:32:45 +08:00
|
|
|
|
|
|
|
EXPECT_EQ(0u, supportedPolicies.size());
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef PreambleFixture Gen8UrbEntryAllocationSize;
|
2020-10-21 15:49:11 +08:00
|
|
|
BDWTEST_F(Gen8UrbEntryAllocationSize, WhenPreambleIsCreatedThenUrbEntryAllocationSizeIsCorrect) {
|
2017-12-21 07:45:38 +08:00
|
|
|
uint32_t actualVal = PreambleHelper<FamilyType>::getUrbEntryAllocationSize();
|
|
|
|
EXPECT_EQ(0x782u, actualVal);
|
|
|
|
}
|
|
|
|
|
2020-10-21 15:49:11 +08:00
|
|
|
BDWTEST_F(PreambleVfeState, WhenProgrammingVfeStateThenProgrammingIsCorrect) {
|
2022-07-25 23:30:11 +08:00
|
|
|
typedef Gen8Family::PIPE_CONTROL PIPE_CONTROL;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
LinearStream &cs = linearStream;
|
2022-07-25 23:30:11 +08:00
|
|
|
auto pVfeCmd = PreambleHelper<Gen8Family>::getSpaceForVfeState(&linearStream, *defaultHwInfo, EngineGroupType::RenderCompute);
|
2021-04-02 02:26:29 +08:00
|
|
|
StreamProperties emptyProperties{};
|
2022-12-20 23:56:50 +08:00
|
|
|
PreambleHelper<Gen8Family>::programVfeState(pVfeCmd, pDevice->getRootDeviceEnvironment(), 0u, 0, 168u, emptyProperties, nullptr);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2022-07-25 23:30:11 +08:00
|
|
|
parseCommands<Gen8Family>(cs);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
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.getDcFlushEnable());
|
|
|
|
EXPECT_EQ(1u, pc.getCommandStreamerStallEnable());
|
|
|
|
}
|