Skip to content

Commit

Permalink
[Amdgpu] Enable shared array on amdgpu backend (taichi-dev#7403)
Browse files Browse the repository at this point in the history
Issue: #taichi-dev#6434

### Brief Summary

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and quadpixels committed May 13, 2023
1 parent 7b1beef commit 27a25cd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions python/taichi/lang/simt/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def arch_uses_spv(arch):

def sync():
arch = impl.get_runtime().prog.config().arch
if arch == _ti_core.cuda:
if arch == _ti_core.cuda or arch == _ti_core.amdgpu:
return impl.call_internal("block_barrier", with_runtime_context=False)
if arch_uses_spv(arch):
return impl.call_internal("workgroupBarrier",
Expand Down Expand Up @@ -38,7 +38,7 @@ def thread_idx():

def global_thread_idx():
arch = impl.get_runtime().prog.config().arch
if arch == _ti_core.cuda:
if arch == _ti_core.cuda or _ti_core.amdgpu:
return impl.get_runtime().compiling_callable.ast_builder(
).insert_thread_idx_expr()
if arch_uses_spv(arch):
Expand Down
2 changes: 2 additions & 0 deletions taichi/runtime/llvm/llvm_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,8 @@ std::unique_ptr<llvm::Module> TaichiLLVMContext::module_from_file(
function_pass_manager.doFinalization();
patch_intrinsic("thread_idx", llvm::Intrinsic::amdgcn_workitem_id_x);
patch_intrinsic("block_idx", llvm::Intrinsic::amdgcn_workgroup_id_x);
patch_intrinsic("block_barrier", llvm::Intrinsic::amdgcn_s_barrier,
false);

link_module_with_amdgpu_libdevice(module);
patch_amdgpu_kernel_dim(
Expand Down
2 changes: 1 addition & 1 deletion tests/python/test_shared_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from tests import test_utils


@test_utils.test(arch=[ti.cuda, ti.vulkan])
@test_utils.test(arch=[ti.cuda, ti.vulkan, ti.amdgpu])
def test_shared_array_nested_loop():
block_dim = 128
nBlocks = 64
Expand Down

0 comments on commit 27a25cd

Please sign in to comment.