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

Commit 0e6c5c5

Browse files
author
Sven Verdoolaege
committed
fixThreadsBelowFilter: reuse mapRemaining
fixThreadsBelowFilter is nearly identical to mapRemaining. The main difference is that fixThreadsBelowFilter performs the mapping below a node because that node may not have any children. Insert an empty band below the node to ensure that there is a child and then simply reuse mapRemaining.
1 parent 5afe8d2 commit 0e6c5c5

File tree

1 file changed

+3
-28
lines changed

1 file changed

+3
-28
lines changed

tc/core/polyhedral/cuda/mapped_scop.cc

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -171,34 +171,9 @@ void fixThreadsBelowFilter(
171171
return;
172172
}
173173

174-
std::unordered_set<mapping::ThreadId, mapping::ThreadId::Hash> ids;
175-
for (size_t i = begin; i < end; ++i) {
176-
ids.insert(mapping::ThreadId::makeId(i));
177-
}
178-
auto root = mscop.schedule();
179-
auto domain = activeDomainPoints(root, filterTree);
180-
auto mappingFilter = makeFixRemainingZeroFilter(domain, ids);
181-
auto filter = filterTree->elemAs<detail::ScheduleTreeElemFilter>();
182-
CHECK(filter) << "Not a filter: " << *filter;
183-
// Active domain points will contain spaces for different statements
184-
// When inserting below a leaf filter, this would break the tightening
185-
// invariant that leaf mapping filters have a single space.
186-
// So we intersect with the universe set of the filter to only keep the
187-
// space for the legitimate statement.
188-
mappingFilter = mappingFilter & filter->filter_.universe();
189-
auto mapping = detail::ScheduleTree::makeMappingFilter(mappingFilter, ids);
190-
insertNodeBelow(filterTree, std::move(mapping));
191-
192-
for (size_t i = begin; i < end; ++i) {
193-
if (mapping::ThreadId::makeId(i) == mapping::ThreadId::x()) {
194-
// Mapping happened below filterTree, so we need points active for its
195-
// children. After insertion, filterTree is guaranteed to have at least
196-
// one child.
197-
mscop.threadIdxXScheduleDepthState.emplace_back(std::make_pair(
198-
activeDomainPoints(mscop.schedule(), filterTree->child({0})),
199-
filterTree->scheduleDepth(mscop.schedule())));
200-
}
201-
}
174+
auto band = detail::ScheduleTree::makeEmptyBand(mscop.scop().scheduleRoot());
175+
auto bandTree = insertNodeBelow(filterTree, std::move(band));
176+
mscop.mapRemaining<mapping::ThreadId>(bandTree, begin);
202177
}
203178

204179
bool MappedScop::detectReductions(detail::ScheduleTree* tree) {

0 commit comments

Comments
 (0)