Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIR] Add cp.async support for tir.if_then_else #13966

Merged
merged 23 commits into from
Feb 17, 2023
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add comment and trigger PrintPredicatedCpAsyncAssembly in codegen_cud…
…a.cc
  • Loading branch information
cblmemo committed Feb 12, 2023
commit d700b21472f5379f1c59bb3e2a6175da16361849
7 changes: 6 additions & 1 deletion src/target/source/codegen_cuda.cc
Original file line number Diff line number Diff line change
@@ -914,7 +914,12 @@ void CodeGenCUDA::VisitExpr_(const CallNode* op, std::ostream& os) {
std::string src = this->PrintExpr(op->args[2]);
std::string src_offset = this->PrintExpr(op->args[3]);
std::string size = this->PrintExpr(op->args[4]);
this->stream << PrintCpAsyncAssembly(dst, dst_offset, src, src_offset, size);
// use size of argument list to indicate whether or not to use predicated cp.async
if (op->args.size() == 5)
this->stream << PrintCpAsyncAssembly(dst, dst_offset, src, src_offset, size);
else
this->stream << PrintPredicatedCpAsyncAssembly(dst, dst_offset, src, src_offset,
size, this->PrintExpr(op->args[5]));
cblmemo marked this conversation as resolved.
Show resolved Hide resolved
} else if (op->op.same_as(builtin::ptx_commit_group())) {
this->stream << "__asm__ __volatile__(\"cp.async.commit_group;\");\n\n";
} else if (op->op.same_as(builtin::ptx_wait_group())) {
2 changes: 1 addition & 1 deletion src/tir/transforms/inject_ptx_async_copy.cc
Original file line number Diff line number Diff line change
@@ -81,6 +81,7 @@ class PTXAsyncCopyInjector : public StmtMutator {
auto dst_offset = store->indices[0];
Array<PrimExpr> args = {store->buffer->data, tir::Mul(dst_offset, PrimExpr(index_factor)),
load->buffer->data, src_offset, PrimExpr(bytes)};
// use arguments size to indicate whether or not to use predicated cp.async
if (predicated) args.push_back(predicate_value);
return Evaluate(Call(store->buffer->dtype, tvm::tir::builtin::ptx_cp_async(), args));
}
@@ -113,7 +114,6 @@ class PTXAsyncCopyInjector : public StmtMutator {
if (src_offset.defined() && dst_offset.defined()) {
Array<PrimExpr> args = {store->buffer->data, tir::Mul(dst_offset, PrimExpr(index_factor)),
load->buffer->data, src_offset, PrimExpr(bytes)};
if (predicated) args.push_back(predicate_value);
return Evaluate(Call(store->buffer->dtype, tvm::tir::builtin::ptx_cp_async(), args));
}
}