Closed YuxinPan closed 2 years ago
Hi @YuxinPan , the outermost loop of a Taichi kernel is paralleled executed, thus the order of the kk[None]
loaded of material[kk[None]] = 1
is not guaranteed. Some simple modifications can help address this issue, such as the example below:
@ti.kernel
def apply_grid() -> ti.i32:
for i in range(n_width): # ti.static(range(36))
for j in range(n_length):
x[i * n_length + j] = [ i* dx, j * dx]
material[i * n_length + j] = 1 # 0: fluid 1: jelly 2: snow
return 0
Hi @YuxinPan , the outermost loop of a Taichi kernel is paralleled executed, thus the order of the
kk[None]
loaded ofmaterial[kk[None]] = 1
is not guaranteed. Some simple modifications can help address this issue, such as the example below:@ti.kernel def apply_grid() -> ti.i32: for i in range(n_width): # ti.static(range(36)) for j in range(n_length): x[i * n_length + j] = [ i* dx, j * dx] material[i * n_length + j] = 1 # 0: fluid 1: jelly 2: snow return 0
Thanks, that indeed fixed this issue!
Describe the bug Taichi vector field values being changed randomly by kernel after explicit assignment of values inside a function. This happens without a certain pattern.
To Reproduce Please see the code below to reproduce. The dev environment is: [Taichi] version 0.8.9, latest version 0.9.2, llvm 10.0.0, commit 8a0942ba, linux, python 3.9.7
Log/Screenshots There is no error message as the program can finish execution, but wrong value is shown below after manual filtering.