Skip to content

Commit 68872ab

Browse files
sys-igcigcbot
authored andcommitted
Changes in code.
1 parent b2ef745 commit 68872ab

File tree

1 file changed

+9
-152
lines changed

1 file changed

+9
-152
lines changed

visa/GraphColor.cpp

Lines changed: 9 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -6103,129 +6103,8 @@ void GraphColor::computeDegreeForARF()
61036103

61046104
void GraphColor::computeSpillCosts(bool useSplitLLRHeuristic)
61056105
{
6106-
std::vector <LiveRange*> addressSensitiveVars;
6106+
std::vector <LiveRange *> addressSensitiveVars;
61076107
float maxNormalCost = 0.0f;
6108-
VarReferences directRefs(kernel);
6109-
std::list<std::pair<G4_INST*, G4_BB*>> indirectRefs;
6110-
6111-
if (liveAnalysis.livenessClass(G4_GRF))
6112-
{
6113-
// gather all instructions with indirect operands
6114-
// for ref count computation once.
6115-
for (auto bb : kernel.fg.getBBList())
6116-
{
6117-
for (auto inst : bb->getInstList())
6118-
{
6119-
auto dst = inst->getDst();
6120-
if (dst && dst->isIndirect())
6121-
{
6122-
indirectRefs.push_back(std::make_pair(inst, bb));
6123-
continue;
6124-
}
6125-
6126-
for (unsigned int i = 0; i != inst->getNumSrc(); ++i)
6127-
{
6128-
auto src = inst->getSrc(i);
6129-
if (!src || !src->isSrcRegRegion() || !src->asSrcRegRegion()->isIndirect())
6130-
{
6131-
continue;
6132-
}
6133-
indirectRefs.push_back(std::make_pair(inst, bb));
6134-
continue;
6135-
}
6136-
}
6137-
}
6138-
}
6139-
6140-
auto getWeightedRefCount = [&](G4_Declare* dcl, unsigned int useWt = 1, unsigned int defWt = 1)
6141-
{
6142-
auto defs = directRefs.getDefs(dcl);
6143-
auto uses = directRefs.getUses(dcl);
6144-
auto& loops = kernel.fg.getLoops();
6145-
6146-
unsigned int refCount = 0;
6147-
const unsigned int assumeLoopIter = 10;
6148-
6149-
if (defs)
6150-
{
6151-
for (auto def : *defs)
6152-
{
6153-
auto* bb = std::get<1>(def);
6154-
auto* innerMostLoop = loops.getInnerMostLoop(bb);
6155-
if (innerMostLoop)
6156-
{
6157-
auto nestingLevel = innerMostLoop->getNestingLevel();
6158-
refCount += (unsigned int)std::pow(assumeLoopIter, nestingLevel);
6159-
}
6160-
else
6161-
refCount += defWt;
6162-
}
6163-
}
6164-
6165-
if (uses)
6166-
{
6167-
for (auto use : *uses)
6168-
{
6169-
auto* bb = std::get<1>(use);
6170-
auto* innerMostLoop = loops.getInnerMostLoop(bb);
6171-
if (innerMostLoop)
6172-
{
6173-
auto nestingLevel = innerMostLoop->getNestingLevel();
6174-
refCount += (unsigned int)std::pow(assumeLoopIter, nestingLevel);
6175-
}
6176-
else
6177-
refCount += useWt;
6178-
}
6179-
}
6180-
6181-
if (dcl->getAddressed())
6182-
{
6183-
for (auto& item : indirectRefs)
6184-
{
6185-
auto inst = item.first;
6186-
auto bb = item.second;
6187-
6188-
auto dst = inst->getDst();
6189-
if (dst && dst->isIndirect())
6190-
{
6191-
if (liveAnalysis.getPointsToAnalysis().isPresentInPointsTo(dst->getTopDcl()->getRegVar(), dcl->getRegVar()))
6192-
{
6193-
auto* innerMostLoop = loops.getInnerMostLoop(bb);
6194-
if (innerMostLoop)
6195-
{
6196-
auto nestingLevel = innerMostLoop->getNestingLevel();
6197-
refCount += (unsigned int)std::pow(assumeLoopIter, nestingLevel);
6198-
}
6199-
else
6200-
refCount += useWt;
6201-
}
6202-
}
6203-
6204-
for (unsigned int i = 0; i != inst->getNumSrc(); ++i)
6205-
{
6206-
auto src = inst->getSrc(i);
6207-
if (!src || !src->isSrcRegRegion() || !src->asSrcRegRegion()->isIndirect())
6208-
{
6209-
continue;
6210-
}
6211-
if (liveAnalysis.getPointsToAnalysis().isPresentInPointsTo(src->asSrcRegRegion()->getTopDcl()->getRegVar(), dcl->getRegVar()))
6212-
{
6213-
auto* innerMostLoop = loops.getInnerMostLoop(bb);
6214-
if (innerMostLoop)
6215-
{
6216-
auto nestingLevel = innerMostLoop->getNestingLevel();
6217-
refCount += (unsigned int)std::pow(assumeLoopIter, nestingLevel);
6218-
}
6219-
else
6220-
refCount += useWt;
6221-
}
6222-
}
6223-
6224-
}
6225-
}
6226-
6227-
return refCount == 0 ? 1 : refCount;
6228-
};
62296108

62306109
auto incSpillCostCandidate = [&](LiveRange* lr)
62316110
{
@@ -6237,7 +6116,7 @@ void GraphColor::computeSpillCosts(bool useSplitLLRHeuristic)
62376116

62386117
// this condition is a safety measure and isnt expected to be true.
62396118
auto it = revAddrTakenMap.find(lr->getDcl());
6240-
if (it == revAddrTakenMap.end())
6119+
if(it == revAddrTakenMap.end())
62416120
return true;
62426121

62436122
for (auto& addrVar : (*it).second)
@@ -6315,43 +6194,22 @@ void GraphColor::computeSpillCosts(bool useSplitLLRHeuristic)
63156194
{
63166195
if (useSplitLLRHeuristic)
63176196
{
6318-
spillCost = 1.0f * lrs[i]->getRefCount() / (lrs[i]->getDegree() + 1);
6197+
spillCost = 1.0f*lrs[i]->getRefCount() / (lrs[i]->getDegree() + 1);
63196198
}
63206199
else
63216200
{
63226201
assert(lrs[i]->getDcl()->getTotalElems() > 0);
6323-
if (!liveAnalysis.livenessClass(G4_GRF))
6324-
{
6325-
// address or flag variables
6326-
unsigned short numRows = lrs[i]->getDcl()->getNumRows();
6327-
spillCost = 1.0f * lrs[i]->getRefCount() * lrs[i]->getRefCount() * lrs[i]->getDcl()->getByteSize() *
6328-
(float)sqrt(lrs[i]->getDcl()->getByteSize())
6329-
/ ((float)sqrt(lrs[i]->getDegree() + 1) * (float)(sqrt(sqrt(numRows))));
6330-
}
6331-
else
6332-
{
6333-
// GRF variables
6334-
6335-
auto refCount = getWeightedRefCount(lrs[i]->getDcl());
6336-
unsigned int degree = 0;
6337-
{
6338-
for (unsigned int j = 0; j != getIntf()->getSparseIntfForVar(i).size(); ++j)
6339-
{
6340-
if (lrs[j]->getDcl()->getByteSize() >= (unsigned int)getGRFSize() / 2)
6341-
degree += lrs[j]->getDcl()->getNumRows() + lrs[i]->getDcl()->getNumRows() - 1;
6342-
}
6343-
}
6344-
6345-
spillCost = 1.0f * refCount * refCount * refCount
6346-
/ ((float)(degree + 1) * (float)(degree + 1));
6347-
}
6202+
unsigned short numRows = lrs[i]->getDcl()->getNumRows();
6203+
spillCost = 1.0f * lrs[i]->getRefCount() * lrs[i]->getRefCount() * lrs[i]->getDcl()->getByteSize() *
6204+
(float)sqrt(lrs[i]->getDcl()->getByteSize())
6205+
/ ((float)sqrt(lrs[i]->getDegree() + 1) * (float)(sqrt(sqrt(numRows))));
63486206
}
63496207
}
63506208
else
63516209
{
63526210
spillCost =
63536211
liveAnalysis.livenessClass(G4_GRF) ?
6354-
lrs[i]->getDegree() : 1.0f * lrs[i]->getRefCount() * lrs[i]->getRefCount() / (lrs[i]->getDegree() + 1);
6212+
lrs[i]->getDegree() : 1.0f*lrs[i]->getRefCount()*lrs[i]->getRefCount() / (lrs[i]->getDegree() + 1);
63556213
}
63566214

63576215
lrs[i]->setSpillCost(spillCost);
@@ -6379,7 +6237,7 @@ void GraphColor::computeSpillCosts(bool useSplitLLRHeuristic)
63796237
// normal live ranges, so that they get colored before all the normal
63806238
// live ranges.
63816239
//
6382-
for (LiveRange* lr : addressSensitiveVars)
6240+
for (LiveRange *lr : addressSensitiveVars)
63836241
{
63846242
if (lr->getSpillCost() != MAXSPILLCOST)
63856243
{
@@ -6389,7 +6247,6 @@ void GraphColor::computeSpillCosts(bool useSplitLLRHeuristic)
63896247
}
63906248

63916249

6392-
63936250
//
63946251
// subtract lr's neighbors that are still in work list
63956252
//

0 commit comments

Comments
 (0)