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

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 def get_max_pcie_link_generation(self) -> int: 

85 """ 

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

87  

88 For Fermi™ or newer fully supported devices. 

89  

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

95  

96 def get_gpu_max_pcie_link_generation(self) -> int: 

97 """ 

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

99  

100 For Fermi™ or newer fully supported devices. 

101 """ 

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

103  

104 def get_max_pcie_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 def get_current_pcie_link_generation(self) -> int: 

117 """ 

118 Retrieve the current PCIe link generation. 

119  

120 For Fermi™ or newer fully supported devices. 

121 """ 

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

123  

124 def get_current_pcie_link_width(self) -> int: 

125 """ 

126 Retrieve the current PCIe link width. 

127  

128 For Fermi™ or newer fully supported devices. 

129 """ 

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

131  

132 def get_pcie_throughput(self, counter: PcieUtilCounter) -> int: 

133 """ 

134 Retrieve PCIe utilization information, in KB/s. 

135  

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

137 is the PCIe throughput over that interval. 

138  

139 For Maxwell™ or newer fully supported devices. 

140  

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

145  

146 def get_pcie_replay_counter(self) -> int: 

147 """ 

148 Retrieve the PCIe replay counter. 

149  

150 For Kepler™ or newer fully supported devices. 

151 """ 

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