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

Commit 67fc014

Browse files
author
Sven Verdoolaege
committed
MappedScop::reductionMapSchedule: extract out ScheduleTreeElemBand::memberRange
This function will be reused in the next commit.
1 parent 14df3a2 commit 67fc014

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

tc/core/polyhedral/cuda/mapped_scop.cc

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -299,19 +299,13 @@ isl::multi_union_pw_aff MappedScop::reductionMapSchedule(
299299
auto reductionBand = st->elemAs<detail::ScheduleTreeElemBand>();
300300
TC_CHECK(reductionBand);
301301

302-
// Drop band members following the reduction dimension and preceding those
303-
// mapped to threads.
304-
auto reductionSchedule = reductionBand->mupa_;
305302
auto nMember = reductionBand->nMember();
306303
auto reductionDim = reductionBand->nOuterCoincident();
307304
auto nMappedThreads = numThreads.view.size();
308305
TC_CHECK_GE(nMember, reductionDim + 1);
309-
reductionSchedule = reductionSchedule.drop_dims(
310-
isl::dim_type::set, reductionDim + 1, nMember - (reductionDim + 1));
311-
reductionSchedule = reductionSchedule.drop_dims(
312-
isl::dim_type::set, 0, reductionDim - nMappedThreads + 1);
313306

314-
return reductionSchedule;
307+
auto first = reductionDim + 1 - nMappedThreads;
308+
return reductionBand->memberRange(first, nMappedThreads);
315309
}
316310

317311
detail::ScheduleTree* MappedScop::separateReduction(detail::ScheduleTree* st) {

tc/core/polyhedral/schedule_tree_elem.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,18 @@ void ScheduleTreeElemBand::drop(size_t pos, size_t n) {
175175
TC_CHECK_EQ(nBegin - n, nMember());
176176
}
177177

178+
isl::multi_union_pw_aff ScheduleTreeElemBand::memberRange(
179+
size_t first,
180+
size_t n) const {
181+
auto list = mupa_.get_union_pw_aff_list();
182+
auto space = addRange(mupa_.get_space().domain(), n);
183+
auto end = first + n;
184+
TC_CHECK_LE(end, nMember());
185+
list = list.drop(end, nMember() - end);
186+
list = list.drop(0, first);
187+
return isl::multi_union_pw_aff(space, list);
188+
}
189+
178190
bool ScheduleTreeElemBand::operator==(const ScheduleTreeElemBand& other) const {
179191
if (permutable_ != other.permutable_) {
180192
return false;

tc/core/polyhedral/schedule_tree_elem.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,10 @@ struct ScheduleTreeElemBand : public ScheduleTreeElemBase {
248248
// behavior with respect to changes in the schedule space.
249249
void drop(size_t pos, size_t n);
250250

251+
// Extract the range of "n" members starting at "first"
252+
// (in an anonymous space).
253+
isl::multi_union_pw_aff memberRange(size_t first, size_t n) const;
254+
251255
public:
252256
bool permutable_{false};
253257
isl::multi_union_pw_aff mupa_;

0 commit comments

Comments
 (0)