@@ -643,6 +643,39 @@ namespace IGC
643
643
return result;
644
644
}
645
645
646
+ uint32_t COpenCLKernel::getReqdSubGroupSize (llvm::Function& F, MetaDataUtils* MDUtils) const
647
+ {
648
+ FunctionInfoMetaDataHandle funcInfoMD = MDUtils->getFunctionsInfoItem (&F);
649
+ int simd_size = funcInfoMD->getSubGroupSize ()->getSIMDSize ();
650
+
651
+ // Finds the kernel and get the group simd size from the kernel
652
+ if (m_FGA)
653
+ {
654
+ llvm::Function* Kernel = &F;
655
+ auto FG = m_FGA->getGroup (&F);
656
+ Kernel = FG->getHead ();
657
+ funcInfoMD = MDUtils->getFunctionsInfoItem (Kernel);
658
+ simd_size = funcInfoMD->getSubGroupSize ()->getSIMDSize ();
659
+ }
660
+ return simd_size;
661
+ }
662
+
663
+ uint32_t COpenCLKernel::getMaxPressure (llvm::Function& F, MetaDataUtils* MDUtils) const
664
+ {
665
+ FunctionInfoMetaDataHandle funcInfoMD = MDUtils->getFunctionsInfoItem (&F);
666
+ unsigned int maxPressure = funcInfoMD->getMaxRegPressure ()->getMaxPressure ();
667
+
668
+ if (m_FGA)
669
+ {
670
+ llvm::Function* Kernel = &F;
671
+ auto FG = m_FGA->getGroup (&F);
672
+ Kernel = FG->getHead ();
673
+ funcInfoMD = MDUtils->getFunctionsInfoItem (Kernel);
674
+ maxPressure = funcInfoMD->getMaxRegPressure ()->getMaxPressure ();
675
+ }
676
+ return maxPressure;
677
+ }
678
+
646
679
void COpenCLKernel::CreateKernelArgInfo ()
647
680
{
648
681
auto funcMDIt = m_Context->getModuleMetaData ()->FuncMD .find (entry);
@@ -3659,7 +3692,25 @@ namespace IGC
3659
3692
3660
3693
// Func and Perf checks pass, compile this SIMD
3661
3694
if (simdStatus == SIMDStatus::SIMD_PASS)
3695
+ {
3662
3696
return true ;
3697
+ }
3698
+ // Report an error if intel_reqd_sub_group_size cannot be satisfied
3699
+ else
3700
+ {
3701
+ MetaDataUtils* pMdUtils = EP.getAnalysis <MetaDataUtilsWrapper>().getMetaDataUtils ();
3702
+ CodeGenContext* ctx = GetContext ();
3703
+ auto reqdSubGroupSize = getReqdSubGroupSize (F, pMdUtils);
3704
+ if (reqdSubGroupSize == numLanes (simdMode))
3705
+ {
3706
+ ctx->EmitError (
3707
+ (std::string (" Cannot compile a kernel in the SIMD mode specified by intel_reqd_sub_group_size(" ) +
3708
+ std::to_string (reqdSubGroupSize) +
3709
+ std::string (" )" )).c_str (),
3710
+ &F);
3711
+ return false ;
3712
+ }
3713
+ }
3663
3714
3664
3715
// Functional failure, skip compiling this SIMD
3665
3716
if (simdStatus == SIMDStatus::SIMD_FUNC_FAIL)
@@ -3682,28 +3733,16 @@ namespace IGC
3682
3733
CodeGenContext* pCtx = GetContext ();
3683
3734
MetaDataUtils* pMdUtils = EP.getAnalysis <MetaDataUtilsWrapper>().getMetaDataUtils ();
3684
3735
FunctionInfoMetaDataHandle funcInfoMD = pMdUtils->getFunctionsInfoItem (&F);
3685
- int simd_size = funcInfoMD-> getSubGroupSize ()-> getSIMDSize ( );
3736
+ uint32_t simd_size = getReqdSubGroupSize (F, pMdUtils );
3686
3737
bool hasSubGroupForce = hasSubGroupIntrinsicPVC (F);
3687
- unsigned int maxPressure = funcInfoMD->getMaxRegPressure ()->getMaxPressure ();
3688
-
3689
- // Finds the kernel and get the group simd size from the kernel
3690
- if (m_FGA)
3691
- {
3692
- llvm::Function* Kernel = &F;
3693
- auto FG = m_FGA->getGroup (&F);
3694
- Kernel = FG->getHead ();
3695
- funcInfoMD = pMdUtils->getFunctionsInfoItem (Kernel);
3696
- simd_size = funcInfoMD->getSubGroupSize ()->getSIMDSize ();
3697
- maxPressure = funcInfoMD->getMaxRegPressure ()->getMaxPressure ();
3698
- }
3738
+ uint32_t maxPressure = getMaxPressure (F, pMdUtils);
3699
3739
3700
3740
auto FG = m_FGA ? m_FGA->getGroup (&F) : nullptr ;
3701
3741
bool hasStackCall = FG && FG->hasStackCall ();
3702
3742
bool isIndirectGroup = FG && m_FGA->isIndirectCallGroup (FG);
3703
3743
bool hasSubroutine = FG && !FG->isSingleIgnoringStackOverflowDetection () && !hasStackCall && !isIndirectGroup;
3704
3744
bool forceLowestSIMDForStackCalls = IGC_IS_FLAG_ENABLED (ForceLowestSIMDForStackCalls) && (hasStackCall || isIndirectGroup);
3705
3745
3706
-
3707
3746
if (simd_size == 0 )
3708
3747
{
3709
3748
if (maxPressure >= IGC_GET_FLAG_VALUE (ForceSIMDRPELimit) &&
@@ -3849,19 +3888,8 @@ namespace IGC
3849
3888
MetaDataUtils* pMdUtils = EP.getAnalysis <MetaDataUtilsWrapper>().getMetaDataUtils ();
3850
3889
ModuleMetaData* modMD = pCtx->getModuleMetaData ();
3851
3890
FunctionInfoMetaDataHandle funcInfoMD = pMdUtils->getFunctionsInfoItem (&F);
3852
- int simd_size = funcInfoMD->getSubGroupSize ()->getSIMDSize ();
3853
- unsigned int maxPressure = funcInfoMD->getMaxRegPressure ()->getMaxPressure ();
3854
-
3855
- // Finds the kernel and get the group simd size from the kernel
3856
- if (m_FGA)
3857
- {
3858
- llvm::Function* Kernel = &F;
3859
- auto FG = m_FGA->getGroup (&F);
3860
- Kernel = FG->getHead ();
3861
- funcInfoMD = pMdUtils->getFunctionsInfoItem (Kernel);
3862
- simd_size = funcInfoMD->getSubGroupSize ()->getSIMDSize ();
3863
- maxPressure = funcInfoMD->getMaxRegPressure ()->getMaxPressure ();
3864
- }
3891
+ uint32_t simd_size = getReqdSubGroupSize (F, pMdUtils);
3892
+ uint32_t maxPressure = getMaxPressure (F, pMdUtils);
3865
3893
3866
3894
// For simd variant functions, detect which SIMD sizes are needed
3867
3895
if (compileFunctionVariants && F.hasFnAttribute (" variant-function-def" ))
@@ -3896,14 +3924,6 @@ namespace IGC
3896
3924
bool hasIndirectCall = FG && FG->hasIndirectCall ();
3897
3925
if (hasNestedCall || hasIndirectCall || isIndirectGroup)
3898
3926
{
3899
- // If sub_group_size is set to 32, resize it to 16 so SIMD16 compilation will still succeed
3900
- if (simd_size == 32 )
3901
- {
3902
- pCtx->EmitWarning (" Detected 'reqd_sub_group_size=32', but compiling to SIMD16 due to enabling CallWA, which does not support SIMD32 when nested/indirect calls are present." );
3903
- llvm::Function* Kernel = FG->getHead ();
3904
- funcInfoMD = pMdUtils->getFunctionsInfoItem (Kernel);
3905
- funcInfoMD->getSubGroupSize ()->setSIMDSize (16 );
3906
- }
3907
3927
pCtx->SetSIMDInfo (SIMD_SKIP_HW, simdMode, ShaderDispatchMode::NOT_APPLICABLE);
3908
3928
return SIMDStatus::SIMD_FUNC_FAIL;
3909
3929
}
0 commit comments