/* * Copyright (C) 2018-2019 Intel Corporation * * SPDX-License-Identifier: MIT * */ #include "runtime/command_stream/preemption.h" #include "unit_tests/helpers/debug_manager_state_restore.h" #include "unit_tests/preamble/preamble_fixture.h" #include "reg_configs_common.h" using namespace NEO; typedef PreambleFixture IclSlm; GEN11TEST_F(IclSlm, shouldBeEnabledOnGen11) { typedef ICLFamily::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(0u, lri.getDataDword() & 1); } GEN11TEST_F(IclSlm, givenGen11WhenProgramingL3ThenErrorDetectionBehaviorControlBitSet) { uint32_t l3Config = PreambleHelper::getL3Config(**platformDevices, true); uint32_t errorDetectionBehaviorControlBit = 1 << 9; EXPECT_TRUE((l3Config & errorDetectionBehaviorControlBit) != 0); } typedef PreambleFixture Gen11UrbEntryAllocationSize; GEN11TEST_F(Gen11UrbEntryAllocationSize, getUrbEntryAllocationSize) { uint32_t actualVal = PreambleHelper::getUrbEntryAllocationSize(); EXPECT_EQ(0x782u, actualVal); } typedef PreambleVfeState Gen11PreambleVfeState; GEN11TEST_F(Gen11PreambleVfeState, WaOff) { typedef typename ICLFamily::PIPE_CONTROL PIPE_CONTROL; testWaTable->waSendMIFLUSHBeforeVFE = 0; LinearStream &cs = linearStream; PreambleHelper::programVFEState(&linearStream, pPlatform->getDevice(0)->getHardwareInfo(), 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()); } GEN11TEST_F(Gen11PreambleVfeState, WaOn) { typedef typename ICLFamily::PIPE_CONTROL PIPE_CONTROL; testWaTable->waSendMIFLUSHBeforeVFE = 1; LinearStream &cs = linearStream; PreambleHelper::programVFEState(&linearStream, pPlatform->getDevice(0)->getHardwareInfo(), 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()); } typedef PreambleFixture PreemptionWatermarkGen11; GEN11TEST_F(PreemptionWatermarkGen11, givenPreambleThenPreambleWorkAroundsIsNotProgrammed) { PreambleHelper::programGenSpecificPreambleWorkArounds(&linearStream, **platformDevices); parseCommands(linearStream); auto cmd = findMmioCmd(cmdList.begin(), cmdList.end(), FfSliceCsChknReg2::address); ASSERT_EQ(nullptr, cmd); MockDevice device; size_t expectedSize = PreemptionHelper::getRequiredPreambleSize(device); EXPECT_EQ(expectedSize, PreambleHelper::getAdditionalCommandsSize(device)); } typedef PreambleFixture ThreadArbitrationGen11; GEN11TEST_F(ThreadArbitrationGen11, givenPreambleWhenItIsProgrammedThenThreadArbitrationIsSet) { DebugManagerStateRestore dbgRestore; DebugManager.flags.ForcePreemptionMode.set(static_cast(PreemptionMode::Disabled)); typedef ICLFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM; typedef ICLFamily::PIPE_CONTROL PIPE_CONTROL; LinearStream &cs = linearStream; uint32_t l3Config = PreambleHelper::getL3Config(**platformDevices, true); MockDevice mockDevice; PreambleHelper::programPreamble(&linearStream, mockDevice, l3Config, ThreadArbitrationPolicy::RoundRobin, nullptr); parseCommands(cs); auto ppC = find(cmdList.begin(), cmdList.end()); ASSERT_NE(ppC, cmdList.end()); auto cmd = findMmioCmd(cmdList.begin(), cmdList.end(), RowChickenReg4::address); ASSERT_NE(nullptr, cmd); EXPECT_EQ(RowChickenReg4::regDataForArbitrationPolicy[ThreadArbitrationPolicy::RoundRobin], cmd->getDataDword()); MockDevice device; EXPECT_EQ(0u, PreambleHelper::getAdditionalCommandsSize(device)); EXPECT_EQ(sizeof(MI_LOAD_REGISTER_IMM) + sizeof(PIPE_CONTROL), PreambleHelper::getThreadArbitrationCommandsSize()); } GEN11TEST_F(ThreadArbitrationGen11, defaultArbitrationPolicy) { EXPECT_EQ(ThreadArbitrationPolicy::RoundRobinAfterDependency, PreambleHelper::getDefaultThreadArbitrationPolicy()); }