Skip to content

Commit

Permalink
[CUDA] Support memory reuse for dynamic shared memory (#9341)
Browse files Browse the repository at this point in the history
* reuse shared dyn

* minor

* format

* format

* address comment and fix

* address comment

* address comment
  • Loading branch information
jinhongyii authored Oct 31, 2021
1 parent 4087e72 commit a6e90b9
Show file tree
Hide file tree
Showing 4 changed files with 546 additions and 31 deletions.
3 changes: 2 additions & 1 deletion src/driver/driver_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,6 @@ transform::Sequential MixedModulePassManager(IRModule mixed_mod, Target target)
mixed_pass_list.push_back(BindTarget(target));

mixed_pass_list.push_back(tir::transform::VerifyMemory());
mixed_pass_list.push_back(tir::transform::MergeDynamicSharedMemoryAllocations());

if (ShouldAnnotateEntryFunc(target, mixed_mod)) {
mixed_pass_list.push_back(AnnotateEntryFunc(true));
Expand All @@ -603,6 +602,8 @@ transform::Sequential MixedModulePassManager(IRModule mixed_mod, Target target)
}

mixed_pass_list.push_back(tir::transform::ThreadSync("shared"));
mixed_pass_list.push_back(tir::transform::ThreadSync("shared.dyn"));
mixed_pass_list.push_back(tir::transform::MergeDynamicSharedMemoryAllocations());
mixed_pass_list.push_back(tir::transform::ThreadSync("warp"));
mixed_pass_list.push_back(tir::transform::InferFragment());
mixed_pass_list.push_back(tir::transform::LowerThreadAllreduce());
Expand Down
2 changes: 1 addition & 1 deletion src/target/source/codegen_cuda.cc
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ void CodeGenCUDA::PrintStorageSync(const CallNode* op) {
const std::string& sync = op->args[0].as<StringImmNode>()->value;
if (sync == "warp") {
// DO nothing.
} else if (sync == "shared") {
} else if (sync == "shared" || sync == "shared.dyn") {
this->PrintIndent();
this->stream << "__syncthreads();\n";
} else if (sync == "global") {
Expand Down
Loading

0 comments on commit a6e90b9

Please sign in to comment.