Skip to content

Commit

Permalink
Minor refactoration
Browse files Browse the repository at this point in the history
  • Loading branch information
roastduck committed Apr 22, 2024
1 parent 722f909 commit 15d60c1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
23 changes: 11 additions & 12 deletions src/analyze/deps.cc
Original file line number Diff line number Diff line change
Expand Up @@ -407,28 +407,27 @@ std::string AnalyzeDeps::makeCond(GenPBExpr &genPBExpr,
if (isRedundant) {
continue;
}

auto &&[cond, baseStmtId] = condItem;
auto cond_after = normalizeConditionalExpr(cond);
std::string tmp;
if (!ret.empty()) {
ret += " and ";
}
int size = cond_after.size();
for (auto &&[l, r] : cond_after) {
Expr expr_tmp = l;
if (r.isValid()) {
expr_tmp = makeLAnd(l, r);

auto condFactors = normalizeConditionalExpr(cond);
std::string tmp;
for (auto &&[i, factor] : views::enumerate(condFactors)) {
auto &&[l, r] = factor;
if (i > 0) {
tmp += " or ";
}
auto &&[str, vars] = genPBExpr.gen(expr_tmp);
auto &&[str, vars] =
genPBExpr.gen(r.isValid() ? makeLAnd(l, r) : l);
for (auto &&[expr, str] : vars) {
if (expr->nodeType() != ASTNodeType::Var) {
externals[expr] = str;
}
}
tmp += str;
size--;
if (size > 0)
tmp += " or ";
tmp += "(" + str + ")";
}
ret += " ( " + tmp + ")";
}
Expand Down
11 changes: 8 additions & 3 deletions src/schedule/parallelize_as.cc
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,14 @@ Stmt parallelizeAs(const Stmt &_ast, const ID &nest, const ID &reference,
presburger, *acc, acc->iter_.size(), acc->access_.size(), "",
externals, {}, true);
if (!externals.empty()) {
throw InvalidSchedule(
FT_MSG << "Indirect thread mapping in reference loop nest "
<< reference << " is not supported");
MessageBuilder err;
err << "Indirect thread mapping in reference loop nest "
<< reference
<< " is not supported. Indirection expressions are: ";
for (auto &&[expr, _] : externals) {
err << expr << ", ";
}
throw InvalidSchedule(err);
}

std::unordered_map<std::string, For> iter2Scope;
Expand Down

0 comments on commit 15d60c1

Please sign in to comment.