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

Commit b9550b7

Browse files
committed
memory promotion heuristic: introduce collectMappingsTo
This function returns the union of all mapping filters that map to the given type of mapping ids. It is similar in functionality to extractDomainToIds except for the return type. In particular, it ignores elements introduced by extension nodes. It will be used to collect block and thread mappings in the following commits.
1 parent ee49486 commit b9550b7

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tc/core/polyhedral/cuda/memory_promotion_heuristic.cc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,29 @@ bool promotionImprovesCoalescing(
323323
return false;
324324
}
325325

326+
/*
327+
* Returns the union of all mapping filters to "MappingType" in "scop".
328+
*
329+
* Note: similarly to MappedScop::[thread|block]MappingSchedule, this function
330+
* does not take into account elements introduced by extension nodes.
331+
*/
332+
template <typename MappingType>
333+
isl::union_set collectMappingsTo(const Scop& scop) {
334+
auto root = scop.scheduleRoot();
335+
auto domain = scop.domain();
336+
auto mappingFilters = detail::ScheduleTree::collect(
337+
root, detail::ScheduleTreeType::MappingFilter);
338+
mappingFilters = functional::Filter(isMappingTo<MappingType>, mappingFilters);
339+
auto mapping = isl::union_set::empty(domain.get_space());
340+
for (auto mf : mappingFilters) {
341+
auto filterNode = mf->elemAs<detail::ScheduleTreeElemMappingFilter>();
342+
auto filter = filterNode->filter_.intersect(
343+
activeDomainPointsNoMappingNoExtension(root, mf));
344+
mapping = mapping.unite(filterNode->filter_);
345+
}
346+
return mapping;
347+
}
348+
326349
/*
327350
* Check if the given "group" can be promoted to registers for the given
328351
* mapping to thread identifiers and within the given outer schedule.

0 commit comments

Comments
 (0)