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

Commit 05e56c5

Browse files
committed
fullSchedule: handle innermost zero-dimensional bands
Existing implementation of fullSchedule iteratively takes a flat product of multi union piecewise affine expressions with partial schedule, starting from the innermost band. It also intersects the domain of the multi union piecewise affine expression with the filter sets. However, if the innermost band is zero-dimensional, it is expected to have an explicit domain, which it does not in this case. The domain intersection then fails. Collect the domain information separately from taking flat ranges and intersect the domain of the affine expression only after it was fully constructed.
1 parent d2e2460 commit 05e56c5

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/core/polyhedral/memory_promotion_heuristic.cc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ void mapCopiesToThreads(MappedScop& mscop, bool unroll) {
121121
/*
122122
* Transform schedule bands into a union_map.
123123
* Takes all partial schedules at leaves as MUPAs (without accounting for
124-
* intermediate non-band nodes), transforms them into union maps and intersects
124+
* intermediate non-band nodes), intersects
125125
* their domain with the filters between the root and the
126-
* current leaves.
126+
* current leaves and transforms them into union maps.
127127
* Mapping filters are ignored.
128128
*/
129129
isl::union_map fullSchedule(const detail::ScheduleTree* root) {
@@ -145,21 +145,24 @@ isl::union_map fullSchedule(const detail::ScheduleTree* root) {
145145
auto schedule = isl::union_map::empty(
146146
root->elemAs<ScheduleTreeElemDomain>()->domain_.get_space());
147147
for (auto node : leaves) {
148+
auto domain = root->elemAs<ScheduleTreeElemDomain>()->domain_;
148149
auto prefixMupa = prefixScheduleMupa(root, node);
149150
if (auto band = node->elemAs<ScheduleTreeElemBand>()) {
150151
prefixMupa = prefixMupa.flat_range_product(band->mupa_);
151152
}
152-
auto current = isl::union_map::from(prefixMupa);
153153

154154
auto pathToRoot = node->ancestors(root);
155155
pathToRoot.push_back(node);
156156
for (auto n : pathToRoot) {
157157
if (auto filterNode = n->elemAs<ScheduleTreeElemFilter>()) {
158-
current = current.intersect_domain(filterNode->filter_);
158+
domain = domain.intersect(filterNode->filter_);
159159
}
160160
}
161161

162-
schedule = schedule.unite(current);
162+
prefixMupa = isl::manage(isl_multi_union_pw_aff_intersect_domain(
163+
prefixMupa.release(), domain.copy()));
164+
165+
schedule = schedule.unite(isl::union_map::from(prefixMupa));
163166
if (!schedule.is_single_valued()) {
164167
std::stringstream ss;
165168
ss << "schedules must be single-valued " << schedule << std::endl

0 commit comments

Comments
 (0)