Skip to content

Commit 3419bad

Browse files
committed
cuda.core.system: Naming improvements suggested in #1945
1 parent b991295 commit 3419bad

File tree

5 files changed

+38
-26
lines changed

5 files changed

+38
-26
lines changed

cuda_core/cuda/core/system/_device.pyx

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -215,23 +215,23 @@ cdef class Device:
215215
return nvml.device_get_minor_number(self._handle)
216216

217217
@property
218-
def is_c2c_mode_enabled(self) -> bool:
218+
def is_c2c_enabled(self) -> bool:
219219
"""
220220
Whether the C2C (Chip-to-Chip) mode is enabled for this device.
221221
"""
222222
return bool(nvml.device_get_c2c_mode_info_v(self._handle).is_c2c_enabled)
223223

224224
@property
225-
def persistence_mode_enabled(self) -> bool:
225+
def persistence_mode(self) -> bool:
226226
"""
227227
Whether persistence mode is enabled for this device.
228228

229229
For Linux only.
230230
"""
231231
return nvml.device_get_persistence_mode(self._handle) == nvml.EnableState.FEATURE_ENABLED
232232

233-
@persistence_mode_enabled.setter
234-
def persistence_mode_enabled(self, enabled: bool) -> None:
233+
@persistence_mode.setter
234+
def persistence_mode(self, enabled: bool) -> None:
235235
nvml.device_set_persistence_mode(
236236
self._handle,
237237
nvml.EnableState.FEATURE_ENABLED if enabled else nvml.EnableState.FEATURE_DISABLED
@@ -409,13 +409,14 @@ cdef class Device:
409409
# CLOCK
410410
# See external class definitions in _clock.pxi
411411

412-
def clock(self, clock_type: ClockType) -> ClockInfo:
412+
def get_clock(self, clock_type: ClockType) -> ClockInfo:
413413
"""
414414
Get information about and manage a specific clock on a device.
415415
"""
416416
return ClockInfo(self._handle, clock_type)
417417

418-
def get_auto_boosted_clocks_enabled(self) -> tuple[bool, bool]:
418+
@property
419+
def is_auto_boosted_clocks_enabled(self) -> tuple[bool, bool]:
419420
"""
420421
Retrieve the current state of auto boosted clocks on a device.
421422

@@ -440,7 +441,8 @@ cdef class Device:
440441
current, default = nvml.device_get_auto_boosted_clocks_enabled(self._handle)
441442
return current == nvml.EnableState.FEATURE_ENABLED, default == nvml.EnableState.FEATURE_ENABLED
442443

443-
def get_current_clock_event_reasons(self) -> list[ClocksEventReasons]:
444+
@property
445+
def current_clock_event_reasons(self) -> list[ClocksEventReasons]:
444446
"""
445447
Retrieves the current clocks event reasons.
446448

@@ -450,7 +452,8 @@ cdef class Device:
450452
reasons[0] = nvml.device_get_current_clocks_event_reasons(self._handle)
451453
return [ClocksEventReasons(1 << reason) for reason in _unpack_bitmask(reasons)]
452454

453-
def get_supported_clock_event_reasons(self) -> list[ClocksEventReasons]:
455+
@property
456+
def supported_clock_event_reasons(self) -> list[ClocksEventReasons]:
454457
"""
455458
Retrieves supported clocks event reasons that can be returned by
456459
:meth:`get_current_clock_event_reasons`.
@@ -492,17 +495,17 @@ cdef class Device:
492495
# DISPLAY
493496

494497
@property
495-
def display_mode(self) -> bool:
498+
def is_display_connected(self) -> bool:
496499
"""
497500
The display mode for this device.
498501

499502
Indicates whether a physical display (e.g. monitor) is currently connected to
500503
any of the device's connectors.
501504
"""
502-
return True if nvml.device_get_display_mode(self._handle) == nvml.EnableState.FEATURE_ENABLED else False
505+
return nvml.device_get_display_mode(self._handle) == nvml.EnableState.FEATURE_ENABLED
503506

504507
@property
505-
def display_active(self) -> bool:
508+
def is_display_active(self) -> bool:
506509
"""
507510
The display active status for this device.
508511

@@ -512,7 +515,7 @@ cdef class Device:
512515

513516
Display can be active even when no monitor is physically attached.
514517
"""
515-
return True if nvml.device_get_display_active(self._handle) == nvml.EnableState.FEATURE_ENABLED else False
518+
return nvml.device_get_display_active(self._handle) == nvml.EnableState.FEATURE_ENABLED
516519

517520
##########################################################################
518521
# EVENTS
@@ -580,7 +583,7 @@ cdef class Device:
580583
# FAN
581584
# See external class definitions in _fan.pxi
582585
583-
def fan(self, fan: int = 0) -> FanInfo:
586+
def get_fan(self, fan: int = 0) -> FanInfo:
584587
"""
585588
Get information and manage a specific fan on a device.
586589
"""
@@ -707,7 +710,8 @@ cdef class Device:
707710
"""
708711
return GpuDynamicPstatesInfo(nvml.device_get_dynamic_pstates_info(self._handle))
709712
710-
def get_supported_pstates(self) -> list[Pstates]:
713+
@property
714+
def supported_pstates(self) -> list[Pstates]:
711715
"""
712716
Get all supported Performance States (P-States) for the device.
713717

cuda_core/cuda/core/system/_fan.pxi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ cdef class FanInfo:
9696
"""
9797
return FanControlPolicy(nvml.device_get_fan_control_policy_v2(self._handle, self._fan))
9898

99-
def set_default_fan_speed(self):
99+
def set_default_speed(self):
100100
"""
101101
Set the speed of the fan control policy to default.
102102

cuda_core/cuda/core/system/_inforom.pxi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ cdef class InforomInfo:
1212
def __init__(self, device: Device):
1313
self._device = device
1414

15-
def get_version(self, inforom: InforomObject) -> str:
15+
@property
16+
def version(self, inforom: InforomObject) -> str:
1617
"""
1718
Retrieves the InfoROM version for a given InfoROM object.
1819

cuda_core/cuda/core/system/_pci_info.pxi

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ cdef class PciInfo:
8181
"""
8282
return self._pci_info_ext.sub_class
8383

84-
def get_max_pcie_link_generation(self) -> int:
84+
@property
85+
def link_generation(self) -> int:
8586
"""
8687
Retrieve the maximum PCIe link generation possible with this device and system.
8788

@@ -93,15 +94,17 @@ cdef class PciInfo:
9394
"""
9495
return nvml.device_get_max_pcie_link_generation(self._handle)
9596

96-
def get_gpu_max_pcie_link_generation(self) -> int:
97+
@property
98+
def max_link_generation(self) -> int:
9799
"""
98100
Retrieve the maximum PCIe link generation supported by this GPU device.
99101

100102
For Fermi™ or newer fully supported devices.
101103
"""
102104
return nvml.device_get_gpu_max_pcie_link_generation(self._handle)
103105

104-
def get_max_pcie_link_width(self) -> int:
106+
@property
107+
def max_link_width(self) -> int:
105108
"""
106109
Retrieve the maximum PCIe link width possible with this device and system.
107110

@@ -113,23 +116,26 @@ cdef class PciInfo:
113116
"""
114117
return nvml.device_get_max_pcie_link_width(self._handle)
115118

116-
def get_current_pcie_link_generation(self) -> int:
119+
@property
120+
def current_link_generation(self) -> int:
117121
"""
118122
Retrieve the current PCIe link generation.
119123

120124
For Fermi™ or newer fully supported devices.
121125
"""
122126
return nvml.device_get_curr_pcie_link_generation(self._handle)
123127

124-
def get_current_pcie_link_width(self) -> int:
128+
@property
129+
def current_link_width(self) -> int:
125130
"""
126131
Retrieve the current PCIe link width.
127132

128133
For Fermi™ or newer fully supported devices.
129134
"""
130135
return nvml.device_get_curr_pcie_link_width(self._handle)
131136

132-
def get_pcie_throughput(self, counter: PcieUtilCounter) -> int:
137+
@property
138+
def throughput(self, counter: PcieUtilCounter) -> int:
133139
"""
134140
Retrieve PCIe utilization information, in KB/s.
135141

@@ -143,7 +149,8 @@ cdef class PciInfo:
143149
"""
144150
return nvml.device_get_pcie_throughput(self._handle, counter)
145151

146-
def get_pcie_replay_counter(self) -> int:
152+
@property
153+
def replay_counter(self) -> int:
147154
"""
148155
Retrieve the PCIe replay counter.
149156

cuda_core/cuda/core/system/_temperature.pxi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ cdef class Temperature:
7777
def __init__(self, handle: int):
7878
self._handle = handle
7979

80-
def sensor(
80+
def get_sensor(
8181
self,
8282
sensor: TemperatureSensors = TemperatureSensors.TEMPERATURE_GPU
8383
) -> int:
@@ -97,7 +97,7 @@ cdef class Temperature:
9797
"""
9898
return nvml.device_get_temperature_v(self._handle, sensor)
9999

100-
def threshold(self, threshold_type: TemperatureThresholds) -> int:
100+
def get_threshold(self, threshold_type: TemperatureThresholds) -> int:
101101
"""
102102
Retrieves the temperature threshold for this GPU with the specified
103103
threshold type, in degrees Celsius.
@@ -127,7 +127,7 @@ cdef class Temperature:
127127
"""
128128
return nvml.device_get_margin_temperature(self._handle)
129129

130-
def thermal_settings(self, sensor_index: ThermalTarget) -> ThermalSettings:
130+
def get_thermal_settings(self, sensor_index: ThermalTarget) -> ThermalSettings:
131131
"""
132132
Used to execute a list of thermal system instructions.
133133

0 commit comments

Comments
 (0)