Coverage for cuda / core / system / _pci_info.pxi: 69.23%
26 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
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 def get_max_pcie_link_generation(self) -> int:
85 """
86 Retrieve the maximum PCIe link generation possible with this device and system.
88 For Fermi™ or newer fully supported devices.
90 For example, for a generation 2 PCIe device attached to a generation 1
91 PCIe bus, the max link generation this function will report is
92 generation 1.
93 """
94 return nvml.device_get_max_pcie_link_generation(self._handle) 1a
96 def get_gpu_max_pcie_link_generation(self) -> int:
97 """
98 Retrieve the maximum PCIe link generation supported by this GPU device.
100 For Fermi™ or newer fully supported devices.
101 """
102 return nvml.device_get_gpu_max_pcie_link_generation(self._handle) 1a
104 def get_max_pcie_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 def get_current_pcie_link_generation(self) -> int:
117 """
118 Retrieve the current PCIe link generation.
120 For Fermi™ or newer fully supported devices.
121 """
122 return nvml.device_get_curr_pcie_link_generation(self._handle) 1a
124 def get_current_pcie_link_width(self) -> int:
125 """
126 Retrieve the current PCIe link width.
128 For Fermi™ or newer fully supported devices.
129 """
130 return nvml.device_get_curr_pcie_link_width(self._handle) 1a
132 def get_pcie_throughput(self, counter: PcieUtilCounter) -> int:
133 """
134 Retrieve PCIe utilization information, in KB/s.
136 This function is querying a byte counter over a 20ms interval, and thus
137 is the PCIe throughput over that interval.
139 For Maxwell™ or newer fully supported devices.
141 This method is not supported in virtual machines running virtual GPU
142 (vGPU).
143 """
144 return nvml.device_get_pcie_throughput(self._handle, counter) 1a
146 def get_pcie_replay_counter(self) -> int:
147 """
148 Retrieve the PCIe replay counter.
150 For Kepler™ or newer fully supported devices.
151 """
152 return nvml.device_get_pcie_replay_counter(self._handle) 1a