Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jul 23, 2023
1 parent e1c7811 commit 5987825
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions python/taichi/lang/simt/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,21 @@ def sync():
return impl.call_internal("workgroupBarrier", with_runtime_context=False)
raise ValueError(f"ti.block.shared_array is not supported for arch {arch}")


def sync_all_nonzero(predicate):
arch = impl.get_runtime().prog.config().arch
if arch == _ti_core.cuda:
return impl.call_internal("block_barrier_and_i32", predicate, with_runtime_context=False)
raise ValueError(f"ti.block.sync_all_nonzero is not supported for arch {arch}")


def sync_any_nonzero(predicate):
arch = impl.get_runtime().prog.config().arch
if arch == _ti_core.cuda:
return impl.call_internal("block_barrier_or_i32", predicate, with_runtime_context=False)
raise ValueError(f"ti.block.sync_any_nonzero is not supported for arch {arch}")


def sync_count_nonzero(predicate):
arch = impl.get_runtime().prog.config().arch
if arch == _ti_core.cuda:
Expand Down
4 changes: 3 additions & 1 deletion tests/python/test_simt.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def foo():
for i in range(32):
assert a[i] == 0


@test_utils.test(arch=ti.cuda)
def test_sync_all_nonzero():
a = ti.field(dtype=ti.i32, shape=256)
Expand Down Expand Up @@ -62,7 +63,6 @@ def foo():
assert a[i] == 0



@test_utils.test(arch=ti.cuda)
def test_any_nonzero():
a = ti.field(dtype=ti.i32, shape=32)
Expand Down Expand Up @@ -90,6 +90,7 @@ def foo():
for i in range(32):
assert a[i] == 1


@test_utils.test(arch=ti.cuda)
def test_sync_any_nonzero():
a = ti.field(dtype=ti.i32, shape=256)
Expand Down Expand Up @@ -117,6 +118,7 @@ def foo():
for i in range(256):
assert a[i] == 1


@test_utils.test(arch=ti.cuda)
def test_sync_count_nonzero():
a = ti.field(dtype=ti.i32, shape=256)
Expand Down

0 comments on commit 5987825

Please sign in to comment.