[PATCH i-g-t v2 16/21] gputop: Add support to drm-cycles/drm-total-cycles
Lucas De Marchi
lucas.demarchi at intel.com
Tue Apr 23 23:44:26 UTC 2024
Add support for using only GPU timestamps to calculate the utilization.
It uses drm-cycles and drm-total-cycles read from fdinfo. For any
2 samples, the utilization is calculated as:
u[i+1] - u[i]
pct = -----------------
Gt[i+1] - Gt[i]
with u == drm-cycles and Gt == drm-total-cycles.
Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
---
tools/gputop.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/tools/gputop.c b/tools/gputop.c
index bca7f4bc7..9edb76acc 100644
--- a/tools/gputop.c
+++ b/tools/gputop.c
@@ -208,8 +208,16 @@ print_client(struct igt_drm_client *c, struct igt_drm_client **prevc,
if (!c->engines->capacity[i])
continue;
- pct = (double)c->u[i].delta_busy / period_us / 1e3 * 100 /
- c->engines->capacity[i];
+ switch (c->dcut) {
+ case DCUT_ENGINE_TIME:
+ pct = (double)c->u[i].delta_busy / period_us / 1e3 * 100 /
+ c->engines->capacity[i];
+ break;
+ case DCUT_GPU_TOTAL_CYCLES:
+ pct = (double)c->u[i].delta_busy / c->u[i].delta_total_cycles * 100 /
+ c->engines->capacity[i];
+ break;
+ }
/*
* Guard against fluctuations between our scanning period and
--
2.43.0
More information about the igt-dev
mailing list