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

Commit 167d414

Browse files
author
Sven Verdoolaege
committed
mapRemaining: drop redundant size argument
mapRemaining is always used to map all remaining block/thread identifiers and there is no need to specify the total number of those identifiers since this can be derived from the identifier type.
1 parent 847e091 commit 167d414

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

tc/core/polyhedral/cuda/mapped_scop.cc

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,26 @@ isl::union_set makeFixRemainingZeroFilter(
9191
bool anyNonCoincidentMember(const detail::ScheduleTreeElemBand* band) {
9292
return band->nOuterCoincident() < band->nMember();
9393
}
94+
95+
/*
96+
* Return a reference to the mapping sizes
97+
* for the mapping of type "MappingTypeId".
98+
*/
99+
template <typename MappingTypeId>
100+
const CudaDim& mappingSize(const MappedScop* mscop);
101+
template <>
102+
const CudaDim& mappingSize<mapping::BlockId>(const MappedScop* mscop) {
103+
return mscop->numBlocks;
104+
}
105+
template <>
106+
const CudaDim& mappingSize<mapping::ThreadId>(const MappedScop* mscop) {
107+
return mscop->numThreads;
108+
}
94109
} // namespace
95110

96111
template <typename MappingTypeId>
97-
void MappedScop::mapRemaining(
98-
detail::ScheduleTree* tree,
99-
size_t nMapped,
100-
size_t nToMap) {
112+
void MappedScop::mapRemaining(detail::ScheduleTree* tree, size_t nMapped) {
113+
size_t nToMap = mappingSize<MappingTypeId>(this).view.size();
101114
if (nMapped >= nToMap) {
102115
return;
103116
}
@@ -140,7 +153,7 @@ void MappedScop::mapToBlocksAndScaleBand(
140153
for (size_t i = 0; i < nBlocksToMap; ++i) {
141154
band = map(band, i, mapping::BlockId::makeId(i));
142155
}
143-
mapRemaining<mapping::BlockId>(band, nBlocksToMap, numBlocks.view.size());
156+
mapRemaining<mapping::BlockId>(band, nBlocksToMap);
144157
bandScale(band, tileSizes);
145158
}
146159

@@ -462,7 +475,7 @@ size_t MappedScop::mapInnermostBandsToThreads(detail::ScheduleTree* st) {
462475
// because we cannot map parent bands anyway.
463476
auto nMapped = mapToThreads(st);
464477
if (nMapped > 0) {
465-
mapRemaining<mapping::ThreadId>(st, nMapped, numThreads.view.size());
478+
mapRemaining<mapping::ThreadId>(st, nMapped);
466479
markUnroll(scop_->scheduleRoot(), st, unroll);
467480
return numThreads.view.size();
468481
}
@@ -645,8 +658,7 @@ std::unique_ptr<MappedScop> MappedScop::makeWithOuterBlockInnerThreadStrategy(
645658
auto child = outerBand->child({0});
646659
size_t numMappedInnerThreads =
647660
mappedScop->mapInnermostBandsToThreads(child);
648-
mappedScop->mapRemaining<mapping::ThreadId>(
649-
child, numMappedInnerThreads, mappedScop->numThreads.view.size());
661+
mappedScop->mapRemaining<mapping::ThreadId>(child, numMappedInnerThreads);
650662
LOG_IF(INFO, FLAGS_debug_tc_mapper)
651663
<< "After mapping to threads:" << std::endl
652664
<< *mappedScop->schedule();

tc/core/polyhedral/cuda/mapped_scop.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ class MappedScop {
102102
}
103103

104104
// Given that "nMapped" identifiers of type "MappingTypeId" have already
105-
// been mapped, map the remaining ones (up to "nToMap") to zero
105+
// been mapped, map the remaining ones to zero
106106
// for all statement instances.
107107
template <typename MappingTypeId>
108-
void mapRemaining(detail::ScheduleTree* tree, size_t nMapped, size_t nToMap);
108+
void mapRemaining(detail::ScheduleTree* tree, size_t nMapped);
109109

110110
// Fix the values of the specified parameters in the context
111111
// to the corresponding specified values.

tc/core/polyhedral/cuda/memory_promotion_heuristic.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ void mapCopiesToThreads(MappedScop& mscop, bool unroll) {
115115
mscop.numThreads.view[t]);
116116
++t;
117117
}
118-
mscop.mapRemaining<mapping::ThreadId>(
119-
bandNode, t, mscop.numThreads.view.size());
118+
mscop.mapRemaining<mapping::ThreadId>(bandNode, t);
120119

121120
// Unroll if requested.
122121
if (unroll) {

0 commit comments

Comments
 (0)