Coverage for cuda / core / system / _pci_info.pxi: 100.00%
19 statements
« prev ^ index » next coverage.py v7.14.0, created at 2026-05-22 01:37 +0000
« prev ^ index » next coverage.py v7.14.0, created at 2026-05-22 01:37 +0000
1# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2#
3# SPDX-License-Identifier: Apache-2.0
6cdef class PciInfo:
7 """
8 PCI information about a GPU device.
9 """
11 cdef object _pci_info_ext
12 cdef intptr_t _handle
14 def __init__(self, pci_info_ext: nvml.PciInfoExt_v1, handle: int):
15 self._pci_info_ext = pci_info_ext 1bacd
16 self._handle = handle 1bacd
18 @property
19 def bus(self) -> int:
20 """
21 The bus on which the device resides, 0 to 255
22 """
23 return self._pci_info_ext.bus 1a
25 @property
26 def bus_id(self) -> str:
27 """
28 The tuple domain:bus:device.function PCI identifier string
29 """
30 return self._pci_info_ext.bus_id 1bacd
32 @property
33 def device(self) -> int:
34 """
35 The device's id on the bus, 0 to 31
36 """
37 return self._pci_info_ext.device_ 1a
39 @property
40 def domain(self) -> int:
41 """
42 The PCI domain on which the device's bus resides, 0 to 0xffffffff
43 """
44 return self._pci_info_ext.domain 1a
46 @property
47 def vendor_id(self) -> int:
48 """
49 The PCI vendor id of the device
50 """
51 return self._pci_info_ext.pci_device_id & 0xFFFF 1a
53 @property
54 def device_id(self) -> int:
55 """
56 The PCI device id of the device
57 """
58 return self._pci_info_ext.pci_device_id >> 16 1a
60 @property
61 def subsystem_id(self) -> int:
62 """
63 The subsystem device ID
64 """
65 return self._pci_info_ext.pci_sub_system_id 1a
67 @property
68 def base_class(self) -> int:
69 """
70 The 8-bit PCI base class code
71 """
72 return self._pci_info_ext.base_class 1a
74 @property
75 def sub_class(self) -> int:
76 """
77 The 8-bit PCI sub class code
78 """
79 return self._pci_info_ext.sub_class 1a
81 @property
82 def link_generation(self) -> int:
83 """
84 Retrieve the maximum PCIe link generation possible with this device and system.
86 For Fermi™ or newer fully supported devices.
88 For example, for a generation 2 PCIe device attached to a generation 1
89 PCIe bus, the max link generation this function will report is
90 generation 1.
91 """
92 return nvml.device_get_max_pcie_link_generation(self._handle) 1a
94 @property
95 def max_link_generation(self) -> int:
96 """
97 Retrieve the maximum PCIe link generation supported by this GPU device.
99 For Fermi™ or newer fully supported devices.
100 """
101 return nvml.device_get_gpu_max_pcie_link_generation(self._handle) 1a
103 @property
104 def max_link_width(self) -> int:
105 """
106 Retrieve the maximum PCIe link width possible with this device and system.
108 For Fermi™ or newer fully supported devices.
110 For example, for a device with a 16x PCIe bus width attached to a 8x
111 PCIe system bus this function will report
112 a max link width of 8.
113 """
114 return nvml.device_get_max_pcie_link_width(self._handle) 1a
116 @property
117 def current_link_generation(self) -> int:
118 """
119 Retrieve the current PCIe link generation.
121 For Fermi™ or newer fully supported devices.
122 """
123 return nvml.device_get_curr_pcie_link_generation(self._handle) 1a
125 @property
126 def current_link_width(self) -> int:
127 """
128 Retrieve the current PCIe link width.
130 For Fermi™ or newer fully supported devices.
131 """
132 return nvml.device_get_curr_pcie_link_width(self._handle) 1a
134 @property
135 def rx_throughput(self) -> int:
136 """
137 Retrieve PCIe reception throughput, in KB/s.
139 This function is querying a byte counter over a 20ms interval, and thus
140 is the PCIe throughput over that interval.
142 For Maxwell™ or newer fully supported devices.
144 This method is not supported in virtual machines running virtual GPU
145 (vGPU).
146 """
147 return nvml.device_get_pcie_throughput(self._handle, nvml.PcieUtilCounter.PCIE_UTIL_RX_BYTES) 1a
149 @property
150 def tx_throughput(self) -> int:
151 """
152 Retrieve PCIe transmission throughput, in KB/s.
154 This function is querying a byte counter over a 20ms interval, and thus
155 is the PCIe throughput over that interval.
157 For Maxwell™ or newer fully supported devices.
159 This method is not supported in virtual machines running virtual GPU
160 (vGPU).
161 """
162 return nvml.device_get_pcie_throughput(self._handle, nvml.PcieUtilCounter.PCIE_UTIL_TX_BYTES) 1a
164 @property
165 def replay_counter(self) -> int:
166 """
167 Retrieve the PCIe replay counter.
169 For Kepler™ or newer fully supported devices.
170 """
171 return nvml.device_get_pcie_replay_counter(self._handle) 1a