在提问之前请确定你已经努力阅读了文档,并且尝试自己在互联网上搜索。
请尽可能提供你的demo代码或者GitHub的gist地址。
通过使用CUDA.jl库包进行GPU并行计算,想要提高程序运行速度,但是不知道为什么速度一点也没有提高,反而比CPU 并行跑的更慢了呢,请大神帮我看看!搞了两三个月了,十分着急!
# code
``` function kernel_Density(m,h,N,Pa,Nei,Ndist)
index = (blockIdx().x - 1) * blockDim().x + threadIdx().x
stride = blockDim().x * gridDim().x
for i = index : stride : N
Pa[i,7] = 4*m/(pi*h^2)
for n = 1 : 60
if Nei[i,n] != 0
neighborRho = (h^2-(Ndist[i,n])^2)^3
else
neighborRho = 0
end
Pa[i,7] = Pa[i,7] + (4*m/(pi*h*h*h*h*h*h*h*h))*neighborRho
end
end
return nothing
end
d_Pa = CuArray(Pa)
d_Nei = CuArray(Nei)
d_Ndist = CuArray(Ndist)
@cuda blocks=20 threads=500 kernel_Density(m,h,N,d_Pa,d_Nei,d_Ndist)