Skip to content

Commit 187f187

Browse files
weiyu-chensys_zuul
authored andcommitted
Do not consider subgroup-uniform values (e.g., subgroup intrinsics and dispatch mask) as uniform for certain platforms.
Change-Id: I95a6340b0a950870f0bd33d28fc4932368783efd
1 parent 7fd15c0 commit 187f187

File tree

3 files changed

+38
-18
lines changed

3 files changed

+38
-18
lines changed

IGC/Compiler/CISACodeGen/Platform.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,12 @@ namespace IGC
382382
{
383383
return IGC_IS_FLAG_ENABLED(FuseTypedWrite);
384384
}
385+
386+
bool HasUniformSubGroupIntrinsic() const
387+
{
388+
return IGC_IS_FLAG_DISABLED(NonUniformSubGroupIntrinsic) &&
389+
m_platformInfo.eProductFamily != IGFX_TIGERLAKE_LP;
390+
}
385391
// ***** Below go accessor methods for testing WA data from WA_TABLE *****
386392

387393
bool WaDoNotPushConstantsForAllPulledGSTopologies() const

IGC/Compiler/CISACodeGen/WIAnalysis.cpp

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,32 +1131,45 @@ WIAnalysis::WIDependancy WIAnalysisRunner::calculate_dep(const CallInst* inst)
11311131
return WIAnalysis::UNIFORM;
11321132
}
11331133

1134-
if (intrinsic_name == llvm_waveShuffleIndex)
1134+
if (m_CGCtx->platform.HasUniformSubGroupIntrinsic())
11351135
{
1136-
Value* op0 = inst->getArgOperand(0);
1137-
Value* op1 = inst->getArgOperand(1);
1138-
if (WIAnalysis::UNIFORM == getDependency(op0) ||
1139-
WIAnalysis::UNIFORM == getDependency(op1))
1136+
if (intrinsic_name == llvm_waveShuffleIndex)
1137+
{
1138+
Value* op0 = inst->getArgOperand(0);
1139+
Value* op1 = inst->getArgOperand(1);
1140+
if (WIAnalysis::UNIFORM == getDependency(op0) ||
1141+
WIAnalysis::UNIFORM == getDependency(op1))
1142+
{
1143+
return WIAnalysis::UNIFORM;
1144+
}
1145+
}
1146+
1147+
if (intrinsic_name == llvm_waveBallot || intrinsic_name == llvm_waveAll)
11401148
{
11411149
return WIAnalysis::UNIFORM;
11421150
}
1143-
}
11441151

1145-
if (intrinsic_name == llvm_waveBallot || intrinsic_name == llvm_waveAll)
1146-
{
1147-
return WIAnalysis::UNIFORM;
1148-
}
1152+
if (intrinsic_name == llvm_waveClustered)
1153+
{
1154+
const unsigned clusterSize = static_cast<unsigned>(
1155+
cast<llvm::ConstantInt>(inst->getArgOperand(2))->getZExtValue());
11491156

1150-
if (intrinsic_name == llvm_waveClustered)
1157+
constexpr unsigned maxSimdSize = 32;
1158+
if (clusterSize == maxSimdSize)
1159+
{
1160+
// TODO: do the same for SIMD8 and SIMD16 if possible.
1161+
return WIAnalysis::UNIFORM;
1162+
}
1163+
}
1164+
}
1165+
else
11511166
{
1152-
const unsigned clusterSize = static_cast<unsigned>(
1153-
cast<llvm::ConstantInt>(inst->getArgOperand(2))->getZExtValue());
1154-
1155-
constexpr unsigned maxSimdSize = 32;
1156-
if (clusterSize == maxSimdSize)
1167+
if (GII_id == GenISAIntrinsic::GenISA_getSR0 ||
1168+
GII_id == GenISAIntrinsic::GenISA_eu_id ||
1169+
GII_id == GenISAIntrinsic::GenISA_eu_thread_id)
11571170
{
1158-
// TODO: do the same for SIMD8 and SIMD16 if possible.
1159-
return WIAnalysis::UNIFORM;
1171+
// do not assume these per-thread values are globally uniform
1172+
return WIAnalysis::RANDOM;
11601173
}
11611174
}
11621175

IGC/common/igc_flags.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ DECLARE_IGC_REGKEY(bool, UniformMemOptLimit, 0, "Limit of uniform
282282
DECLARE_IGC_REGKEY(bool, EnableFunctionPointer, true, "Enables support for function pointers and indirect calls", false)
283283
DECLARE_IGC_REGKEY(bool, EnableIndirectCallOptimization, false, "Enables inlining indirect calls by comparing function addresses", false)
284284
DECLARE_IGC_REGKEY(bool, ForceFFIDOverwrite, false, "Force overwriting ffid in sr0.0", false)
285+
DECLARE_IGC_REGKEY(bool, NonUniformSubGroupIntrinsic, false, "Consider sub-group intrinsics to be non-uniform", false)
285286

286287
DECLARE_IGC_REGKEY(bool, EnableReadGTPinInput, true, "Enables setting GTPin context flags by reading the input to the compiler adapters", false)
287288

0 commit comments

Comments
 (0)