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

1# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. 

2# 

3# SPDX-License-Identifier: Apache-2.0 

4  

5  

6cdef class PciInfo: 

7 """ 

8 PCI information about a GPU device. 

9 """ 

10  

11 cdef object _pci_info_ext 

12 cdef intptr_t _handle 

13  

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

17  

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

24  

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

31  

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

38  

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

45  

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

52  

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

59  

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

66  

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

73  

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

80  

81 @property 

82 def link_generation(self) -> int: 

83 """ 

84 Retrieve the maximum PCIe link generation possible with this device and system. 

85  

86 For Fermi™ or newer fully supported devices. 

87  

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

93  

94 @property 

95 def max_link_generation(self) -> int: 

96 """ 

97 Retrieve the maximum PCIe link generation supported by this GPU device. 

98  

99 For Fermi™ or newer fully supported devices. 

100 """ 

101 return nvml.device_get_gpu_max_pcie_link_generation(self._handle) 1a

102  

103 @property 

104 def max_link_width(self) -> int: 

105 """ 

106 Retrieve the maximum PCIe link width possible with this device and system. 

107  

108 For Fermi™ or newer fully supported devices. 

109  

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

115  

116 @property 

117 def current_link_generation(self) -> int: 

118 """ 

119 Retrieve the current PCIe link generation. 

120  

121 For Fermi™ or newer fully supported devices. 

122 """ 

123 return nvml.device_get_curr_pcie_link_generation(self._handle) 1a

124  

125 @property 

126 def current_link_width(self) -> int: 

127 """ 

128 Retrieve the current PCIe link width. 

129  

130 For Fermi™ or newer fully supported devices. 

131 """ 

132 return nvml.device_get_curr_pcie_link_width(self._handle) 1a

133  

134 @property 

135 def rx_throughput(self) -> int: 

136 """ 

137 Retrieve PCIe reception throughput, in KB/s. 

138  

139 This function is querying a byte counter over a 20ms interval, and thus 

140 is the PCIe throughput over that interval. 

141  

142 For Maxwell™ or newer fully supported devices. 

143  

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

148  

149 @property 

150 def tx_throughput(self) -> int: 

151 """ 

152 Retrieve PCIe transmission throughput, in KB/s. 

153  

154 This function is querying a byte counter over a 20ms interval, and thus 

155 is the PCIe throughput over that interval. 

156  

157 For Maxwell™ or newer fully supported devices. 

158  

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

163  

164 @property 

165 def replay_counter(self) -> int: 

166 """ 

167 Retrieve the PCIe replay counter. 

168  

169 For Kepler™ or newer fully supported devices. 

170 """ 

171 return nvml.device_get_pcie_replay_counter(self._handle) 1a