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

Commit 02e6781

Browse files
committed
promoteToSharedBelow: disallow promotion anywhere below thread mapping
Shared memory is accessible from all threads. If promotion is requested below the thread mapping, the scoped tensor reference groups are specific to threads, guaranteeing no reuse between different threads. It does not make sense to use shared memory in such cases. Furthermore, if one attempted to use shared memory below thread mapping, e.g., to hide global memory latency, one would have to account for the pre-existing thread mapping when emitting shared<->global memory copies.
1 parent 56a0343 commit 02e6781

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

tc/core/polyhedral/cuda/memory_promotion_heuristic.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,17 @@ void promoteToSharedBelow(
440440
size_t& remainingMemory) {
441441
auto root = scop.scheduleRoot();
442442

443+
// Promotion to shared below threads does not make sense because the computed
444+
// groups would be specific to threads thus not benefiting from coalescing or
445+
// inter-thread communication through shared memory (use registers instead).
446+
auto ancestors = node->ancestors(root);
447+
ancestors.push_back(node);
448+
for (auto ancestor : ancestors) {
449+
if (isMappingTo<mapping::ThreadId>(ancestor)) {
450+
throw promotion::IncorrectScope(
451+
"shared memory promotion below thread mapping");
452+
}
453+
}
443454
// Children of a sequence/set band must be filters, but promotion would
444455
// insert an extension node.
445456
if (node->as<detail::ScheduleTreeSequence>() ||

test/test_cuda_mapper_memory_promotion.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,12 +439,10 @@ TEST_F(MapperMemoryPromotionRAW, fitAtOuterDepths) {
439439

440440
TEST_F(MapperMemoryPromotionRAW, throwIfCopiesBelowThreads) {
441441
EXPECT_THROW(
442-
makeWithSharedGreedy(42, 40, 64, 64, 3, 8192),
443-
promotion::PromotionBelowThreadsException);
442+
makeWithSharedGreedy(42, 40, 64, 64, 3, 8192), promotion::IncorrectScope);
444443

445444
EXPECT_THROW(
446-
makeWithSharedGreedy(42, 40, 64, 64, 4, 8192),
447-
promotion::PromotionBelowThreadsException);
445+
makeWithSharedGreedy(42, 40, 64, 64, 4, 8192), promotion::IncorrectScope);
448446
}
449447

450448
class MatMulBias : public TestMapper {

0 commit comments

Comments
 (0)