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

Commit cb4c7ce

Browse files
committed
transform isThreadId into a function template isMappingIdType
Thus it can be reused for block ids in the following commits.
1 parent 5b95adb commit cb4c7ce

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

tc/core/polyhedral/cuda/memory_promotion_heuristic.cc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,17 @@ namespace tc {
3434
namespace polyhedral {
3535
namespace {
3636

37-
bool isThreadId(const mapping::MappingId& id) {
38-
return id == mapping::ThreadId::x() or id == mapping::ThreadId::y() or
39-
id == mapping::ThreadId::z();
37+
/*
38+
* Is "id" a mapping of the type provided as template argument?
39+
*/
40+
template <typename MappingType>
41+
bool isMappingIdType(const mapping::MappingId& id) {
42+
for (size_t i = 0; i < MappingType::kMaxDim; ++i) {
43+
if (id == MappingType::makeId(i)) {
44+
return true;
45+
}
46+
}
47+
return false;
4048
}
4149

4250
/*
@@ -47,7 +55,7 @@ bool isThreadMapping(const detail::ScheduleTree* tree) {
4755

4856
if (auto filterNode = tree->elemAs<ScheduleTreeElemMappingFilter>()) {
4957
for (auto& kvp : filterNode->mapping) {
50-
if (isThreadId(kvp.first)) {
58+
if (isMappingIdType<mapping::ThreadId>(kvp.first)) {
5159
return true;
5260
}
5361
}

0 commit comments

Comments
 (0)