Skip to content

Commit 95c299f

Browse files
pratikasharigcbot
authored andcommitted
[Autobackout][FuncReg]Revert of change: 371e584
Add example snippet in comments. Add example snippet in comments.
1 parent e5b2134 commit 95c299f

File tree

6 files changed

+53
-217
lines changed

6 files changed

+53
-217
lines changed

visa/GraphColor.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10739,11 +10739,7 @@ int GlobalRA::coloringRegAlloc()
1073910739
if (iterationNo == 0 && !fastCompile &&
1074010740
kernel.getOption(vISA_DoSplitOnSpill))
1074110741
{
10742-
if (builder.getOption(vISA_RATrace))
10743-
{
10744-
std::cout << "\t--var split around loop\n";
10745-
}
10746-
LoopVarSplit loopSplit(kernel, &coloring, &liveAnalysis);
10742+
LoopVarSplit loopSplit(kernel, &coloring, &rpe);
1074710743
kernel.fg.getLoops().computePreheaders();
1074810744
loopSplit.run();
1074910745
}

visa/RPE.cpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,10 @@ SPDX-License-Identifier: MIT
1414

1515
namespace vISA
1616
{
17-
RPE::RPE(const GlobalRA& g, const LivenessAnalysis* l, DECLARE_LIST* spills) : m(1024), gra(g), liveAnalysis(l), live(l->getNumSelectedVar()),
17+
RPE::RPE(const GlobalRA& g, const LivenessAnalysis* l) : m(1024), gra(g), liveAnalysis(l), live(l->getNumSelectedVar()),
1818
vars(l->vars)
1919
{
2020
options = g.kernel.getOptions();
21-
if (spills)
22-
{
23-
std::for_each(spills->begin(), spills->end(),
24-
[&](const G4_Declare* dcl) { spilledVars.insert(dcl); });
25-
}
2621
}
2722

2823
void RPE::run()
@@ -144,8 +139,6 @@ namespace vISA
144139
{
145140
auto range = vars[i];
146141
G4_Declare* rootDcl = range->getDeclare()->getRootDeclare();
147-
if (isSpilled(rootDcl))
148-
continue;
149142
if (rootDcl->getNumElems() > 1)
150143
{
151144
regPressure += rootDcl->getNumRows();
@@ -173,21 +166,18 @@ namespace vISA
173166
auto change = before^after;
174167
if (change)
175168
{
176-
auto dcl = vars[id]->getDeclare();
177-
if (isSpilled(dcl))
178-
return;
179169
// For <1 GRF variable we have to take alignment into consideration as well when computing register pressure.
180170
// For now we double each <1GRF variable's size if its alignment also exceeds its size.
181171
// Alternative is to simply take the alignment as the size, but it might cause performance regressions
182172
// due to being too conservative (i.e., a GRF-aligned variable may share physical GRF with several other
183-
auto dclSize = dcl->getByteSize();
184-
if (dclSize < gra.builder.getGRFSize() && dclSize < static_cast<uint32_t>(dcl->getSubRegAlign()) * 2)
173+
auto dclSize = vars[id]->getDeclare()->getByteSize();
174+
if (dclSize < gra.builder.getGRFSize() && dclSize < static_cast<uint32_t>(vars[id]->getDeclare()->getSubRegAlign()) * 2)
185175
{
186176
dclSize *= 2;
187177
}
188178

189179
double delta = dclSize < gra.builder.getGRFSize() ?
190-
dclSize / (double) gra.builder.getGRFSize() : (double) dcl->getNumRows();
180+
dclSize / (double) gra.builder.getGRFSize() : (double) vars[id]->getDeclare()->getNumRows();
191181
if (before & change)
192182
{
193183
if (regPressure < delta)

visa/RPE.h

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace vISA
1818
class RPE
1919
{
2020
public:
21-
RPE(const GlobalRA&, const LivenessAnalysis*, DECLARE_LIST* spills = nullptr);
21+
RPE(const GlobalRA&, const LivenessAnalysis*);
2222

2323
~RPE()
2424
{
@@ -56,24 +56,10 @@ namespace vISA
5656
const Options* options;
5757
SparseBitSet live;
5858
const std::vector<G4_RegVar*>& vars;
59-
// Variables part of spilledVars set dont contribute to
60-
// program register pressure. This is useful to model
61-
// register pressure immediately after coloring (spill
62-
// iteration).
63-
std::unordered_set<const G4_Declare*> spilledVars;
6459

6560
void regPressureBBExit(G4_BB*);
6661
void updateRegisterPressure(unsigned int, unsigned int, unsigned int);
6762
void updateLiveness(SparseBitSet&, uint32_t, bool);
68-
69-
70-
bool isSpilled(const G4_Declare* dcl) const
71-
{
72-
auto it = spilledVars.find(dcl);
73-
if (it == spilledVars.end())
74-
return false;
75-
return true;
76-
}
7763
};
7864
}
7965
#endif

visa/SpillManagerGMRF.cpp

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3268,6 +3268,14 @@ void SpillManagerGRF::insertSpillRangeCode(
32683268
return;
32693269
}
32703270

3271+
if (builder_->getOption(vISA_DoSplitOnSpill))
3272+
{
3273+
// if spilled inst is copy of original variable to it's split variable
3274+
// then simply remove the instruction.
3275+
if (LoopVarSplit::removeFromPreheader(&gra, spillDcl, bb, spilledInstIter))
3276+
return;
3277+
}
3278+
32713279
auto checkRMWNeeded = [this, spilledRegion]()
32723280
{
32733281
return noRMWNeeded.find(spilledRegion) == noRMWNeeded.end();
@@ -3545,6 +3553,22 @@ void SpillManagerGRF::insertFillGRFRangeCode(
35453553
G4_INST* fillSendInst = nullptr;
35463554
auto spillDcl = filledRegion->getTopDcl()->getRootDeclare();
35473555

3556+
if (builder_->getOption(vISA_DoSplitOnSpill))
3557+
{
3558+
// if spilled inst is copy of split variable to it's spilled variable
3559+
// then simply remove the instruction.
3560+
//
3561+
// if inst is:
3562+
// (W) mov (8|M0) SPLIT1 V10
3563+
//
3564+
// and SPLIT1 is marked as spilled then don't insert spill code for it.
3565+
// V10 is guaranteed to be spilled already so there is no point spilling
3566+
// SPLIT1. we simply remove above instruction and any fill emitted to load
3567+
// V10 and return.
3568+
if (LoopVarSplit::removeFromLoopExit(&gra, spillDcl, bb, filledInstIter))
3569+
return;
3570+
}
3571+
35483572
auto sisIt = scalarImmSpill.find(spillDcl);
35493573
if (sisIt != scalarImmSpill.end())
35503574
{
@@ -4517,20 +4541,6 @@ bool SpillManagerGRF::insertSpillFillCode(
45174541
return false;
45184542
}
45194543

4520-
if (kernel->getOption(vISA_DoSplitOnSpill))
4521-
{
4522-
// remove all spilled splits
4523-
for (const LiveRange* lr : *spilledLRs_)
4524-
{
4525-
auto dcl = lr->getDcl();
4526-
// check whether spilled variable is one of split vars
4527-
if (gra.splitResults.find(dcl) == gra.splitResults.end())
4528-
continue;
4529-
4530-
LoopVarSplit::removeAllSplitInsts(&gra, dcl);
4531-
}
4532-
}
4533-
45344544
// Insert spill/fill code for all basic blocks.
45354545
updateRMWNeeded();
45364546
FlowGraph& fg = kernel->fg;

0 commit comments

Comments
 (0)