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

Commit bd2e9e8

Browse files
committed
move extractDomainToThread into MappedScop, and rename to threadMappingSchedule
This function will be used in the following commits outside of mapped_scop.cc and must become a part of the visible API. Additionally, as a member of MappedScop, it can obtain the number of mapped threads directly.
1 parent 2fb2c39 commit bd2e9e8

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

tc/core/polyhedral/cuda/mapped_scop.cc

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -466,24 +466,6 @@ constexpr auto kBlock = "block";
466466
// Name of the space of warps
467467
constexpr auto kWarp = "warp";
468468

469-
/*
470-
* Extract a mapping from the domain elements active at "tree"
471-
* to the thread identifiers, where all branches in "tree"
472-
* are assumed to have been mapped to thread identifiers.
473-
* "nThread" is the number of thread identifiers.
474-
* The result lives in a space of the form block[x, ...].
475-
*/
476-
isl::multi_union_pw_aff extractDomainToThread(
477-
const detail::ScheduleTree* tree,
478-
size_t nThread) {
479-
std::vector<mapping::MappingId> ids;
480-
for (size_t i = 0; i < nThread; ++i) {
481-
ids.emplace_back(mapping::ThreadId::makeId(i));
482-
}
483-
auto tupleId = isl::id(tree->ctx_, kBlock);
484-
return extractDomainToIds(tree, ids, tupleId);
485-
}
486-
487469
/*
488470
* Construct a mapping
489471
*
@@ -518,6 +500,16 @@ isl::multi_aff constructThreadToWarp(
518500
}
519501
} // namespace
520502

503+
isl::multi_union_pw_aff MappedScop::threadMappingSchedule(
504+
const detail::ScheduleTree* tree) const {
505+
std::vector<mapping::MappingId> ids;
506+
for (size_t i = 0; i < numThreads.view.size(); ++i) {
507+
ids.emplace_back(mapping::ThreadId::makeId(i));
508+
}
509+
auto tupleId = isl::id(tree->ctx_, kBlock);
510+
return extractDomainToIds(tree, ids, tupleId);
511+
}
512+
521513
Scop::SyncLevel MappedScop::findBestSync(
522514
detail::ScheduleTree* st1,
523515
detail::ScheduleTree* st2,
@@ -708,7 +700,7 @@ void MappedScop::insertBestSyncInSeq(detail::ScheduleTree* seq) {
708700

709701
auto outer = hasOuterSequentialMember(scop_->scheduleRoot(), seq);
710702

711-
auto domainToThread = extractDomainToThread(seq, numThreads.view.size());
703+
auto domainToThread = threadMappingSchedule(seq);
712704
auto threadToWarp = constructThreadToWarp(seq->ctx_, 32, numThreads);
713705
auto domainToWarp = domainToThread.apply(threadToWarp);
714706

tc/core/polyhedral/cuda/mapped_scop.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,13 @@ class MappedScop {
186186
size_t nChildren,
187187
bool hasOuterSequentialMember);
188188

189+
// Extract a mapping from the domain elements active at "tree"
190+
// to the thread identifiers, where all branches in "tree"
191+
// are assumed to have been mapped to thread identifiers.
192+
// The result lives in a space of the form block[x, ...].
193+
isl::multi_union_pw_aff threadMappingSchedule(
194+
const detail::ScheduleTree* tree) const;
195+
189196
private:
190197
// Insert the optimal combination of synchronizations in the sequence
191198
void insertBestSyncInSeq(detail::ScheduleTree* seq);

0 commit comments

Comments
 (0)