@@ -8,6 +8,7 @@ SPDX-License-Identifier: MIT
88
99#include " Compiler/CISACodeGen/CISABuilder.hpp"
1010#include " Compiler/CISACodeGen/ShaderCodeGen.hpp"
11+ #include " Compiler/CISACodeGen/IGCLivenessAnalysis.h"
1112#include " Compiler/CISACodeGen/OpenCLKernelCodeGen.hpp"
1213#include " Compiler/Optimizer/OpenCLPasses/NamedBarriers/NamedBarriersResolution.hpp"
1314#include " common/allocator.h"
@@ -3545,8 +3546,8 @@ void CEncoder::SetAbortOnSpillThreshold(bool canAbortOnSpill, bool AllowSpill) {
35453546 }
35463547}
35473548
3548- void CEncoder::InitVISABuilderOptions (TARGET_PLATFORM VISAPlatform, bool canAbortOnSpill , bool hasStackCall ,
3549- bool enableVISA_IR) {
3549+ void CEncoder::InitVISABuilderOptions (TARGET_PLATFORM VISAPlatform, SIMDMode simdMode , bool canAbortOnSpill ,
3550+ bool hasStackCall, bool enableVISA_IR) {
35503551 CodeGenContext *context = m_program->GetContext ();
35513552 bool KernelDebugEnable = false ;
35523553 bool ForceNonCoherentStatelessBti = false ;
@@ -4239,13 +4240,16 @@ void CEncoder::InitVISABuilderOptions(TARGET_PLATFORM VISAPlatform, bool canAbor
42394240
42404241 auto funcInfoMD = context->getMetaDataUtils ()->getFunctionsInfoItem (m_program->entry );
42414242 uint32_t MaxRegPressure = funcInfoMD->getMaxRegPressure ()->getMaxPressure ();
4243+ // need to adjust since MaxRegPressure assumes minimal SIMD
4244+ auto guessedSimd = IGCLivenessAnalysisBase::bestGuessSIMDSize (context, context->getMetaDataUtils (), m_program->entry );
4245+ MaxRegPressure = MaxRegPressure * numLanes (simdMode) / numLanes (guessedSimd);
42424246 uint32_t RegPressureThreshold = (uint32_t )(context->getNumGRFPerThread (true ) * 0.6 );
4243-
4247+ bool maxPressureHeur = MaxRegPressure > 0 && MaxRegPressure < RegPressureThreshold &&
4248+ m_program->GetParent ()->getLLVMFunction ()->size () == 1 ;
42444249 if (context->type == ShaderType::OPENCL_SHADER &&
4245- (m_program->m_Platform ->limitedBCR () || (MaxRegPressure > 0 && MaxRegPressure < RegPressureThreshold ))) {
4250+ (m_program->m_Platform ->limitedBCR () || (maxPressureHeur ))) {
42464251 SaveOption (vISA_enableBCR, true );
4247- if (m_program->GetParent ()->getLLVMFunction ()->size () == 1 &&
4248- m_program->m_Platform ->getMinDispatchMode () != SIMDMode::SIMD8)
4252+ if (m_program->m_Platform ->getMinDispatchMode () != SIMDMode::SIMD8)
42494253 SaveOption (vISA_forceBCR, true );
42504254 }
42514255 if (context->type == ShaderType::OPENCL_SHADER && m_program->m_Platform ->supportDpasInstruction ()) {
@@ -4722,7 +4726,7 @@ void CEncoder::InitLabelMap(const llvm::Function *F) {
47224726 }
47234727}
47244728
4725- void CEncoder::InitEncoder (bool canAbortOnSpill, bool hasStackCall, bool hasInlineAsmCall,
4729+ void CEncoder::InitEncoder (SIMDMode simdMode, bool canAbortOnSpill, bool hasStackCall, bool hasInlineAsmCall,
47264730 bool hasAdditionalVisaAsmToLink, int numThreadsPerEU, uint lowerBoundGRF, uint upperBoundGRF,
47274731 VISAKernel *prevKernel) {
47284732 m_aliasesMap.clear ();
@@ -4770,7 +4774,7 @@ void CEncoder::InitEncoder(bool canAbortOnSpill, bool hasStackCall, bool hasInli
47704774 if (IsCodePatchCandidate ()) {
47714775 SetHasPrevKernel (prevKernel != nullptr );
47724776 }
4773- InitVISABuilderOptions (VISAPlatform, canAbortOnSpill, hasStackCall, builderOpt == VISA_BUILDER_BOTH);
4777+ InitVISABuilderOptions (VISAPlatform, simdMode, canAbortOnSpill, hasStackCall, builderOpt == VISA_BUILDER_BOTH);
47744778
47754779 if (numThreadsPerEU > 0 ) {
47764780 // Number of threads per EU is set per kernel (by function MD)
0 commit comments