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

Commit abe1c98

Browse files
author
Sven Verdoolaege
committed
use templated isl types promotedFootprint
1 parent 331eb12 commit abe1c98

File tree

4 files changed

+21
-15
lines changed

4 files changed

+21
-15
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: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -146,20 +146,20 @@ bool TensorReferenceGroup::isReadOnly() const {
146146
return result;
147147
}
148148

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

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

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

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

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

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

@@ -507,7 +507,7 @@ ScheduleTree* insertCopiesUnder(
507507
// control flow, but we should only write back elements that are actually
508508
// written to. In any case, intersect the footprint with the set of existing
509509
// tensor elements.
510-
auto promotedFootprint = group.promotedFootprint().set_tuple_id(groupId);
510+
auto promotedFootprint = group.promotedFootprint().set_tuple_id<Promoted>(groupId);
511511
auto scheduleUniverse =
512512
isl::set::universe(promotionSpace.domain().unwrap().domain());
513513
auto arrayId = promotionSpace.domain().unwrap().get_map_range_tuple_id();
@@ -517,8 +517,8 @@ ScheduleTree* insertCopiesUnder(
517517
auto readExtension =
518518
extension.intersect_range(approximatedRead).set_range_tuple_id(readId);
519519
auto writtenElements =
520-
group.scopedWrites().intersect_range(tensorElements).wrap();
521-
writtenElements = writtenElements.product(promotedFootprint);
520+
group.scopedWrites().intersect_range(tensorElements).wrap()
521+
.product(promotedFootprint);
522522
auto writeExtension =
523523
extension.intersect_range(writtenElements).set_range_tuple_id(writeId);
524524

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)