你好!
@ti.kernel
def type_count(types: ti.types.ndarray(), pos: ti.types.ndarray()):
for i in range(pos.shape[0]):
types[int(pos[i])] += 1
@ti.kernel
def type_err_count(err_count: ti.types.ndarray(), if_correct: ti.types.ndarray(), op_type: ti.types.ndarray()):
for i in range(if_correct.shape[0]):
if if_correct[i] == 0:
err_count[int(op_type[i])] += 1
请问对于上面的两个kernel,taichi在cpu上是否能够保证正确执行?以第一个kernel为例,不同的i可能对应相同的pos[i],于是不同的线程会需要修改相同位置的数据。
我在cpu上使用taichi的时候多次运行可以得到相同的结果,但是在使用cuda的时候总会得到不同的结果。