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

[SIMT] [cuda] Use correct source lane offset for warp intrinsics #4734

Merged
merged 3 commits into from
Apr 8, 2022
Merged
Changes from all commits
Commits
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
22 changes: 15 additions & 7 deletions python/taichi/lang/simt/warp.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,38 +27,46 @@ def ballot(predicate):
def shfl_sync_i32(mask, val, offset):
return expr.Expr(
_ti_core.insert_internal_func_call(
"cuda_shfl_sync_i32", expr.make_expr_group(mask, val, offset, 32),
# lane offset is 31 for warp size 32
"cuda_shfl_sync_i32",
expr.make_expr_group(mask, val, offset, 31),
False))


def shfl_sync_f32(mask, val, offset):
return expr.Expr(
_ti_core.insert_internal_func_call(
"cuda_shfl_sync_f32", expr.make_expr_group(mask, val, offset, 32),
# lane offset is 31 for warp size 32
"cuda_shfl_sync_f32",
expr.make_expr_group(mask, val, offset, 31),
False))


def shfl_down_i32(mask, val, offset):
# Here we use 31 as the last argument since 32 (warp size) does not work
# for some reason. Using 31 leads to the desired behavior.
return expr.Expr(
_ti_core.insert_internal_func_call(
"cuda_shfl_down_sync_i32",
expr.make_expr_group(mask, val, offset, 31), False))
# lane offset is 31 for warp size 32
expr.make_expr_group(mask, val, offset, 31),
False))


def shfl_up_i32(mask, val, offset):
return expr.Expr(
_ti_core.insert_internal_func_call(
"cuda_shfl_up_sync_i32",
expr.make_expr_group(mask, val, offset, 32), False))
# lane offset is 0 for warp size 32
expr.make_expr_group(mask, val, offset, 0),
False))


def shfl_up_f32(mask, val, offset):
return expr.Expr(
_ti_core.insert_internal_func_call(
"cuda_shfl_up_sync_f32",
expr.make_expr_group(mask, val, offset, 32), False))
# lane offset is 0 for warp size 32
expr.make_expr_group(mask, val, offset, 0),
False))


def shfl_xor_i32(mask, val, offset):
Expand Down