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

Commit ee49486

Browse files
committed
transform isThreadMapping into a function template isMappingTo
Thus it can be reused for blocks in the following commits.
1 parent cb4c7ce commit ee49486

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tc/core/polyhedral/cuda/memory_promotion_heuristic.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,16 @@ bool isMappingIdType(const mapping::MappingId& id) {
4848
}
4949

5050
/*
51-
* Is "tree" a mapping filter that maps a thread identifier?
51+
* Is "tree" a mapping filter that maps identifiers of the type provided as
52+
* template argument?
5253
*/
53-
bool isThreadMapping(const detail::ScheduleTree* tree) {
54+
template <typename MappingType>
55+
bool isMappingTo(const detail::ScheduleTree* tree) {
5456
using namespace detail;
5557

5658
if (auto filterNode = tree->elemAs<ScheduleTreeElemMappingFilter>()) {
5759
for (auto& kvp : filterNode->mapping) {
58-
if (isMappingIdType<mapping::ThreadId>(kvp.first)) {
60+
if (isMappingIdType<MappingType>(kvp.first)) {
5961
return true;
6062
}
6163
}
@@ -100,7 +102,7 @@ void mapCopiesToThreads(MappedScop& mscop, bool unroll) {
100102
// Check that we are not mapping to threads below other thread mappings.
101103
std::unordered_set<mapping::ThreadId, mapping::ThreadId::Hash> usedThreads;
102104
for (auto n : node->ancestors(root)) {
103-
if (isThreadMapping(n)) {
105+
if (isMappingTo<mapping::ThreadId>(n)) {
104106
throw promotion::PromotionBelowThreadsException(
105107
"attempted to map memory copies to threads below "
106108
"another thread mapping");
@@ -257,7 +259,7 @@ const detail::ScheduleTree* findThreadMappingAncestor(
257259
const detail::ScheduleTree* root,
258260
const detail::ScheduleTree* node) {
259261
auto ancestors = node->ancestors(root);
260-
ancestors = functional::Filter(isThreadMapping, ancestors);
262+
ancestors = functional::Filter(isMappingTo<mapping::ThreadId>, ancestors);
261263
if (ancestors.size() < 1) {
262264
throw promotion::PromotionLogicError("missing MappingFilter");
263265
}

0 commit comments

Comments
 (0)