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

Commit 822494f

Browse files
committed
introduce a Kind of a promoted declaration
A kernel variable can be declared as shared or as automatic (register).
1 parent feed0a4 commit 822494f

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

include/tc/core/polyhedral/scop.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,11 @@ struct Scop {
306306
void promoteEverythingAt(std::vector<size_t> pos);
307307

308308
struct PromotedDecl {
309+
enum class Kind { SharedMem, Register };
310+
309311
isl::id tensorId;
310312
std::vector<size_t> sizes;
313+
Kind kind;
311314
};
312315

313316
struct PromotionInfo {
@@ -356,7 +359,8 @@ struct Scop {
356359
// Assumes such argument exists.
357360
const Halide::OutputImageParam& findArgument(isl::id id) const;
358361

359-
// Promote a tensor reference group to shared memory, inserting the copy
362+
// Promote a tensor reference group to a storage of a given "kind",
363+
// inserting the copy
360364
// statements below the given node. Inserts an Extension node below the give
361365
// node, unless there is already another Extension node which introduces
362366
// copies. The Extension node has a unique Sequence child, whose children
@@ -368,7 +372,8 @@ struct Scop {
368372
// If "forceLastExtentOdd" is set, the last extent in the declaration is
369373
// incremented if it is even. This serves as a simple heuristic to reduce
370374
// shared memory bank conflicts.
371-
void promoteGroupToShared(
375+
void promoteGroup(
376+
PromotedDecl::Kind kind,
372377
isl::id tensorId,
373378
std::unique_ptr<TensorReferenceGroup>&& gr,
374379
detail::ScheduleTree* tree,

src/core/polyhedral/memory_promotion_heuristic.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,8 @@ void promoteToSharedGreedy(
530530
continue;
531531
}
532532

533-
scop.promoteGroupToShared(
533+
scop.promoteGroup(
534+
Scop::PromotedDecl::Kind::SharedMem,
534535
tensorId,
535536
std::move(group),
536537
bandNode,

src/core/polyhedral/scop.cc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ void checkFiltersDisjointStatements(const ScheduleTree* root) {
179179
}
180180
} // namespace
181181

182-
void Scop::promoteGroupToShared(
182+
void Scop::promoteGroup(
183+
PromotedDecl::Kind kind,
183184
isl::id tensorId,
184185
std::unique_ptr<TensorReferenceGroup>&& gr,
185186
ScheduleTree* tree,
@@ -192,7 +193,7 @@ void Scop::promoteGroupToShared(
192193
if (sizes.size() > 0 && forceLastExtentOdd && (sizes.back() % 2) == 0) {
193194
sizes.back() += 1;
194195
}
195-
promotedDecls_[groupId] = PromotedDecl{tensorId, sizes};
196+
promotedDecls_[groupId] = PromotedDecl{tensorId, sizes, kind};
196197

197198
auto group = std::shared_ptr<TensorReferenceGroup>(std::move(gr));
198199
for (const auto& id : activeStmts) {
@@ -248,7 +249,13 @@ void Scop::promoteEverythingAt(std::vector<size_t> pos) {
248249
auto groupMap = TensorReferenceGroup::accessedBySubtree(tree, *this);
249250
for (auto& p : groupMap) {
250251
for (auto& gr : p.second) {
251-
promoteGroupToShared(p.first, std::move(gr), tree, activeStmts, schedule);
252+
promoteGroup(
253+
PromotedDecl::Kind::SharedMem,
254+
p.first,
255+
std::move(gr),
256+
tree,
257+
activeStmts,
258+
schedule);
252259
}
253260
}
254261
insertSyncsAroundCopies(tree);

0 commit comments

Comments
 (0)