Skip to content

Commit 0b97863

Browse files
houjenkoigcbot
authored andcommitted
Enable SSOShifter by default (3rd attempt)
This includes a fix to skip sso padding when it reaches the kernel size limit
1 parent dbba167 commit 0b97863

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

IGC/Compiler/CISACodeGen/CISABuilder.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6172,6 +6172,8 @@ namespace IGC
61726172
shaderOverrideVISAFirstPass(visaOverrideFiles, kernelName);
61736173
}
61746174

6175+
vISA::FINALIZER_INFO* jitInfo = nullptr;
6176+
61756177
// Compile generated VISA text string for inlineAsm
61766178
if (m_hasInlineAsm || visaAsmOverride || additionalVISAAsmToLink)
61776179
{
@@ -6181,11 +6183,15 @@ namespace IGC
61816183
// return immediately if there is error during parsing visaasm
61826184
if (pMainKernel == nullptr)
61836185
return;
6186+
pMainKernel->GetJitInfo(jitInfo);
61846187
}
61856188
//Compile to generate the V-ISA binary
61866189
else
61876190
{
61886191
pMainKernel = vMainKernel;
6192+
pMainKernel->GetJitInfo(jitInfo);
6193+
6194+
jitInfo->stats.scratchSpaceSizeLimit = m_program->ProgramOutput()->m_scratchSpaceSizeLimit;
61896195
m_vIsaCompileStatus = vbuilder->Compile(
61906196
m_enableVISAdump ? GetDumpFileName("isa").c_str() : "", nullptr, emitVisaOnly);
61916197
}
@@ -6205,9 +6211,6 @@ namespace IGC
62056211
// Collect metrics from vISA
62066212
context->metrics.CollectRegStats(vISAstats, m_program->entry);
62076213

6208-
vISA::FINALIZER_INFO* jitInfo = nullptr;
6209-
pMainKernel->GetJitInfo(jitInfo);
6210-
62116214
// Depend on vISA information about barriers presence to make sure that it's
62126215
// always set properly, even if a barrier is used as a part of Inline vISA code only.
62136216
if (jitInfo->numBarriers != 0)

IGC/common/igc_flags.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ DECLARE_IGC_REGKEY(bool, LTOForStage1Compilation, true, "LTO for stage 1 c
648648
DECLARE_IGC_REGKEY(bool, EnableTrackPtr, false, "Track Staging Context alloc/dealloc", false)
649649
DECLARE_IGC_REGKEY(bool, ExtraRetrySIMD16, false, "Enable extra simd16 with retry for STAGE1_BEST_PREF", false)
650650
DECLARE_IGC_REGKEY(bool, SaveRestoreIR, true, "Save/Restore IR for staged compilation to avoid duplicated compilations", false)
651-
DECLARE_IGC_REGKEY(DWORD, SSOShifter, 0, "Adjust ScratchSurfaceOffset with shl(hwtid, shifter). 0 menas disabling padding", false)
651+
DECLARE_IGC_REGKEY(DWORD, SSOShifter, 9, "Adjust ScratchSurfaceOffset with shl(hwtid, shifter). 0 menas disabling padding", false)
652652
DECLARE_IGC_REGKEY(DWORD, DelayEmuInt64AddLimit, 0, "Delay emulating Int64 Add operations in vISA", false)
653653
DECLARE_IGC_REGKEY(DWORD, CodePatch, 2, "Enable Pixel Shader code patching to directly emit code after stitching", false)
654654
DECLARE_IGC_REGKEY(DWORD, CodePatchLimit, 0, "Debug CodePatch via limiting the number of shader been patched", false)

visa/BuildCISAIRImpl.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1862,8 +1862,15 @@ int CISA_IR_Builder::Compile(const char *nameInput, std::ostream *os,
18621862
{
18631863
auto& builder = *func->getKernel()->fg.builder;
18641864
auto& spillMemUsed = builder.getJitInfo()->stats.spillMemUsed;
1865+
auto& scratchSpaceSizeLimit = builder.getJitInfo()->stats.scratchSpaceSizeLimit;
1866+
// Skip padding when
1867+
// 1. spill size is smaller than the threshold
1868+
// 2. spill size is larger than scratchSpaceSizeLimit
1869+
// (it cannot be encoded into the binary due to the limit)
18651870
bool skip_padding =
1866-
builder.kernel.getuInt32Option(vISA_SkipPaddingScratchSpaceSize) >= spillMemUsed;
1871+
builder.kernel.getuInt32Option(vISA_SkipPaddingScratchSpaceSize) >= spillMemUsed ||
1872+
(scratchSpaceSizeLimit != 0 &&
1873+
spillMemUsed + (1U << builder.kernel.getuInt32Option(vISA_SSOShifter)) * 8 > scratchSpaceSizeLimit);
18671874
bool SSO_padding =
18681875
!skip_padding &&
18691876
builder.getPlatform() == Xe_DG2 &&

visa/include/JitterDataStruct.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ struct PERF_STATS {
5656
// spill cost calculation.
5757
uint32_t numGRFSpillFillWeighted = 0;
5858

59+
// The limit of scratch space size per kernel
60+
uint32_t scratchSpaceSizeLimit = 0;
61+
5962
// spillMemUsed is the scratch size in byte of entire vISA stack for this
6063
// function/kernel. It contains spill size and caller/callee save size.
6164
// For kernel/entry functions, the value is the sum of potential callees

0 commit comments

Comments
 (0)