/* * Copyright (C) 2018-2020 Intel Corporation * * SPDX-License-Identifier: MIT * */ #include "shared/source/command_stream/thread_arbitration_policy.h" #include "shared/source/gen8/reg_configs.h" #include "shared/source/helpers/preamble.h" #include "shared/test/unit_test/preamble/preamble_fixture.h" #include "opencl/test/unit_test/fixtures/platform_fixture.h" using namespace NEO; typedef PreambleFixture BdwSlm; BDWTEST_F(BdwSlm, shouldBeEnabledOnGen8) { typedef BDWFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM; LinearStream &cs = linearStream; uint32_t l3Config = PreambleHelper::getL3Config(*defaultHwInfo, true); PreambleHelper::programL3(&cs, l3Config); parseCommands(cs); auto itorLRI = find(cmdList.begin(), cmdList.end()); ASSERT_NE(cmdList.end(), itorLRI); const auto &lri = *reinterpret_cast(*itorLRI); auto RegisterOffset = L3CNTLRegisterOffset::registerOffset; EXPECT_EQ(RegisterOffset, lri.getRegisterOffset()); EXPECT_EQ(1u, lri.getDataDword() & 1); } typedef PreambleFixture Gen8L3Config; BDWTEST_F(Gen8L3Config, checkNoSLM) { bool slmUsed = false; uint32_t l3Config = 0; l3Config = getL3ConfigHelper(slmUsed); EXPECT_EQ(0x80000340u, l3Config); uint32_t errorDetectionBehaviorControlBit = 1 << 9; EXPECT_TRUE((l3Config & errorDetectionBehaviorControlBit) != 0); } BDWTEST_F(Gen8L3Config, checkSLM) { bool slmUsed = true; uint32_t l3Config = 0; l3Config = getL3ConfigHelper(slmUsed); EXPECT_EQ(0x60000321u, l3Config); uint32_t errorDetectionBehaviorControlBit = 1 << 9; EXPECT_TRUE((l3Config & errorDetectionBehaviorControlBit) != 0); } BDWTEST_F(Gen8L3Config, givenGen8IsL3Programing) { bool l3ConfigDifference; bool isL3Programmable; l3ConfigDifference = PreambleHelper::getL3Config(*defaultHwInfo, true) != PreambleHelper::getL3Config(*defaultHwInfo, false); isL3Programmable = PreambleHelper::isL3Configurable(*defaultHwInfo); EXPECT_EQ(l3ConfigDifference, isL3Programmable); } typedef PreambleFixture ThreadArbitrationGen8; BDWTEST_F(ThreadArbitrationGen8, givenPolicyWhenThreadArbitrationProgrammedThenDoNothing) { typedef BDWFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM; LinearStream &cs = linearStream; PreambleHelper::programThreadArbitration(&cs, ThreadArbitrationPolicy::RoundRobin); EXPECT_EQ(0u, cs.getUsed()); MockDevice device; EXPECT_EQ(0u, PreambleHelper::getAdditionalCommandsSize(device)); EXPECT_EQ(0u, PreambleHelper::getThreadArbitrationCommandsSize()); EXPECT_EQ(0u, PreambleHelper::getDefaultThreadArbitrationPolicy()); } typedef PreambleFixture Gen8UrbEntryAllocationSize; BDWTEST_F(Gen8UrbEntryAllocationSize, getUrbEntryAllocationSize) { uint32_t actualVal = PreambleHelper::getUrbEntryAllocationSize(); EXPECT_EQ(0x782u, actualVal); } BDWTEST_F(PreambleVfeState, basic) { typedef BDWFamily::PIPE_CONTROL PIPE_CONTROL; LinearStream &cs = linearStream; PreambleHelper::programVFEState(&linearStream, *defaultHwInfo, 0, 0, 168u, aub_stream::EngineType::ENGINE_RCS); parseCommands(cs); auto itorPC = find(cmdList.begin(), cmdList.end()); ASSERT_NE(cmdList.end(), itorPC); const auto &pc = *reinterpret_cast(*itorPC); EXPECT_TRUE(pc.getDcFlushEnable()); EXPECT_EQ(1u, pc.getCommandStreamerStallEnable()); }