Coverage for cuda / core / system / _pci_info.pxi: 90.00%
20 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-29 01:27 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-29 01:27 +0000
1# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2#
3# SPDX-License-Identifier: Apache-2.0
6PcieUtilCounter = nvml.PcieUtilCounter
9cdef class PciInfo:
10 """
11 PCI information about a GPU device.
12 """
14 cdef object _pci_info_ext
15 cdef intptr_t _handle
17 def __init__(self, pci_info_ext: nvml.PciInfoExt_v1, handle: int):
18 self._pci_info_ext = pci_info_ext 1bacd
19 self._handle = handle 1bacd
21 @property
22 def bus(self) -> int:
23 """
24 The bus on which the device resides, 0 to 255
25 """
26 return self._pci_info_ext.bus 1a
28 @property
29 def bus_id(self) -> str:
30 """
31 The tuple domain:bus:device.function PCI identifier string
32 """
33 return self._pci_info_ext.bus_id 1bacd
35 @property
36 def device(self) -> int:
37 """
38 The device's id on the bus, 0 to 31
39 """
40 return self._pci_info_ext.device_ 1a
42 @property
43 def domain(self) -> int:
44 """
45 The PCI domain on which the device's bus resides, 0 to 0xffffffff
46 """
47 return self._pci_info_ext.domain 1a
49 @property
50 def vendor_id(self) -> int:
51 """
52 The PCI vendor id of the device
53 """
54 return self._pci_info_ext.pci_device_id & 0xFFFF 1a
56 @property
57 def device_id(self) -> int:
58 """
59 The PCI device id of the device
60 """
61 return self._pci_info_ext.pci_device_id >> 16 1a
63 @property
64 def subsystem_id(self) -> int:
65 """
66 The subsystem device ID
67 """
68 return self._pci_info_ext.pci_sub_system_id 1a
70 @property
71 def base_class(self) -> int:
72 """
73 The 8-bit PCI base class code
74 """
75 return self._pci_info_ext.base_class 1a
77 @property
78 def sub_class(self) -> int:
79 """
80 The 8-bit PCI sub class code
81 """
82 return self._pci_info_ext.sub_class 1a
84 @property
85 def link_generation(self) -> int:
86 """
87 Retrieve the maximum PCIe link generation possible with this device and system.
89 For Fermi™ or newer fully supported devices.
91 For example, for a generation 2 PCIe device attached to a generation 1
92 PCIe bus, the max link generation this function will report is
93 generation 1.
94 """
95 return nvml.device_get_max_pcie_link_generation(self._handle) 1a
97 @property
98 def max_link_generation(self) -> int:
99 """
100 Retrieve the maximum PCIe link generation supported by this GPU device.
102 For Fermi™ or newer fully supported devices.
103 """
104 return nvml.device_get_gpu_max_pcie_link_generation(self._handle) 1a
106 @property
107 def max_link_width(self) -> int:
108 """
109 Retrieve the maximum PCIe link width possible with this device and system.
111 For Fermi™ or newer fully supported devices.
113 For example, for a device with a 16x PCIe bus width attached to a 8x
114 PCIe system bus this function will report
115 a max link width of 8.
116 """
117 return nvml.device_get_max_pcie_link_width(self._handle) 1a
119 @property
120 def current_link_generation(self) -> int:
121 """
122 Retrieve the current PCIe link generation.
124 For Fermi™ or newer fully supported devices.
125 """
126 return nvml.device_get_curr_pcie_link_generation(self._handle) 1a
128 @property
129 def current_link_width(self) -> int:
130 """
131 Retrieve the current PCIe link width.
133 For Fermi™ or newer fully supported devices.
134 """
135 return nvml.device_get_curr_pcie_link_width(self._handle) 1a
137 def get_throughput(self, counter: PcieUtilCounter) -> int:
138 """
139 Retrieve PCIe utilization information, in KB/s.
141 This function is querying a byte counter over a 20ms interval, and thus
142 is the PCIe throughput over that interval.
144 For Maxwell™ or newer fully supported devices.
146 This method is not supported in virtual machines running virtual GPU
147 (vGPU).
148 """
149 return nvml.device_get_pcie_throughput(self._handle, counter) 1a
151 @property
152 def replay_counter(self) -> int:
153 """
154 Retrieve the PCIe replay counter.
156 For Kepler™ or newer fully supported devices.
157 """
158 return nvml.device_get_pcie_replay_counter(self._handle) 1a