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

Commit 1ec2911

Browse files
committed
do not include filter constraints in original accesses
Initial implementation of TensorReference instances was costructing original access maps by intersecting the domain of scop-wise access maps with the set of active domain points obtained by traversing the tree. This set can contain constraints coming from mapping filters, which would have to be removed for further analyses. Initial implementation was gisting the domain of the access relation with itself in an attempt to remove these constranits. It does not work fully because these constraints typically fix some input dimensions of a map to parameters modulo constant, which triggers similar fixing of the output dimensions related to the input dimensions. When constructing TensorReferences, do not use the result of intersecting the scop-wise access maps with active domain points. Instead, only check if this intersection is not empty before adding the original (unconstrained) access relation. Whenever it is necessary in shared memory promotion heuristic, pass the set of active domain points and intersect access relations locally.
1 parent d8437a8 commit 1ec2911

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/core/polyhedral/memory_promotion.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,11 @@ void addSingletonReferenceGroups(
321321
// access relations have a shape :: [D -> ref] -> O
322322
// use currying to isolate the D part before intersecting with the domain
323323
// Compute initial groups with single reference per group.
324-
accesses = accesses.curry().intersect_domain(domain).uncurry();
325324
for (auto a : isl::UnionAsVector<isl::union_map>(accesses)) {
325+
if (isl::union_map(a.curry()).intersect_domain(domain).is_empty()) {
326+
continue;
327+
}
328+
326329
auto tensorId = a.get_tuple_id(isl::dim_type::out);
327330
addSingletonReferenceGroup(tensorGroups, tensorId, schedule, a, type);
328331
}

src/core/polyhedral/memory_promotion_heuristic.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ size_t computeThreadIdxxScheduleDepth(
278278
bool isCoalesced(
279279
const ThreadIdxxScheduleDepthState& threadIdxxScheduleDepthState,
280280
const TensorReferenceGroup& group,
281-
isl::union_map schedule) {
281+
isl::union_map schedule,
282+
isl::union_set activePoints) {
282283
auto originalAccesses = group.originalAccesses();
283284

284285
for (auto accessMap : isl::UnionAsVector<isl::union_map>(originalAccesses)) {
@@ -288,7 +289,7 @@ bool isCoalesced(
288289
tensorSpace, tensorSpace.dim(isl::dim_type::set) - 1);
289290
auto domainUMap = isl::union_set(isl::set(access.domain()));
290291
int threadIdxxDepth = computeThreadIdxxScheduleDepth(
291-
threadIdxxScheduleDepthState, domainUMap);
292+
threadIdxxScheduleDepthState, domainUMap.intersect(activePoints));
292293
auto partialScheduleUMap =
293294
schedule.intersect_domain(domainUMap.universe());
294295
if (partialScheduleUMap.n_map() != 1) {
@@ -398,6 +399,7 @@ void promoteToSharedGreedy(
398399
auto groupMap = TensorReferenceGroup::accessedBySubtree(bandNode, scop);
399400
auto activeStmts = activeStatements(root, bandNode);
400401
auto partialSched = partialSchedule(root, bandNode);
402+
auto activePoints = activeDomainPoints(root, bandNode);
401403

402404
// Prepare groups for sorting, to have specified order necessary for
403405
// reproducibility and tests.
@@ -457,7 +459,11 @@ void promoteToSharedGreedy(
457459
// Do not promote if the group features no reuse and is accessed in a
458460
// coalesced way.
459461
if (!hasReuse(*group, fullSched, depth) &&
460-
isCoalesced(threadIdxxScheduleDepthState, *group, fullSched)) {
462+
isCoalesced(
463+
threadIdxxScheduleDepthState,
464+
*group,
465+
fullSched,
466+
activePoints)) {
461467
continue;
462468
}
463469

0 commit comments

Comments
 (0)