55from libc.stdint cimport intptr_t, uint64_t
66from libc.math cimport ceil
77
8- import sys
9- if sys.version_info >= (3 , 11 ):
10- from enum import StrEnum
11- else :
12- from backports.strenum import StrEnum
138from multiprocessing import cpu_count
149from typing import Iterable
1510import warnings
1611
1712from cuda.bindings import nvml
18- try :
19- from cuda.bindings._internal._fast_enum import FastEnum
20- except ImportError :
21- from enum import IntEnum as FastEnum
2213
2314from ._nvml_context cimport initialize
15+ from cuda.core.system.typing import (
16+ AddressingMode,
17+ AffinityScope,
18+ DeviceArch,
19+ ClockId,
20+ ClocksEventReasons,
21+ ClockType,
22+ CoolerControl,
23+ CoolerTarget,
24+ DeviceArch,
25+ EventType,
26+ FanControlPolicy,
27+ FieldId,
28+ GpuP2PCapsIndex,
29+ GpuP2PStatus,
30+ GpuTopologyLevel,
31+ InforomObject,
32+ TemperatureThresholds,
33+ ThermalController,
34+ ThermalTarget,
35+ )
2436
2537
2638cdef object _pstate_to_int(object pstate):
@@ -57,53 +69,12 @@ include "_temperature.pxi"
5769include " _utilization.pxi"
5870
5971
60- class AddressingMode (StrEnum ):
61- """
62- Addressing mode of a device.
63-
64- For Kepler™ or newer fully supported devices.
65- """
66- HMM = " hmm"
67- ATS = " ats"
68-
69-
70- AddressingMode.HMM.__doc__ = """
71- System allocated memory (``malloc``, ``mmap``) is addressable from the device
72- (GPU), via software-based mirroring of the CPU's page tables, on the GPU.
73- """
74-
75-
76- AddressingMode.ATS.__doc__ = """
77- System allocated memory (``malloc``, ``mmap``) is addressable from the device
78- (GPU), via Address Translation Services. This means that there is (effectively)
79- a single set of page tables, and the CPU and GPU both use them.
80- """
81-
82-
8372_ADDRESSING_MODE_MAPPING = {
8473 nvml.DeviceAddressingModeType.DEVICE_ADDRESSING_MODE_HMM: AddressingMode.HMM,
8574 nvml.DeviceAddressingModeType.DEVICE_ADDRESSING_MODE_ATS: AddressingMode.ATS,
8675}
8776
8877
89- class AffinityScope (StrEnum ):
90- """
91- Scope for affinity queries.
92- """
93- NODE = " node"
94- SOCKET = " socket"
95-
96-
97- AffinityScope.NODE.__doc__ = """
98- The NUMA node is the scope of the affinity query. This is the default scope.
99- """
100-
101-
102- AffinityScope.SOCKET.__doc__ = """
103- The CPU socket is the scope of the affinity query.
104- """
105-
106-
10778_AFFINITY_SCOPE_MAPPING = {
10879 AffinityScope.NODE: nvml.AffinityScope.NODE,
10980 AffinityScope.SOCKET: nvml.AffinityScope.SOCKET,
@@ -132,37 +103,6 @@ _BRAND_TYPE_MAPPING = {
132103}
133104
134105
135- # This uses FastEnum instead of StrEnum because the ordering of the values is
136- # meaningful, e.g. Kepler "or later"
137- class DeviceArch (FastEnum ):
138- """
139- Device architecture.
140- """
141- KEPLER = int (nvml.DeviceArch.KEPLER)
142- MAXWELL = int (nvml.DeviceArch.MAXWELL)
143- PASCAL = int (nvml.DeviceArch.PASCAL)
144- VOLTA = int (nvml.DeviceArch.VOLTA)
145- TURING = int (nvml.DeviceArch.TURING)
146- AMPERE = int (nvml.DeviceArch.AMPERE)
147- ADA = int (nvml.DeviceArch.ADA)
148- HOPPER = int (nvml.DeviceArch.HOPPER)
149- BLACKWELL = int (nvml.DeviceArch.BLACKWELL)
150- UNKNOWN = int (nvml.DeviceArch.UNKNOWN)
151-
152-
153- class GpuP2PCapsIndex (StrEnum ):
154- """
155- GPU peer-to-peer capabilities index.
156- """
157- READ = " read"
158- WRITE = " write"
159- NVLINK = " nvlink"
160- ATOMICS = " atomics"
161- PCI = " pci"
162- PROP = " prop"
163- UNKNOWN = " unknown"
164-
165-
166106_GPU_P2P_CAPS_INDEX_MAPPING = {
167107 GpuP2PCapsIndex.READ: nvml.GpuP2PCapsIndex.P2P_CAPS_INDEX_READ,
168108 GpuP2PCapsIndex.WRITE: nvml.GpuP2PCapsIndex.P2P_CAPS_INDEX_WRITE,
@@ -174,19 +114,6 @@ _GPU_P2P_CAPS_INDEX_MAPPING = {
174114}
175115
176116
177- class GpuP2PStatus (StrEnum ):
178- """
179- GPU peer-to-peer status.
180- """
181- OK = " ok"
182- CHIPSET_NOT_SUPPORTED = " chipset not supported"
183- GPU_NOT_SUPPORTED = " GPU not supported"
184- IOH_TOPOLOGY_NOT_SUPPORTED = " IOH topology not supported"
185- DISABLED_BY_REGKEY = " disabled by regkey"
186- NOT_SUPPORTED = " not supported"
187- UNKNOWN = " unknown"
188-
189-
190117_GPU_P2P_STATUS_MAPPING = {
191118 nvml.GpuP2PStatus.P2P_STATUS_OK: GpuP2PStatus.OK,
192119 nvml.GpuP2PStatus.P2P_STATUS_CHIPSET_NOT_SUPPORTED: GpuP2PStatus.CHIPSET_NOT_SUPPORTED,
@@ -198,18 +125,6 @@ _GPU_P2P_STATUS_MAPPING = {
198125}
199126
200127
201- class GpuTopologyLevel (StrEnum ):
202- """
203- Represents level relationships within a system between two GPUs.
204- """
205- INTERNAL = " internal"
206- SINGLE = " single"
207- MULTIPLE = " multiple"
208- HOSTBRIDGE = " hostbridge"
209- NODE = " node"
210- SYSTEM = " system"
211-
212-
213128_GPU_TOPOLOGY_LEVEL_MAPPING = {
214129 GpuTopologyLevel.INTERNAL: nvml.GpuTopologyLevel.TOPOLOGY_INTERNAL,
215130 GpuTopologyLevel.SINGLE: nvml.GpuTopologyLevel.TOPOLOGY_SINGLE,
@@ -1204,27 +1119,8 @@ def get_p2p_status(device1: Device, device2: Device, index: GpuP2PCapsIndex | st
12041119
12051120
12061121__all__ = [
1207- "AddressingMode",
1208- "AffinityScope",
1209- "ClockId",
1210- "ClocksEventReasons",
1211- "ClockType",
1212- "CoolerControl",
1213- "CoolerTarget",
12141122 "Device",
1215- "DeviceArch",
1216- "EventType",
1217- "FanControlPolicy",
1218- "FieldId",
12191123 "get_p2p_status",
12201124 "get_topology_common_ancestor",
1221- "GpuP2PCapsIndex",
1222- "GpuP2PStatus",
1223- "GpuTopologyLevel",
1224- "InforomObject",
12251125 "NvlinkInfo",
1226- "TemperatureThresholds",
1227- "ThermalController",
1228- "ThermalTarget",
1229- "Utilization",
12301126]
0 commit comments