llvm.org GIT mirror llvm / bc04e5d
[AMDGPU] SISched: Detect dependency types between blocks Patch by Axel Davy (axel.davy@normalesup.org) Differential revision: https://reviews.llvm.org/D30153 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298872 91177308-0d34-0410-b5e6-96231b3b80d8 Valery Pykhtin 3 years ago
2 changed file(s) with 39 addition(s) and 26 deletion(s). Raw diff Collapse all Expand all
538538 Preds.push_back(Pred);
539539
540540 assert(none_of(Succs,
541 [=](SIScheduleBlock *S) { return PredID == S->getID(); }) &&
541 [=](std::pair
542 SIScheduleBlockLinkKind> S) {
543 return PredID == S.first->getID();
544 }) &&
542545 "Loop in the Block Graph!");
543546 }
544547
545 void SIScheduleBlock::addSucc(SIScheduleBlock *Succ) {
548 void SIScheduleBlock::addSucc(SIScheduleBlock *Succ,
549 SIScheduleBlockLinkKind Kind) {
546550 unsigned SuccID = Succ->getID();
547551
548552 // Check if not already predecessor.
549 for (SIScheduleBlock* S : Succs) {
550 if (SuccID == S->getID())
553 for (std::pair &S : Succs) {
554 if (SuccID == S.first->getID()) {
555 if (S.second == SIScheduleBlockLinkKind::NoData &&
556 Kind == SIScheduleBlockLinkKind::Data)
557 S.second = Kind;
551558 return;
559 }
552560 }
553561 if (Succ->isHighLatencyBlock())
554562 ++NumHighLatencySuccessors;
555 Succs.push_back(Succ);
563 Succs.push_back(std::make_pair(Succ, Kind));
564
556565 assert(none_of(Preds,
557566 [=](SIScheduleBlock *P) { return SuccID == P->getID(); }) &&
558567 "Loop in the Block Graph!");
572581 }
573582
574583 dbgs() << "\nSuccessors:\n";
575 for (SIScheduleBlock* S : Succs) {
576 S->printDebug(false);
584 for (std::pair S : Succs) {
585 if (S.second == SIScheduleBlockLinkKind::Data)
586 dbgs() << "(Data Dep) ";
587 S.first->printDebug(false);
577588 }
578589
579590 if (Scheduled) {
10951106 if (SuccDep.isWeak() || Succ->NodeNum >= DAGSize)
10961107 continue;
10971108 if (Node2CurrentBlock[Succ->NodeNum] != SUID)
1098 CurrentBlocks[SUID]->addSucc(CurrentBlocks[Node2CurrentBlock[Succ->NodeNum]]);
1109 CurrentBlocks[SUID]->addSucc(CurrentBlocks[Node2CurrentBlock[Succ->NodeNum]],
1110 SuccDep.isCtrl() ? NoData : Data);
10991111 }
11001112 for (SDep& PredDep : SU->Preds) {
11011113 SUnit *Pred = PredDep.getSUnit();
12891301 Block->Height = 0;
12901302 else {
12911303 unsigned Height = 0;
1292 for (SIScheduleBlock *Succ : Block->getSuccs()) {
1293 if (Height < Succ->Height + 1)
1294 Height = Succ->Height + 1;
1295 }
1304 for (const auto &Succ : Block->getSuccs())
1305 Height = std::min(Height, Succ.first->Height + 1);
12961306 Block->Height = Height;
12971307 }
12981308 }
15731583 }
15741584
15751585 void SIScheduleBlockScheduler::releaseBlockSuccs(SIScheduleBlock *Parent) {
1576 for (SIScheduleBlock* Block : Parent->getSuccs()) {
1577 --BlockNumPredsLeft[Block->getID()];
1578 if (BlockNumPredsLeft[Block->getID()] == 0) {
1579 ReadyBlocks.push_back(Block);
1580 }
1581 // TODO: Improve check. When the dependency between the high latency
1582 // instructions and the instructions of the other blocks are WAR or WAW
1583 // there will be no wait triggered. We would like these cases to not
1584 // update LastPosHighLatencyParentScheduled.
1585 if (Parent->isHighLatencyBlock())
1586 LastPosHighLatencyParentScheduled[Block->getID()] = NumBlockScheduled;
1586 for (const auto &Block : Parent->getSuccs()) {
1587 if (--BlockNumPredsLeft[Block.first->getID()] == 0)
1588 ReadyBlocks.push_back(Block.first);
1589
1590 if (Parent->isHighLatencyBlock() &&
1591 Block.second == SIScheduleBlockLinkKind::Data)
1592 LastPosHighLatencyParentScheduled[Block.first->getID()] = NumBlockScheduled;
15871593 }
15881594 }
15891595
5252
5353 class SIScheduleDAGMI;
5454 class SIScheduleBlockCreator;
55
56 enum SIScheduleBlockLinkKind {
57 NoData,
58 Data
59 };
5560
5661 class SIScheduleBlock {
5762 SIScheduleDAGMI *DAG;
9196 unsigned ID;
9297
9398 std::vector Preds; // All blocks predecessors.
94 std::vector Succs; // All blocks successors.
99 // All blocks successors, and the kind of link
100 std::vector> Succs;
95101 unsigned NumHighLatencySuccessors = 0;
96102
97103 public:
111117
112118 // Add block pred, which has instruction predecessor of SU.
113119 void addPred(SIScheduleBlock *Pred);
114 void addSucc(SIScheduleBlock *Succ);
120 void addSucc(SIScheduleBlock *Succ, SIScheduleBlockLinkKind Kind);
115121
116122 const std::vector& getPreds() const { return Preds; }
117 const std::vector& getSuccs() const { return Succs; }
123 ArrayRef>
124 getSuccs() const { return Succs; }
118125
119126 unsigned Height; // Maximum topdown path length to block without outputs
120127 unsigned Depth; // Maximum bottomup path length to block without inputs