/* * Copyright (C) 2018-2019 Intel Corporation * * SPDX-License-Identifier: MIT * */ #include "runtime/command_stream/preemption.h" #include "runtime/command_stream/thread_arbitration_policy.h" #include "runtime/gen9/reg_configs.h" #include "runtime/helpers/preamble.h" #include "unit_tests/gen_common/gen_cmd_parse.h" #include "unit_tests/helpers/debug_manager_state_restore.h" #include "unit_tests/preamble/preamble_fixture.h" using namespace NEO; typedef PreambleFixture SklSlm; SKLTEST_F(SklSlm, shouldBeEnabledOnGen9) { typedef SKLFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM; LinearStream &cs = linearStream; uint32_t l3Config = PreambleHelper::getL3Config(**platformDevices, 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 Gen9L3Config; SKLTEST_F(Gen9L3Config, 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); l3Config = getL3ConfigHelper(slmUsed); EXPECT_EQ(0x80000340u, l3Config); EXPECT_TRUE((l3Config & errorDetectionBehaviorControlBit) != 0); } SKLTEST_F(Gen9L3Config, 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); l3Config = getL3ConfigHelper(slmUsed); EXPECT_EQ(0x60000321u, l3Config); EXPECT_TRUE((l3Config & errorDetectionBehaviorControlBit) != 0); } typedef PreambleFixture ThreadArbitration; SKLTEST_F(ThreadArbitration, givenPreambleWhenItIsProgrammedThenThreadArbitrationIsSetToRoundRobin) { DebugManagerStateRestore dbgRestore; DebugManager.flags.ForcePreemptionMode.set(static_cast(PreemptionMode::Disabled)); typedef SKLFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM; typedef SKLFamily::PIPE_CONTROL PIPE_CONTROL; LinearStream &cs = linearStream; uint32_t l3Config = PreambleHelper::getL3Config(**platformDevices, true); MockDevice mockDevice(**platformDevices); PreambleHelper::programPreamble(&linearStream, mockDevice, l3Config, ThreadArbitrationPolicy::RoundRobin, nullptr); parseCommands(cs); auto ppC = find(cmdList.begin(), cmdList.end()); ASSERT_NE(ppC, cmdList.end()); auto itorLRI = reverse_find(cmdList.rbegin(), cmdList.rend()); ASSERT_NE(cmdList.rend(), itorLRI); const auto &lri = *reinterpret_cast(*itorLRI); EXPECT_EQ(0xE404u, lri.getRegisterOffset()); EXPECT_EQ(0x100u, lri.getDataDword()); EXPECT_EQ(0u, PreambleHelper::getAdditionalCommandsSize(MockDevice(*platformDevices[0]))); EXPECT_EQ(sizeof(MI_LOAD_REGISTER_IMM) + sizeof(PIPE_CONTROL), PreambleHelper::getThreadArbitrationCommandsSize()); } SKLTEST_F(ThreadArbitration, defaultArbitrationPolicy) { EXPECT_EQ(ThreadArbitrationPolicy::RoundRobin, PreambleHelper::getDefaultThreadArbitrationPolicy()); } GEN9TEST_F(PreambleVfeState, WaOff) { typedef typename FamilyType::PIPE_CONTROL PIPE_CONTROL; testWaTable.waSendMIFLUSHBeforeVFE = 0; LinearStream &cs = linearStream; PreambleHelper::programVFEState(&linearStream, **platformDevices, 0, 0); parseCommands(cs); auto itorPC = find(cmdList.begin(), cmdList.end()); ASSERT_NE(cmdList.end(), itorPC); const auto &pc = *reinterpret_cast(*itorPC); EXPECT_FALSE(pc.getRenderTargetCacheFlushEnable()); EXPECT_FALSE(pc.getDepthCacheFlushEnable()); EXPECT_FALSE(pc.getDcFlushEnable()); EXPECT_EQ(1u, pc.getCommandStreamerStallEnable()); } GEN9TEST_F(PreambleVfeState, WaOn) { typedef typename FamilyType::PIPE_CONTROL PIPE_CONTROL; testWaTable.waSendMIFLUSHBeforeVFE = 1; LinearStream &cs = linearStream; PreambleHelper::programVFEState(&linearStream, **platformDevices, 0, 0); parseCommands(cs); auto itorPC = find(cmdList.begin(), cmdList.end()); ASSERT_NE(cmdList.end(), itorPC); const auto &pc = *reinterpret_cast(*itorPC); EXPECT_TRUE(pc.getRenderTargetCacheFlushEnable()); EXPECT_TRUE(pc.getDepthCacheFlushEnable()); EXPECT_TRUE(pc.getDcFlushEnable()); EXPECT_EQ(1u, pc.getCommandStreamerStallEnable()); }