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

Atmoic min get wrong result on cuda backend when block_dim is 16 #5148

Closed
BillXu2000 opened this issue Jun 13, 2022 · 3 comments · Fixed by #5161
Closed

Atmoic min get wrong result on cuda backend when block_dim is 16 #5148

BillXu2000 opened this issue Jun 13, 2022 · 3 comments · Fixed by #5161
Labels
potential bug Something that looks like a bug but not yet confirmed

Comments

@BillXu2000
Copy link
Collaborator

Describe the bug
Atmoic min get wrong result on cuda backend when block_dim is 16.

To Reproduce
Run the code below. The expected answer is 1, but I got 0 on my computer.

import taichi as ti

ti.init(arch=ti.cuda)

n = 16
x = ti.field(dtype=ti.f32, shape=n)

@ti.kernel
def test():
    hit_time = 1
    for i in x:
        ti.atomic_min(hit_time, 1)
    print(hit_time)

test()

Setting n to any number larger than 16, print value of hit_time, or replacing for i in x with for i in range(n) will get the right answer.
Especially, replacing for i in x with for i in range(n) will only change the block_dim in the final Taichi IR, and thus I think the bug might be at cuda codegen phase.

@BillXu2000 BillXu2000 added the potential bug Something that looks like a bug but not yet confirmed label Jun 13, 2022
@taichi-ci-bot taichi-ci-bot moved this to Untriaged in Taichi Lang Jun 13, 2022
@BillXu2000
Copy link
Collaborator Author

Related (same) issue: #5142

@bobcao3
Copy link
Collaborator

bobcao3 commented Jun 13, 2022

Can you try to disable reduction optimization and see whether that fixes this?

@BillXu2000
Copy link
Collaborator Author

Disabling reduction optimization will fix this bug.

Repository owner moved this from Untriaged to Done in Taichi Lang Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
potential bug Something that looks like a bug but not yet confirmed
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants