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

Commit fc63411

Browse files
author
Sven Verdoolaege
committed
move warning on positive minimal mapping to MappedScop::map
tightenLaunchBounds logs a warning if the minimum of the block or thread mapping is strictly positive since it would be possible to shift the mapping over that minimum and further tighten the bounds. Given the current infrastructure of TC, it is fairly unlikely that this would happen and especially for this to happen consistently over the entire tree. Furthermore, by the time tightenLaunchBounds is called it is too late to change the mapping. Move the warning to where the mapping is constructed and where it could in principle still be adjusted.
1 parent 6ff195e commit fc63411

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

tc/core/polyhedral/cuda/mapped_scop.cc

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,26 @@ namespace polyhedral {
4848

4949
namespace {
5050

51+
/*
52+
* Check if the minimum of any affine function in "list" is strictly
53+
* positive on "domain" and, if so, print a warning.
54+
* The functions in "list" are used for mapping to block/thread identifiers.
55+
* If the minimum is strictly positive, then this means some
56+
* identifiers do nothing in the corresponding subtree.
57+
* Note that tightenLaunchBounds (if extended to consider
58+
* the minimal value of the mapping) may not help much because
59+
* those identifiers may get used in other parts of the tree.
60+
* Furthermore, at that point it is too late to change the mapping.
61+
*/
62+
static void checkMinimum(isl::union_set domain, isl::union_pw_aff_list list) {
63+
for (auto upa : list) {
64+
upa = upa.intersect_domain(domain);
65+
auto min = upa.min_val();
66+
LOG_IF(WARNING, min.is_pos())
67+
<< "Opportunity for shifting mapping -> min:" << min;
68+
}
69+
}
70+
5171
template <typename ExceptionType>
5272
inline void throwIfHasPattern(
5373
ScheduleTreeMatcher matcher,
@@ -111,7 +131,8 @@ detail::ScheduleTree* MappedScop::map(
111131
TC_CHECK_LE(nToMap, extent.size()) << "dimension overflow";
112132

113133
auto root = scop_->scheduleRoot();
114-
auto domain = activeDomainPoints(root, tree).universe();
134+
auto domain = activeDomainPoints(root, tree);
135+
auto universe = domain.universe();
115136

116137
std::vector<MappingTypeId> idList;
117138
auto affList = isl::union_pw_aff_list(list.get_ctx(), 0);
@@ -127,10 +148,12 @@ detail::ScheduleTree* MappedScop::map(
127148
for (size_t i = nToMap; i < extent.size(); ++i) {
128149
auto id = MappingTypeId::makeId(i);
129150
affList = affList.add(
130-
isl::union_pw_aff(domain, isl::val::zero(domain.get_ctx())));
151+
isl::union_pw_aff(universe, isl::val::zero(domain.get_ctx())));
131152
idList.emplace_back(id);
132153
}
133154

155+
checkMinimum(domain, affList);
156+
134157
auto mapping = detail::ScheduleTree::makeMapping(idList, affList);
135158
tree = insertNodeAbove(root, tree, std::move(mapping))->child({0});
136159

tc/core/polyhedral/cuda/tighten_launch_bounds.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@ size_t maxValue(const Scop& scop, const MappingIdType& id) {
8484
min = std::min(min, range.first);
8585
max = std::max(max, range.second);
8686
}
87-
// Ignore min for now but there is a future possibility for shifting
88-
LOG_IF(WARNING, min > 0)
89-
<< "Opportunity for tightening launch bounds with shifting -> min:"
90-
<< min;
9187
TC_CHECK(max < sizetMax) << "missing mapping to " << id << "\n" << *root;
9288
TC_CHECK(min < sizetMax) << "missing mapping to " << id << " type\n" << *root;
9389
// Inclusive range needs + 1 to translate to sizes

0 commit comments

Comments
 (0)