Skip to content

Commit 1248544

Browse files
DianaChenigcbot
authored andcommitted
vISA: minor refactoring in LocalScheduler
Minor code clean-up
1 parent 64fbde1 commit 1248544

File tree

2 files changed

+29
-28
lines changed

2 files changed

+29
-28
lines changed

visa/LocalScheduler/LocalScheduler_G4IR.cpp

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,33 +1171,25 @@ bool DDD::hasReadSuppression(G4_INST* prevInst, G4_INST* nextInst, bool multiSup
11711171
return suppressionSrcs > 1;
11721172
}
11731173

1174-
bool DDD::hasSameSourceOneDPAS(G4_INST *curInst, G4_INST *nextInst, BitSet &liveDst, BitSet &liveSrc)
1175-
{
1176-
G4_Type curTypes[4];
1177-
G4_Type nextTypes[4];
11781174

1179-
//Get Types
1180-
for(int i = 0; i < 4; i++)
1181-
{
1182-
curTypes[i] = Type_UNDEF;
1183-
nextTypes[i] = Type_UNDEF;
1184-
}
1185-
curTypes[0] = curInst->getDst()->getType();
1186-
nextTypes[0] = nextInst->getDst()->getType();
1187-
for (int i = 0; i < 3; i++)
1188-
{
1189-
curTypes[i + 1] = curInst->getSrc(i)->getType();
1190-
nextTypes[i + 1] = nextInst->getSrc(i)->getType();
1191-
}
1175+
bool DDD::hsaSameTypesAllOperands(const G4_INST& curInst, const G4_INST& nextInst) const
1176+
{
1177+
assert(curInst.getNumDst() == 1 && curInst.getNumDst() == nextInst.getNumDst());
1178+
if (curInst.getDst()->getType() != nextInst.getDst()->getType())
1179+
return false;
11921180

1193-
//Same type for all operands
1194-
for(int i = 0; i < 4; i++)
1195-
{
1196-
if (curTypes[i] != nextTypes[i])
1197-
{
1181+
assert(curInst.getNumSrc() == nextInst.getNumSrc());
1182+
for (auto i = 0; i < curInst.getNumSrc(); ++i)
1183+
if (curInst.getSrc(i)->getType() != nextInst.getSrc(i)->getType())
11981184
return false;
1199-
}
1200-
}
1185+
1186+
return true;
1187+
}
1188+
1189+
bool DDD::hasSameSourceOneDPAS(G4_INST *curInst, G4_INST *nextInst, BitSet &liveDst, BitSet &liveSrc)
1190+
{
1191+
if (!hsaSameTypesAllOperands(*curInst, *nextInst))
1192+
return false;
12011193

12021194
G4_InstDpas* curDpasInst = curInst->asDpasInst();
12031195
G4_InstDpas* nextDpasInst = nextInst->asDpasInst();
@@ -1404,9 +1396,14 @@ DDD::DDD(Mem_Manager& m, G4_BB* bb, const LatencyTable& lt, G4_Kernel* k)
14041396
liveSrc.clear();
14051397
liveDst.clear();
14061398

1407-
while (nextInst->isDpas() &&
1408-
hasSameSourceOneDPAS(curInst, nextInst, liveDst, liveSrc))
1399+
// group continuous dpas in the same node if they can potentially form a dpas macro
1400+
while (nextInst->isDpas())
14091401
{
1402+
bool canGroup = false;
1403+
canGroup = hasSameSourceOneDPAS(curInst, nextInst, liveDst, liveSrc);
1404+
if (!canGroup)
1405+
break;
1406+
14101407
//Pushed to the same node
14111408
node->instVec.insert(node->instVec.begin(), nextInst);
14121409
nodeId--;
@@ -2116,7 +2113,7 @@ struct criticalCmpForMad
21162113
};
21172114

21182115
// 1).The priority queue is ordered as original sequence order.
2119-
// 2).If there is a mad instruction be scheduled, trying to search the candidate which has read suppression in src1and src2.
2116+
// 2).If there is a mad instruction be scheduled, trying to search the candidate which has read suppression in src1 and src2.
21202117
// 3).The scheduling is only applied to the BB whose instructions are mostly mad.
21212118
// 4).This scheduling is not for general instruction scheduling, it's controlled by option vISA_ScheduleForReadSuppression
21222119
uint32_t DDD::listScheduleForSuppression(G4_BB_Schedule* schedule)

visa/LocalScheduler/LocalScheduler_G4IR.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,12 @@ class DDD {
255255

256256
bool hasReadSuppression(G4_INST *curInst, G4_INST *nextInst, BitSet &liveDst, BitSet &liveSrc);
257257
bool hasReadSuppression(G4_INST* prevInst, G4_INST* nextInst, bool multipSuppression);
258-
bool hasSameSourceOneDPAS(G4_INST * curInst, G4_INST * nextInst, BitSet & liveDst, BitSet & liveSrc);
259258

259+
private:
260+
bool hasSameSourceOneDPAS(G4_INST* curInst, G4_INST* nextInst, BitSet& liveDst, BitSet& liveSrc);
261+
bool hsaSameTypesAllOperands(const G4_INST& curInst, const G4_INST& nextInst) const;
262+
263+
public:
260264
DDD(Mem_Manager& m, G4_BB* bb, const LatencyTable& lt, G4_Kernel* k);
261265
~DDD()
262266
{

0 commit comments

Comments
 (0)