@@ -244,22 +244,21 @@ int GPU_fdinfo::get_gpu_load()
244
244
return result;
245
245
}
246
246
247
- void GPU_fdinfo::find_intel_gt_dir ()
247
+ void GPU_fdinfo::find_i915_gt_dir ()
248
248
{
249
249
std::string device = " /sys/bus/pci/devices/" + pci_dev + " /drm" ;
250
250
251
- auto dir_iterator = fs::directory_iterator (device);
252
-
253
251
// Find first dir which starts with name "card"
254
252
for (const auto & entry : fs::directory_iterator (device)) {
255
253
auto path = entry.path ().string ();
254
+
256
255
if (path.substr (device.size () + 1 , 4 ) == " card" ) {
257
256
device = path;
258
257
break ;
259
258
}
260
259
}
261
260
262
- device += " /gt_cur_freq_mhz " ;
261
+ device += " /gt_act_freq_mhz " ;
263
262
264
263
if (!fs::exists (device)) {
265
264
SPDLOG_WARN (
@@ -272,13 +271,63 @@ void GPU_fdinfo::find_intel_gt_dir()
272
271
gpu_clock_stream.open (device);
273
272
274
273
if (!gpu_clock_stream.good ())
275
- SPDLOG_WARN (" Intel gt dir: failed to open {}" , device);
274
+ SPDLOG_WARN (" Intel i915 gt dir: failed to open {}" , device);
275
+ }
276
+
277
+ void GPU_fdinfo::find_xe_gt_dir ()
278
+ {
279
+ std::string device = " /sys/bus/pci/devices/" + pci_dev + " /tile0" ;
280
+
281
+ if (!fs::exists (device)) {
282
+ SPDLOG_WARN (
283
+ " \" {}\" doesn't exist. GPU clock will be unavailable." ,
284
+ device
285
+ );
286
+ return ;
287
+ }
288
+
289
+ bool has_rcs = true ;
290
+
291
+ // Check every "gt" dir if it has "engines/rcs" inside
292
+ for (const auto & entry : fs::directory_iterator (device)) {
293
+ auto path = entry.path ().string ();
294
+
295
+ if (path.substr (device.size () + 1 , 2 ) != " gt" )
296
+ continue ;
297
+
298
+ SPDLOG_DEBUG (" Checking \" {}\" for rcs." , path);
299
+
300
+ if (!fs::exists (path + " /engines/rcs" )) {
301
+ SPDLOG_DEBUG (" Skipping \" {}\" because rcs doesn't exist." , path);
302
+ continue ;
303
+ }
304
+
305
+ SPDLOG_DEBUG (" Found rcs in \" {}\" " , path);
306
+ has_rcs = true ;
307
+ device = path;
308
+ break ;
309
+
310
+ }
311
+
312
+ if (!has_rcs) {
313
+ SPDLOG_WARN (
314
+ " rcs not found inside \" {}\" . GPU clock will not be available." ,
315
+ device
316
+ );
317
+ return ;
318
+ }
319
+
320
+ device += " /freq0/act_freq" ;
321
+
322
+ gpu_clock_stream.open (device);
323
+
324
+ if (!gpu_clock_stream.good ())
325
+ SPDLOG_WARN (" Intel xe gt dir: failed to open {}" , device);
276
326
}
277
327
278
328
int GPU_fdinfo::get_gpu_clock ()
279
329
{
280
- // Only i915 currently supported
281
- if (module != " i915" || !gpu_clock_stream.is_open ())
330
+ if (!gpu_clock_stream.is_open ())
282
331
return 0 ;
283
332
284
333
std::string clock_str;
0 commit comments