Skip to content

Commit 1c01d0a

Browse files
iwwuigcbot
authored andcommitted
Add support to override SpillThreshold
Add support to override SIMD16_SpillThreshold and others via MetaData
1 parent bcdefc1 commit 1c01d0a

File tree

3 files changed

+77
-13
lines changed

3 files changed

+77
-13
lines changed

IGC/Compiler/CISACodeGen/CISABuilder.cpp

Lines changed: 72 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4043,6 +4043,65 @@ namespace IGC
40434043
}
40444044
}
40454045

4046+
unsigned int CEncoder::GetSpillThreshold(SIMDMode simdmode)
4047+
{
4048+
CodeGenContext* context = m_program->GetContext();
4049+
ShaderType shaderType = context->type;
4050+
unsigned int value = 0;
4051+
4052+
if (shaderType == ShaderType::COMPUTE_SHADER)
4053+
{
4054+
switch (simdmode)
4055+
{
4056+
case SIMDMode::SIMD16:
4057+
value = context->m_DriverInfo.getCSSIMD16_SpillThreshold();
4058+
break;
4059+
case SIMDMode::SIMD32:
4060+
value = context->m_DriverInfo.getCSSIMD32_SpillThreshold();
4061+
break;
4062+
default:
4063+
break;
4064+
}
4065+
return value;
4066+
}
4067+
4068+
// Below is for non-CS
4069+
switch (simdmode)
4070+
{
4071+
case SIMDMode::SIMD8:
4072+
value = context->m_DriverInfo.getSIMD8_SpillThreshold();
4073+
break;
4074+
case SIMDMode::SIMD16:
4075+
value = context->m_DriverInfo.getSIMD16_SpillThreshold();
4076+
break;
4077+
case SIMDMode::SIMD32:
4078+
value = context->m_DriverInfo.getSIMD32_SpillThreshold();
4079+
break;
4080+
default:
4081+
break;
4082+
}
4083+
4084+
unsigned int AILvalue = 0;
4085+
switch (simdmode)
4086+
{
4087+
case SIMDMode::SIMD8:
4088+
// no AIL support
4089+
break;
4090+
case SIMDMode::SIMD16:
4091+
AILvalue = context->getModuleMetaData()->SIMD16_SpillThreshold;
4092+
break;
4093+
case SIMDMode::SIMD32:
4094+
AILvalue = context->getModuleMetaData()->SIMD32_SpillThreshold;
4095+
break;
4096+
default:
4097+
break;
4098+
}
4099+
4100+
if (AILvalue)
4101+
value = AILvalue;
4102+
return value;
4103+
}
4104+
40464105
void CEncoder::SetAbortOnSpillThreshold(bool canAbortOnSpill, bool AllowSpill)
40474106
{
40484107
CodeGenContext* context = m_program->GetContext();
@@ -4057,18 +4116,18 @@ namespace IGC
40574116
if (m_program->m_Platform->getGRFSize() >= 64)
40584117
{
40594118
if (m_program->m_dispatchSize == SIMDMode::SIMD16)
4060-
SaveOption(vISA_AbortOnSpillThreshold, context->m_DriverInfo.getSIMD16_SpillThreshold() * 4);
4119+
SaveOption(vISA_AbortOnSpillThreshold, GetSpillThreshold(m_program->m_dispatchSize) * 4);
40614120
else if (m_program->m_dispatchSize == SIMDMode::SIMD32)
4062-
SaveOption(vISA_AbortOnSpillThreshold, context->m_DriverInfo.getSIMD32_SpillThreshold() * 4);
4121+
SaveOption(vISA_AbortOnSpillThreshold, GetSpillThreshold(m_program->m_dispatchSize) * 4);
40634122
}
40644123
else
40654124
{
40664125
if (m_program->m_dispatchSize == SIMDMode::SIMD8)
4067-
SaveOption(vISA_AbortOnSpillThreshold, context->m_DriverInfo.getSIMD8_SpillThreshold() * 2);
4126+
SaveOption(vISA_AbortOnSpillThreshold, GetSpillThreshold(m_program->m_dispatchSize) * 2);
40684127
else if (m_program->m_dispatchSize == SIMDMode::SIMD16)
4069-
SaveOption(vISA_AbortOnSpillThreshold, context->m_DriverInfo.getSIMD16_SpillThreshold() * 2);
4128+
SaveOption(vISA_AbortOnSpillThreshold, GetSpillThreshold(m_program->m_dispatchSize) * 2);
40704129
else
4071-
SaveOption(vISA_AbortOnSpillThreshold, context->m_DriverInfo.getSIMD32_SpillThreshold() * 2);
4130+
SaveOption(vISA_AbortOnSpillThreshold, GetSpillThreshold(m_program->m_dispatchSize) * 2);
40724131
}
40734132
}
40744133
break;
@@ -4079,16 +4138,16 @@ namespace IGC
40794138
if (m_program->m_Platform->getGRFSize() >= 64)
40804139
{
40814140
if (m_program->m_dispatchSize == SIMDMode::SIMD16)
4082-
SaveOption(vISA_AbortOnSpillThreshold, context->m_DriverInfo.getCSSIMD16_SpillThreshold() * 4);
4141+
SaveOption(vISA_AbortOnSpillThreshold, GetSpillThreshold(m_program->m_dispatchSize) * 4);
40834142
else if (m_program->m_dispatchSize == SIMDMode::SIMD32)
4084-
SaveOption(vISA_AbortOnSpillThreshold, context->m_DriverInfo.getCSSIMD32_SpillThreshold() * 4);
4143+
SaveOption(vISA_AbortOnSpillThreshold, GetSpillThreshold(m_program->m_dispatchSize) * 4);
40854144
}
40864145
else
40874146
{
40884147
if (m_program->m_dispatchSize == SIMDMode::SIMD16)
4089-
SaveOption(vISA_AbortOnSpillThreshold, context->m_DriverInfo.getCSSIMD16_SpillThreshold() * 2);
4148+
SaveOption(vISA_AbortOnSpillThreshold, GetSpillThreshold(m_program->m_dispatchSize) * 2);
40904149
else if (m_program->m_dispatchSize == SIMDMode::SIMD32)
4091-
SaveOption(vISA_AbortOnSpillThreshold, context->m_DriverInfo.getCSSIMD32_SpillThreshold() * 2);
4150+
SaveOption(vISA_AbortOnSpillThreshold, GetSpillThreshold(m_program->m_dispatchSize) * 2);
40924151
}
40934152
}
40944153
break;
@@ -4101,16 +4160,16 @@ namespace IGC
41014160
if (m_program->m_Platform->getGRFSize() >= 64)
41024161
{
41034162
if (m_program->m_dispatchSize == SIMDMode::SIMD8)
4104-
SaveOption(vISA_AbortOnSpillThreshold, context->m_DriverInfo.getSIMD8_SpillThreshold() * 2);
4163+
SaveOption(vISA_AbortOnSpillThreshold, GetSpillThreshold(m_program->m_dispatchSize) * 2);
41054164
else if (m_program->m_dispatchSize == SIMDMode::SIMD16)
4106-
SaveOption(vISA_AbortOnSpillThreshold, context->m_DriverInfo.getSIMD16_SpillThreshold() * 4);
4165+
SaveOption(vISA_AbortOnSpillThreshold, GetSpillThreshold(m_program->m_dispatchSize) * 4);
41074166
else if (m_program->m_dispatchSize == SIMDMode::SIMD32)
4108-
SaveOption(vISA_AbortOnSpillThreshold, context->m_DriverInfo.getSIMD32_SpillThreshold() * 4);
4167+
SaveOption(vISA_AbortOnSpillThreshold, GetSpillThreshold(m_program->m_dispatchSize) * 4);
41094168
}
41104169
else
41114170
{
41124171
if (m_program->m_dispatchSize == SIMDMode::SIMD8)
4113-
SaveOption(vISA_AbortOnSpillThreshold, context->m_DriverInfo.getSIMD8_SpillThreshold() * 2);
4172+
SaveOption(vISA_AbortOnSpillThreshold, GetSpillThreshold(m_program->m_dispatchSize) * 2);
41144173
}
41154174
}
41164175
break;

IGC/Compiler/CISACodeGen/CISABuilder.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,8 @@ namespace IGC
736736
void SaveOption(vISAOptions option, const char* val);
737737
void SetBuilderOptions(VISABuilder* pbuilder);
738738

739+
unsigned int GetSpillThreshold(SIMDMode simdmode);
740+
739741
private:
740742
// helper functions for compile flow
741743
/// shaderOverrideVISAFirstPass - pre-process shader overide dir for visa shader override.

IGC/common/MDFrameWork.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,9 @@ namespace IGC
760760
bool isHDCFastClearShader = false;
761761

762762
std::array<uint32_t, NUM_ARG_SPACE_RESERVATION_SLOTS> argRegisterReservations{};
763+
764+
uint8_t SIMD16_SpillThreshold = 0;
765+
uint8_t SIMD32_SpillThreshold = 0;
763766
};
764767

765768
void serialize(const IGC::ModuleMetaData &moduleMD, llvm::Module* module);

0 commit comments

Comments
 (0)