Skip to content

Commit 3356972

Browse files
jfuentesigcbot
authored andcommitted
Add GRF selection based on spill allowed option
1 parent 9355261 commit 3356972

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ bool EmitPass::runOnFunction(llvm::Function& F)
700700
CShader * simd16Program = Iter->second->GetShader(SIMDMode::SIMD16);
701701
if (simd16Program &&
702702
simd16Program->ProgramOutput()->m_programBin != 0 &&
703-
simd16Program->ProgramOutput()->m_scratchSpaceUsedBySpills == 0)
703+
!m_pCtx->hasSpills(simd16Program->ProgramOutput()->m_scratchSpaceUsedBySpills))
704704
return false;
705705
}
706706
if (IGC_IS_FLAG_ENABLED(EnableKernelCostInfo)) {
@@ -813,7 +813,7 @@ bool EmitPass::runOnFunction(llvm::Function& F)
813813
m_encoder->GetSimdSize() == prevShader->GetEncoder().GetSimdSize() &&
814814
prevShader->GetEncoder().IsCodePatchCandidate() &&
815815
prevShader->ProgramOutput()->m_programBin &&
816-
prevShader->ProgramOutput()->m_scratchSpaceUsedBySpills == 0)
816+
!m_pCtx->hasSpills(prevShader->ProgramOutput()->m_scratchSpaceUsedBySpills))
817817
{
818818
prevKernel = prevShader->GetEncoder().GetVISAKernel();
819819
m_encoder->SetPayloadEnd(prevShader->GetEncoder().GetPayloadEnd());
@@ -1324,7 +1324,7 @@ bool EmitPass::runOnFunction(llvm::Function& F)
13241324

13251325
if (m_encoder->IsCodePatchCandidate())
13261326
{
1327-
if (m_currShader->ProgramOutput()->m_scratchSpaceUsedBySpills)
1327+
if (m_pCtx->hasSpills(m_currShader->ProgramOutput()->m_scratchSpaceUsedBySpills))
13281328
{
13291329
if (IGC_GET_FLAG_VALUE(CodePatchExperiments))
13301330
{
@@ -1434,7 +1434,7 @@ bool EmitPass::runOnFunction(llvm::Function& F)
14341434
if (!m_encoder->IsCodePatchCandidate() ||
14351435
m_encoder->HasPrevKernel() ||
14361436
!m_currShader->ProgramOutput()->m_programBin ||
1437-
m_currShader->ProgramOutput()->m_scratchSpaceUsedBySpills)
1437+
m_pCtx->hasSpills(m_currShader->ProgramOutput()->m_scratchSpaceUsedBySpills))
14381438
{
14391439
m_pCtx->m_prevShader = nullptr;
14401440
// Postpone destroying VISA builder to

IGC/Compiler/CISACodeGen/OpenCLKernelCodeGen.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ namespace IGC
220220
auto& annotatnions = funcMD.UserAnnotations;
221221
auto output = shader->ProgramOutput();
222222

223-
if (output->m_scratchSpaceUsedBySpills > 0 &&
223+
if (hasSpills(output->m_scratchSpaceUsedBySpills) &&
224224
std::find(annotatnions.begin(), annotatnions.end(), "igc-do-not-spill") != annotatnions.end())
225225
{
226226
std::string msg =
@@ -3252,7 +3252,7 @@ namespace IGC
32523252
return RetryType::NO_Retry_Pick_Prv;
32533253
}
32543254
else if (
3255-
pOutput->m_scratchSpaceUsedBySpills == 0 ||
3255+
!ctx->hasSpills(pOutput->m_scratchSpaceUsedBySpills) ||
32563256
ctx->getModuleMetaData()->compOpt.OptDisable ||
32573257
ctx->m_retryManager.IsLastTry() ||
32583258
(!ctx->m_retryManager.kernelSkip.empty() &&

IGC/Compiler/CodeGenPublic.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,7 @@ namespace IGC
10291029
// Map to store global offsets in original global buffer
10301030
std::map<std::string, uint64_t> inlineProgramScopeGlobalOffsets;
10311031
std::vector<std::string> entry_names;
1032+
uint m_spillAllowed = 0;
10321033
private:
10331034
//For storing error message
10341035
std::stringstream oclErrorMessage;
@@ -1279,6 +1280,11 @@ namespace IGC
12791280

12801281
return false;
12811282
}
1283+
1284+
bool hasSpills(uint mscratchSpaceUsedBySpills)
1285+
{
1286+
return (mscratchSpaceUsedBySpills > m_spillAllowed);
1287+
}
12821288
};
12831289

12841290
struct SComputeShaderSecondCompileInput

visa/G4_Kernel.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,6 +2150,7 @@ GRFMode::GRFMode(const TARGET_PLATFORM platform, Options *op) : options(op) {
21502150
unsigned GRFMode::setModeByRegPressure(unsigned maxRP,
21512151
unsigned largestInputReg) {
21522152
unsigned size = configs.size(), i = 0;
2153+
bool spillAllowed = 0;
21532154
// find appropiate GRF based on reg pressure
21542155
for (; i < size; i++) {
21552156
if (configs[i].VRTEnable && configs[i].numGRF >= lowerBoundGRF &&
@@ -2159,8 +2160,12 @@ unsigned GRFMode::setModeByRegPressure(unsigned maxRP,
21592160
// Check that we've at least 8 GRFs over and above
21602161
// those blocked for kernel input. This helps cases
21612162
// where an 8 GRF variable shows up in entry BB.
2162-
(largestInputReg + 8) <= configs[i].numGRF)
2163-
return configs[currentMode].numGRF;
2163+
(largestInputReg + 8) <= configs[i].numGRF) {
2164+
if (spillAllowed && currentMode > 0)
2165+
return configs[--currentMode].numGRF;
2166+
else
2167+
return configs[currentMode].numGRF;
2168+
}
21642169
}
21652170
}
21662171
// RP is greater than the maximum GRF available, so set the largest GRF

0 commit comments

Comments
 (0)