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

Commit ef975a1

Browse files
author
Sven Verdoolaege
committed
Scop::makeScop: extract out halide2isl::makeParamContext
It is more convenient and more natural to iterate over the parameters in the symbol table and these belong to halide2isl.
1 parent 20f696b commit ef975a1

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

tc/core/halide2isl.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,16 @@ isl::space makeParamSpace(isl::ctx ctx, const SymbolTable& symbolTable) {
228228
return space;
229229
}
230230

231+
isl::set makeParamContext(isl::ctx ctx, const SymbolTable& symbolTable) {
232+
auto space = makeParamSpace(ctx, symbolTable);
233+
auto context = isl::set::universe(space);
234+
for (auto p : symbolTable.params) {
235+
isl::aff a(isl::aff::param_on_domain_space(space, isl::id(ctx, p.name())));
236+
context = context & (a >= 0);
237+
}
238+
return context;
239+
}
240+
231241
isl::map extractAccess(
232242
isl::set domain,
233243
const IRNode* op,

tc/core/halide2isl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ SymbolTable makeSymbolTable(const tc2halide::HalideComponents& components);
4343
/// Make the space of all parameter values from the symbol table
4444
isl::space makeParamSpace(isl::ctx ctx, const SymbolTable& symbolTable);
4545

46+
/// Make the parameter set marking all parameters from the symbol table
47+
/// as non-negative.
48+
isl::set makeParamContext(isl::ctx ctx, const SymbolTable& symbolTable);
49+
4650
/// Make a constant-valued affine function over a space.
4751
isl::aff makeIslAffFromInt(isl::space space, int64_t i);
4852

tc/core/polyhedral/scop.cc

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,8 @@ ScopUPtr Scop::makeScop(
4747

4848
halide2isl::SymbolTable sym = halide2isl::makeSymbolTable(components);
4949

50-
isl::space paramSpace = halide2isl::makeParamSpace(ctx, sym);
51-
auto globalParameterContext = isl::set::universe(paramSpace);
52-
isl::local_space ls(globalParameterContext.get_space());
53-
for (int i = 0; i < globalParameterContext.dim(isl::dim_type::param); ++i) {
54-
globalParameterContext =
55-
globalParameterContext & (isl::aff(ls, isl::dim_type::param, i) >= 0);
56-
}
50+
auto globalParameterContext = halide2isl::makeParamContext(ctx, sym);
51+
isl::space paramSpace = globalParameterContext.get_space();
5752

5853
ScopUPtr scop(new Scop());
5954
scop->globalParameterContext = globalParameterContext;

0 commit comments

Comments
 (0)