Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEA] Allow passing of NULL pointer in CUDA function #44

Open
gmarkall opened this issue Aug 16, 2024 · 1 comment
Open

[FEA] Allow passing of NULL pointer in CUDA function #44

gmarkall opened this issue Aug 16, 2024 · 1 comment
Labels
feature request New feature or request

Comments

@gmarkall
Copy link
Collaborator

From numba/numba#9655:

There is currently not a way to pass a NULL pointer to a C function from a compiled python function in CUDA. The value cffi.NULL should be valid in such functions.

For example:

from numba import cuda
import cffi

ffi = cffi.FFI()

func = cuda.declare_device('func', 'int32(CPointer(int32))')

@cuda.jit(link=['/content/func.cu'])
def kernel(values) :
  i_thread = cuda.threadIdx.x

  values[i_thread] = func(ffi.NULL)

cc @ed-o-saurus

@jakirkham
Copy link

In Cython code, we have had some success using uintptr_t (for example)

Cython treats uintptr_t as coercible to/from a Python int object. So users are then able to pass 0 then have that treated as NULL at the Cython/C/C++ layer. There may be some explicit casting between uintptr_t and C/C++ pointer types like void* (for example), but this is pretty trivial/fast to do

Not sure exactly how this maps to numba-cuda's model of working with C/C++, but hopefully this is a helpful way of thinking about the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants