Skip to content

Commit 2fabece

Browse files
DianaChenigcbot
authored andcommitted
IGA SWSB: Clear sbid-dependency after force-sync-all
Clear sbid-dependency after force-sync-all for some instructions (e.g. instruction with CR/CE/SR access, or indirect reg access). This can avoid redundant swsb set after force-sync-all instructions.
1 parent 549d74e commit 2fabece

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

visa/iga/IGALibrary/IR/SWSBSetter.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -560,16 +560,26 @@ send.dc0 (16|M0) r38 r118 null 0x0 a0.0 ret (16|M0)
560560
561561
Right now mov will have false dependense on the first send.
562562
*/
563-
void SWSBAnalyzer::clearSBIDDependence(InstList::iterator insertPoint,
563+
bool SWSBAnalyzer::clearSBIDDependence(InstList::iterator insertPoint,
564564
Instruction *lastInst, Block *bb) {
565+
566+
auto clearSBID = [&](const SBID& in) {
567+
m_freeSBIDList[in.sbid].reset();
568+
assert(m_IdToDepSetMap.find(in.sbid) != m_IdToDepSetMap.end());
569+
assert(m_IdToDepSetMap[in.sbid].first->getDepClass() ==
570+
DEP_CLASS::OUT_OF_ORDER);
571+
clearDepBuckets(*m_IdToDepSetMap[in.sbid].first);
572+
clearDepBuckets(*m_IdToDepSetMap[in.sbid].second);
573+
};
574+
565575
bool sbidInUse = false;
566576
for (uint32_t i = 0; i < m_SBIDCount; ++i) {
567577
// there are still dependencies that might be used outside of this basic
568578
// block
569579
if (!m_freeSBIDList[i].isFree) {
580+
clearSBID(m_freeSBIDList[i]);
570581
sbidInUse = true;
571582
}
572-
m_freeSBIDList[i].reset();
573583
}
574584

575585
// if last instruction in basic block is EOT no need to generate flushes
@@ -583,6 +593,8 @@ void SWSBAnalyzer::clearSBIDDependence(InstList::iterator insertPoint,
583593
if (sbidInUse) {
584594
insertSyncAllRdWr(insertPoint, bb);
585595
}
596+
597+
return sbidInUse;
586598
}
587599

588600
// Keeping track of dependencies that need to be cleared because they are no
@@ -1302,10 +1314,9 @@ void SWSBAnalyzer::run() {
13021314
InstListIterator insert_point = instIter;
13031315
if (first_inst_in_dpas_macro != instList.end())
13041316
insert_point = first_inst_in_dpas_macro;
1305-
if (input->getDepClass() == DEP_CLASS::OUT_OF_ORDER)
1317+
bool forceSyncAll = clearSBIDDependence(insert_point, inst, bb);
1318+
if (!forceSyncAll && input->getDepClass() == DEP_CLASS::OUT_OF_ORDER)
13061319
insertSyncAllRdWr(insert_point, bb);
1307-
else
1308-
clearSBIDDependence(insert_point, inst, bb);
13091320

13101321
// clear in-order dependency
13111322
clearBuckets(input, output);

visa/iga/IGALibrary/IR/SWSBSetter.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ class SWSBAnalyzer {
140140
// clear dependency of the given dep
141141
void clearDepBuckets(DepSet &dep);
142142
// clear all sbid, set ids to all free and insert sync to sync with all pipes
143-
void clearSBIDDependence(InstList::iterator insertPoint,
143+
// return if there are active sbid in-use before and sync.allrd/sync.allwr
144+
// instructions are inserted to sync them
145+
bool clearSBIDDependence(InstList::iterator insertPoint,
144146
Instruction *lastInst, Block *bb);
145147
// clear given input and output dependency in the buckets (for in-order pipes
146148
// only)

0 commit comments

Comments
 (0)