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

Commit a6618b1

Browse files
author
Sven Verdoolaege
committed
Scop::makeIslAffFromStmtExpr: construct affine expression in parameter space
This is a further step towards allowing makeIslAffBoundsFromExpr to only work in terms of parameters. In particular, it removes a reliance on the names of set dimensions. Since the parameter space is taken from the iteration domain, the parameter space argument to Scop::makeIslAffFromStmtExpr is no longer needed.
1 parent 220ff68 commit a6618b1

File tree

4 files changed

+11
-23
lines changed

4 files changed

+11
-23
lines changed

tc/core/polyhedral/codegen_llvm.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,7 @@ isl::ast_node collectIteratorMaps(
648648
scop.halide.statements.at(stmtId).as<Halide::Internal::Provide>();
649649
for (auto e : provide->args) {
650650
const auto& map = iteratorMap;
651-
auto space = map.get_space().params();
652-
auto aff = scop.makeIslAffFromStmtExpr(stmtId, space, e);
651+
auto aff = scop.makeIslAffFromStmtExpr(stmtId, e);
653652
auto pulled = isl::pw_aff(aff).pullback(map);
654653
TC_CHECK_EQ(pulled.n_piece(), 1);
655654
subscripts.push_back(build.expr_from(pulled));

tc/core/polyhedral/cuda/codegen.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ struct CodegenStatementContext : CodegenContext {
136136
// of the variables does not correspond to a parameter or
137137
// an instance identifier of the statement.
138138
isl::aff makeIslAffFromExpr(const Halide::Expr& e) const {
139-
auto space = iteratorMap().get_space().params();
140-
return scop().makeIslAffFromStmtExpr(statementId(), space, e);
139+
return scop().makeIslAffFromStmtExpr(statementId(), e);
141140
}
142141

143142
isl::id astNodeId;

tc/core/polyhedral/scop.cc

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -503,18 +503,12 @@ const Halide::OutputImageParam& Scop::findArgument(isl::id id) const {
503503
return *halide.inputs.begin();
504504
}
505505

506-
isl::aff Scop::makeIslAffFromStmtExpr(
507-
isl::id stmtId,
508-
isl::space paramSpace,
509-
const Halide::Expr& e) const {
510-
auto tuple = halide.domains.at(stmtId).tuple;
511-
auto space = paramSpace.named_set_from_params_id(stmtId, tuple.size());
512-
// Set the names of the set dimensions of "space" for use
513-
// by halide2isl::makeIslAffFromExpr.
514-
for (int i = 0; i < tuple.size(); ++i) {
515-
space = space.set_dim_id(isl::dim_type::set, i, tuple.get_id(i));
516-
}
517-
return halide2isl::makeIslAffFromExpr(space, e);
506+
isl::aff Scop::makeIslAffFromStmtExpr(isl::id stmtId, const Halide::Expr& e)
507+
const {
508+
auto domain = halide.domains.at(stmtId);
509+
auto aff = halide2isl::makeIslAffFromExpr(domain.paramSpace, e);
510+
aff = aff.unbind_params_insert_domain(domain.tuple);
511+
return aff;
518512
}
519513

520514
} // namespace polyhedral

tc/core/polyhedral/scop.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -411,15 +411,11 @@ struct Scop {
411411
const Halide::OutputImageParam& findArgument(isl::id id) const;
412412

413413
// Make an affine function from a Halide Expr that is defined
414-
// over the instance set of the statement with identifier "stmtId" and
415-
// with parameters specified by "paramSpace". Return a
416-
// null isl::aff if the expression is not affine. Fail if any
414+
// over the instance set of the statement with identifier "stmtId".
415+
// Return a null isl::aff if the expression is not affine. Fail if any
417416
// of the variables does not correspond to a parameter or
418417
// an instance identifier of the statement.
419-
isl::aff makeIslAffFromStmtExpr(
420-
isl::id stmtId,
421-
isl::space paramSpace,
422-
const Halide::Expr& e) const;
418+
isl::aff makeIslAffFromStmtExpr(isl::id stmtId, const Halide::Expr& e) const;
423419

424420
// Promote a tensor reference group to a storage of a given "kind",
425421
// inserting the copy

0 commit comments

Comments
 (0)