Skip to content

Commit f3ab66a

Browse files
committed
Privatize system.Device helper classes
Remove helper/data-container classes from cuda.core.system's public API (__all__) since they are not intended to be directly instantiated by users. These classes are returned by Device properties/methods and serve as nested data containers. Classes removed from __all__: BAR1MemoryInfo, ClockInfo, ClockOffsets, CoolerInfo, DeviceAttributes, DeviceEvents, EventData, FanInfo, FieldValue, FieldValues, GpuDynamicPstatesInfo, GpuDynamicPstatesUtilization, InforomInfo, PciInfo, RepairStatus, Temperature, ThermalSensor, ThermalSettings. Enums, exceptions, Device itself, and free functions remain public. Also: - Update api.rst to document helper classes via their private module path (system._device.ClassName) - Update Device property/method docstrings to link to helper classes using :obj:`~ClassName` role - Update tests to import helper classes from _device module
1 parent f73c1c8 commit f3ab66a

File tree

7 files changed

+93
-93
lines changed

7 files changed

+93
-93
lines changed

cuda_core/cuda/core/system/_clock.pxi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ cdef class ClockInfo:
129129

130130
Returns
131131
-------
132-
ClockOffsets
132+
:obj:`~_device.ClockOffsets`
133133
An object with the min, max and current clock offset.
134134
"""
135135
return ClockOffsets(nvml.device_get_clock_offsets(self._handle, self._clock_type, pstate))

cuda_core/cuda/core/system/_device.pyx

Lines changed: 30 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ cdef class Device:
159159
@property
160160
def arch(self) -> DeviceArch:
161161
"""
162-
Device architecture.
162+
:obj:`~DeviceArch` device architecture.
163163

164164
For example, a Tesla V100 will report ``DeviceArchitecture.name ==
165165
"VOLTA"``, and RTX A6000 will report ``DeviceArchitecture.name ==
@@ -177,7 +177,7 @@ cdef class Device:
177177
@property
178178
def brand(self) -> BrandType:
179179
"""
180-
Brand of the device
180+
:obj:`~BrandType` brand of the device
181181
"""
182182
return BrandType(nvml.device_get_brand(self._handle))
183183

@@ -289,7 +289,7 @@ cdef class Device:
289289

290290
Returns
291291
-------
292-
Iterator of Device
292+
Iterator over :obj:`~Device`
293293
An iterator over available devices.
294294
"""
295295
for device_id in range(nvml.device_get_count_v2()):
@@ -301,7 +301,7 @@ cdef class Device:
301301
@property
302302
def addressing_mode(self) -> AddressingMode:
303303
"""
304-
Get the addressing mode of the device.
304+
Get the :obj:`~AddressingMode` of the device.
305305

306306
Addressing modes can be one of:
307307

@@ -334,7 +334,7 @@ cdef class Device:
334334

335335
Returns
336336
-------
337-
Iterator of Device
337+
Iterator of :obj:`~Device`
338338
An iterator over available devices.
339339
"""
340340
cdef Device device
@@ -411,7 +411,7 @@ cdef class Device:
411411

412412
def clock(self, clock_type: ClockType) -> ClockInfo:
413413
"""
414-
Get information about and manage a specific clock on a device.
414+
:obj:`~_device.ClockInfo` object to get information about and manage a specific clock on a device.
415415
"""
416416
return ClockInfo(self._handle, clock_type)
417417

@@ -442,7 +442,7 @@ cdef class Device:
442442

443443
def get_current_clock_event_reasons(self) -> list[ClocksEventReasons]:
444444
"""
445-
Retrieves the current clocks event reasons.
445+
Retrieves the current :obj:`~ClocksEventReasons`.
446446

447447
For all fully supported products.
448448
"""
@@ -452,7 +452,7 @@ cdef class Device:
452452

453453
def get_supported_clock_event_reasons(self) -> list[ClocksEventReasons]:
454454
"""
455-
Retrieves supported clocks event reasons that can be returned by
455+
Retrieves supported :obj:`~ClocksEventReasons` that can be returned by
456456
:meth:`get_current_clock_event_reasons`.
457457

458458
For all fully supported products.
@@ -470,7 +470,7 @@ cdef class Device:
470470
@property
471471
def cooler(self) -> CoolerInfo:
472472
"""
473-
Get information about cooler on a device.
473+
:obj:`~_device.CoolerInfo` object with cooler information for the device.
474474
"""
475475
return CoolerInfo(nvml.device_get_cooler_info(self._handle))
476476

@@ -481,7 +481,7 @@ cdef class Device:
481481
@property
482482
def attributes(self) -> DeviceAttributes:
483483
"""
484-
Get various device attributes.
484+
:obj:`~_device.DeviceAttributes` object with various device attributes.
485485

486486
For Ampere™ or newer fully supported devices. Only available on Linux
487487
systems.
@@ -549,9 +549,9 @@ cdef class Device:
549549

550550
Returns
551551
-------
552-
:class:`DeviceEvents`
552+
:obj:`~_device.DeviceEvents`
553553
An object representing the registered events. Call
554-
:meth:`DeviceEvents.wait` on this object to wait for events.
554+
:meth:`~_device.DeviceEvents.wait` on this object to wait for events.
555555

556556
Raises
557557
------
@@ -582,7 +582,7 @@ cdef class Device:
582582
583583
def fan(self, fan: int = 0) -> FanInfo:
584584
"""
585-
Get information and manage a specific fan on a device.
585+
:obj:`~_device.FanInfo` object to get information and manage a specific fan on a device.
586586
"""
587587
if fan < 0 or fan >= self.num_fans:
588588
raise ValueError(f"Fan index {fan} is out of range [0, {self.num_fans})")
@@ -605,22 +605,22 @@ cdef class Device:
605605

606606
Each value specified can raise its own exception. That exception will
607607
be raised when attempting to access the corresponding ``value`` from the
608-
returned :class:`FieldValues` container.
608+
returned :obj:`~_device.FieldValues` container.
609609

610610
To confirm that there are no exceptions in the entire container, call
611-
:meth:`FieldValues.validate`.
611+
:meth:`~_device.FieldValues.validate`.
612612

613613
Parameters
614614
----------
615-
field_ids: list of int or tuple of (int, int)
615+
field_ids: list[int | tuple[int, int]]
616616
List of field IDs to query.
617617

618618
Each item may be either a single value from the :class:`FieldId`
619619
enum, or a pair of (:class:`FieldId`, scope ID).
620620

621621
Returns
622622
-------
623-
:class:`FieldValues`
623+
:obj:`~_device.FieldValues`
624624
Container of field values corresponding to the requested field IDs.
625625
"""
626626
return FieldValues(nvml.device_get_field_values(self._handle, field_ids))
@@ -631,7 +631,7 @@ cdef class Device:
631631

632632
Parameters
633633
----------
634-
field_ids: list of int or tuple of (int, int)
634+
field_ids: list[int | tuple[int, int]]
635635
List of field IDs to clear.
636636

637637
Each item may be either a single value from the :class:`FieldId`
@@ -646,7 +646,7 @@ cdef class Device:
646646
@property
647647
def inforom(self) -> InforomInfo:
648648
"""
649-
Accessor for InfoROM information.
649+
:obj:`~_device.InforomInfo` object with InfoROM information.
650650

651651
For all products with an InfoROM.
652652
"""
@@ -659,7 +659,7 @@ cdef class Device:
659659
@property
660660
def bar1_memory_info(self) -> BAR1MemoryInfo:
661661
"""
662-
Get information about BAR1 memory.
662+
:obj:`~_device.BAR1MemoryInfo` object with BAR1 memory information.
663663

664664
BAR1 is used to map the FB (device memory) so that it can be directly
665665
accessed by the CPU or by 3rd party devices (peer-to-peer on the PCIE
@@ -670,7 +670,7 @@ cdef class Device:
670670
@property
671671
def memory_info(self) -> MemoryInfo:
672672
"""
673-
Object with memory information.
673+
:obj:`~_device.MemoryInfo` object with memory information.
674674
"""
675675
return MemoryInfo(nvml.device_get_memory_info_v2(self._handle))
676676
@@ -681,7 +681,7 @@ cdef class Device:
681681
@property
682682
def pci_info(self) -> PciInfo:
683683
"""
684-
The PCI attributes of this device.
684+
:obj:`~_device.PciInfo` object with the PCI attributes of this device.
685685
"""
686686
return PciInfo(nvml.device_get_pci_info_ext(self._handle), self._handle)
687687
@@ -703,7 +703,7 @@ cdef class Device:
703703
@property
704704
def dynamic_pstates_info(self) -> GpuDynamicPstatesInfo:
705705
"""
706-
Retrieve performance monitor samples from the associated subdevice.
706+
:obj:`~_device.GpuDynamicPstatesInfo` object with performance monitor samples from the associated subdevice.
707707
"""
708708
return GpuDynamicPstatesInfo(nvml.device_get_dynamic_pstates_info(self._handle))
709709
@@ -713,6 +713,11 @@ cdef class Device:
713713

714714
The returned list contains a contiguous list of valid P-States supported by
715715
the device.
716+
717+
Return
718+
------
719+
list[Pstates]
720+
A list of supported P-States for the device.
716721
"""
717722
return [Pstates(x) for x in nvml.device_get_supported_performance_states(self._handle)]
718723
@@ -723,7 +728,7 @@ cdef class Device:
723728
@property
724729
def repair_status(self) -> RepairStatus:
725730
"""
726-
Get the repair status for TPC/Channel repair.
731+
:obj:`~_device.RepairStatus` object with TPC/Channel repair status.
727732

728733
For Ampere™ or newer fully supported devices.
729734
"""
@@ -736,7 +741,7 @@ cdef class Device:
736741
@property
737742
def temperature(self) -> Temperature:
738743
"""
739-
Get information about temperatures on a device.
744+
:obj:`~_device.Temperature` object with temperature information for the device.
740745
"""
741746
return Temperature(self._handle)
742747
@@ -822,46 +827,27 @@ def get_p2p_status(device1: Device, device2: Device, index: GpuP2PCapsIndex) ->
822827
__all__ = [
823828
"AddressingMode",
824829
"AffinityScope",
825-
"BAR1MemoryInfo",
826830
"BrandType",
827831
"ClockId",
828-
"ClockInfo",
829-
"ClockOffsets",
830832
"ClocksEventReasons",
831833
"ClockType",
832834
"CoolerControl",
833-
"CoolerInfo",
834835
"CoolerTarget",
835836
"Device",
836837
"DeviceArch",
837-
"DeviceAttributes",
838-
"DeviceEvents",
839-
"EventData",
840838
"EventType",
841839
"FanControlPolicy",
842-
"FanInfo",
843840
"FieldId",
844-
"FieldValue",
845-
"FieldValues",
846841
"get_p2p_status",
847842
"get_topology_common_ancestor",
848-
"GpuDynamicPstatesInfo",
849-
"GpuDynamicPstatesUtilization",
850843
"GpuP2PCapsIndex",
851844
"GpuP2PStatus",
852845
"GpuTopologyLevel",
853-
"InforomInfo",
854846
"InforomObject",
855-
"MemoryInfo",
856847
"PcieUtilCounter",
857-
"PciInfo",
858848
"Pstates",
859-
"RepairStatus",
860-
"Temperature",
861849
"TemperatureSensors",
862850
"TemperatureThresholds",
863851
"ThermalController",
864-
"ThermalSensor",
865-
"ThermalSettings",
866852
"ThermalTarget",
867853
]

cuda_core/cuda/core/system/_system_events.pyx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ cdef class SystemEvent:
2626
@property
2727
def event_type(self) -> SystemEventType:
2828
"""
29-
The type of event that was triggered.
29+
The :obj:`~SystemEventType` that was triggered.
3030
"""
3131
return SystemEventType(self._event_data.event_type)
3232

@@ -40,7 +40,7 @@ cdef class SystemEvent:
4040
@property
4141
def device(self) -> _device.Device:
4242
"""
43-
The device associated with this event.
43+
The :obj:`~_device.Device` associated with this event.
4444
"""
4545
return _device.Device(pci_bus_id=self.gpu_id)
4646

@@ -56,6 +56,9 @@ cdef class SystemEvents:
5656
return len(self._event_data)
5757

5858
def __getitem__(self, idx: int) -> SystemEvent:
59+
"""
60+
Get the :obj:`~_system_events.SystemEvent` at the specified index.
61+
"""
5962
return SystemEvent(self._event_data[idx])
6063

6164

@@ -107,6 +110,12 @@ cdef class RegisteredSystemEvents:
107110
buffer_size: int
108111
The maximum number of events to retrieve. Must be at least 1.
109112

113+
Returns
114+
-------
115+
:obj:`~_system_events.SystemEvents`
116+
A set of events that were received. The number of events returned may
117+
be less than the specified buffer size if fewer events were available.
118+
110119
Raises
111120
------
112121
:class:`cuda.core.system.TimeoutError`
@@ -142,9 +151,9 @@ def register_events(events: SystemEventType | int | list[SystemEventType | int])
142151

143152
Returns
144153
-------
145-
:class:`RegisteredSystemEvents`
154+
:obj:`~_system_events.RegisteredSystemEvents`
146155
An object representing the registered events. Call
147-
:meth:`RegisteredSystemEvents.wait` on this object to wait for events.
156+
:meth:`~_system_events.RegisteredSystemEvents.wait` on this object to wait for events.
148157

149158
Raises
150159
------
@@ -156,8 +165,5 @@ def register_events(events: SystemEventType | int | list[SystemEventType | int])
156165
157166
__all__ = [
158167
"register_events",
159-
"RegisteredSystemEvents",
160-
"SystemEvent",
161-
"SystemEvents",
162168
"SystemEventType",
163169
]

cuda_core/cuda/core/system/_temperature.pxi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ cdef class Temperature:
140140

141141
Returns
142142
-------
143-
:class:`ThermalSettings`
143+
:obj:`~_device.ThermalSettings`
144144
The thermal settings for the specified sensor.
145145
"""
146146
return ThermalSettings(nvml.device_get_thermal_settings(self._handle, sensor_index))

cuda_core/docs/source/api.rst

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,6 @@ Events
199199
:toctree: generated/
200200

201201
system.register_events
202-
system.RegisteredSystemEvents
203-
system.SystemEvent
204-
system.SystemEvents
205202
system.SystemEventType
206203

207204
Enums
@@ -215,6 +212,7 @@ Enums
215212
system.BrandType
216213
system.ClockId
217214
system.ClocksEventReasons
215+
system.ClockType
218216
system.CoolerControl
219217
system.CoolerTarget
220218
system.DeviceArch
@@ -238,29 +236,6 @@ Types
238236
:template: autosummary/cyclass.rst
239237

240238
system.Device
241-
system.BAR1MemoryInfo
242-
system.ClockInfo
243-
system.ClockOffsets
244-
system.ClockType
245-
system.CoolerInfo
246-
system.DeviceAttributes
247-
system.DeviceEvents
248-
system.EventData
249-
system.FanInfo
250-
system.FieldValue
251-
system.FieldValues
252-
system.GpuDynamicPstatesInfo
253-
system.GpuDynamicPstatesUtilization
254-
system.GpuP2PCapsIndex
255-
system.GpuP2PStatus
256-
system.GpuTopologyLevel
257-
system.InforomInfo
258-
system.MemoryInfo
259-
system.PciInfo
260-
system.RepairStatus
261-
system.Temperature
262-
system.ThermalSensor
263-
system.ThermalSettings
264239

265240
.. module:: cuda.core.utils
266241

0 commit comments

Comments
 (0)