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

Commit d758224

Browse files
author
Sven Verdoolaege
committed
emitCopyStmt: use emitAccess
Do this mainly for consistency with the emitAccess in emitMappedTensorAccess and to simplify the code. It also removes a call to toString(isl::pw_aff), which can then be inlined in the next commit.
1 parent c8ffe57 commit d758224

File tree

2 files changed

+6
-27
lines changed

2 files changed

+6
-27
lines changed

include/tc/core/polyhedral/cuda/codegen.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ struct CodegenStatementContext;
3131

3232
namespace detail {
3333

34-
void emitDirectSubscripts(
35-
isl::pw_multi_aff subscripts,
36-
const CodegenStatementContext& context);
37-
3834
std::string toString(isl::pw_aff subscript);
3935

4036
isl::pw_aff makeAffFromMappedExpr(

src/core/polyhedral/cuda/codegen.cc

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -371,27 +371,21 @@ void emitAccess(AFF access, const CodegenStatementContext& context) {
371371
} // namespace
372372

373373
void emitCopyStmt(const CodegenStatementContext& context) {
374-
using detail::emitDirectSubscripts;
375-
376374
auto stmtId = context.statementId();
377375

378376
auto iteratorMap = context.iteratorMap();
379377
auto promoted = iteratorMap.range_factor_range();
380378
auto original = iteratorMap.range_factor_domain().range_factor_range();
381379
auto isRead = stmtId.get_name() == kReadIdName;
382-
auto originalName = original.get_tuple_id(isl::dim_type::out).get_name();
383-
auto promotedName = promoted.get_tuple_id(isl::dim_type::out).get_name();
384380

385381
if (isRead) {
386-
context.ss << promotedName;
387-
emitDirectSubscripts(promoted, context);
388-
context.ss << " = " << originalName;
389-
emitDirectSubscripts(original, context);
382+
emitAccess(isl::multi_pw_aff(promoted), context);
383+
context.ss << " = ";
384+
emitAccess(isl::multi_pw_aff(original), context);
390385
} else {
391-
context.ss << originalName;
392-
emitDirectSubscripts(original, context);
393-
context.ss << " = " << promotedName;
394-
emitDirectSubscripts(promoted, context);
386+
emitAccess(isl::multi_pw_aff(original), context);
387+
context.ss << " = ";
388+
emitAccess(isl::multi_pw_aff(promoted), context);
395389
}
396390
context.ss << ";" << std::endl;
397391
}
@@ -627,17 +621,6 @@ void emitMappedTensorAccess(
627621
emitAccess(astToPromoted, context);
628622
}
629623

630-
void emitDirectSubscripts(
631-
isl::pw_multi_aff subscripts,
632-
const CodegenStatementContext& context) {
633-
auto mpa = isl::multi_pw_aff(subscripts); // this conversion is safe
634-
for (auto pa : isl::MPA(mpa)) {
635-
context.ss << "[";
636-
context.ss << toString(pa.pa);
637-
context.ss << "]";
638-
}
639-
}
640-
641624
} // namespace detail
642625

643626
// TODO: b0,b1,b2 and t0,t1,t2 are actually hardcoded in codegen_cuda

0 commit comments

Comments
 (0)