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

Commit eb1cb66

Browse files
committed
introduce MappedScop::blockMappingSchedule
By analogy with MappedScop::threadMappingSchedule, this function constructs the mapping of domain elements to blocks as multi_union_pw_aff. It will be used in the subsequent commits.
1 parent bd2e9e8 commit eb1cb66

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

tc/core/polyhedral/cuda/mapped_scop.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,8 @@ bool hasOuterSequentialMember(
461461
return false;
462462
}
463463

464+
// Name of the space of blocks inside the grid
465+
constexpr auto kGrid = "grid";
464466
// Name of the space of threads inside a block
465467
constexpr auto kBlock = "block";
466468
// Name of the space of warps
@@ -510,6 +512,16 @@ isl::multi_union_pw_aff MappedScop::threadMappingSchedule(
510512
return extractDomainToIds(tree, ids, tupleId);
511513
}
512514

515+
isl::multi_union_pw_aff MappedScop::blockMappingSchedule(
516+
const detail::ScheduleTree* tree) const {
517+
std::vector<mapping::MappingId> ids;
518+
for (size_t i = 0; i < numBlocks.view.size(); ++i) {
519+
ids.emplace_back(mapping::BlockId::makeId(i));
520+
}
521+
auto tupleId = isl::id(tree->ctx_, kGrid);
522+
return extractDomainToIds(scop_->scheduleRoot(), tree, ids, tupleId);
523+
}
524+
513525
Scop::SyncLevel MappedScop::findBestSync(
514526
detail::ScheduleTree* st1,
515527
detail::ScheduleTree* st2,

tc/core/polyhedral/cuda/mapped_scop.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,13 @@ class MappedScop {
193193
isl::multi_union_pw_aff threadMappingSchedule(
194194
const detail::ScheduleTree* tree) const;
195195

196+
// Extract a mapping from the domain elements active at "tree"
197+
// to the block identifiers, where all branches in "tree"
198+
// are assumed to have been mapped to block identifiers.
199+
// The result lives in a space of the form grid[x, ...].
200+
isl::multi_union_pw_aff blockMappingSchedule(
201+
const detail::ScheduleTree* tree) const;
202+
196203
private:
197204
// Insert the optimal combination of synchronizations in the sequence
198205
void insertBestSyncInSeq(detail::ScheduleTree* seq);

0 commit comments

Comments
 (0)