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

Commit ddbe6a9

Browse files
author
Sven Verdoolaege
committed
test_mapper.cc: do not assume parameters have a fixed position
It doesn't really matter for the use cases in test_mapper.cc because all parameters get assigned the same value, but it allows this variant of makeContext to be removed. Replace it by one that takes an initializer_list.
1 parent 0cbd6b8 commit ddbe6a9

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

include/tc/core/polyhedral/scop.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ struct Scop {
118118
writes = writes.intersect_params(globalParameterContext);
119119
}
120120

121-
// Returns a set that specializes (all) the scop's parameter space to the
122-
// integer values passed to the function.
123-
// WARNING: this version relies on parameter ordering, be sure you know what
124-
// you are doing.
121+
// Returns a set that specializes the named scop's subset of
122+
// parameter space to the integer values passed to the function.
125123
template <typename T>
126-
isl::set makeContext(const std::vector<T>& sizes = std::vector<T>()) const {
124+
isl::set makeContext(
125+
const std::unordered_map<std::string, T>& sizes =
126+
std::unordered_map<std::string, T>()) const {
127127
auto s = domain().get_space().params();
128128
return makeSpecializationSet(s, sizes);
129129
}
@@ -132,8 +132,7 @@ struct Scop {
132132
// parameter space to the integer values passed to the function.
133133
template <typename T>
134134
isl::set makeContext(
135-
const std::unordered_map<std::string, T>& sizes =
136-
std::unordered_map<std::string, T>()) const {
135+
std::initializer_list<std::pair<const std::string, T>> sizes) {
137136
auto s = domain().get_space().params();
138137
return makeSpecializationSet(s, sizes);
139138
}

include/tc/external/detail/islpp.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,14 @@ inline isl::set makeSpecializationSet(
348348
return makeSpecializationSet(space, aux);
349349
}
350350

351+
template <typename T>
352+
inline isl::set makeSpecializationSet(
353+
isl::space space,
354+
std::initializer_list<std::pair<const std::string, T>> paramValues) {
355+
std::unordered_map<std::string, T> map(paramValues);
356+
return makeSpecializationSet(space, map);
357+
}
358+
351359
// WARNING: this version relies on parameter ordering, be sure you know what
352360
// you are doing.
353361
template <typename T>

test/test_mapper.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ TEST_F(PolyhedralMapperTest, MergedContexts) {
333333
auto scop = PrepareAndJoinBands(makeMatmulTc());
334334

335335
// Unit test claims to use scop->globalParameterContext properly
336-
auto context = scop->makeContext(std::vector<int>{64, 64, 64});
336+
auto context = scop->makeContext<int>({{"M", 64}, {"N", 64}, {"K", 64}});
337337
auto& globalParameterContext =
338338
const_cast<isl::set&>(scop->globalParameterContext);
339339
globalParameterContext = globalParameterContext.intersect(context);
@@ -349,7 +349,7 @@ TEST_F(PolyhedralMapperTest, FilterMerge) {
349349
auto schedule = scop->scheduleRoot();
350350

351351
// Unit test claims to use scop->globalParameterContext properly
352-
auto context = scop->makeContext(std::vector<int>{64, 64, 64});
352+
auto context = scop->makeContext<int>({{"M", 64}, {"N", 64}, {"K", 64}});
353353
auto& globalParameterContext =
354354
const_cast<isl::set&>(scop->globalParameterContext);
355355
globalParameterContext = globalParameterContext.intersect(context);

0 commit comments

Comments
 (0)