Skip to content

Commit 4af024f

Browse files
stefan-iligcbot
authored andcommitted
Add heuristic for dropping to SIMD16 on XE3
Add heuristic on XE3 to force SIMD16 mode before reaching larger GRF sizes.
1 parent 53d6029 commit 4af024f

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

+33
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,34 @@ bool EmitPass::shouldForceEarlyRecompile(MetaDataUtils *pMdUtils,
687687
return PassedThreshold;
688688
}
689689

690+
bool EmitPass::shouldDropToSIMD16(MetaDataUtils *pMdUtils,
691+
llvm::Function *F) {
692+
if (m_pCtx->type != ShaderType::OPENCL_SHADER || IGC_IS_FLAG_DISABLED(AllowEarlySIMD16DropForXE3)) {
693+
return false;
694+
}
695+
696+
if (!m_canAbortOnSpill || !m_pCtx->isAutoGRFSelectionEnabled() || !isEntryFunc(pMdUtils, F)) {
697+
return false;
698+
}
699+
700+
// If there are user set values for SIMD size or GRF number just return
701+
if (IGC_IS_FLAG_ENABLED(ForceCSSIMD32) || m_pCtx->getModuleMetaData()->csInfo.forcedSIMDSize != 0 ||
702+
m_pCtx->getNumGRFPerThread( false) != 0) {
703+
return false;
704+
}
705+
706+
// Currently, we do this optimization only for XE3 but we can relax this requirement to all platforms
707+
// where abortOnSpills is enabled.
708+
if (!m_pCtx->platform.isCoreXE3()) {
709+
return false;
710+
}
711+
712+
auto MaxRegPressure = getMaxRegPressureInFunctionGroup(F, pMdUtils);
713+
auto Threshold = IGC_GET_FLAG_VALUE(EarlySIMD16DropForXE3Threshold);
714+
bool shouldDrop = MaxRegPressure > Threshold;
715+
return shouldDrop;
716+
}
717+
690718
bool EmitPass::runOnFunction(llvm::Function& F)
691719
{
692720
m_currFuncHasSubroutine = false;
@@ -756,6 +784,11 @@ bool EmitPass::runOnFunction(llvm::Function& F)
756784
return false;
757785
}
758786

787+
if (shouldDropToSIMD16(pMdUtils, &F))
788+
{
789+
return false;
790+
}
791+
759792
// Force SIMD8 on library compilations for non-OCL shaders
760793
if (m_pCtx->type != ShaderType::OPENCL_SHADER &&
761794
m_pCtx->getCompilerOption().IsLibraryCompilation &&

IGC/Compiler/CISACodeGen/EmitVISAPass.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,8 @@ class EmitPass : public llvm::FunctionPass
11841184

11851185
bool shouldForceEarlyRecompile(IGCMD::MetaDataUtils* pMdUtils, llvm::Function* F);
11861186

1187+
bool shouldDropToSIMD16(IGCMD::MetaDataUtils* pMdUtils, llvm::Function* F);
1188+
11871189
bool isHalfGRFReturn(CVariable* dst, SIMDMode simdMode);
11881190

11891191
void emitFeedbackEnable();

IGC/common/igc_flags.h

+2
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,8 @@ DECLARE_IGC_REGKEY(bool, EnableReusingXYZWStoreConstPayload, true, "Enable reusi
899899
DECLARE_IGC_REGKEY(bool, EnableReusingLSCStoreConstPayload, false, "Enable reusing LSC stores const payload", false)
900900
DECLARE_IGC_REGKEY(bool, AllowSIMD16DropForXE2, true, "Controls the switch for XE2 simd16 drop", false)
901901
DECLARE_IGC_REGKEY(bool, AllowSIMD16DropForXE3, true, "Controls the switch for XE3 simd16 drop", false)
902+
DECLARE_IGC_REGKEY(bool, AllowEarlySIMD16DropForXE3, true, "Controls the early drop to simd16 for XE3", false)
903+
DECLARE_IGC_REGKEY(DWORD, EarlySIMD16DropForXE3Threshold, 190, "Threshold for the early drop to simd16 for XE3", false)
902904
DECLARE_IGC_REGKEY(DWORD, RegPressureVerbocity, 0, "Different printing types", false)
903905
DECLARE_IGC_REGKEY(DWORD, RetryRevertExcessiveSpillingKernelThreshold, 10000, "Sets the threshold for Retry Manager to know which kernel is considered as Excessive Spilling and applies different set of rules", false)
904906
DECLARE_IGC_REGKEY(DWORD, RetryRevertExcessiveSpillingKernelCoefficient, 102, "Sets the coefficient for Retry Manager to know whether we should revert back to a previously compiled kernel", false)

0 commit comments

Comments
 (0)