@@ -66,15 +66,20 @@ static struct gpu_info_intel *gpu_infos;
6666
6767__attribute__((constructor )) static void init_extract_gpuinfo_intel (void ) { register_gpu_vendor (& gpu_vendor_intel ); }
6868
69- bool gpuinfo_intel_init (void ) { return true; }
69+ bool gpuinfo_intel_init (void ) {
70+ gpuinfo_intel_xpumanager_init ();
71+ return true;
72+ }
73+
7074void gpuinfo_intel_shutdown (void ) {
71- for (unsigned i = 0 ; i < intel_gpu_count ; ++ i ) {
72- struct gpu_info_intel * current = & gpu_infos [i ];
73- if (current -> card_fd )
74- close (current -> card_fd );
75- nvtop_device_unref (current -> card_device );
76- nvtop_device_unref (current -> driver_device );
77- }
75+ for (unsigned i = 0 ; i < intel_gpu_count ; ++ i ) {
76+ struct gpu_info_intel * current = & gpu_infos [i ];
77+ if (current -> card_fd )
78+ close (current -> card_fd );
79+ nvtop_device_unref (current -> card_device );
80+ nvtop_device_unref (current -> driver_device );
81+ }
82+ gpuinfo_intel_xpumanager_shutdown ();
7883}
7984
8085const char * gpuinfo_intel_last_error_string (void ) { return "Err" ; }
@@ -109,6 +114,7 @@ static void add_intel_cards(struct nvtop_device *dev, struct list_head *devices,
109114 thisGPU -> card_device = nvtop_device_ref (dev );
110115 thisGPU -> driver_device = nvtop_device_ref (parent );
111116 thisGPU -> hwmon_device = nvtop_device_get_hwmon (thisGPU -> driver_device );
117+ thisGPU -> xpum_device_id = -1 ;
112118
113119 const char * devname ;
114120 if (nvtop_device_get_devname (thisGPU -> card_device , & devname ) >= 0 )
@@ -118,6 +124,12 @@ static void add_intel_cards(struct nvtop_device *dev, struct list_head *devices,
118124 int retval = nvtop_device_get_property_value (thisGPU -> driver_device , "PCI_SLOT_NAME" , & pdev_val );
119125 assert (retval >= 0 && pdev_val != NULL && "Could not retrieve device PCI slot name" );
120126 strncpy (thisGPU -> base .pdev , pdev_val , PDEV_LEN );
127+
128+ if (gpuinfo_intel_xpumanager_is_available ()) {
129+ gpuinfo_intel_xpumanager_get_device_id (pdev_val , & thisGPU -> xpum_device_id );
130+ gpuinfo_intel_xpumanager_populate_static_info (& thisGPU -> base , thisGPU -> xpum_device_id );
131+ }
132+
121133 list_add_tail (& thisGPU -> base .list , devices );
122134 // Register a fdinfo callback for this GPU
123135 processinfo_register_fdinfo_callback (parse_drm_fdinfo_intel , & thisGPU -> base );
@@ -224,6 +236,13 @@ void gpuinfo_intel_refresh_dynamic_info(struct gpu_info *_gpu_info) {
224236
225237 RESET_ALL (dynamic_info -> valid );
226238
239+ if (gpu_info -> xpum_device_id >= 0 && gpuinfo_intel_xpumanager_is_available ()) {
240+ gpuinfo_intel_xpumanager_refresh_dynamic_info (_gpu_info , gpu_info -> xpum_device_id );
241+ if (GPUINFO_DYNAMIC_FIELD_VALID (dynamic_info , gpu_util_rate )) {
242+ return ;
243+ }
244+ }
245+
227246 // We are creating new devices because the device_get_sysattr_value caches its querries
228247 const char * syspath ;
229248 nvtop_device * card_dev_noncached = NULL ;
0 commit comments