Dear all,
I am trying to understand how to debug when using @cuda.jit, however I came up with some doubts, more specifically how my arrays mutate within the several threads. So to test, I desire to understand the values of my array in a determined absolute position loop, when I debug I and print(A) and for my surprise I get a pointer.
So my questions are:
- How can I print my array values starting through the pointer?
(Please notice, to debug I have to execute with the SET “NUMBA_ENABLE_CUDASIM=1”)
Here is the code:
from numba import cuda
import numpy as np
import os
@cuda.jit
def vec_add(A, B, out):
x = cuda.threadIdx.x
bx = cuda.blockIdx.x
bdx = cuda.blockDim.x
i = bx * bdx + x
if i==10:
from pdb import set_trace; set_trace()
print(A)#print(A) in (Pdb) returns a pointer <numba.cuda.simulator.cudadrv.devicearray.FakeWithinKernelCUDAArray object at 0x00000288E604F040>
print(A[i])#Prints 0.0, It is reading from the mutated A array.
for k in range(len(A)):
A[k]=0
out[i] = A[i] + B[i]
a=np.ones(1000)
b=np.arange(1000)
c=np.arange(1000)
threadsperblock = 32
blockspergrid = (a.size + (threadsperblock - 1)) // threadsperblock
vec_add[blockspergrid, threadsperblock](a,b,c)
print(c)
Many thanks!