Skip to content

Commit 0d8fe3f

Browse files
sys-igcigcbot
authored andcommitted
[Autobackout][FunctionalRegression]Revert of change: 2680f8d: Proper SIMD width for enabling forceBCR
Our information on maximal register pressure is based on minimal SIMD width so it needs to be adjusted to the one that we really compile to. Limit enableBCR to single basic block kernels.
1 parent 03ede62 commit 0d8fe3f

File tree

5 files changed

+21
-31
lines changed

5 files changed

+21
-31
lines changed

IGC/Compiler/CISACodeGen/CISABuilder.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ SPDX-License-Identifier: MIT
88

99
#include "Compiler/CISACodeGen/CISABuilder.hpp"
1010
#include "Compiler/CISACodeGen/ShaderCodeGen.hpp"
11-
#include "Compiler/CISACodeGen/IGCLivenessAnalysis.h"
1211
#include "Compiler/CISACodeGen/OpenCLKernelCodeGen.hpp"
1312
#include "Compiler/Optimizer/OpenCLPasses/NamedBarriers/NamedBarriersResolution.hpp"
1413
#include "common/allocator.h"
@@ -3548,8 +3547,8 @@ void CEncoder::SetAbortOnSpillThreshold(bool canAbortOnSpill, bool AllowSpill) {
35483547
}
35493548
}
35503549

3551-
void CEncoder::InitVISABuilderOptions(TARGET_PLATFORM VISAPlatform, SIMDMode simdMode, bool canAbortOnSpill,
3552-
bool hasStackCall, bool enableVISA_IR) {
3550+
void CEncoder::InitVISABuilderOptions(TARGET_PLATFORM VISAPlatform, bool canAbortOnSpill, bool hasStackCall,
3551+
bool enableVISA_IR) {
35533552
CodeGenContext *context = m_program->GetContext();
35543553
bool KernelDebugEnable = false;
35553554
bool ForceNonCoherentStatelessBti = false;
@@ -4242,16 +4241,13 @@ void CEncoder::InitVISABuilderOptions(TARGET_PLATFORM VISAPlatform, SIMDMode sim
42424241

42434242
auto funcInfoMD = context->getMetaDataUtils()->getFunctionsInfoItem(m_program->entry);
42444243
uint32_t MaxRegPressure = funcInfoMD->getMaxRegPressure()->getMaxPressure();
4245-
// need to adjust since MaxRegPressure assumes minimal SIMD
4246-
auto guessedSimd = IGCLivenessAnalysisBase::bestGuessSIMDSize(context, context->getMetaDataUtils(), m_program->entry);
4247-
MaxRegPressure = MaxRegPressure * numLanes(simdMode) / numLanes(guessedSimd);
42484244
uint32_t RegPressureThreshold = (uint32_t)(context->getNumGRFPerThread(true) * 0.6);
4249-
bool maxPressureHeur = MaxRegPressure > 0 && MaxRegPressure < RegPressureThreshold &&
4250-
m_program->GetParent()->getLLVMFunction()->size() == 1;
4245+
42514246
if (context->type == ShaderType::OPENCL_SHADER &&
4252-
(m_program->m_Platform->limitedBCR() || (maxPressureHeur))) {
4247+
(m_program->m_Platform->limitedBCR() || (MaxRegPressure > 0 && MaxRegPressure < RegPressureThreshold))) {
42534248
SaveOption(vISA_enableBCR, true);
4254-
if (m_program->m_Platform->getMinDispatchMode() != SIMDMode::SIMD8)
4249+
if (m_program->GetParent()->getLLVMFunction()->size() == 1 &&
4250+
m_program->m_Platform->getMinDispatchMode() != SIMDMode::SIMD8)
42554251
SaveOption(vISA_forceBCR, true);
42564252
}
42574253
if (context->type == ShaderType::OPENCL_SHADER && m_program->m_Platform->supportDpasInstruction()) {
@@ -4740,7 +4736,7 @@ void CEncoder::InitLabelMap(const llvm::Function *F) {
47404736
}
47414737
}
47424738

4743-
void CEncoder::InitEncoder(SIMDMode simdMode, bool canAbortOnSpill, bool hasStackCall, bool hasInlineAsmCall,
4739+
void CEncoder::InitEncoder(bool canAbortOnSpill, bool hasStackCall, bool hasInlineAsmCall,
47444740
bool hasAdditionalVisaAsmToLink, int numThreadsPerEU, uint lowerBoundGRF, uint upperBoundGRF,
47454741
VISAKernel *prevKernel) {
47464742
m_aliasesMap.clear();
@@ -4788,7 +4784,7 @@ void CEncoder::InitEncoder(SIMDMode simdMode, bool canAbortOnSpill, bool hasStac
47884784
if (IsCodePatchCandidate()) {
47894785
SetHasPrevKernel(prevKernel != nullptr);
47904786
}
4791-
InitVISABuilderOptions(VISAPlatform, simdMode, canAbortOnSpill, hasStackCall, builderOpt == VISA_BUILDER_BOTH);
4787+
InitVISABuilderOptions(VISAPlatform, canAbortOnSpill, hasStackCall, builderOpt == VISA_BUILDER_BOTH);
47924788

47934789
if (numThreadsPerEU > 0) {
47944790
// Number of threads per EU is set per kernel (by function MD)

IGC/Compiler/CISACodeGen/CISABuilder.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,10 @@ struct SEncoderState {
118118

119119
class CEncoder {
120120
public:
121-
void InitEncoder(SIMDMode simdMode, bool canAbortOnSpill, bool hasStackCall, bool hasInlineAsmCall,
122-
bool hasAdditionalVisaAsmToLink, int numThreadsPerEU, uint lowerBoundGRF, uint upperBoundGRF,
123-
VISAKernel *prevKernel);
121+
void InitEncoder(bool canAbortOnSpill, bool hasStackCall, bool hasInlineAsmCall, bool hasAdditionalVisaAsmToLink,
122+
int numThreadsPerEU, uint lowerBoundGRF, uint upperBoundGRF, VISAKernel *prevKernel);
124123
void InitBuildParams(llvm::SmallVector<std::unique_ptr<const char, std::function<void(const char *)>>, 10> &params);
125-
void InitVISABuilderOptions(TARGET_PLATFORM VISAPlatform, SIMDMode simdMode, bool canAbortOnSpill, bool hasStackCall,
124+
void InitVISABuilderOptions(TARGET_PLATFORM VISAPlatform, bool canAbortOnSpill, bool hasStackCall,
126125
bool enableVISA_IR);
127126
SEncoderState CopyEncoderState();
128127
void SetEncoderState(SEncoderState &newState);

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ bool EmitPass::runOnFunction(llvm::Function &F) {
773773
}
774774
// call builder after pre-analysis pass where scratchspace offset to VISA is
775775
// calculated
776-
m_encoder->InitEncoder(m_SimdMode, m_canAbortOnSpill, m_currShader->HasStackCalls(), hasInlineAsmCall,
776+
m_encoder->InitEncoder(m_canAbortOnSpill, m_currShader->HasStackCalls(), hasInlineAsmCall,
777777
hasAdditionalVisaAsmToLink, numThreadsPerEU, lowerBoundGRF, upperBoundGRF, prevKernel);
778778

779779
if (!m_encoder->IsCodePatchCandidate())

IGC/Compiler/CISACodeGen/IGCLivenessAnalysis.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ unsigned int IGCLivenessAnalysisBase::registerSizeInBytes() {
4545
return 32;
4646
}
4747

48-
SIMDMode IGCLivenessAnalysisBase::bestGuessSIMDSize(IGC::CodeGenContext *CGCtx, IGCMD::MetaDataUtils *MDUtils,
49-
Function *F, GenXFunctionGroupAnalysis *FGA) {
48+
SIMDMode IGCLivenessAnalysisBase::bestGuessSIMDSize(Function *F) {
5049
switch (IGC_GET_FLAG_VALUE(ForceOCLSIMDWidth)) {
5150
case 0:
5251
break;
@@ -70,23 +69,19 @@ SIMDMode IGCLivenessAnalysisBase::bestGuessSIMDSize(IGC::CodeGenContext *CGCtx,
7069
if (CGCtx->platform.isProductChildOf(IGFX_PVC)) {
7170
bool abortOnSpills =
7271
IGC_GET_FLAG_VALUE(AllowSIMD16DropForXE2Plus) && (CGCtx->platform.isCoreXE2() || CGCtx->platform.isCoreXE3());
73-
if (abortOnSpills)
72+
auto FG = FGA ? FGA->getGroup(F) : nullptr;
73+
bool hasStackCall = (FG && FG->hasStackCall()) || (F && F->hasFnAttribute("visaStackCall"));
74+
bool isIndirectGroup = FG && FGA->isIndirectCallGroup(FG);
75+
bool hasSubroutine = FG && !FG->isSingle() && !hasStackCall && !isIndirectGroup;
76+
if (abortOnSpills || hasSubroutine) {
7477
return SIMDMode::SIMD16;
75-
if (FGA) {
76-
auto FG = FGA ? FGA->getGroup(F) : nullptr;
77-
bool hasStackCall = (FG && FG->hasStackCall()) || (F && F->hasFnAttribute("visaStackCall"));
78-
bool isIndirectGroup = FG && FGA->isIndirectCallGroup(FG);
79-
bool hasSubroutine = FG && !FG->isSingle() && !hasStackCall && !isIndirectGroup;
80-
if (hasSubroutine)
81-
return SIMDMode::SIMD16;
8278
}
8379
return SIMDMode::SIMD32;
8480
}
81+
8582
return SIMDMode::SIMD8;
8683
}
8784

88-
SIMDMode IGCLivenessAnalysisBase::bestGuessSIMDSize(Function *F) { return bestGuessSIMDSize(CGCtx, MDUtils, F, FGA); }
89-
9085
ValueSet IGCLivenessAnalysisBase::getDefs(llvm::BasicBlock &BB) {
9186

9287
ValueSet &BBIn = In[&BB];

IGC/Compiler/CISACodeGen/IGCLivenessAnalysis.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ class IGCLivenessAnalysisBase {
6363
unsigned int estimateSizeInBytes(ValueSet &Set, llvm::Function &F, unsigned int SIMD, WIAnalysisRunner *WI = nullptr);
6464
void collectPressureForBB(llvm::BasicBlock &BB, InsideBlockPressureMap &BBListing, unsigned int SIMD,
6565
WIAnalysisRunner *WI = nullptr);
66+
6667
SIMDMode bestGuessSIMDSize(Function *F = nullptr);
67-
static SIMDMode bestGuessSIMDSize(IGC::CodeGenContext *CGCtx, IGCMD::MetaDataUtils *MDUtils, Function *F = nullptr,
68-
GenXFunctionGroupAnalysis *FGA = nullptr);
68+
6969
unsigned int bytesToRegisters(unsigned int Bytes) {
7070
unsigned int RegisterSizeInBytes = registerSizeInBytes();
7171
unsigned int AmountOfRegistersRoundUp = (Bytes + RegisterSizeInBytes - 1) / RegisterSizeInBytes;

0 commit comments

Comments
 (0)