Skip to content

Commit 9b3acc8

Browse files
kgibalaCompute-Runtime-Automation
authored andcommitted
Remove dependency on sharedHandles when program SCM
Related-To: NEO-6056 Signed-off-by: Krzysztof Gibala <[email protected]>
1 parent 7c473d0 commit 9b3acc8

File tree

4 files changed

+25
-33
lines changed

4 files changed

+25
-33
lines changed
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 Intel Corporation
2+
* Copyright (C) 2019-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -8,6 +8,10 @@
88
#include "shared/source/helpers/state_compute_mode_helper.h"
99

1010
namespace NEO {
11+
1112
template <>
12-
bool StateComputeModeHelper<TGLLPFamily>::isStateComputeModeRequired(const CsrSizeRequestFlags &csrSizeRequestFlags, bool isThreadArbitionPolicyProgrammed) { return false; }
13-
} // namespace NEO
13+
bool StateComputeModeHelper<TGLLPFamily>::isStateComputeModeRequired(const CsrSizeRequestFlags &csrSizeRequestFlags, bool isThreadArbitionPolicyProgrammed) {
14+
return csrSizeRequestFlags.coherencyRequestChanged || csrSizeRequestFlags.hasSharedHandles || csrSizeRequestFlags.numGrfRequiredChanged;
15+
}
16+
17+
} // namespace NEO

opencl/source/xe_hp_core/state_compute_mode_helper_xe_hp_core.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
#include "shared/source/helpers/state_compute_mode_helper.h"
99

1010
namespace NEO {
11+
1112
template <>
1213
bool StateComputeModeHelper<XeHpFamily>::isStateComputeModeRequired(const CsrSizeRequestFlags &csrSizeRequestFlags, bool isThreadArbitionPolicyProgrammed) {
13-
return false;
14+
return csrSizeRequestFlags.coherencyRequestChanged || csrSizeRequestFlags.numGrfRequiredChanged;
1415
}
16+
1517
} // namespace NEO

opencl/test/unit_test/command_stream/compute_mode_tests_xehp_and_later.cpp

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, ComputeModeRequirements, givenCoherencyWithSharedHa
4747
using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE;
4848
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
4949

50-
auto cmdsSize = sizeof(STATE_COMPUTE_MODE) + sizeof(PIPE_CONTROL);
50+
auto cmdsSize = 0u;
5151

5252
overrideComputeModeRequest<FamilyType>(false, false, true);
5353
auto retSize = getCsrHw<FamilyType>()->getCmdSizeForComputeMode();
@@ -57,6 +57,8 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, ComputeModeRequirements, givenCoherencyWithSharedHa
5757
retSize = getCsrHw<FamilyType>()->getCmdSizeForComputeMode();
5858
EXPECT_EQ(cmdsSize, retSize);
5959

60+
cmdsSize = sizeof(STATE_COMPUTE_MODE) + sizeof(PIPE_CONTROL);
61+
6062
overrideComputeModeRequest<FamilyType>(true, true, true);
6163
retSize = getCsrHw<FamilyType>()->getCmdSizeForComputeMode();
6264
EXPECT_EQ(cmdsSize, retSize);
@@ -214,7 +216,7 @@ HWTEST2_F(ComputeModeRequirements, givenCoherencyRequirementWithoutSharedHandles
214216
csr->getMemoryManager()->freeGraphicsMemory(graphicAlloc);
215217
}
216218

217-
HWTEST2_F(ComputeModeRequirements, givenCoherencyRequirementWithSharedHandlesWhenFlushTaskCalledThenAlwaysProgramCmds, ForceNonCoherentSupportedMatcher) {
219+
HWTEST2_F(ComputeModeRequirements, givenCoherencyRequirementWithSharedHandlesWhenFlushTaskCalledThenProgramCmdsWhenNeeded, ForceNonCoherentSupportedMatcher) {
218220
SetUpImpl<FamilyType>();
219221
using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE;
220222
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
@@ -232,7 +234,7 @@ HWTEST2_F(ComputeModeRequirements, givenCoherencyRequirementWithSharedHandlesWhe
232234
csr->flushTask(stream, 0, stream, stream, stream, 0, flags, *device);
233235
};
234236

235-
auto flushTaskAndFindCmds = [&](bool expectCoherent) {
237+
auto flushTaskAndFindCmds = [&](bool expectCoherent, bool areCommandsProgrammed) {
236238
flushTask(expectCoherent);
237239
HardwareParse hwParser;
238240
hwParser.parseCommands<FamilyType>(getCsrHw<FamilyType>()->commandStream, startOffset);
@@ -252,20 +254,20 @@ HWTEST2_F(ComputeModeRequirements, givenCoherencyRequirementWithSharedHandlesWhe
252254
EXPECT_NE(nullptr, pc);
253255
}
254256
}
255-
EXPECT_TRUE(foundOne);
257+
EXPECT_EQ(foundOne, areCommandsProgrammed);
256258
};
257259

258-
flushTaskAndFindCmds(false); // first time
259-
flushTaskAndFindCmds(false); // not changed
260-
flushTaskAndFindCmds(true); // changed
261-
flushTaskAndFindCmds(true); // not changed
262-
flushTaskAndFindCmds(false); // changed
263-
flushTaskAndFindCmds(false); // not changed
260+
flushTaskAndFindCmds(false, true); // first time
261+
flushTaskAndFindCmds(false, false); // not changed
262+
flushTaskAndFindCmds(true, true); // changed
263+
flushTaskAndFindCmds(true, false); // not changed
264+
flushTaskAndFindCmds(false, true); // changed
265+
flushTaskAndFindCmds(false, false); // not changed
264266

265267
csr->getMemoryManager()->freeGraphicsMemory(graphicsAlloc);
266268
}
267269

268-
HWTEST2_F(ComputeModeRequirements, givenFlushWithoutSharedHandlesWhenPreviouslyUsedThenProgramPcAndSCM, ForceNonCoherentSupportedMatcher) {
270+
HWTEST2_F(ComputeModeRequirements, givenFlushWithoutSharedHandlesWhenPreviouslyUsedThenPcAndSCMAreNotProgrammed, ForceNonCoherentSupportedMatcher) {
269271
SetUpImpl<FamilyType>();
270272
using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE;
271273
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
@@ -284,22 +286,7 @@ HWTEST2_F(ComputeModeRequirements, givenFlushWithoutSharedHandlesWhenPreviouslyU
284286
HardwareParse hwParser;
285287
hwParser.parseCommands<FamilyType>(getCsrHw<FamilyType>()->commandStream, startOffset);
286288

287-
typename STATE_COMPUTE_MODE::FORCE_NON_COHERENT expectedCoherentValue = STATE_COMPUTE_MODE::FORCE_NON_COHERENT_FORCE_GPU_NON_COHERENT;
288-
uint32_t expectedCoherentMask = FamilyType::stateComputeModeForceNonCoherentMask | FamilyType::stateComputeModeLargeGrfModeMask;
289-
290-
bool foundOne = false;
291-
for (auto it = hwParser.cmdList.begin(); it != hwParser.cmdList.end(); it++) {
292-
auto cmd = genCmdCast<STATE_COMPUTE_MODE *>(*it);
293-
if (cmd) {
294-
EXPECT_EQ(expectedCoherentValue, cmd->getForceNonCoherent());
295-
EXPECT_TRUE(isValueSet(cmd->getMaskBits(), expectedCoherentMask));
296-
EXPECT_FALSE(foundOne);
297-
foundOne = true;
298-
auto pc = genCmdCast<PIPE_CONTROL *>(*(++it));
299-
EXPECT_NE(nullptr, pc);
300-
}
301-
}
302-
EXPECT_TRUE(foundOne);
289+
EXPECT_EQ(0u, hwParser.cmdList.size());
303290

304291
csr->getMemoryManager()->freeGraphicsMemory(graphicAlloc);
305292
}

shared/source/command_stream/command_stream_receiver_hw_tgllp_and_later.inl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ void CommandStreamReceiverHw<GfxFamily>::programComputeMode(LinearStream &stream
5353

5454
template <>
5555
inline bool CommandStreamReceiverHw<Family>::isComputeModeNeeded() const {
56-
return csrSizeRequestFlags.coherencyRequestChanged || csrSizeRequestFlags.hasSharedHandles || csrSizeRequestFlags.numGrfRequiredChanged ||
57-
StateComputeModeHelper<Family>::isStateComputeModeRequired(csrSizeRequestFlags, this->lastSentThreadArbitrationPolicy != this->requiredThreadArbitrationPolicy);
56+
return StateComputeModeHelper<Family>::isStateComputeModeRequired(csrSizeRequestFlags, this->lastSentThreadArbitrationPolicy != this->requiredThreadArbitrationPolicy);
5857
}
5958

6059
template <>

0 commit comments

Comments
 (0)