Skip to content

Commit 8e65535

Browse files
bcheng0127igcbot
authored andcommitted
Add DPAS SBID.dst for any instruction which uses the architecture register
During the exeuction of dpas instruction, the architecture registers cannot be updated
1 parent 7a2a2c2 commit 8e65535

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

visa/LocalScheduler/SWSB_G4IR.cpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,15 @@ static bool isDclExclusiveLoad(const G4_Declare *declare1,
275275
return declare1->isExclusiveLoad();
276276
}
277277

278+
static void checkAndRemoveDpasNode(SBNode *curLiveNode,
279+
std::vector<SBNode *> &liveDPASNodes) {
280+
auto dpasIt =
281+
std::find(liveDPASNodes.begin(), liveDPASNodes.end(), curLiveNode);
282+
if (dpasIt != liveDPASNodes.end()) {
283+
liveDPASNodes.erase(dpasIt);
284+
}
285+
}
286+
278287
bool SBFootprint::hasOverlap(const SBFootprint *liveFootprint,
279288
unsigned short &internalOffset) const {
280289
for (const SBFootprint *curFootprintPtr = this; curFootprintPtr;
@@ -6796,6 +6805,7 @@ void G4_BB_SB::SBDDD(G4_BB *bb, LiveGRFBuckets *&LB,
67966805
mathID = indexes->mathIndex;
67976806
first_DPASID = indexes->DPASIndex;
67986807
SBNode *lastDpasNode = nullptr;
6808+
std::vector<SBNode *> liveDPASNodes; // Recording local live dpas nodes
67996809

68006810
for (int i = 0; i < PIPE_DPAS; i++) {
68016811
latestDepALUID[i] = indexes->latestDepALUID[i];
@@ -7089,6 +7099,7 @@ void G4_BB_SB::SBDDD(G4_BB *bb, LiveGRFBuckets *&LB,
70897099
node->setDPASID(DPASID);
70907100
DPASID += node->getDPASSize();
70917101
lastDpasNode = node;
7102+
liveDPASNodes.push_back(node);
70927103
}
70937104

70947105
// Get buckets for all GRF registers which are used in curInst
@@ -7143,6 +7154,13 @@ void G4_BB_SB::SBDDD(G4_BB *bb, LiveGRFBuckets *&LB,
71437154
}
71447155
}
71457156

7157+
if (node->hasDistOneAreg()) {
7158+
for (auto dpasNode : liveDPASNodes) {
7159+
createAddGRFEdge(dpasNode, node, RAW, DEP_EXPLICT);
7160+
}
7161+
liveDPASNodes.clear();
7162+
}
7163+
71467164
if (BDvec.empty() && node->distDep.empty()) {
71477165
if (ALUID >= SWSB_MAX_ALU_DEPENDENCE_DISTANCE &&
71487166
ALUID != node->getALUID()) {
@@ -7275,6 +7293,9 @@ void G4_BB_SB::SBDDD(G4_BB *bb, LiveGRFBuckets *&LB,
72757293
tokenAfterDPASCycle)) {
72767294
LB->killOperand(bn_it);
72777295
createAddGRFEdge(liveNode, node, dep, DEP_EXPLICT);
7296+
if (liveNode->getLastInstruction()->isDpas()) {
7297+
checkAndRemoveDpasNode(liveNode, liveDPASNodes);
7298+
}
72787299
liveNode->setInstKilled(true); // Instruction level kill
72797300
instKill = true;
72807301
continue;
@@ -7286,6 +7307,9 @@ void G4_BB_SB::SBDDD(G4_BB *bb, LiveGRFBuckets *&LB,
72867307
} else {
72877308
LB->killOperand(bn_it);
72887309
createAddGRFEdge(liveNode, node, dep, DEP_EXPLICT);
7310+
if (liveNode->getLastInstruction()->isDpas()) {
7311+
checkAndRemoveDpasNode(liveNode, liveDPASNodes);
7312+
}
72897313
liveNode->setInstKilled(true); // Instruction level kill
72907314
instKill = true;
72917315
continue;
@@ -8100,10 +8124,14 @@ void SWSB::addGlobalDependence(unsigned globalSendNum,
81008124
// the order of the operands are scanned is not an issue anymore.
81018125
// i.e explicit RAW and WAW can cover all other dependences.
81028126
// Only S0 and GRF regsiters can introduce global SBID dependence
8127+
std::vector<SBNode *> liveDPASNodes; // Record live in dpas nodes
81038128
LiveGRFBuckets send_use_kills(globalRegisterNum);
81048129
for (unsigned i : send_kill.dst) {
81058130
for (SBBucketNode *sBucketNode : globalDstSBSendNodes[i]) {
81068131
SBNode *sNode = sBucketNode->node;
8132+
if (sNode->getLastInstruction()->isDpas()) {
8133+
liveDPASNodes.push_back(sNode);
8134+
}
81078135
sb_bb->getLiveBucketsFromFootprint(sNode->getFirstFootprint(Opnd_dst),
81088136
sBucketNode, &send_use_kills);
81098137
sNode->setInstKilled(false);
@@ -8114,6 +8142,9 @@ void SWSB::addGlobalDependence(unsigned globalSendNum,
81148142
for (unsigned i : send_kill.src) {
81158143
for (SBBucketNode *sBucketNode : globalSrcSBSendNodes[i]) {
81168144
SBNode *sNode = sBucketNode->node;
8145+
if (sNode->getLastInstruction()->isDpas()) {
8146+
liveDPASNodes.push_back(sNode);
8147+
}
81178148
sb_bb->getLiveBucketsFromFootprint(
81188149
sNode->getFirstFootprint(sBucketNode->opndNum), sBucketNode,
81198150
&send_use_kills);
@@ -8128,6 +8159,13 @@ void SWSB::addGlobalDependence(unsigned globalSendNum,
81288159
SBNode *node = SBNodes[j];
81298160
G4_INST *curInst = node->getLastInstruction();
81308161

8162+
if (node->hasDistOneAreg()) {
8163+
for (auto dpasNode : liveDPASNodes) {
8164+
sb_bb->createAddGRFEdge(dpasNode, node, RAW, DEP_EXPLICT);
8165+
}
8166+
liveDPASNodes.clear();
8167+
}
8168+
81318169
BDvec.clear();
81328170
sb_bb->getGRFBucketDescs(node, BDvec, true);
81338171
if (BDvec.empty()) {
@@ -8228,6 +8266,9 @@ void SWSB::addGlobalDependence(unsigned globalSendNum,
82288266
send_use_kills.killOperand(bn_it);
82298267
sb_bb->createAddGRFEdge(curLiveNode, node, dep,
82308268
DEP_EXPLICT);
8269+
if (curLiveNode->getLastInstruction()->isDpas()) {
8270+
checkAndRemoveDpasNode(curLiveNode, liveDPASNodes);
8271+
}
82318272
curLiveNode->setInstKilled(true); // Instruction level
82328273
// kill
82338274
instKill = true;
@@ -8239,6 +8280,9 @@ void SWSB::addGlobalDependence(unsigned globalSendNum,
82398280
send_use_kills.killOperand(bn_it);
82408281
sb_bb->createAddGRFEdge(curLiveNode, node, dep,
82418282
DEP_EXPLICT);
8283+
if (curLiveNode->getLastInstruction()->isDpas()) {
8284+
checkAndRemoveDpasNode(curLiveNode, liveDPASNodes);
8285+
}
82428286
curLiveNode->setInstKilled(true); // Instruction level
82438287
// kill
82448288
instKill = true;
@@ -8267,6 +8311,9 @@ void SWSB::addGlobalDependence(unsigned globalSendNum,
82678311
send_use_kills.killOperand(bn_it);
82688312
sb_bb->createAddGRFEdge(curLiveNode, node, dep,
82698313
DEP_EXPLICT);
8314+
if (curLiveNode->getLastInstruction()->isDpas()) {
8315+
checkAndRemoveDpasNode(curLiveNode, liveDPASNodes);
8316+
}
82708317
curLiveNode->setInstKilled(
82718318
true); // Instruction level kill
82728319
instKill = true;
@@ -8279,6 +8326,9 @@ void SWSB::addGlobalDependence(unsigned globalSendNum,
82798326
send_use_kills.killOperand(bn_it);
82808327
sb_bb->createAddGRFEdge(curLiveNode, node, dep,
82818328
DEP_EXPLICT);
8329+
if (curLiveNode->getLastInstruction()->isDpas()) {
8330+
checkAndRemoveDpasNode(curLiveNode, liveDPASNodes);
8331+
}
82828332
curLiveNode->setInstKilled(true);
82838333
instKill = true;
82848334
continue;
@@ -8287,6 +8337,9 @@ void SWSB::addGlobalDependence(unsigned globalSendNum,
82878337
} else {
82888338
send_use_kills.killOperand(bn_it);
82898339
sb_bb->createAddGRFEdge(curLiveNode, node, dep, DEP_EXPLICT);
8340+
if (curLiveNode->getLastInstruction()->isDpas()) {
8341+
checkAndRemoveDpasNode(curLiveNode, liveDPASNodes);
8342+
}
82908343
curLiveNode->setInstKilled(true); // Instruction level kill
82918344
instKill = true;
82928345
continue;

0 commit comments

Comments
 (0)