File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ cdef class _HelperCUpointer_attribute:
5050 # Return values
5151 cdef driver.CUcontext _ctx
5252 cdef unsigned int _uint
53+ cdef int _int
5354 cdef driver.CUdeviceptr _devptr
5455 cdef void** _void
5556 cdef driver.CUDA_POINTER_ATTRIBUTE_P2P_TOKENS _token
Original file line number Diff line number Diff line change @@ -248,12 +248,14 @@ cdef class _HelperCUpointer_attribute:
248248 else:
249249 self._cptr = <void*><void_ptr>init_value.getPtr()
250250 elif self._attr in ({{if 'CU_POINTER_ATTRIBUTE_MEMORY_TYPE'}}cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_MEMORY_TYPE,{{endif}}
251- {{if 'CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL'}}cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL,{{endif}}
252251 {{if 'CU_POINTER_ATTRIBUTE_ALLOWED_HANDLE_TYPES'}}cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_ALLOWED_HANDLE_TYPES,{{endif}}
253252 {{if 'CU_POINTER_ATTRIBUTE_IS_GPU_DIRECT_RDMA_CAPABLE'}}cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_IS_GPU_DIRECT_RDMA_CAPABLE,{{endif}}
254253 {{if 'CU_POINTER_ATTRIBUTE_ACCESS_FLAGS'}}cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_ACCESS_FLAGS,{{endif}}):
255254 self._uint = init_value
256255 self._cptr = <void*>&self._uint
256+ elif self._attr in ({{if 'CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL'}}cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL,{{endif}}):
257+ self._int = init_value
258+ self._cptr = <void*>&self._int
257259 elif self._attr in ({{if 'CU_POINTER_ATTRIBUTE_DEVICE_POINTER'}}cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_DEVICE_POINTER,{{endif}}
258260 {{if 'CU_POINTER_ATTRIBUTE_RANGE_START_ADDR'}}cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_RANGE_START_ADDR,{{endif}}):
259261 if self._is_getter:
Original file line number Diff line number Diff line change @@ -450,6 +450,22 @@ def test_cuda_pointer_attr():
450450 assert err == cuda .CUresult .CUDA_SUCCESS
451451
452452
453+ @pytest .mark .skipif (
454+ driverVersionLessThan (11030 ) or not supportsManagedMemory (), reason = "When new attributes were introduced"
455+ )
456+ def test_pointer_get_attributes_device_ordinal ():
457+ attributes = [
458+ cuda .CUpointer_attribute .CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL ,
459+ ]
460+
461+ attrs = cuda .cuPointerGetAttributes (len (attributes ), attributes , 0 )
462+
463+ # device ordinals are always small numbers. A large number would indicate
464+ # an overflow error.
465+
466+ assert abs (attrs [1 ][0 ]) < 256
467+
468+
453469@pytest .mark .skipif (not supportsManagedMemory (), reason = "When new attributes were introduced" )
454470def test_cuda_mem_range_attr ():
455471 (err ,) = cuda .cuInit (0 )
You can’t perform that action at this time.
0 commit comments