Skip to content

Commit e182aa6

Browse files
Unify program thread abitration logic for gen9 and gen11
Use single call for programming thread arbitration logic in flushTask. Related-To: NEO-5995 Signed-off-by: Filip Hazubski <[email protected]>
1 parent 5700619 commit e182aa6

File tree

11 files changed

+157
-51
lines changed

11 files changed

+157
-51
lines changed

opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_4_tests.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include "opencl/test/unit_test/test_macros/test_checks_ocl.h"
1717
#include "test.h"
1818

19+
#include "test_traits_common.h"
20+
1921
using namespace NEO;
2022

2123
using MultiRootDeviceCommandStreamReceiverBufferTests = MultiRootDeviceFixture;
@@ -662,6 +664,41 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenStaticPartitioningEnabledWhen
662664
EXPECT_TRUE(found);
663665
}
664666

667+
struct PreambleThreadArbitrationMatcher {
668+
template <PRODUCT_FAMILY productFamily>
669+
static constexpr bool isMatched() {
670+
if constexpr (HwMapper<productFamily>::GfxProduct::supportsCmdSet(IGFX_GEN8_CORE)) {
671+
return TestTraits<NEO::ToGfxCoreFamily<productFamily>::get()>::implementsPreambleThreadArbitration;
672+
}
673+
return false;
674+
}
675+
};
676+
677+
HWTEST2_F(CommandStreamReceiverFlushTaskTests, givenVariousInputWhenFlushingTaskThenProgramThreadArbitrationPolicyWhenNeeded, PreambleThreadArbitrationMatcher) {
678+
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
679+
auto &hwHelper = HwHelper::get(pDevice->getHardwareInfo().platform.eRenderCoreFamily);
680+
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
681+
682+
commandStreamReceiver.requiredThreadArbitrationPolicy = hwHelper.getDefaultThreadArbitrationPolicy();
683+
flushTask(commandStreamReceiver);
684+
size_t parsingOffset = commandStreamReceiver.commandStream.getUsed();
685+
for (auto arbitrationChanged : ::testing::Bool()) {
686+
commandStreamReceiver.lastSentThreadArbitrationPolicy = arbitrationChanged ? ThreadArbitrationPolicy::NotPresent
687+
: hwHelper.getDefaultThreadArbitrationPolicy();
688+
for (auto isPreambleNeeded : ::testing::Bool()) {
689+
commandStreamReceiver.isPreambleSent = !isPreambleNeeded;
690+
691+
flushTask(commandStreamReceiver);
692+
HardwareParse csHwParser;
693+
csHwParser.parseCommands<FamilyType>(commandStreamReceiver.commandStream, parsingOffset);
694+
auto miLoadRegisterCommandsCount = findAll<MI_LOAD_REGISTER_IMM *>(csHwParser.cmdList.begin(), csHwParser.cmdList.end()).size();
695+
size_t expectedCount = (isPreambleNeeded ? 2 : (arbitrationChanged ? 1 : 0));
696+
EXPECT_EQ(expectedCount, miLoadRegisterCommandsCount);
697+
parsingOffset = commandStreamReceiver.commandStream.getUsed();
698+
}
699+
}
700+
}
701+
665702
namespace CpuIntrinsicsTests {
666703
extern volatile uint32_t *pauseAddress;
667704
extern uint32_t pauseValue;

opencl/test/unit_test/command_stream/command_stream_receiver_hw_1_tests.cpp

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -140,35 +140,49 @@ HWTEST_F(UltCommandStreamReceiverTest, givenSentStateSipFlagSetAndSourceLevelDeb
140140
pDevice->setDebuggerActive(false);
141141
}
142142

143-
HWTEST_F(UltCommandStreamReceiverTest, givenPreambleSentAndThreadArbitrationPolicyChangedWhenEstimatingPreambleCmdSizeThenResultDependsOnPolicyProgrammingCmdSize) {
143+
HWTEST_F(UltCommandStreamReceiverTest, givenPreambleSentAndThreadArbitrationPolicyChangedWhenEstimatingFlushTaskSizeThenResultDependsOnPolicyProgrammingCmdSize) {
144144
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
145145
commandStreamReceiver.isPreambleSent = true;
146146

147147
commandStreamReceiver.requiredThreadArbitrationPolicy = commandStreamReceiver.lastSentThreadArbitrationPolicy;
148-
auto policyNotChanged = commandStreamReceiver.getRequiredCmdSizeForPreamble(*pDevice);
148+
auto policyNotChangedPreamble = commandStreamReceiver.getRequiredCmdSizeForPreamble(*pDevice);
149+
auto policyNotChangedFlush = commandStreamReceiver.getRequiredCmdStreamSize(flushTaskFlags, *pDevice);
149150

150151
commandStreamReceiver.requiredThreadArbitrationPolicy = commandStreamReceiver.lastSentThreadArbitrationPolicy + 1;
151-
auto policyChanged = commandStreamReceiver.getRequiredCmdSizeForPreamble(*pDevice);
152-
153-
auto actualDifference = policyChanged - policyNotChanged;
154-
auto expectedDifference = PreambleHelper<FamilyType>::getThreadArbitrationCommandsSize();
155-
EXPECT_EQ(expectedDifference, actualDifference);
152+
auto policyChangedPreamble = commandStreamReceiver.getRequiredCmdSizeForPreamble(*pDevice);
153+
auto policyChangedFlush = commandStreamReceiver.getRequiredCmdStreamSize(flushTaskFlags, *pDevice);
154+
155+
auto actualDifferenceForPreamble = policyChangedPreamble - policyNotChangedPreamble;
156+
auto actualDifferenceForFlush = policyChangedFlush - policyNotChangedFlush;
157+
auto expectedDifference = PreambleHelper<FamilyType>::getThreadArbitrationCommandsSize() +
158+
commandStreamReceiver.getCmdSizeForComputeMode();
159+
EXPECT_EQ(0u, actualDifferenceForPreamble);
160+
EXPECT_EQ(expectedDifference, actualDifferenceForFlush);
156161
}
157162

158-
HWTEST_F(UltCommandStreamReceiverTest, givenPreambleSentWhenEstimatingPreambleCmdSizeThenResultDependsOnPolicyProgrammingAndAdditionalCmdsSize) {
163+
HWTEST_F(UltCommandStreamReceiverTest, givenPreambleSentWhenEstimatingFlushTaskSizeThenResultDependsOnPolicyProgrammingAndAdditionalCmdsSize) {
159164
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
160165
commandStreamReceiver.requiredThreadArbitrationPolicy = commandStreamReceiver.lastSentThreadArbitrationPolicy;
161166

162167
commandStreamReceiver.isPreambleSent = false;
163-
auto preambleNotSent = commandStreamReceiver.getRequiredCmdSizeForPreamble(*pDevice);
168+
auto preambleNotSentPreamble = commandStreamReceiver.getRequiredCmdSizeForPreamble(*pDevice);
169+
auto preambleNotSentFlush = commandStreamReceiver.getRequiredCmdStreamSize(flushTaskFlags, *pDevice);
164170

165171
commandStreamReceiver.isPreambleSent = true;
166-
auto preambleSent = commandStreamReceiver.getRequiredCmdSizeForPreamble(*pDevice);
172+
auto preambleSentPreamble = commandStreamReceiver.getRequiredCmdSizeForPreamble(*pDevice);
173+
auto preambleSentFlush = commandStreamReceiver.getRequiredCmdStreamSize(flushTaskFlags, *pDevice);
167174

168-
auto actualDifference = preambleNotSent - preambleSent;
169-
auto expectedDifference = PreambleHelper<FamilyType>::getThreadArbitrationCommandsSize() + PreambleHelper<FamilyType>::getAdditionalCommandsSize(*pDevice);
175+
auto actualDifferenceForPreamble = preambleNotSentPreamble - preambleSentPreamble;
176+
auto actualDifferenceForFlush = preambleNotSentFlush - preambleSentFlush;
170177

171-
EXPECT_EQ(expectedDifference, actualDifference);
178+
commandStreamReceiver.isPreambleSent = false;
179+
auto expectedDifferenceForPreamble = PreambleHelper<FamilyType>::getAdditionalCommandsSize(*pDevice);
180+
auto expectedDifferenceForFlush = expectedDifferenceForPreamble + PreambleHelper<FamilyType>::getThreadArbitrationCommandsSize() +
181+
commandStreamReceiver.getCmdSizeForL3Config() +
182+
PreambleHelper<FamilyType>::getCmdSizeForPipelineSelect(pDevice->getHardwareInfo());
183+
184+
EXPECT_EQ(expectedDifferenceForPreamble, actualDifferenceForPreamble);
185+
EXPECT_EQ(expectedDifferenceForFlush, actualDifferenceForFlush);
172186
}
173187

174188
HWCMDTEST_F(IGFX_GEN8_CORE, UltCommandStreamReceiverTest, givenMediaVfeStateDirtyEstimatingPreambleCmdSizeThenResultDependsVfeStateProgrammingCmdSize) {
@@ -218,12 +232,12 @@ HWTEST_F(UltCommandStreamReceiverTest, givenPreambleSentAndForceSemaphoreDelayBe
218232
auto preambleSent = commandStreamReceiver.getRequiredCmdSizeForPreamble(*pDevice);
219233

220234
auto actualDifferenceWhenSemaphoreDelayNotReprogrammed = preambleNotSentAndSemaphoreDelayNotReprogrammed - preambleSent;
221-
auto expectedDifference = PreambleHelper<FamilyType>::getThreadArbitrationCommandsSize() + PreambleHelper<FamilyType>::getAdditionalCommandsSize(*pDevice);
235+
auto expectedDifference = PreambleHelper<FamilyType>::getAdditionalCommandsSize(*pDevice);
222236

223237
EXPECT_EQ(expectedDifference, actualDifferenceWhenSemaphoreDelayNotReprogrammed);
224238

225239
auto actualDifferenceWhenSemaphoreDelayReprogrammed = preambleNotSentAndSemaphoreDelayReprogrammed - preambleSent;
226-
expectedDifference = PreambleHelper<FamilyType>::getThreadArbitrationCommandsSize() + PreambleHelper<FamilyType>::getAdditionalCommandsSize(*pDevice) + PreambleHelper<FamilyType>::getSemaphoreDelayCommandSize();
240+
expectedDifference = PreambleHelper<FamilyType>::getAdditionalCommandsSize(*pDevice) + PreambleHelper<FamilyType>::getSemaphoreDelayCommandSize();
227241

228242
EXPECT_EQ(expectedDifference, actualDifferenceWhenSemaphoreDelayReprogrammed);
229243
}

shared/source/command_stream/command_stream_receiver_hw_base.inl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,6 @@ inline size_t CommandStreamReceiverHw<GfxFamily>::getRequiredCmdSizeForPreamble(
129129
if (!this->isPreambleSent) {
130130
size += PreambleHelper<GfxFamily>::getAdditionalCommandsSize(device);
131131
}
132-
if (!this->isPreambleSent || this->lastSentThreadArbitrationPolicy != this->requiredThreadArbitrationPolicy) {
133-
size += PreambleHelper<GfxFamily>::getThreadArbitrationCommandsSize();
134-
}
135132
if (!this->isPreambleSent) {
136133
if (DebugManager.flags.ForceSemaphoreDelayBetweenWaits.get() > -1) {
137134
size += PreambleHelper<GfxFamily>::getSemaphoreDelayCommandSize();
@@ -333,6 +330,7 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
333330
pageTableManagerInitialized = pageTableManager->initPageTableManagerRegisters(this);
334331
}
335332

333+
bool isPreambleNeeded = !this->isPreambleSent;
336334
programHardwareContext(commandStreamCSR);
337335
programComputeMode(commandStreamCSR, dispatchFlags, device.getHardwareInfo());
338336
programPipelineSelect(commandStreamCSR, dispatchFlags.pipelineSelectArgs);
@@ -342,7 +340,7 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
342340
addPipeControlBefore3dState(commandStreamCSR, dispatchFlags);
343341
programPerDssBackedBuffer(commandStreamCSR, device, dispatchFlags);
344342

345-
if (this->lastSentThreadArbitrationPolicy != this->requiredThreadArbitrationPolicy) {
343+
if (this->lastSentThreadArbitrationPolicy != this->requiredThreadArbitrationPolicy || isPreambleNeeded) {
346344
PreambleHelper<GfxFamily>::programThreadArbitration(&commandStreamCSR, this->requiredThreadArbitrationPolicy);
347345
this->lastSentThreadArbitrationPolicy = this->requiredThreadArbitrationPolicy;
348346
}
@@ -824,6 +822,10 @@ size_t CommandStreamReceiverHw<GfxFamily>::getRequiredCmdStreamSize(const Dispat
824822
size += TimestampPacketHelper::getRequiredCmdStreamSize<GfxFamily>(dispatchFlags.csrDependencies);
825823
size += TimestampPacketHelper::getRequiredCmdStreamSizeForTaskCountContainer<GfxFamily>(dispatchFlags.csrDependencies);
826824

825+
if (!this->isPreambleSent || this->lastSentThreadArbitrationPolicy != this->requiredThreadArbitrationPolicy) {
826+
size += PreambleHelper<GfxFamily>::getThreadArbitrationCommandsSize();
827+
}
828+
827829
if (stallingCommandsOnNextFlushRequired) {
828830
size += getCmdSizeForStallingCommands(dispatchFlags);
829831
}

shared/source/helpers/preamble_base.inl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ template <typename GfxFamily>
7777
void PreambleHelper<GfxFamily>::programPreamble(LinearStream *pCommandStream, Device &device, uint32_t l3Config,
7878
uint32_t requiredThreadArbitrationPolicy, GraphicsAllocation *preemptionCsr) {
7979
programL3(pCommandStream, l3Config);
80-
programThreadArbitration(pCommandStream, requiredThreadArbitrationPolicy);
8180
programPreemption(pCommandStream, device, preemptionCsr);
8281
if (device.isDebuggerActive()) {
8382
programKernelDebugging(pCommandStream);

shared/test/common/gen11/test_preamble_gen11.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ GEN11TEST_F(PreemptionWatermarkGen11, WhenPreambleIsCreatedThenWorkAroundsIsNotP
115115
}
116116

117117
typedef PreambleFixture ThreadArbitrationGen11;
118-
GEN11TEST_F(ThreadArbitrationGen11, givenPreambleWhenItIsProgrammedThenThreadArbitrationIsSet) {
118+
GEN11TEST_F(ThreadArbitrationGen11, givenPreambleWhenItIsProgrammedThenThreadArbitrationIsNotSet) {
119119
DebugManagerStateRestore dbgRestore;
120120
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::Disabled));
121121
typedef ICLFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
@@ -129,6 +129,28 @@ GEN11TEST_F(ThreadArbitrationGen11, givenPreambleWhenItIsProgrammedThenThreadArb
129129

130130
parseCommands<FamilyType>(cs);
131131

132+
auto ppC = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
133+
ASSERT_EQ(cmdList.end(), ppC);
134+
135+
auto cmd = findMmioCmd<FamilyType>(cmdList.begin(), cmdList.end(), RowChickenReg4::address);
136+
ASSERT_EQ(nullptr, cmd);
137+
138+
MockDevice device;
139+
EXPECT_EQ(0u, PreambleHelper<ICLFamily>::getAdditionalCommandsSize(device));
140+
EXPECT_EQ(sizeof(MI_LOAD_REGISTER_IMM) + sizeof(PIPE_CONTROL), PreambleHelper<ICLFamily>::getThreadArbitrationCommandsSize());
141+
}
142+
143+
GEN11TEST_F(ThreadArbitrationGen11, whenThreadArbitrationPolicyIsProgrammedThenCorrectValuesAreSet) {
144+
DebugManagerStateRestore dbgRestore;
145+
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::Disabled));
146+
typedef ICLFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
147+
typedef ICLFamily::PIPE_CONTROL PIPE_CONTROL;
148+
LinearStream &cs = linearStream;
149+
MockDevice mockDevice;
150+
PreambleHelper<FamilyType>::programThreadArbitration(&linearStream, ThreadArbitrationPolicy::RoundRobin);
151+
152+
parseCommands<FamilyType>(cs);
153+
132154
auto ppC = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
133155
ASSERT_NE(ppC, cmdList.end());
134156

@@ -186,4 +208,4 @@ GEN11TEST_F(PreambleFixtureGen11, whenKernelDebuggingCommandsAreProgrammedThenCo
186208
pCmd = reinterpret_cast<MI_LOAD_REGISTER_IMM *>(*it);
187209
EXPECT_EQ(0xe400u, pCmd->getRegisterOffset());
188210
EXPECT_EQ((1u << 7) | (1u << 4), pCmd->getDataDword());
189-
}
211+
}

shared/test/common/gen11/test_traits_gen11.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ struct TestTraits<IGFX_GEN11_CORE> {
1616
static constexpr bool auxTranslationSupported = false;
1717
static constexpr bool isUsingNonDefaultIoctls = false;
1818
static constexpr bool deviceEnqueueSupport = true;
19+
static constexpr bool implementsPreambleThreadArbitration = true;
1920
};

shared/test/common/gen12lp/test_traits_gen12lp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ struct TestTraits<IGFX_GEN12LP_CORE> {
1616
static constexpr bool auxTranslationSupported = true;
1717
static constexpr bool isUsingNonDefaultIoctls = false;
1818
static constexpr bool deviceEnqueueSupport = false;
19+
static constexpr bool implementsPreambleThreadArbitration = false;
1920
};

shared/test/common/gen8/test_traits_gen8.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ struct TestTraits<IGFX_GEN8_CORE> {
1515
static constexpr bool iohInSbaSupported = true;
1616
static constexpr bool isUsingNonDefaultIoctls = false;
1717
static constexpr bool deviceEnqueueSupport = false;
18+
static constexpr bool implementsPreambleThreadArbitration = false;
1819
};

shared/test/common/gen9/preamble_tests_gen9.cpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#include "shared/test/common/helpers/debug_manager_state_restore.h"
9+
#include "shared/test/unit_test/preamble/preamble_fixture.h"
910
#include "shared/test/unit_test/source_level_debugger/source_level_debugger_preamble_test.h"
1011

1112
#include "gtest/gtest.h"
@@ -61,3 +62,59 @@ GEN9TEST_F(PreambleTestGen9, givenGen9ThenL3IsProgrammed) {
6162

6263
EXPECT_EQ(l3ConfigDifference, isL3Programmable);
6364
}
65+
66+
using ThreadArbitrationGen9 = PreambleFixture;
67+
GEN9TEST_F(ThreadArbitrationGen9, givenPreambleWhenItIsProgrammedThenThreadArbitrationIsNotSet) {
68+
DebugManagerStateRestore dbgRestore;
69+
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::Disabled));
70+
typedef SKLFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
71+
typedef SKLFamily::PIPE_CONTROL PIPE_CONTROL;
72+
LinearStream &cs = linearStream;
73+
uint32_t l3Config = PreambleHelper<FamilyType>::getL3Config(*defaultHwInfo, true);
74+
MockDevice mockDevice;
75+
PreambleHelper<SKLFamily>::programPreamble(&linearStream, mockDevice, l3Config,
76+
ThreadArbitrationPolicy::RoundRobin,
77+
nullptr);
78+
79+
parseCommands<SKLFamily>(cs);
80+
81+
auto ppC = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
82+
ASSERT_EQ(cmdList.end(), ppC);
83+
84+
auto itorLRI = reverse_find<MI_LOAD_REGISTER_IMM *>(cmdList.rbegin(), cmdList.rend());
85+
ASSERT_NE(cmdList.rend(), itorLRI);
86+
87+
const auto &lri = *reinterpret_cast<MI_LOAD_REGISTER_IMM *>(*itorLRI);
88+
EXPECT_NE(0xE404u, lri.getRegisterOffset());
89+
EXPECT_NE(0x100u, lri.getDataDword());
90+
91+
MockDevice device;
92+
EXPECT_EQ(0u, PreambleHelper<SKLFamily>::getAdditionalCommandsSize(device));
93+
EXPECT_EQ(sizeof(MI_LOAD_REGISTER_IMM) + sizeof(PIPE_CONTROL), PreambleHelper<SKLFamily>::getThreadArbitrationCommandsSize());
94+
}
95+
96+
GEN9TEST_F(ThreadArbitrationGen9, whenThreadArbitrationPolicyIsProgrammedThenCorrectValuesAreSet) {
97+
DebugManagerStateRestore dbgRestore;
98+
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::Disabled));
99+
typedef SKLFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
100+
typedef SKLFamily::PIPE_CONTROL PIPE_CONTROL;
101+
LinearStream &cs = linearStream;
102+
MockDevice mockDevice;
103+
PreambleHelper<FamilyType>::programThreadArbitration(&linearStream, ThreadArbitrationPolicy::RoundRobin);
104+
105+
parseCommands<SKLFamily>(cs);
106+
107+
auto ppC = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
108+
ASSERT_NE(ppC, cmdList.end());
109+
110+
auto itorLRI = reverse_find<MI_LOAD_REGISTER_IMM *>(cmdList.rbegin(), cmdList.rend());
111+
ASSERT_NE(cmdList.rend(), itorLRI);
112+
113+
const auto &lri = *reinterpret_cast<MI_LOAD_REGISTER_IMM *>(*itorLRI);
114+
EXPECT_EQ(0xE404u, lri.getRegisterOffset());
115+
EXPECT_EQ(0x100u, lri.getDataDword());
116+
117+
MockDevice device;
118+
EXPECT_EQ(0u, PreambleHelper<SKLFamily>::getAdditionalCommandsSize(device));
119+
EXPECT_EQ(sizeof(MI_LOAD_REGISTER_IMM) + sizeof(PIPE_CONTROL), PreambleHelper<SKLFamily>::getThreadArbitrationCommandsSize());
120+
}

shared/test/common/gen9/skl/test_preamble_skl.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -71,35 +71,6 @@ SKLTEST_F(Gen9L3Config, GivenSlmWhenProgrammingL3ThenProgrammingIsCorrect) {
7171
}
7272

7373
typedef PreambleFixture ThreadArbitration;
74-
SKLTEST_F(ThreadArbitration, givenPreambleWhenItIsProgrammedThenThreadArbitrationIsSetToRoundRobin) {
75-
DebugManagerStateRestore dbgRestore;
76-
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::Disabled));
77-
typedef SKLFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
78-
typedef SKLFamily::PIPE_CONTROL PIPE_CONTROL;
79-
LinearStream &cs = linearStream;
80-
uint32_t l3Config = PreambleHelper<FamilyType>::getL3Config(*defaultHwInfo, true);
81-
MockDevice mockDevice;
82-
PreambleHelper<SKLFamily>::programPreamble(&linearStream, mockDevice, l3Config,
83-
ThreadArbitrationPolicy::RoundRobin,
84-
nullptr);
85-
86-
parseCommands<SKLFamily>(cs);
87-
88-
auto ppC = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
89-
ASSERT_NE(ppC, cmdList.end());
90-
91-
auto itorLRI = reverse_find<MI_LOAD_REGISTER_IMM *>(cmdList.rbegin(), cmdList.rend());
92-
ASSERT_NE(cmdList.rend(), itorLRI);
93-
94-
const auto &lri = *reinterpret_cast<MI_LOAD_REGISTER_IMM *>(*itorLRI);
95-
EXPECT_EQ(0xE404u, lri.getRegisterOffset());
96-
EXPECT_EQ(0x100u, lri.getDataDword());
97-
98-
MockDevice device;
99-
EXPECT_EQ(0u, PreambleHelper<SKLFamily>::getAdditionalCommandsSize(device));
100-
EXPECT_EQ(sizeof(MI_LOAD_REGISTER_IMM) + sizeof(PIPE_CONTROL), PreambleHelper<SKLFamily>::getThreadArbitrationCommandsSize());
101-
}
102-
10374
SKLTEST_F(ThreadArbitration, GivenDefaultWhenProgrammingPreambleThenArbitrationPolicyIsRoundRobin) {
10475
EXPECT_EQ(ThreadArbitrationPolicy::RoundRobin, HwHelperHw<SKLFamily>::get().getDefaultThreadArbitrationPolicy());
10576
}

0 commit comments

Comments
 (0)