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

Commit 0c6bb7f

Browse files
author
Sven Verdoolaege
committed
promotedFootprint: use templated isl types
1 parent b0a06e3 commit 0c6bb7f

File tree

4 files changed

+26
-18
lines changed

4 files changed

+26
-18
lines changed

tc/core/polyhedral/domain_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ namespace polyhedral {
33

44
struct Band;
55
struct Prefix;
6+
struct Promoted;
67
struct Reduction;
78
struct ReductionSchedule;
89
struct Scope;

tc/core/polyhedral/memory_promotion.cc

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -147,20 +147,20 @@ bool TensorReferenceGroup::isReadOnly() const {
147147
return result;
148148
}
149149

150-
isl::set TensorReferenceGroup::promotedFootprint() const {
150+
isl::Set<Tensor> TensorReferenceGroup::promotedFootprint() const {
151151
auto space = scopedAccesses().get_space().range();
152152
auto sizes = approximation.box.get_size();
153153
if (!sizes.get_space().has_equal_tuples(space)) {
154154
throw promotion::GroupingError("unexpected dimensionality mismatch");
155155
}
156156

157-
isl::set footprint = isl::set::universe(space);
158-
auto identity = isl::multi_aff::identity(space.map_from_set());
157+
isl::Set<Tensor> footprint = isl::Set<Tensor>::universe(space);
158+
auto identity = isl::MultiAff<Tensor, Tensor>::identity(space.map_from_set());
159159
for (size_t i = 0, e = sizes.size(); i < e; ++i) {
160160
auto aff = identity.get_aff(i);
161161
auto size = sizes.get_val(i);
162-
footprint =
163-
footprint & (isl::aff_set(aff) >= 0) & (isl::aff_set(aff) < size);
162+
footprint = footprint & aff.asPwAff().nonneg_set() &
163+
(size - aff).asPwAff().pos_set();
164164
}
165165
return footprint;
166166
}
@@ -175,14 +175,14 @@ std::vector<size_t> TensorReferenceGroup::approximationSizes() const {
175175
}
176176

177177
namespace {
178-
isl::map referenceScopedAccessesImpl(
178+
isl::Map<Scope, Tensor> referenceScopedAccessesImpl(
179179
const TensorReferenceGroup& group,
180180
AccessType type) {
181181
if (group.references.size() == 0) {
182182
throw promotion::GroupingError("no references in the group");
183183
}
184-
auto accesses =
185-
isl::map::empty(group.references.front()->scopedAccess.get_space());
184+
auto accesses = isl::Map<Scope, Tensor>::empty(
185+
group.references.front()->scopedAccess.get_space());
186186

187187
for (const auto& ref : group.references) {
188188
if (ref->type != type) {
@@ -203,11 +203,11 @@ isl::set TensorReferenceGroup::readFootprint() const {
203203
return referenceScopedAccessesImpl(*this, AccessType::Read).range();
204204
}
205205

206-
isl::map TensorReferenceGroup::scopedWrites() const {
206+
isl::Map<Scope, Tensor> TensorReferenceGroup::scopedWrites() const {
207207
return referenceScopedAccessesImpl(*this, AccessType::Write);
208208
}
209209

210-
isl::map TensorReferenceGroup::scopedReads() const {
210+
isl::Map<Scope, Tensor> TensorReferenceGroup::scopedReads() const {
211211
return referenceScopedAccessesImpl(*this, AccessType::Read);
212212
}
213213

@@ -509,7 +509,8 @@ ScheduleTree* insertCopiesUnder(
509509
// control flow, but we should only write back elements that are actually
510510
// written to. In any case, intersect the footprint with the set of existing
511511
// tensor elements.
512-
auto promotedFootprint = group.promotedFootprint().set_tuple_id(groupId);
512+
auto promotedFootprint =
513+
group.promotedFootprint().set_tuple_id<Promoted>(groupId);
513514
auto scheduleUniverse =
514515
isl::set::universe(promotionSpace.domain().unwrap().domain());
515516
auto arrayId = promotionSpace.domain().unwrap().get_map_range_tuple_id();
@@ -518,9 +519,10 @@ ScheduleTree* insertCopiesUnder(
518519
approximatedRead = approximatedRead.product(promotedFootprint);
519520
auto readExtension =
520521
extension.intersect_range(approximatedRead).set_range_tuple_id(readId);
521-
auto writtenElements =
522-
group.scopedWrites().intersect_range(tensorElements).wrap();
523-
writtenElements = writtenElements.product(promotedFootprint);
522+
auto writtenElements = group.scopedWrites()
523+
.intersect_range(tensorElements)
524+
.wrap()
525+
.product(promotedFootprint);
524526
auto writeExtension =
525527
extension.intersect_range(writtenElements).set_range_tuple_id(writeId);
526528

tc/core/polyhedral/memory_promotion.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ class TensorReferenceGroup {
126126
}
127127

128128
// Access relations in terms of partial schedule of the scoping point.
129-
isl::map scopedWrites() const;
130-
isl::map scopedReads() const;
131-
isl::map scopedAccesses() const {
129+
isl::Map<Scope, Tensor> scopedWrites() const;
130+
isl::Map<Scope, Tensor> scopedReads() const;
131+
isl::Map<Scope, Tensor> scopedAccesses() const {
132132
return scopedWrites().unite(scopedReads());
133133
}
134134

@@ -146,7 +146,7 @@ class TensorReferenceGroup {
146146
isl::map approximateScopedAccesses() const;
147147

148148
isl::multi_aff promotion() const;
149-
isl::set promotedFootprint() const;
149+
isl::Set<Tensor> promotedFootprint() const;
150150

151151
std::vector<size_t> approximationSizes() const;
152152

tc/external/detail/islpp.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ inline T operator-(T a, T b) {
4545
return a.sub(b);
4646
}
4747

48+
template <typename T>
49+
inline auto operator-(isl::val a, T b) -> decltype(b.add_constant(a)) {
50+
return b.neg().add_constant(a);
51+
}
52+
4853
template <typename T>
4954
inline T operator&(T S1, T S2) {
5055
return S1.intersect(S2);

0 commit comments

Comments
 (0)