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

Loop inside a if statement is identified as an outermost loop #4324

Closed
erizmr opened this issue Feb 18, 2022 · 3 comments · Fixed by #4447
Closed

Loop inside a if statement is identified as an outermost loop #4324

erizmr opened this issue Feb 18, 2022 · 3 comments · Fixed by #4447
Labels
potential bug Something that looks like a bug but not yet confirmed

Comments

@erizmr
Copy link
Contributor

erizmr commented Feb 18, 2022

Describe the bug
The loop inside a if statement is identified as an outermost loop, which is incompatible with the current doc.
image

According to the current doc, it is the loop at the outermost scope that gets parallelized, not the outermost loop.
https://docs.taichi.graphics/#parallel-for-loops

To Reproduce

import taichi as ti
ti.init()

x = ti.field(dtype=int, shape=())
x[None] = 1

@ti.kernel
def test_break():
    if x[None] > 0:
        for i in range(5):
            x[None] += 1
            break
test_break()
import taichi as ti
ti.init()

@ti.kernel
def test_break_2(x:int):
    if x > 0:
        for i in range(5):
            x = 1
            break
	
test_break_2(2)

Log/Screenshots
image

@erizmr erizmr added the potential bug Something that looks like a bug but not yet confirmed label Feb 18, 2022
@lin-hitonami
Copy link
Contributor

I've spotted it in #4238. I will take a look at the code and determine whether we change the code or the documentation.

@qiao-bo
Copy link
Contributor

qiao-bo commented Mar 3, 2022

Did we change the doc or had a fix already? can we close this issue?

@lin-hitonami
Copy link
Contributor

The outermost loop which is not in the outermost scope is not parallelized. We should change the code to allow break in these loops.

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
None yet
Development

Successfully merging a pull request may close this issue.

3 participants