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

Commit 1addda3

Browse files
author
Sven Verdoolaege
committed
[RFC] use templated isl types accessSubscriptsAreUnrolledLoops
Templated isl types require the user to specify the domain and range universes of isl objects, allowing the compiler to check whether it makes sense to combine pairs of objects. This RFC only converts isPromotableToRegistersBelow and some related functions to illustrate the effect. The isPromotableToRegistersBelow was already applying operations correctly, so the code itself did not require any changes. However, one variable was reused to store different types of intermediate result and this one had to be split up into several variables because they now have different types.
1 parent 2142a16 commit 1addda3

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

tc/core/polyhedral/cuda/memory_promotion_heuristic.cc

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -298,11 +298,12 @@ struct Unrolled;
298298
* different references may have different values, but all of them remain
299299
* independent of non-unrolled loop iterators.
300300
*/
301+
template <typename Outer>
301302
bool accessSubscriptsAreUnrolledLoops(
302303
const TensorReferenceGroup& group,
303304
const detail::ScheduleTree* root,
304305
const detail::ScheduleTree* scope,
305-
isl::multi_union_pw_aff outerSchedule) {
306+
isl::MultiUnionPwAff<Statement, Outer> outerSchedule) {
306307
using namespace detail;
307308

308309
auto nodes = ScheduleTree::collect(scope);
@@ -319,14 +320,14 @@ bool accessSubscriptsAreUnrolledLoops(
319320
ancestors.push_back(leaf);
320321
auto subdomain = activeDomainPointsBelow(root, leaf);
321322

322-
auto unrolledDims = isl::union_pw_aff_list(leaf->ctx_, 1);
323+
auto unrolledDims = isl::UnionPwAffListOn<Statement>(leaf->ctx_, 1);
323324
for (auto node : ancestors) {
324-
auto band = node->as<detail::ScheduleTreeBand>();
325+
auto band = node->template as<detail::ScheduleTreeBand>();
325326
if (!band) {
326327
continue;
327328
}
328329

329-
isl::multi_union_pw_aff schedule = band->mupa_;
330+
auto schedule = band->mupa_;
330331
schedule = schedule.intersect_domain(subdomain);
331332
for (size_t i = 0, e = band->nMember(); i < e; ++i) {
332333
if (!band->unroll_[i]) {
@@ -336,21 +337,23 @@ bool accessSubscriptsAreUnrolledLoops(
336337
}
337338
}
338339

339-
auto space = subdomain.get_space().add_unnamed_tuple_ui<Unrolled>(
340+
auto space = subdomain.get_space().template add_unnamed_tuple_ui<Unrolled>(
340341
unrolledDims.size());
341-
auto unrolledDimsMupa = isl::multi_union_pw_aff(space, unrolledDims);
342+
auto unrolledDimsMupa =
343+
isl::MultiUnionPwAff<Statement, Unrolled>(space, unrolledDims);
342344

343345
// It is possible that no loops are unrolled, in which case
344346
// unrolledDimsMupa is zero-dimensional and needs an explicit domain
345347
// to be convertible to a union_map.
346348
unrolledDimsMupa =
347349
unrolledDimsMupa.intersect_domain(group.originalAccesses().domain());
348350

349-
isl::union_map accesses = group.originalAccesses();
350-
auto schedule = outerSchedule.flat_range_product(unrolledDimsMupa);
351-
accesses = accesses.apply_domain(isl::union_map::from(schedule));
351+
auto accesses = group.originalAccesses();
352+
auto schedule = outerSchedule.range_product(unrolledDimsMupa);
353+
auto scheduleMap = schedule.toUnionMap();
354+
auto scheduledAccesses = accesses.apply_domain(scheduleMap);
352355

353-
if (!accesses.is_single_valued()) {
356+
if (!scheduledAccesses.is_single_valued()) {
354357
return false;
355358
}
356359
}

0 commit comments

Comments
 (0)