Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.4k views
in Technique[技术] by (71.8m points)

prime testing in cuda python

I know the implementation of prime testing isnt the best, trying to use it at practice for working with CUDA. I don't understand why the file won't compile. Please don't give me a solution for prime testing for I am intrested in learning myself.

import numpy as np
from numba import jit, cuda


@cuda.jit()
def seive(array):
    i = cuda.grid(1)
    k = 2
    while k <= math.sqrt(array[i]):
        if array[i] % k == 0:
            array[i]
            break
        k += 1


size = 20
arr = np.array([i for i in range(0, size)], np.float64)
print(arr)
seive[4, 5](arr)
print(arr)

OUTPUT:

[ 0.  1.  2.  3.  4.  5.  6.  7.  8.  9. 10. 11. 12. 13. 14. 15. 16. 17.
 18. 19. 20.]
Traceback (most recent call last):
  File "C:/Users/PycharmProjects/EulerProjectGPU/main.py", line 20, in <module>
    seive[4, 5](arr)
  File "C:Usersanaconda3envsEulerProjectGPUlibsite-packages
umbacudacompiler.py", line 769, in __call__
    return self.dispatcher.call(args, self.griddim, self.blockdim,
  File "C:Usersanaconda3envsEulerProjectGPUlibsite-packages
umbacudacompiler.py", line 861, in call
    kernel = self.compile(argtypes)
  File "C:Usersanaconda3envsEulerProjectGPUlibsite-packages
umbacudacompiler.py", line 935, in compile
    kernel.bind()
  File "C:Usersanaconda3envsEulerProjectGPUlibsite-packages
umbacudacompiler.py", line 576, in bind
    self._func.get()
  File "C:Usersanaconda3envsEulerProjectGPUlibsite-packages
umbacudacompiler.py", line 446, in get
    ptx = self.ptx.get()
  File "C:Usersanaconda3envsEulerProjectGPUlibsite-packages
umbacudacompiler.py", line 415, in get
    ptx = nvvm.llvm_to_ptx(self.llvmir, arch=arch,
  File "C:Usersanaconda3envsEulerProjectGPUlibsite-packages
umbacudacudadrv
vvm.py", line 525, in llvm_to_ptx
    ptx = cu.compile(**opts)
  File "C:Usersanaconda3envsEulerProjectGPUlibsite-packages
umbacudacudadrv
vvm.py", line 232, in compile
    self._try_error(err, 'Failed to compile
')
  File "C:Usersanaconda3envsEulerProjectGPUlibsite-packages
umbacudacudadrv
vvm.py", line 250, in _try_error
    self.driver.check_error(err, "%s
%s" % (msg, self.get_log()))
  File "C:Usersanaconda3envsEulerProjectGPUlibsite-packages
umbacudacudadrv
vvm.py", line 140, in check_error
    raise exc
numba.cuda.cudadrv.error.NvvmError: Failed to compile

<unnamed> (44, 19): parse expected comma after load's type
NVVM_ERROR_COMPILATION

Process finished with exit code 1```

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...