You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A for loop in @ti.kernel and under acrh vulkan give incorrect result with count=count+k but is OK with count+= k and is also OK under arch cpu.
--coding:Latin-1 -
import taichi as ti
ti.init(arch=ti.vulkan)
@ti.kernel
def count_primes(n: int) -> int:
count = 0
for k in range(0, n):
count = count + k
#count += k
return count
print(count_primes(30))
#ti.profiler.print_kernel_profiler_info()
Result :
[Taichi] version 1.6.0, llvm 15.0.1, commit f1c6fbb, win, python 3.11.6
[Taichi] Starting on arch=vulkan
28
Process finished with exit code 0
28 is incorrect should be 435
With count+= k :
I am under Windows 11 PC : HP, CPU :AMD Ryzen 7 3700U with Radeon Vega Mobile Gfx 2.30 GHz
GPU : AMD radeon RX Vega 10, Vulkan : version up -to-date 31.0.21905.1001
A for loop in @ti.kernel and under acrh vulkan give incorrect result with count=count+k but is OK with count+= k and is also OK under arch cpu.
--coding:Latin-1 -
import taichi as ti
ti.init(arch=ti.vulkan)
@ti.kernel
def count_primes(n: int) -> int:
count = 0
for k in range(0, n):
count = count + k
#count += k
return count
print(count_primes(30))
#ti.profiler.print_kernel_profiler_info()
Result :
[Taichi] version 1.6.0, llvm 15.0.1, commit f1c6fbb, win, python 3.11.6
[Taichi] Starting on arch=vulkan
28
Process finished with exit code 0
28 is incorrect should be 435
With count+= k :
--coding:Latin-1 -
import taichi as ti
#ti.init(arch=ti.cpu, debug = True, verbose= True)
#ti.init(arch=ti.cpu)
#ti.init(arch=ti.vulkan, debug = True, verbose= True)
#ti.init(arch=ti.cuda)
#ti.init(arch=ti.opengl)
ti.init(arch=ti.vulkan)
#ti.init(kernel_profiler=True)
@ti.kernel
def count_primes(n: int) -> int:
count = 0
for k in range(0, n):
#count = count + k
count += k
return count
print(count_primes(30))
Result:
[Taichi] version 1.6.0, llvm 15.0.1, commit f1c6fbb, win, python 3.11.6
[Taichi] Starting on arch=vulkan
435
Process finished with exit code 0
is correct and work fine also in any cases under cpu instead vulkan
The text was updated successfully, but these errors were encountered: