# 求助，以下代码没有用到随机函数，每次运行结果却不一样

``````import taichi as ti
import scipy.io as sio
ti.init(arch = ti.gpu,default_fp=ti.f64)

NP=16384
x = ti.Vector.field(1,ti.f64,NP)
v = ti.Vector.field(3,ti.f64,NP)

nx=128
rho = ti.Vector.field(1,ti.f64,nx)

x_mt=xx_mt['x']
vx_mt=vvx_mt['vx']
for p in range(NP):
x[p].x = x_mt[p,0]
v[p].x = vx_mt[p,0]
v[p].y = 0.0
v[p].z = 0.0

@ti.kernel
def position():
for p in x:
x[p] += v[p].x
if x[p].x>=nx:
x[p] += -nx
if x[p].x<0:
x[p] += nx

@ti.kernel
def charge():
for i in rho:
rho[i].x = 0.000399992328#rho0
for p in x:#P2G
base = x[p].cast(int)
fx = (x[p].x - base.cast(ti.f64))
rho[base] += (1.0-fx)*(-3.1249400625e-06)#q
rho[base+1] += fx*(-3.1249400625e-06)
position()
charge()
``````

[Taichi] version 1.0.2, llvm 10.0.0, commit 14f0acba, win, python 3.9.5
[Taichi] Starting on arch=cuda

rho[0].x
1.2526766219601858e-06
rho[1].x
-9.459752682234363e-07

[Taichi] version 1.0.2, llvm 10.0.0, commit 14f0acba, win, python 3.9.5
[Taichi] Starting on arch=cuda

rho[0].x
1.2526766219601316e-06
rho[1].x
-9.459752682233065e-07

[Taichi] version 1.0.2, llvm 10.0.0, commit 14f0acba, win, python 3.9.5
[Taichi] Starting on arch=x64

rho[0].x
1.2526766219602847e-06
rho[1].x
-9.459752682232722e-07

[Taichi] version 1.0.2, llvm 10.0.0, commit 14f0acba, win, python 3.9.5
[Taichi] Starting on arch=x64

rho[0].x
1.2526766219602305e-06
rho[1].x
-9.459752682232722e-07

rho[0]每次都不一样（无论在GPU还是CPU上），差异在后四位；
rho[1]在GPU上得到的结果每次都不一样，差异在后四位，在CPU上得到的结果一样。