Skip to content

Commit f236e7a

Browse files
ppogotovigcbot
authored andcommitted
Disable memopt on retry for common kernels.
Change memopt windows size to 1 for common kernels helps to avoid functional issues. This workaround should be removed once the issue is resolved.
1 parent 498f6c3 commit f236e7a

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

IGC/Compiler/CISACodeGen/MemOpt.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ namespace {
8282
bool AllowNegativeSymPtrsForLoad = false;
8383
bool AllowVector8LoadStore = false;
8484

85+
unsigned Limit = IGC_GET_FLAG_VALUE(MemOptWindowSize);
86+
8587
// Map of profit vector lengths per scalar type. Each entry specifies the
8688
// profit vector length of a given scalar type.
8789
// NOTE: Prepare the profit vector lengths in the *DESCENDING* order.
@@ -520,6 +522,18 @@ bool MemOpt::runOnFunction(Function& F) {
520522
CGC = getAnalysis<CodeGenContextWrapper>().getCodeGenContext();
521523
TLI = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
522524

525+
auto isKernelWithForcedRetry = [this](Function* F) -> bool {
526+
auto it = std::find(CGC->m_kernelsWithForcedRetry.begin(), CGC->m_kernelsWithForcedRetry.end(), F);
527+
return (it != CGC->m_kernelsWithForcedRetry.end()) && !CGC->m_retryManager.IsFirstTry();
528+
};
529+
bool shouldMemOptWindowSizeBeReduced = isKernelWithForcedRetry(&F);
530+
531+
if (shouldMemOptWindowSizeBeReduced) {
532+
Limit = 1;
533+
} else {
534+
Limit = IGC_GET_FLAG_VALUE(MemOptWindowSize);
535+
}
536+
523537
if (ProfitVectorLengths.empty())
524538
buildProfitVectorLengths(F);
525539

@@ -636,7 +650,6 @@ bool MemOpt::removeRedBlockRead(GenIntrinsicInst* LeadingBlockRead,
636650
TrivialMemRefListTy& ToOpt, unsigned& sg_size)
637651
{
638652
MemRefListTy::iterator MI = aMI;
639-
const unsigned Limit = IGC_GET_FLAG_VALUE(MemOptWindowSize);
640653
const unsigned windowEnd = Limit + MI->second;
641654
auto ME = MemRefs.end();
642655

@@ -1208,7 +1221,6 @@ bool MemOpt::mergeLoad(LoadInst* LeadingLoad,
12081221
// List of instructions need dependency check.
12091222
SmallVector<Instruction*, 8> CheckList;
12101223

1211-
const unsigned Limit = IGC_GET_FLAG_VALUE(MemOptWindowSize);
12121224
// Given the Start position of the Window is MI->second,
12131225
// the End postion of the Window is "limit + Windows' start".
12141226
const unsigned windowEnd = Limit + MI->second;
@@ -1562,7 +1574,6 @@ bool MemOpt::mergeStore(StoreInst* LeadingStore,
15621574
// List of instructions need dependency check.
15631575
SmallVector<Instruction*, 8> CheckList;
15641576

1565-
const unsigned Limit = IGC_GET_FLAG_VALUE(MemOptWindowSize);
15661577
// Given the Start position of the Window is MI->second,
15671578
// the End postion of the Window is "limit + Windows' start".
15681579
const unsigned windowEnd = Limit + MI->second;

IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,6 @@ void AddAnalysisPasses(CodeGenContext& ctx, IGCPassManager& mpm)
366366

367367
mpm.add(new DpasScan());
368368

369-
mpm.add(new MatchCommonKernelPatterns());
370-
371369
// let CleanPHINode be right before Layout
372370
mpm.add(createCleanPHINodePass());
373371
if(IGC_IS_FLAG_SET(DumpRegPressureEstimate)) mpm.add(new IGCRegisterPressurePrinter("final"));
@@ -723,6 +721,7 @@ void AddLegalizationPasses(CodeGenContext& ctx, IGCPassManager& mpm, PSSignature
723721
}
724722
// Should help MemOpt pass to merge more loads
725723
mpm.add(createSinkCommonOffsetFromGEPPass());
724+
mpm.add(new MatchCommonKernelPatterns());
726725

727726
// Run MemOpt
728727
if (!isOptDisabled &&

0 commit comments

Comments
 (0)