taichi: Support break in non-parallel for statements
Concisely describe the proposed feature
@ti.kernel
def sums():
for i in range(n):
is_prime[i] = 1
for j in range(i):
if i % j == 0:
is_prime[i] = 0
if j * j > i:
break # This is not supported now...
Describe the solution you’d like (if any)
Add an IR pass that lower non-parallel fors with break statements into while statements.
While statements already support breaks (WhileControlStmt).
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 34 (16 by maintainers)
We can only lower non-parallel for loops into while. Struct-for loops are always parallel.
Stmt::make<LocaLoadStmt>(LaneAttribute<LocalAddress>(alloca, 0))?You probably need a
LocalLoadStmtto convert that local pointer to a local value?Why not allow me to binary cmp_lt with alloca-ed loop_var…
I guess using a local
AllocaStmtis easier? You might have multiple instances of serial fors running in parallel so allocating GlobalTemp would be tricky.No, it’s no longer an existing submodule. It’s just part of the module list. Not sure if we will need it sometime later so I kept the git URL.
I also found
taichi_assetsmay be not appreciated by some users, containing some meshes used by mpm examples which may not be so useful for some people… Is this cloned bygit clone --recursive?I believe for
git clone --recursivethis is automaticDoes this work for you? https://stackoverflow.com/questions/2144406/how-to-make-shallow-git-submodules
Super slow receving spdlog in GFW 😦
Can I specify
--depth=1to that? Didn’t move for a few miniutes…I hate submodules 😦
Make me can’t happily
git add .anymore. Tried.gitignore, didn’t work…Working after
initthenupdate!Try
git submodule init?Nice! Before you start, keep in mind that we only want to lower non-parallel range-for statements that contain at least one FrontendBreakStmt. For loops that live at the outer-most scope are automatically parallel. We should implement this within the
lowerpass whenFrontendBreakStmthas not been lowered intoWhileControlStmt.Great! I decided to work on this today.
exactly!
Btw, break in parallel ones aren’t allowed, right? (break have a clear assumption of serial execution…)