Skip to content

Commit 0a4c172

Browse files
houjenkoZuul
authored andcommitted
Since we determine whether generating SIMD32 based on SIMD16's result, for simplicity, it is better to record whether doing SIMD32 in the context of Stage1 and pass it to Stage2.
Platforms: All Change-Id: I394ec43c87e9417916020f83ad540bbcfa7843f3 Related-to: SCSP-19136 Resolves:
1 parent a595a4e commit 0a4c172

File tree

4 files changed

+31
-17
lines changed

4 files changed

+31
-17
lines changed

IGC/AdaptorCommon/API/igc.h

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,14 @@ enum {
5656
};
5757

5858
enum {
59-
BIT_CG_SIMD8 = 0b00000001,
60-
BIT_CG_SIMD16 = 0b00000010,
61-
BIT_CG_SIMD32 = 0b00000100,
62-
BIT_CG_SPILL8 = 0b00001000,
63-
BIT_CG_SPILL16 = 0b00010000,
64-
BIT_CG_SPILL32 = 0b00100000,
65-
BIT_CG_RETRY = 0b01000000,
59+
BIT_CG_SIMD8 = 0b00000001,
60+
BIT_CG_SIMD16 = 0b00000010,
61+
BIT_CG_SIMD32 = 0b00000100,
62+
BIT_CG_SPILL8 = 0b00001000,
63+
BIT_CG_SPILL16 = 0b00010000,
64+
BIT_CG_SPILL32 = 0b00100000,
65+
BIT_CG_RETRY = 0b01000000,
66+
BIT_CG_DO_SIMD32 = 0b10000000,
6667
};
6768

6869
typedef char CG_CTX_STATS_t;
@@ -74,10 +75,12 @@ typedef struct {
7475
} CG_CTX_t;
7576

7677
#define IsRetry(stats) (stats & (BIT_CG_RETRY))
78+
#define DoSimd32(stats) (stats & (BIT_CG_DO_SIMD32))
7779
#define HasSimd(MODE, stats) (stats & (BIT_CG_SIMD##MODE))
7880
#define HasSimdSpill(MODE, stats) ((stats & (BIT_CG_SIMD##MODE)) && (stats & (BIT_CG_SPILL##MODE)))
7981
#define HasSimdNoSpill(MODE, stats) ((stats & (BIT_CG_SIMD##MODE)) && !(stats & (BIT_CG_SPILL##MODE)))
8082
#define SetRetry(stats) (stats = (stats | (BIT_CG_RETRY)))
83+
#define SetSimd32(stats) (stats = (stats | (BIT_CG_DO_SIMD32)))
8184
#define SetSimdSpill(MODE, stats) (stats = (stats | (BIT_CG_SIMD##MODE) | (BIT_CG_SPILL##MODE)))
8285
#define SetSimdNoSpill(MODE, stats) (stats = (stats | (BIT_CG_SIMD##MODE) & ~(BIT_CG_SPILL##MODE)))
8386

@@ -94,6 +97,8 @@ typedef enum {
9497
#define IsStage1BestPerf(flag, prev_ctx_ptr) (!IsStage2RestSIMDs(prev_ctx_ptr) && flag == FLAG_CG_STAGE1_BEST_PERF)
9598
#define IsAllSIMDs(flag, prev_ctx_ptr) (!IsStage2RestSIMDs(prev_ctx_ptr) && flag == FLAG_CG_ALL_SIMDS)
9699

100+
#define DoSimd32Stage2(prev_ctx_ptr) (IsStage2RestSIMDs(prev_ctx_ptr) && DoSimd32(prev_ctx_ptr->m_stats))
101+
97102
// We don't need compile continuation if no staged compilation enabled denoted by RegKeys.
98103
// If the staged compilation enabled, we don't need compile continuation when SIMD8 is spilled.
99104
#define HasCompileContinuation(flag, prev_ctx_ptr, stats) ( \

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,12 @@ bool EmitPass::runOnFunction(llvm::Function& F)
802802
}
803803
}
804804

805+
if (m_SimdMode == SIMDMode::SIMD16 &&
806+
IsStage1BestPerf(m_pCtx->m_CgFlag, m_pCtx->m_StagingCtx))
807+
{
808+
m_pCtx->m_doSimd32Stage2 = m_currShader->CompileSIMDSize(SIMDMode::SIMD32, *this, F);
809+
}
810+
805811
return false;
806812
}
807813

IGC/Compiler/CISACodeGen/PixelShaderCodeGen.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,23 +1140,22 @@ namespace IGC
11401140
}
11411141
if (simdMode == SIMDMode::SIMD32)
11421142
{
1143+
if (DoSimd32Stage2(ctx->m_StagingCtx))
1144+
{
1145+
return true;
1146+
}
1147+
11431148
if (forceSIMD32)
11441149
{
11451150
return true;
11461151
}
11471152

11481153
CShader* simd16Program = m_parent->GetShader(SIMDMode::SIMD16);
1149-
// We don't check simd16 if we have it in Stage1
1150-
// 1. The check of simd16 here is to disable simd32 if simd16 failed to be generated or spilled.
1151-
// 2. If we have simd16 in stage1, we are sure that simd16 has no spill so we won't need this check.
1152-
if (ctx->m_StagingCtx && !HasSimd(16, ctx->m_StagingCtx->m_stats))
1154+
if ((simd16Program == nullptr ||
1155+
simd16Program->ProgramOutput()->m_programBin == 0 ||
1156+
simd16Program->ProgramOutput()->m_scratchSpaceUsedBySpills > 0))
11531157
{
1154-
if ((simd16Program == nullptr ||
1155-
simd16Program->ProgramOutput()->m_programBin == 0 ||
1156-
simd16Program->ProgramOutput()->m_scratchSpaceUsedBySpills > 0))
1157-
{
1158-
return false;
1159-
}
1158+
return false;
11601159
}
11611160

11621161
const PixelShaderInfo& psInfo = ctx->getModuleMetaData()->psInfo;

IGC/Compiler/CodeGenPublic.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,10 @@ namespace IGC
768768
CG_FLAG_t m_CgFlag = FLAG_CG_ALL_SIMDS;
769769
// Staging context passing from Stage 1 for compile continuation
770770
CG_CTX_t* m_StagingCtx = nullptr;
771+
// We determine whether generating SIMD32 based on SIMD16's result
772+
// For staged compilation, we record if SIMD32 will be generated in Stage1, and
773+
// pass it to Stage2.
774+
bool m_doSimd32Stage2 = false;
771775

772776
protected:
773777
// Objects pointed to by these pointers are owned by this class.

0 commit comments

Comments
 (0)