我正在尝试在共享阵列上运行一个小设备内核函数:
from numbapro import cuda, float32
@cuda.jit('void(float32[:,:],float32,float32)',device=True)
def cu_calculate_distance(template, dx, dy) :
side_length = template.shape[0]
cen = side_length/2
for i in xrange(side_length) :
for j in xrange(side_length) :
template[i,j] = math.sqrt(((i-cen)*dx)**2 + ((j-cen)*dy)**2)
@cuda.autojit
def cuda_test() :
t = cuda.shared.array(shape=(100,100),dtype=float32)
dx = float32(1/100.)
cu_calculate_distance(t,dx,dx)
当我尝试运行cuda_test()函数时,我收到错误:
CompilerError: At line 523:
During: instruction codegen
TypeError: array(float32, 2, C) does not support casting when trying to cast to array(float32, 2, A)
我不明白这个强制转换错误 - 据我所知,我实际上并没有在任何地方重铸数组 - 它被声明为float32共享数组并且它被传递给一个带有float32数组的函数。我错过了什么?