I'm trying to use Cython to call some CUDA code. What I want to do is first use regular Python to copy data to the GPU, and then pass pointers to the data to a Cython method, which will then call some CUDA code to work on the data.
I'm having trouble figuring out how to cast an "int" representing the memory address of the data that is on the GPU to an "int*" array in Cython. Here is what I have in my .pyx file now:
import numpy as np
import ctypes
cimport numpy as np
cdef extern from './solve_sparse_system.h':
void solve_sparse_system_cg(int *device_I, int *device_J, float *device_V, float *device_X, float *device_B) nogil
def solve_sparse_system(np.ndarray[np.int, ndim=1] device_I,
np.ndarray[np.int, ndim=1] device_J,
np.ndarray[np.float32_t, ndim=1] device_V,
np.ndarray[np.float32_t, ndim=1] device_X,
np.ndarray[np.float32_t, ndim=1] device_B):
solve_sparse_system_cg(&device_I[0], &device_J[0], &device_V[0], &device_X[0], &device_B[0])
When I try to compile this I get two errors saying " Cannot take address of Python object" for the "device_I" and "device_J" arguments on the last line. Since I don't get compile errors for the arrays that consist of floats, I think the problem is that there is some issue with the "int" datatype. How can I convert the "int" representing the address of the data into an "int*" here?