Skip to content

Commit

Permalink
[AIE] Protect against empty sets
Browse files Browse the repository at this point in the history
Put in some runtime control, a real one based on timeouts, and a deterministic
one pre-deciding based on estimated milliseconds
  • Loading branch information
Martien de Jong committed Jan 22, 2025
1 parent d0f207c commit cdd02e0
Show file tree
Hide file tree
Showing 7 changed files with 243 additions and 105 deletions.
13 changes: 8 additions & 5 deletions llvm/lib/Target/AIE/AIEPostPipeliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ bool PostPipeliner::tryHeuristics() {

DEBUG_SUMMARY(dbgs() << "-- MinLength=" << MinLength << "\n");

if (II <= 10 && solve()) {
if (solve(MinLength / II)) {
return true;
}

Expand Down Expand Up @@ -752,13 +752,12 @@ class FixedStrategy : public PostPipelinerStrategy {
std::string name() override { return "FixedStrategy"; }
};

bool PostPipeliner::solve() {
bool PostPipeliner::solve(int NS) {
if (!UseSolver) {
return false;
}

Z3BinarySolver Solver;
Solver.setScheduleSize(II, 3);
for (int N = 0; N < NInstr; N++) {
SUnit &SU = DAG->SUnits[N];
auto *MI = SU.getInstr();
Expand Down Expand Up @@ -786,7 +785,7 @@ bool PostPipeliner::solve() {
}
}

// Add loop-carried true dependences to future iterations. The iteration
// Add loop-carried dependences to future iterations. The iteration
// distance is taken into account
for (int N = 0; N < NInstr; N++) {
SUnit &SU = DAG->SUnits[N];
Expand All @@ -801,7 +800,11 @@ bool PostPipeliner::solve() {
}
}

if (!Solver.genModel()) {
Solver.setScheduleSize(II, NS);
Solver.genModel();
if (!Solver.solveModel()) {
// Note: If we can't solve it, it doesn't mean the II isn't feasible,
// so we don't need to avoid running the heuristics.
return false;
}
auto Schedule = Solver.getCycles();
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AIE/AIEPostPipeliner.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class PostPipeliner {
int computeMinScheduleLength() const;

// try to find a solution using a solver
bool solve();
bool solve(int NS);

/// Try all heuristics, stop at the first that fits the II
/// If it returns true, a valid schedule is laid down in Info.
Expand Down
Loading

0 comments on commit cdd02e0

Please sign in to comment.