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

Commit c8ffe57

Browse files
author
Sven Verdoolaege
committed
emitMappedTensorAccess: extract out emitAccess
This allows the function to be reused for printing tensors in copy statements in the next commit.
1 parent 804fdf5 commit c8ffe57

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/core/polyhedral/cuda/codegen.cc

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,17 @@ void emitReductionInit(
359359
context.ss << ";" << endl;
360360
}
361361

362+
namespace {
363+
template <typename AFF>
364+
void emitAccess(AFF access, const CodegenStatementContext& context) {
365+
// Use a temporary isl::ast_build to print the expression.
366+
// Ideally, this should use the build at the point
367+
// where the user statement was created.
368+
auto astBuild = isl::ast_build::from_context(access.domain());
369+
context.ss << astBuild.access_from(access).to_C_str();
370+
}
371+
} // namespace
372+
362373
void emitCopyStmt(const CodegenStatementContext& context) {
363374
using detail::emitDirectSubscripts;
364375

@@ -613,8 +624,7 @@ void emitMappedTensorAccess(
613624
auto astToPromoted =
614625
isl::pw_multi_aff(promotion).pullback(astToScheduledOriginal);
615626

616-
auto astBuild = isl::ast_build::from_context(astToPromoted.domain());
617-
context.ss << astBuild.access_from(astToPromoted).to_C_str();
627+
emitAccess(astToPromoted, context);
618628
}
619629

620630
void emitDirectSubscripts(

0 commit comments

Comments
 (0)