Skip to content

Commit 3129f55

Browse files
authored
MemoryPointer: ensure CUdeviceptr used with NVIDIA binding (#328)
* `MmemoryPointer` ensure `CUdeviceptr` used with NVIDIA binding The docs state that `pointer` should be a `c_void_p`, but the rest of the driver binding code expects the pointer to be represented as a `CUdeviceptr` when the NVIDIA bindings are in use. If we're given a `c_void_p` by the user when using the NVIDIA bindings, we can work around this by converting it to a `CUdeviceptr`. This was first noticed when testing PyArrow with Numba-CUDA. See apache/arrow#47128 * Correct device pointer value usage in EMM test
1 parent c015cab commit 3129f55

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

numba_cuda/numba/cuda/cudadrv/driver.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,6 +2062,9 @@ class MemoryPointer(object):
20622062
__cuda_memory__ = True
20632063

20642064
def __init__(self, context, pointer, size, owner=None, finalizer=None):
2065+
if USE_NV_BINDING and isinstance(pointer, ctypes.c_void_p):
2066+
pointer = binding.CUdeviceptr(pointer.value)
2067+
20652068
self.context = context
20662069
self.device_pointer = pointer
20672070
self.size = size

numba_cuda/numba/cuda/tests/cudadrv/test_emm_plugins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def get_ipc_handle(self, memory):
8484
# the tests don't try to do too much with it (e.g. open / close
8585
# it).
8686
self.get_ipc_handle_called = True
87-
return "Dummy IPC handle for alloc %s" % memory.device_pointer.value
87+
return "Dummy IPC handle for alloc %s" % memory.device_pointer_value
8888

8989
@property
9090
def interface_version(self):

0 commit comments

Comments
 (0)