Skip to content

Commit

Permalink
[AIE] Dump critical path when failing
Browse files Browse the repository at this point in the history
  • Loading branch information
Martien de Jong committed Nov 18, 2024
1 parent 9f3e514 commit a0d79fd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
39 changes: 27 additions & 12 deletions llvm/lib/Target/AIE/AIEPostPipeliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const SlotCounts &Val) {
return OS;
}

namespace {
void dumpEarliestChain(const std::vector<NodeInfo> &Info, int N) {
int Prev = Info[N].LastEarliestPusher;
if (Prev >= 0) {
dumpEarliestChain(Info, Prev);
}
dbgs() << " --> " << N << " @" << Info[N].Cycle << "\n";
}
} // namespace

// The core of the PostPipeliner is simple. We are presented with a DAG that
// represents enough copies of the body to reach the steady state of the loop.
// NInstr is the number of instructions in the original body, the number of
Expand Down Expand Up @@ -197,6 +207,7 @@ void PostPipeliner::scheduleNode(SUnit &SU, int Cycle) {
const int SNum = Succ->NodeNum;
const int NewEarliest = Cycle + Latency;
if (NewEarliest > Info[SNum].Earliest) {
Info[SNum].LastEarliestPusher = SU.NodeNum;
Info[SNum].Earliest = NewEarliest;
LLVM_DEBUG(dbgs() << SNum << " to " << Info[SNum].Earliest << " -; ");
}
Expand All @@ -210,6 +221,7 @@ void PostPipeliner::scheduleNode(SUnit &SU, int Cycle) {
const int PNum = Pred->NodeNum;
const int NewLatest = Cycle - Latency;
if (NewLatest < Info[PNum].Latest) {
Info[PNum].LastLatestPusher = SU.NodeNum;
Info[PNum].Latest = NewLatest;
LLVM_DEBUG(dbgs() << PNum << " to - " << Info[PNum].Latest << "; ");
}
Expand Down Expand Up @@ -453,17 +465,19 @@ int PostPipeliner::mostUrgent(PostPipelinerStrategy &Strategy) {

void PostPipeliner::resetSchedule() {
Scoreboard.clear();
for (int K = 0; K < NInstr; K++) {
auto &N = Info[K];
N.Earliest = N.StaticEarliest;
N.Latest = N.StaticLatest;
N.Cycle = 0;
N.Scheduled = false;
}
for (int K = NInstr; K < NTotalInstrs; K++) {
for (int K = 0; K < NTotalInstrs; K++) {
auto &N = Info[K];
N.Earliest = 0;
N.Latest = -1;
N.LastEarliestPusher = -1;
N.LastLatestPusher = -1;
if (K < NInstr) {
N.Earliest = N.StaticEarliest;
N.Latest = N.StaticLatest;
N.Cycle = 0;
N.Scheduled = false;
} else {
N.Earliest = 0;
N.Latest = -1;
}
}

FirstUnscheduled = 0;
Expand Down Expand Up @@ -527,8 +541,9 @@ bool PostPipeliner::scheduleOtherIterations() {

// All iterations following the first one should fit exactly
if (Earliest > Insert) {
LLVM_DEBUG(dbgs() << " Latency not met (Earliest=" << Earliest
<< ")\n");
LLVM_DEBUG(dbgs() << " Latency not met for " << N
<< "(Earliest=" << Earliest << ")\n";
dumpEarliestChain(Info, N););
return false;
}

Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/Target/AIE/AIEPostPipeliner.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ class NodeInfo {
// implies a minimum stagecount.
int Latest = -1;

// Record critical path components
int LastEarliestPusher = -1;
int LastLatestPusher = -1;

// Latest corrected taking Earliest of an LCD successor into account
int LCDLatest = -1;

Expand Down

0 comments on commit a0d79fd

Please sign in to comment.