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

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

2# 

3# SPDX-License-Identifier: Apache-2.0 

4  

5  

6PcieUtilCounter = nvml.PcieUtilCounter 

7  

8  

9cdef class PciInfo: 

10 """ 

11 PCI information about a GPU device. 

12 """ 

13  

14 cdef object _pci_info_ext 

15 cdef intptr_t _handle 

16  

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

20  

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

27  

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

34  

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

41  

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

48  

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

55  

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

62  

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

69  

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

76  

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

83  

84 @property 

85 def link_generation(self) -> int: 

86 """ 

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

88  

89 For Fermi™ or newer fully supported devices. 

90  

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

96  

97 @property 

98 def max_link_generation(self) -> int: 

99 """ 

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

101  

102 For Fermi™ or newer fully supported devices. 

103 """ 

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

105  

106 @property 

107 def max_link_width(self) -> int: 

108 """ 

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

110  

111 For Fermi™ or newer fully supported devices. 

112  

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

118  

119 @property 

120 def current_link_generation(self) -> int: 

121 """ 

122 Retrieve the current PCIe link generation. 

123  

124 For Fermi™ or newer fully supported devices. 

125 """ 

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

127  

128 @property 

129 def current_link_width(self) -> int: 

130 """ 

131 Retrieve the current PCIe link width. 

132  

133 For Fermi™ or newer fully supported devices. 

134 """ 

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

136  

137 def get_throughput(self, counter: PcieUtilCounter) -> int: 

138 """ 

139 Retrieve PCIe utilization information, in KB/s. 

140  

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

142 is the PCIe throughput over that interval. 

143  

144 For Maxwell™ or newer fully supported devices. 

145  

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

150  

151 @property 

152 def replay_counter(self) -> int: 

153 """ 

154 Retrieve the PCIe replay counter. 

155  

156 For Kepler™ or newer fully supported devices. 

157 """ 

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