Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cuda_bindings/cuda/bindings/_lib/utils.pxd.in
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ cdef class _HelperCUpointer_attribute:
# Return values
cdef driver.CUcontext _ctx
cdef unsigned int _uint
cdef int _int
cdef driver.CUdeviceptr _devptr
cdef void** _void
cdef driver.CUDA_POINTER_ATTRIBUTE_P2P_TOKENS _token
Expand Down
4 changes: 3 additions & 1 deletion cuda_bindings/cuda/bindings/_lib/utils.pxi.in
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,14 @@ cdef class _HelperCUpointer_attribute:
else:
self._cptr = <void*><void_ptr>init_value.getPtr()
elif self._attr in ({{if 'CU_POINTER_ATTRIBUTE_MEMORY_TYPE'}}cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_MEMORY_TYPE,{{endif}}
{{if 'CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL'}}cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL,{{endif}}
{{if 'CU_POINTER_ATTRIBUTE_ALLOWED_HANDLE_TYPES'}}cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_ALLOWED_HANDLE_TYPES,{{endif}}
{{if 'CU_POINTER_ATTRIBUTE_IS_GPU_DIRECT_RDMA_CAPABLE'}}cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_IS_GPU_DIRECT_RDMA_CAPABLE,{{endif}}
{{if 'CU_POINTER_ATTRIBUTE_ACCESS_FLAGS'}}cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_ACCESS_FLAGS,{{endif}}):
self._uint = init_value
self._cptr = <void*>&self._uint
elif self._attr in ({{if 'CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL'}}cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL,{{endif}}):
self._int = init_value
self._cptr = <void*>&self._int
elif self._attr in ({{if 'CU_POINTER_ATTRIBUTE_DEVICE_POINTER'}}cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_DEVICE_POINTER,{{endif}}
{{if 'CU_POINTER_ATTRIBUTE_RANGE_START_ADDR'}}cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_RANGE_START_ADDR,{{endif}}):
if self._is_getter:
Expand Down
16 changes: 16 additions & 0 deletions cuda_bindings/tests/test_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,22 @@ def test_cuda_pointer_attr():
assert err == cuda.CUresult.CUDA_SUCCESS


@pytest.mark.skipif(
driverVersionLessThan(11030) or not supportsManagedMemory(), reason="When new attributes were introduced"
)
def test_pointer_get_attributes_device_ordinal():
attributes = [
cuda.CUpointer_attribute.CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL,
]

attrs = cuda.cuPointerGetAttributes(len(attributes), attributes, 0)

# device ordinals are always small numbers. A large number would indicate
# an overflow error.

assert abs(attrs[1][0]) < 256


@pytest.mark.skipif(not supportsManagedMemory(), reason="When new attributes were introduced")
def test_cuda_mem_range_attr():
(err,) = cuda.cuInit(0)
Expand Down
Loading