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

Commit cd0b955

Browse files
author
Sven Verdoolaege
committed
[RFC] use templated isl types Body
Templated isl types require the user to specify the domain and range universes of isl objects, allowing the compiler to check whether it makes sense to combine pairs of objects. This RFC only converts isPromotableToRegistersBelow and some related functions to illustrate the effect. The isPromotableToRegistersBelow was already applying operations correctly, so the code itself did not require any changes. However, one variable was reused to store different types of intermediate result and this one had to be split up into several variables because they now have different types.
1 parent 1d3d270 commit cd0b955

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

tc/core/polyhedral/body.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include <iostream>
1919

20+
#include "tc/core/polyhedral/domain_types.h"
2021
#include "tc/external/isl.h"
2122

2223
namespace tc {
@@ -26,11 +27,13 @@ namespace polyhedral {
2627
struct Body {
2728
Body() = default;
2829
Body(isl::space paramSpace) {
29-
reductions = writes = reads = isl::union_map::empty(paramSpace);
30+
auto empty = isl::union_map::empty(paramSpace);
31+
writes = reads = isl::UnionMap<isl::Pair<Statement, Tag>, Tensor>(empty);
32+
reductions = isl::UnionMap<Statement, Reduction>(empty);
3033
}
3134

3235
// Specialize to the given context.
33-
void specialize(isl::set context) {
36+
void specialize(isl::Set<> context) {
3437
reads = reads.intersect_params(context);
3538
writes = writes.intersect_params(context);
3639
reductions = reductions.intersect_params(context);
@@ -39,7 +42,7 @@ struct Body {
3942
// Union maps describing the reads and writes done. Uses the ids in
4043
// the schedule tree to denote the containing Stmt, and tags each
4144
// access with a unique reference id of the form __tc_ref_N.
42-
isl::union_map reads, writes;
45+
isl::UnionMap<isl::Pair<Statement, Tag>, Tensor> reads, writes;
4346

4447
// A function on reduction update statement instances that partitions them
4548
// into individual reductions, where each reduction consists of
@@ -73,7 +76,7 @@ struct Body {
7376
// That is, in the example above, it would just be
7477
//
7578
// { S[i] -> R[] : 0 <= i < 4 }
76-
isl::union_map reductions;
79+
isl::UnionMap<Statement, Reduction> reductions;
7780
};
7881

7982
std::ostream& operator<<(std::ostream& os, const Body& body);

tc/core/polyhedral/reduction_matcher.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,18 @@ bool isSupportedReductionUpdateId(isl::id id, const Scop& scop) {
5454

5555
} // namespace
5656

57-
isl::UnionSet<Statement> reductionUpdates(isl::union_set domain, const Scop& scop) {
57+
isl::UnionSet<Statement> reductionUpdates(
58+
isl::UnionSet<Statement> domain,
59+
const Scop& scop) {
5860
domain = scop.body.reductions.intersect_domain(domain).domain();
59-
auto update = isl::union_set::empty(domain.get_space());
60-
domain.foreach_set([&update, &scop](isl::set set) {
61+
auto update = isl::UnionSet<Statement>::empty(domain.get_space());
62+
domain.foreach_set([&update, &scop](isl::Set<Statement> set) {
6163
auto setId = set.get_tuple_id();
6264
if (isSupportedReductionUpdateId(setId, scop)) {
6365
update = update.unite(set);
6466
}
6567
});
66-
return isl::UnionSet<Statement>(update);
68+
return update;
6769
}
6870

6971
} // namespace polyhedral

tc/core/polyhedral/schedule_tree_matcher.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ namespace polyhedral {
2828

2929
// Return the union of the reduction update statements
3030
// that appear in "domain".
31-
isl::UnionSet<Statement> reductionUpdates(isl::union_set domain, const Scop& scop);
31+
isl::UnionSet<Statement> reductionUpdates(
32+
isl::UnionSet<Statement> domain,
33+
const Scop& scop);
3234

3335
// Does "prefix" partition "domain" into individual reductions?
3436
// In particular, do the elements of "domain" access a single tensor

0 commit comments

Comments
 (0)