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

Commit 41c8399

Browse files
author
Sven Verdoolaege
committed
halide2isl: store outer loop iterators in IterationDomain structure
This will make it easier to change the representation of the outer loop iterators and to add extra information related to the iteration domain.
1 parent 8426352 commit 41c8399

File tree

5 files changed

+23
-22
lines changed

5 files changed

+23
-22
lines changed

tc/core/halide2isl.cc

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,8 @@ extractAccesses(isl::set domain, const Stmt& s, AccessMap* accesses) {
347347
* (for the writes) to the corresponding tag in the access relations.
348348
* "statements" collects the mapping from instance set tuple identifiers
349349
* to the corresponding Provide node.
350-
* "iterators" collects the mapping from instance set tuple identifiers
351-
* to the corresponding outer loop iterator names, from outermost to innermost.
350+
* "domains" collects the mapping from instance set tuple identifiers
351+
* to the corresponding iteration domain information.
352352
*/
353353
isl::schedule makeScheduleTreeHelper(
354354
const Stmt& s,
@@ -358,7 +358,7 @@ isl::schedule makeScheduleTreeHelper(
358358
isl::union_map* writes,
359359
AccessMap* accesses,
360360
StatementMap* statements,
361-
IteratorMap* iterators) {
361+
IterationDomainMap* domains) {
362362
isl::schedule schedule;
363363
if (auto op = s.as<For>()) {
364364
// Add one additional dimension to our set of loop variables
@@ -397,14 +397,7 @@ isl::schedule makeScheduleTreeHelper(
397397
auto outerNext = outer;
398398
outerNext.push_back(op->name);
399399
auto body = makeScheduleTreeHelper(
400-
op->body,
401-
set,
402-
outerNext,
403-
reads,
404-
writes,
405-
accesses,
406-
statements,
407-
iterators);
400+
op->body, set, outerNext, reads, writes, accesses, statements, domains);
408401

409402
// Create an affine function that defines an ordering for all
410403
// the statements in the body of this loop over the values of
@@ -434,7 +427,7 @@ isl::schedule makeScheduleTreeHelper(
434427
std::vector<isl::schedule> schedules;
435428
for (Stmt stmt : stmts) {
436429
schedules.push_back(makeScheduleTreeHelper(
437-
stmt, set, outer, reads, writes, accesses, statements, iterators));
430+
stmt, set, outer, reads, writes, accesses, statements, domains));
438431
}
439432
schedule = schedules[0].sequence(schedules[1]);
440433

@@ -445,7 +438,9 @@ isl::schedule makeScheduleTreeHelper(
445438
size_t stmtIndex = statements->size();
446439
isl::id id(set.get_ctx(), kStatementLabel + std::to_string(stmtIndex));
447440
statements->emplace(id, op);
448-
iterators->emplace(id, outer);
441+
IterationDomain iterationDomain;
442+
iterationDomain.iterators = outer;
443+
domains->emplace(id, iterationDomain);
449444
isl::set domain = set.set_tuple_id(id);
450445
schedule = isl::schedule::from_domain(domain);
451446

@@ -476,7 +471,7 @@ ScheduleTreeAndAccesses makeScheduleTree(isl::space paramSpace, const Stmt& s) {
476471
&result.writes,
477472
&result.accesses,
478473
&result.statements,
479-
&result.iterators);
474+
&result.domains);
480475

481476
result.tree = fromIslSchedule(schedule);
482477

tc/core/halide2isl.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,14 @@ isl::aff makeIslAffFromInt(isl::space space, int64_t i);
5656
// does not correspond to a parameter or set dimension of the space.
5757
isl::aff makeIslAffFromExpr(isl::space space, const Halide::Expr& e);
5858

59-
typedef std::unordered_map<isl::id, std::vector<std::string>, isl::IslIdIslHash>
60-
IteratorMap;
59+
// Iteration domain information associated to a statement identifier.
60+
struct IterationDomain {
61+
// The outer loop iterators, from outermost to innermost.
62+
std::vector<std::string> iterators;
63+
};
64+
65+
typedef std::unordered_map<isl::id, IterationDomain, isl::IslIdIslHash>
66+
IterationDomainMap;
6167
typedef std::unordered_map<isl::id, Halide::Internal::Stmt, isl::IslIdIslHash>
6268
StatementMap;
6369
typedef std::unordered_map<const Halide::Internal::IRNode*, isl::id> AccessMap;
@@ -81,9 +87,9 @@ struct ScheduleTreeAndAccesses {
8187
/// refered to above.
8288
StatementMap statements;
8389

84-
/// The correspondence between statement ids and the outer loop iterators
90+
/// The correspondence between statement ids and the iteration domain
8591
/// of the corresponding leaf Stmt.
86-
IteratorMap iterators;
92+
IterationDomainMap domains;
8793
};
8894

8995
/// Make a schedule tree from a Halide Stmt, along with auxiliary data

tc/core/polyhedral/codegen_llvm.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ 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.iterators.at(stmtId);
640+
auto iterators = scop.halide.domains.at(stmtId).iterators;
641641
auto& stmtIteratorMap = iteratorMaps[stmtId];
642642
for (size_t i = 0; i < iterators.size(); ++i) {
643643
auto expr = build.expr_from(iteratorMap.get_pw_aff(i));

tc/core/polyhedral/scop.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ ScopUPtr Scop::makeScop(
6464
scop->halide.statements = std::move(tree.statements);
6565
scop->halide.accesses = std::move(tree.accesses);
6666
scop->halide.reductions = halide2isl::findReductions(components.stmt);
67-
scop->halide.iterators = std::move(tree.iterators);
67+
scop->halide.domains = std::move(tree.domains);
6868

6969
return scop;
7070
}
@@ -508,7 +508,7 @@ isl::aff Scop::makeIslAffFromStmtExpr(
508508
isl::space paramSpace,
509509
const Halide::Expr& e) const {
510510
auto ctx = stmtId.get_ctx();
511-
auto iterators = halide.iterators.at(stmtId);
511+
auto iterators = halide.domains.at(stmtId).iterators;
512512
auto space = paramSpace.named_set_from_params_id(stmtId, iterators.size());
513513
// Set the names of the set dimensions of "space" for use
514514
// by halide2isl::makeIslAffFromExpr.

tc/core/polyhedral/scop.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ struct Scop {
490490
std::unordered_map<isl::id, Halide::Internal::Stmt, isl::IslIdIslHash>
491491
statements;
492492
std::unordered_map<const Halide::Internal::IRNode*, isl::id> accesses;
493-
halide2isl::IteratorMap iterators;
493+
halide2isl::IterationDomainMap domains;
494494
} halide;
495495

496496
// Polyhedral IR

0 commit comments

Comments
 (0)