python报错:
我在使用numba中的cuda.jit加速时,函数出现如下报错:
numba.core.errors.TypingError: Failed in cuda mode pipeline (step: nopython frontend)
non-precise type array(pyobject, 0d, C)
During: typing of argument at D:\big_num_calculating\calculating.py (31)
File "calculating.py", line 31:
其中代码的第31行为:@cuda.jit
报错的函数代码块为:
from numba import cuda
import math
A = 712109216148475924002260208280426602040082602280
A_device = cuda.to_device(A)
B = 969363330882741444824008280206888408688882266224
B_device = cuda.to_device(B)
P_point_x = 652884557691898644204408046028266446228466204200
P_point_x_device = cuda.to_device(P_point_x)
Q_A_point_x = 242592654818097002466006644842440682466444846404
Q_A_point_x_device = cuda.to_device(Q_A_point_x)
p_y = 0
Q_y = 1
# p = 1004782375664996008484828206862404846062606288466
p = 2*10**6
p_device = cuda.to_device(p)
threads_per_block = 1024
blocks_per_grid = math.ceil(p / threads_per_block)
@cuda.jit
def P_yy(p, x):
idx = cuda.threadIdx.x + cuda.blockDim.x * cuda.blockIdx.x
if idx < p:
for k in range(0, p):
if (k ** 2) % p == (x ** 3 + A_device * x + B_device) % p:
return k
else:
continue
if __name__ == "__main__":
start_time = time.time()
P_point_y = P_yy[blocks_per_grid, threads_per_block](p_device, P_point_x_device)
cuda.synchronize()