Coverage for cuda / core / system / _clock.pxi: 57.89%
19 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-08 01:07 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-08 01:07 +0000
1# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2#
3# SPDX-License-Identifier: Apache-2.0
6ClockId = nvml.ClockId
7ClocksEventReasons = nvml.ClocksEventReasons
8ClockType = nvml.ClockType
11cdef class ClockOffsets:
12 """
13 Contains clock offset information.
14 """
16 cdef object _clock_offset
18 def __init__(self, clock_offset: nvml.ClockOffset):
19 self._clock_offset = clock_offset 1a
21 @property
22 def clock_offset_mhz(self) -> int:
23 """
24 The current clock offset in MHz.
25 """
26 return self._clock_offset.clock_offset_m_hz 1a
28 @property
29 def max_offset_mhz(self) -> int:
30 """
31 The maximum clock offset in MHz.
32 """
33 return self._clock_offset.max_clock_offset_m_hz 1a
35 @property
36 def min_offset_mhz(self) -> int:
37 """
38 The minimum clock offset in MHz.
39 """
40 return self._clock_offset.min_clock_offset_m_hz 1a
43cdef class ClockInfo:
44 """
45 Accesses various clock information about a device.
46 """
48 cdef intptr_t _handle
49 cdef int _clock_type
51 def __init__(self, handle, clock_type: ClockType):
52 self._handle = handle 1a
53 self._clock_type = int(clock_type) 1a
55 def get_current_mhz(self, clock_id: ClockId = ClockId.CURRENT) -> int:
56 """
57 Get the current clock speed of a specific clock domain, in MHz.
59 For Kepler™ or newer fully supported devices.
61 Parameters
62 ----------
63 clock_id: :class:`ClockId`
64 The clock ID to query.
66 Returns
67 -------
68 int
69 The clock speed in MHz.
70 """
71 return nvml.device_get_clock(self._handle, self._clock_type, clock_id) 1a
73 def get_max_mhz(self) -> int:
74 """
75 Get the maximum clock speed of a specific clock domain, in MHz.
77 For Fermi™ or newer fully supported devices.
79 Current P0 clocks (reported by :meth:`get_current_mhz` can differ from
80 max clocks by a few MHz.
82 Returns
83 -------
84 int
85 The maximum clock speed in MHz.
86 """
87 return nvml.device_get_max_clock_info(self._handle, self._clock_type) 1a
89 def get_max_customer_boost_mhz(self) -> int:
90 """
91 Get the maximum customer boost clock speed of a specific clock, in MHz.
93 For Pascal™ or newer fully supported devices.
95 Returns
96 -------
97 int
98 The maximum customer boost clock speed in MHz.
99 """
100 return nvml.device_get_max_customer_boost_clock(self._handle, self._clock_type) 1a
102 def get_min_max_clock_of_pstate_mhz(self, pstate: Pstates) -> tuple[int, int]:
103 """
104 Get the minimum and maximum clock speeds for this clock domain
105 at a given performance state (Pstate), in MHz.
107 Parameters
108 ----------
109 pstate: :class:`Pstates`
110 The performance state to query.
112 Returns
113 -------
114 tuple[int, int]
115 A tuple containing the minimum and maximum clock speeds in MHz.
116 """
117 return nvml.device_get_min_max_clock_of_p_state(self._handle, self._clock_type, pstate) 1a
119 def get_offsets(self, pstate: Pstates) -> ClockOffsets:
120 """
121 Retrieve min, max and current clock offset of some clock domain for a given Pstate.
123 For Maxwell™ or newer fully supported devices.
125 Parameters
126 ----------
127 pstate: :class:`Pstates`
128 The performance state to query.
130 Returns
131 -------
132 ClockOffsets
133 An object with the min, max and current clock offset.
134 """
135 return ClockOffsets(nvml.device_get_clock_offsets(self._handle, self._clock_type, pstate)) 1a