Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit 60f6a2f

Browse files
author
Sven Verdoolaege
committed
IterationDomain: store outer loop iterators in an isl::multi_id
In an upcoming commit, affine expressions in terms of the outer loop iterators will first be constructed on top of a parameter space and then converted to an affine expression on top of the iteration domain. The isl::multi_id is needed in this conversion. It will also be used inside makeScheduleTreeHelper to construct the iteration domain.
1 parent 41c8399 commit 60f6a2f

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

tc/core/halide2isl.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ extractAccesses(isl::set domain, const Stmt& s, AccessMap* accesses) {
338338
* recursively descending over the Stmt.
339339
* "s" is the current position in the recursive descent.
340340
* "set" describes the bounds on the outer loop iterators.
341-
* "outer" contains the names of the outer loop iterators
341+
* "outer" contains the identifiers of the outer loop iterators
342342
* from outermost to innermost.
343343
* Return the schedule corresponding to the subtree at "s".
344344
*
@@ -353,7 +353,7 @@ extractAccesses(isl::set domain, const Stmt& s, AccessMap* accesses) {
353353
isl::schedule makeScheduleTreeHelper(
354354
const Stmt& s,
355355
isl::set set,
356-
std::vector<std::string>& outer,
356+
isl::id_list outer,
357357
isl::union_map* reads,
358358
isl::union_map* writes,
359359
AccessMap* accesses,
@@ -394,8 +394,7 @@ isl::schedule makeScheduleTreeHelper(
394394
}
395395

396396
// Recursively descend.
397-
auto outerNext = outer;
398-
outerNext.push_back(op->name);
397+
auto outerNext = outer.add(isl::id(set.get_ctx(), op->name));
399398
auto body = makeScheduleTreeHelper(
400399
op->body, set, outerNext, reads, writes, accesses, statements, domains);
401400

@@ -438,8 +437,10 @@ isl::schedule makeScheduleTreeHelper(
438437
size_t stmtIndex = statements->size();
439438
isl::id id(set.get_ctx(), kStatementLabel + std::to_string(stmtIndex));
440439
statements->emplace(id, op);
440+
auto tupleSpace = isl::space(set.get_ctx(), 0);
441+
tupleSpace = tupleSpace.named_set_from_params_id(id, outer.n());
441442
IterationDomain iterationDomain;
442-
iterationDomain.iterators = outer;
443+
iterationDomain.tuple = isl::multi_id(tupleSpace, outer);
443444
domains->emplace(id, iterationDomain);
444445
isl::set domain = set.set_tuple_id(id);
445446
schedule = isl::schedule::from_domain(domain);
@@ -462,7 +463,7 @@ ScheduleTreeAndAccesses makeScheduleTree(isl::space paramSpace, const Stmt& s) {
462463
result.writes = result.reads = isl::union_map::empty(paramSpace);
463464

464465
// Walk the IR building a schedule tree
465-
std::vector<std::string> outer;
466+
isl::id_list outer(paramSpace.get_ctx(), 0);
466467
auto schedule = makeScheduleTreeHelper(
467468
s,
468469
isl::set::universe(paramSpace),

tc/core/halide2isl.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ isl::aff makeIslAffFromExpr(isl::space space, const Halide::Expr& e);
5858

5959
// Iteration domain information associated to a statement identifier.
6060
struct IterationDomain {
61-
// The outer loop iterators, from outermost to innermost.
62-
std::vector<std::string> iterators;
61+
// The identifier tuple corresponding to the iteration domain.
62+
// The identifiers in the tuple are the outer loop iterators,
63+
// from outermost to innermost.
64+
isl::multi_id tuple;
6365
};
6466

6567
typedef std::unordered_map<isl::id, IterationDomain, isl::IslIdIslHash>

tc/core/polyhedral/codegen_llvm.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -637,11 +637,11 @@ isl::ast_node collectIteratorMaps(
637637
auto stmtId = expr.get_arg(0).as<isl::ast_expr_id>().get_id();
638638
TC_CHECK_EQ(0u, iteratorMaps.count(stmtId)) << "entry exists: " << stmtId;
639639
auto iteratorMap = isl::pw_multi_aff(scheduleMap.reverse());
640-
auto iterators = scop.halide.domains.at(stmtId).iterators;
640+
auto tuple = scop.halide.domains.at(stmtId).tuple;
641641
auto& stmtIteratorMap = iteratorMaps[stmtId];
642-
for (size_t i = 0; i < iterators.size(); ++i) {
642+
for (int i = 0; i < tuple.size(); ++i) {
643643
auto expr = build.expr_from(iteratorMap.get_pw_aff(i));
644-
stmtIteratorMap.emplace(iterators[i], expr);
644+
stmtIteratorMap.emplace(tuple.get_id(i).get_name(), expr);
645645
}
646646
auto& subscripts = stmtSubscripts[stmtId];
647647
auto provide =

tc/core/polyhedral/scop.cc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -507,14 +507,12 @@ isl::aff Scop::makeIslAffFromStmtExpr(
507507
isl::id stmtId,
508508
isl::space paramSpace,
509509
const Halide::Expr& e) const {
510-
auto ctx = stmtId.get_ctx();
511-
auto iterators = halide.domains.at(stmtId).iterators;
512-
auto space = paramSpace.named_set_from_params_id(stmtId, iterators.size());
510+
auto tuple = halide.domains.at(stmtId).tuple;
511+
auto space = paramSpace.named_set_from_params_id(stmtId, tuple.size());
513512
// Set the names of the set dimensions of "space" for use
514513
// by halide2isl::makeIslAffFromExpr.
515-
for (size_t i = 0; i < iterators.size(); ++i) {
516-
isl::id id(ctx, iterators[i]);
517-
space = space.set_dim_id(isl::dim_type::set, i, id);
514+
for (int i = 0; i < tuple.size(); ++i) {
515+
space = space.set_dim_id(isl::dim_type::set, i, tuple.get_id(i));
518516
}
519517
return halide2isl::makeIslAffFromExpr(space, e);
520518
}

0 commit comments

Comments
 (0)