Skip to content

Commit 9cfde76

Browse files
committed
Small fixes
1 parent d54034f commit 9cfde76

2 files changed

Lines changed: 121 additions & 2 deletions

File tree

cuda_bindings/cuda/bindings/_nvml.pxd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ ctypedef nvmlComputeInstanceProfileInfo_t ComputeInstanceProfileInfo
4141
ctypedef nvmlMask255_t Mask255
4242
ctypedef nvmlHostname_v1_t Hostname_v1
4343
ctypedef nvmlNvLinkInfo_v1_t NvLinkInfo_v1
44-
ctypedef nvmlPRMCounterInput_v1_t PRMCounterInput_v1
4544
ctypedef nvmlPowerValue_v2_t PowerValue_v2
4645
ctypedef nvmlVgpuProcessUtilizationSample_t VgpuProcessUtilizationSample
4746
ctypedef nvmlGpuFabricInfo_t GpuFabricInfo

cuda_bindings/cuda/bindings/_nvml.pyx

Lines changed: 121 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,7 @@ NVLINK_MAX_LINKS = 18
11761176

11771177

11781178
class RUSD(_IntEnum):
1179-
POLL_NONE - 0x0 # Disable RUSD polling on all metric groups
1179+
POLL_NONE = 0x0 # Disable RUSD polling on all metric groups
11801180
POLL_CLOCK = 0x1 # Enable RUSD polling on clock group
11811181
POLL_PERF = 0x2 # Enable RUSD polling on performance group
11821182
POLL_MEMORY = 0x4 # Enable RUSD polling on memory group
@@ -15297,6 +15297,126 @@ cdef class RusdSettings_v1:
1529715297
return obj
1529815298

1529915299

15300+
cdef _get_prm_counter_input_v1_dtype_offsets():
15301+
cdef nvmlPRMCounterInput_v1_t pod = nvmlPRMCounterInput_v1_t()
15302+
return _numpy.dtype({
15303+
'names': ['local_port'],
15304+
'formats': [_numpy.uint32],
15305+
'offsets': [
15306+
(<intptr_t>&(pod.localPort)) - (<intptr_t>&pod),
15307+
],
15308+
'itemsize': sizeof(nvmlPRMCounterInput_v1_t),
15309+
})
15310+
15311+
prm_counter_input_v1_dtype = _get_prm_counter_input_v1_dtype_offsets()
15312+
15313+
cdef class PRMCounterInput_v1:
15314+
"""Empty-initialize an instance of `nvmlPRMCounterInput_v1_t`.
15315+
15316+
15317+
.. seealso:: `nvmlPRMCounterInput_v1_t`
15318+
"""
15319+
cdef:
15320+
nvmlPRMCounterInput_v1_t *_ptr
15321+
object _owner
15322+
bint _owned
15323+
bint _readonly
15324+
15325+
def __init__(self):
15326+
self._ptr = <nvmlPRMCounterInput_v1_t *>calloc(1, sizeof(nvmlPRMCounterInput_v1_t))
15327+
if self._ptr == NULL:
15328+
raise MemoryError("Error allocating PRMCounterInput_v1")
15329+
self._owner = None
15330+
self._owned = True
15331+
self._readonly = False
15332+
15333+
def __dealloc__(self):
15334+
cdef nvmlPRMCounterInput_v1_t *ptr
15335+
if self._owned and self._ptr != NULL:
15336+
ptr = self._ptr
15337+
self._ptr = NULL
15338+
free(ptr)
15339+
15340+
def __repr__(self):
15341+
return f"<{__name__}.PRMCounterInput_v1 object at {hex(id(self))}>"
15342+
15343+
@property
15344+
def ptr(self):
15345+
"""Get the pointer address to the data as Python :class:`int`."""
15346+
return <intptr_t>(self._ptr)
15347+
15348+
cdef intptr_t _get_ptr(self):
15349+
return <intptr_t>(self._ptr)
15350+
15351+
def __int__(self):
15352+
return <intptr_t>(self._ptr)
15353+
15354+
def __eq__(self, other):
15355+
cdef PRMCounterInput_v1 other_
15356+
if not isinstance(other, PRMCounterInput_v1):
15357+
return False
15358+
other_ = other
15359+
return (memcmp(<void *><intptr_t>(self._ptr), <void *><intptr_t>(other_._ptr), sizeof(nvmlPRMCounterInput_v1_t)) == 0)
15360+
15361+
def __setitem__(self, key, val):
15362+
if key == 0 and isinstance(val, _numpy.ndarray):
15363+
self._ptr = <nvmlPRMCounterInput_v1_t *>malloc(sizeof(nvmlPRMCounterInput_v1_t))
15364+
if self._ptr == NULL:
15365+
raise MemoryError("Error allocating PRMCounterInput_v1")
15366+
memcpy(<void*>self._ptr, <void*><intptr_t>val.ctypes.data, sizeof(nvmlPRMCounterInput_v1_t))
15367+
self._owner = None
15368+
self._owned = True
15369+
self._readonly = not val.flags.writeable
15370+
else:
15371+
setattr(self, key, val)
15372+
15373+
@property
15374+
def local_port(self):
15375+
"""int: Local port number."""
15376+
return self._ptr[0].localPort
15377+
15378+
@local_port.setter
15379+
def local_port(self, val):
15380+
if self._readonly:
15381+
raise ValueError("This PRMCounterInput_v1 instance is read-only")
15382+
self._ptr[0].localPort = val
15383+
15384+
@staticmethod
15385+
def from_data(data):
15386+
"""Create an PRMCounterInput_v1 instance wrapping the given NumPy array.
15387+
15388+
Args:
15389+
data (_numpy.ndarray): a single-element array of dtype `prm_counter_input_v1_dtype` holding the data.
15390+
"""
15391+
return __from_data(data, "prm_counter_input_v1_dtype", prm_counter_input_v1_dtype, PRMCounterInput_v1)
15392+
15393+
@staticmethod
15394+
def from_ptr(intptr_t ptr, bint readonly=False, object owner=None):
15395+
"""Create an PRMCounterInput_v1 instance wrapping the given pointer.
15396+
15397+
Args:
15398+
ptr (intptr_t): pointer address as Python :class:`int` to the data.
15399+
owner (object): The Python object that owns the pointer. If not provided, data will be copied.
15400+
readonly (bool): whether the data is read-only (to the user). default is `False`.
15401+
"""
15402+
if ptr == 0:
15403+
raise ValueError("ptr must not be null (0)")
15404+
cdef PRMCounterInput_v1 obj = PRMCounterInput_v1.__new__(PRMCounterInput_v1)
15405+
if owner is None:
15406+
obj._ptr = <nvmlPRMCounterInput_v1_t *>malloc(sizeof(nvmlPRMCounterInput_v1_t))
15407+
if obj._ptr == NULL:
15408+
raise MemoryError("Error allocating PRMCounterInput_v1")
15409+
memcpy(<void*>(obj._ptr), <void*>ptr, sizeof(nvmlPRMCounterInput_v1_t))
15410+
obj._owner = None
15411+
obj._owned = True
15412+
else:
15413+
obj._ptr = <nvmlPRMCounterInput_v1_t *>ptr
15414+
obj._owner = owner
15415+
obj._owned = False
15416+
obj._readonly = readonly
15417+
return obj
15418+
15419+
1530015420
cdef _get_excluded_device_info_dtype_offsets():
1530115421
cdef nvmlExcludedDeviceInfo_t pod = nvmlExcludedDeviceInfo_t()
1530215422
return _numpy.dtype({

0 commit comments

Comments
 (0)