Skip to content

Commit b7958b8

Browse files
committed
Fix pointer device ordinal attribute result
1 parent 498b80d commit b7958b8

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

cuda_bindings/cuda/bindings/_lib/utils.pxi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,11 +380,12 @@ cdef class _HelperCUpointer_attribute:
380380
if self._attr in (cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_CONTEXT,):
381381
return self._ctx
382382
elif self._attr in (cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_MEMORY_TYPE,
383-
cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL,
384383
cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_ALLOWED_HANDLE_TYPES,
385384
cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_IS_GPU_DIRECT_RDMA_CAPABLE,
386385
cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_ACCESS_FLAGS,):
387386
return self._uint
387+
elif self._attr in (cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL,):
388+
return self._int
388389
elif self._attr in (cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_DEVICE_POINTER,
389390
cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_RANGE_START_ADDR,):
390391
return self._devptr

cuda_bindings/tests/test_cuda.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -456,12 +456,10 @@ def test_pointer_get_attributes_device_ordinal():
456456
cuda.CUpointer_attribute.CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL,
457457
]
458458

459-
attrs = cuda.cuPointerGetAttributes(len(attributes), attributes, 0)
459+
err, attrs = cuda.cuPointerGetAttributes(len(attributes), attributes, 0)
460460

461-
# device ordinals are always small numbers. A large number would indicate
462-
# an overflow error.
463-
464-
assert abs(attrs[1][0]) < 256
461+
assert err == cuda.CUresult.CUDA_SUCCESS
462+
assert attrs == [cuda.CU_DEVICE_INVALID]
465463

466464

467465
@pytest.mark.skipif(not supportsManagedMemory(), reason="When new attributes were introduced")

0 commit comments

Comments
 (0)