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

Commit 94dc353

Browse files
committed
move getParamValIfFixed to islpp.h
This function wraps isl_set/map_plain_get_val_if_fixed for union sets/maps, and can be useful in different places. Move it to the our extensions for isl bindings and make it a template to accomodate for both sets and maps.
1 parent f736ddb commit 94dc353

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

include/tc/external/detail/islpp.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,21 @@ auto end(L& list) -> ListIter<decltype(list.get(0)), L> {
403403
using detail::begin;
404404
using detail::end;
405405

406+
template <typename T>
407+
isl::val getParamValIfFixed(T t, int pos) {
408+
auto val = isl::val::nan(t.get_ctx());
409+
for (auto set : isl::UnionAsVector<T>(t)) {
410+
auto currentVal = set.plain_get_val_if_fixed(isl::dim_type::param, pos);
411+
if (currentVal.is_nan()) {
412+
return currentVal;
413+
}
414+
if (!val.is_nan() && val != currentVal) {
415+
return isl::val::nan(t.get_ctx());
416+
}
417+
val = currentVal;
418+
}
419+
return val;
420+
}
406421
} // namespace isl
407422

408423
namespace isl {

src/core/polyhedral/memory_promotion_heuristic.cc

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -558,23 +558,6 @@ void promoteGreedilyAtDepth(
558558
mapCopiesToThreads(mscop, unrollCopies);
559559
}
560560

561-
namespace {
562-
isl::val getParamValIfFixed(isl::union_set uset, int pos) {
563-
auto val = isl::val::nan(uset.get_ctx());
564-
for (auto set : isl::UnionAsVector<isl::union_set>(uset)) {
565-
auto currentVal = set.plain_get_val_if_fixed(isl::dim_type::param, pos);
566-
if (currentVal.is_nan()) {
567-
return currentVal;
568-
}
569-
if (!val.is_nan() && val != currentVal) {
570-
return isl::val::nan(uset.get_ctx());
571-
}
572-
val = currentVal;
573-
}
574-
return val;
575-
}
576-
} // namespace
577-
578561
// Assuming the mapping to threads happens in inverse order, i.e. the innermost
579562
// loop is mapped to thread x, promote below that depth.
580563
void promoteToRegistersBelowThreads(
@@ -625,7 +608,7 @@ void promoteToRegistersBelowThreads(
625608
if (id != mapping::ThreadId::makeId(i)) {
626609
continue;
627610
}
628-
if (getParamValIfFixed(points, j) ==
611+
if (isl::getParamValIfFixed(points, j) ==
629612
isl::val::zero(points.get_ctx())) {
630613
continue;
631614
}

0 commit comments

Comments
 (0)