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

Commit 66e8144

Browse files
author
Sven Verdoolaege
committed
[RFC] use templated isl types constructTensorTuple
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 a6a3b7f commit 66e8144

File tree

5 files changed

+26
-8
lines changed

5 files changed

+26
-8
lines changed

tc/core/halide2isl.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ isl::map extractAccess(
258258
// to the outer loop iterators) and then convert this set
259259
// into a map in terms of the iteration domain.
260260

261-
isl::space paramSpace = domain.paramSpace;
261+
auto paramSpace = isl::Space<>(domain.paramSpace);
262262
isl::id tensorID(paramSpace.get_ctx(), tensor);
263263
auto tensorTuple = constructTensorTuple(paramSpace, tensorID, args.size());
264264
auto tensorSpace = tensorTuple.get_space();

tc/core/polyhedral/domain_types.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace tc {
2+
namespace polyhedral {
3+
4+
struct Prefix;
5+
struct Reduction;
6+
struct ReductionSchedule;
7+
struct Scope;
8+
struct Statement;
9+
struct Tag;
10+
struct Tensor;
11+
struct Thread;
12+
struct Warp;
13+
14+
} // namespace polyhedral
15+
} // namespace tc

tc/core/polyhedral/memory_promotion.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ namespace {
410410
// context of the scop.
411411
isl::set tensorElementsSet(const Scop& scop, isl::id tensorId) {
412412
auto halideParameter = scop.findArgument(tensorId).parameter();
413-
auto space = scop.domain().get_space();
413+
auto space = isl::Space<>(scop.domain().get_space());
414414
auto nDim = halideParameter.dimensions();
415415
auto tensorTuple = constructTensorTuple(space, tensorId, nDim);
416416
auto tensorSpace = tensorTuple.get_space();

tc/core/polyhedral/utils.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616
#include "tc/core/polyhedral/utils.h"
1717

18+
#include "tc/core/polyhedral/domain_types.h"
19+
1820
namespace tc {
1921
namespace polyhedral {
2022

@@ -24,15 +26,15 @@ namespace polyhedral {
2426
* of the user.
2527
* Since some names are required, use names of the form "__tc_tensor_arg*".
2628
*/
27-
isl::multi_id
28-
constructTensorTuple(isl::space paramSpace, isl::id tensorId, size_t dim) {
29-
auto tensorSpace = paramSpace.add_named_tuple_id_ui(tensorId, dim);
29+
isl::MultiId<Tensor>
30+
constructTensorTuple(isl::Space<> paramSpace, isl::id tensorId, size_t dim) {
31+
auto tensorSpace = paramSpace.add_named_tuple_id_ui<Tensor>(tensorId, dim);
3032
isl::id_list tensorArgs(paramSpace.get_ctx(), 0);
3133
for (size_t i = 0; i < dim; ++i) {
3234
auto name = std::string("__tc_tensor_arg") + std::to_string(i);
3335
tensorArgs = tensorArgs.add(isl::id(paramSpace.get_ctx(), name));
3436
}
35-
return isl::multi_id(tensorSpace, tensorArgs);
37+
return isl::MultiId<Tensor>(tensorSpace, tensorArgs);
3638
}
3739

3840
} // namespace polyhedral

tc/core/polyhedral/utils.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
#pragma once
1717

18+
#include "tc/core/polyhedral/domain_types.h"
1819
#include "tc/external/isl.h"
1920

2021
namespace tc {
@@ -24,8 +25,8 @@ namespace polyhedral {
2425
* dimension "dim" from the parameter space "paramSpace",
2526
* without any specific names for the indices.
2627
*/
27-
isl::multi_id
28-
constructTensorTuple(isl::space paramSpace, isl::id tensorId, size_t dim);
28+
isl::MultiId<Tensor>
29+
constructTensorTuple(isl::Space<> paramSpace, isl::id tensorId, size_t dim);
2930

3031
} // namespace polyhedral
3132
} // namespace tc

0 commit comments

Comments
 (0)