Skip to content

Commit 52febb2

Browse files
stefan-iligcbot
authored andcommitted
Check intel_reqd_sub_group_size attribute in SIMD16 drop
Check intel_reqd_sub_group_size attribute when deciding if we can early drop to SIMD 16.
1 parent 4fc519a commit 52febb2

File tree

4 files changed

+22
-34
lines changed

4 files changed

+22
-34
lines changed

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -558,33 +558,6 @@ bool EmitPass::shouldForceEarlyRecompile(MetaDataUtils *pMdUtils, llvm::Function
558558
return PassedThreshold;
559559
}
560560

561-
bool EmitPass::shouldDropToSIMD16(MetaDataUtils *pMdUtils, llvm::Function *F) {
562-
if (m_pCtx->type != ShaderType::OPENCL_SHADER || IGC_IS_FLAG_DISABLED(AllowEarlySIMD16DropForXE3)) {
563-
return false;
564-
}
565-
566-
if (!m_canAbortOnSpill || !m_pCtx->isAutoGRFSelectionEnabled() || !isEntryFunc(pMdUtils, F)) {
567-
return false;
568-
}
569-
570-
// If there are user set values for SIMD size or GRF number just return
571-
if (IGC_IS_FLAG_ENABLED(ForceCSSIMD32) || m_pCtx->getModuleMetaData()->csInfo.forcedSIMDSize != 0 ||
572-
m_pCtx->getNumGRFPerThread(false) != 0) {
573-
return false;
574-
}
575-
576-
// Currently, we do this optimization only for XE3 but we can relax this
577-
// requirement to all platforms where abortOnSpills is enabled.
578-
if (!m_pCtx->platform.isCoreXE3()) {
579-
return false;
580-
}
581-
582-
auto MaxRegPressure = getMaxRegPressureInFunctionGroup(F, pMdUtils);
583-
auto Threshold = IGC_GET_FLAG_VALUE(EarlySIMD16DropForXE3Threshold);
584-
bool shouldDrop = MaxRegPressure > Threshold;
585-
return shouldDrop;
586-
}
587-
588561
bool EmitPass::runOnFunction(llvm::Function &F) {
589562
m_currFuncHasSubroutine = false;
590563

@@ -646,10 +619,6 @@ bool EmitPass::runOnFunction(llvm::Function &F) {
646619
return false;
647620
}
648621

649-
if (shouldDropToSIMD16(pMdUtils, &F)) {
650-
return false;
651-
}
652-
653622
// Force SIMD8 on library compilations for non-OCL shaders
654623
if (m_pCtx->type != ShaderType::OPENCL_SHADER && m_pCtx->getCompilerOption().IsLibraryCompilation &&
655624
m_SimdMode != SIMDMode::SIMD8) {

IGC/Compiler/CISACodeGen/EmitVISAPass.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -979,8 +979,6 @@ class EmitPass : public llvm::FunctionPass {
979979

980980
bool shouldForceEarlyRecompile(IGCMD::MetaDataUtils *pMdUtils, llvm::Function *F);
981981

982-
bool shouldDropToSIMD16(IGCMD::MetaDataUtils *pMdUtils, llvm::Function *F);
983-
984982
bool isHalfGRFReturn(CVariable *dst, SIMDMode simdMode);
985983

986984
void emitFeedbackEnable();

IGC/Compiler/CISACodeGen/OpenCLKernelCodeGen.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2415,6 +2415,19 @@ bool COpenCLKernel::CompileSIMDSize(SIMDMode simdMode, EmitPass &EP, llvm::Funct
24152415
return simdStatus == SIMDStatus::SIMD_PASS;
24162416
}
24172417

2418+
static bool shouldDropToSIMD16(uint32_t maxPressure, SIMDMode simdMode, CodeGenContext *pCtx, MetaDataUtils *pMdUtils,
2419+
llvm::Function *F) {
2420+
if (simdMode != SIMDMode::SIMD32 || !isEntryFunc(pMdUtils, F)) {
2421+
return false;
2422+
}
2423+
if (!pCtx->isAutoGRFSelectionEnabled() || pCtx->getNumGRFPerThread(false) != 0) {
2424+
return false;
2425+
}
2426+
auto threshold = IGC_GET_FLAG_VALUE(EarlySIMD16DropForXE3Threshold);
2427+
bool shouldDrop = maxPressure > threshold;
2428+
return shouldDrop;
2429+
}
2430+
24182431
SIMDStatus COpenCLKernel::checkSIMDCompileCondsForMin16(SIMDMode simdMode, EmitPass &EP, llvm::Function &F,
24192432
bool hasSyncRTCalls) {
24202433
if (simdMode == SIMDMode::SIMD8) {
@@ -2524,6 +2537,14 @@ SIMDStatus COpenCLKernel::checkSIMDCompileCondsForMin16(SIMDMode simdMode, EmitP
25242537
}
25252538
}
25262539

2540+
if (EP.m_canAbortOnSpill && pCtx->platform.isCoreXE3() && IGC_IS_FLAG_ENABLED(AllowEarlySIMD16DropForXE3)) {
2541+
bool shouldDrop = shouldDropToSIMD16(maxPressure, simdMode, pCtx, pMdUtils, &F);
2542+
if (shouldDrop) {
2543+
pCtx->SetSIMDInfo(SIMD_SKIP_PERF, simdMode, ShaderDispatchMode::NOT_APPLICABLE);
2544+
return SIMDStatus::SIMD_FUNC_FAIL;
2545+
}
2546+
}
2547+
25272548
return SIMDStatus::SIMD_PASS;
25282549
}
25292550

IGC/common/igc_flags.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,7 @@ DECLARE_IGC_REGKEY(bool, EnableReusingXYZWStoreConstPayload, true, "Enable reusi
15401540
DECLARE_IGC_REGKEY(bool, EnableReusingLSCStoreConstPayload, false, "Enable reusing LSC stores const payload", false)
15411541
DECLARE_IGC_REGKEY(bool, AllowSIMD16DropForXE2, true, "Controls the switch for XE2 simd16 drop", false)
15421542
DECLARE_IGC_REGKEY(bool, AllowSIMD16DropForXE3, true, "Controls the switch for XE3 simd16 drop", false)
1543-
DECLARE_IGC_REGKEY(bool, AllowEarlySIMD16DropForXE3, false,
1543+
DECLARE_IGC_REGKEY(bool, AllowEarlySIMD16DropForXE3, true,
15441544
"Controls the early drop to simd16 for XE3", false)
15451545
DECLARE_IGC_REGKEY(DWORD, EarlySIMD16DropForXE3Threshold, 190, "Threshold for the early drop to simd16 for XE3", false)
15461546
DECLARE_IGC_REGKEY(DWORD, RegPressureVerbocity, 2, "Different printing types", false)

0 commit comments

Comments
 (0)