Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions rpi-gpu-usage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ information to find the processes that have drm stats information like:
```

The application then outputs total GPU usage for the renderer (shaders)
tfu (texture format unit) and binning blocks. It also reads the total CPU
usage for that process.
tfu (texture format unit), binning, csd (compute shader dispatch) and
cache_clean blocks. It also reads the total CPU usage for that process.

```
GPU Utilisation

Client PID Process render tfu bin CPU
----------------------------------------------------------------------
14 2215 labwc 13.2% 0.0% 0.3% 18.7%
38 10668 chromium 0.0% 0.0% 0.0% 0.0%
Client PID Process render tfu bin csd clean CPU
------------------------------------------------------------------------------
14 2215 labwc 13.2% 0.0% 0.3% 0.0% 0.0% 18.7%
187 10982 litert-lm 0.0% 0.0% 0.0% 99.8% 0.2% 99.4%
```

**Command line options**
Expand Down
10 changes: 9 additions & 1 deletion rpi-gpu-usage/rpi-gpu-usage.1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ It reads per-process GPU engine times from DRM fdinfo and global
utilisation from the V3D gpu_stats sysfs interface.
.PP
The display is refreshed once per second, showing per-client
GPU engine usage (render, tfu, bin) and CPU usage.
GPU engine usage (render, tfu, bin, csd, cache_clean) and CPU usage.
.PP
Note that compute workloads (OpenCL, Vulkan compute, ML inference)
run on the
.B csd
queue rather than the render queue, so they will only be visible in
the
.B csd
column.
.SH OPTIONS
.TP
.B \-\-csv
Expand Down
36 changes: 21 additions & 15 deletions rpi-gpu-usage/rpi-gpu-usage.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
#define MAX_CLIENTS 256
#define MAX_COMM 64

/* Engine indices for the three we display */
#define ENG_RENDER 0
#define ENG_TFU 1
#define ENG_BIN 2
#define N_ENGINES 3
/* Engine indices for the queues we display */
#define ENG_RENDER 0
#define ENG_TFU 1
#define ENG_BIN 2
#define ENG_CSD 3
#define ENG_CACHE_CLEAN 4
#define N_ENGINES 5

struct client {
int id;
Expand Down Expand Up @@ -123,9 +125,11 @@ static double read_proc_cpu(int pid)
/* Map fdinfo engine name to our index, or -1 */
static int engine_idx(const char *name)
{
if (strcmp(name, "render") == 0) return ENG_RENDER;
if (strcmp(name, "tfu") == 0) return ENG_TFU;
if (strcmp(name, "bin") == 0) return ENG_BIN;
if (strcmp(name, "render") == 0) return ENG_RENDER;
if (strcmp(name, "tfu") == 0) return ENG_TFU;
if (strcmp(name, "bin") == 0) return ENG_BIN;
if (strcmp(name, "csd") == 0) return ENG_CSD;
if (strcmp(name, "cache_clean") == 0) return ENG_CACHE_CLEAN;
return -1;
}

Expand Down Expand Up @@ -295,7 +299,7 @@ int main(int argc, char *argv[])
curs_set(0);
} else {
printf("timestamp,client_id,pid,process,"
"render%%,tfu%%,bin%%,cpu%%\n");
"render%%,tfu%%,bin%%,csd%%,cache_clean%%,cpu%%\n");
}

struct client prev[MAX_CLIENTS], curr[MAX_CLIENTS];
Expand All @@ -322,11 +326,11 @@ int main(int argc, char *argv[])
if (!csv) {
clear();
mvprintw(0, 0, "GPU Utilisation\n\n");
printw("%6s %-8s %-16s %8s %8s %8s %8s\n",
printw("%6s %-7s %-14s %7s %7s %7s %7s %7s %7s\n",
"Client", "PID", "Process",
"render", "tfu", "bin", "CPU");
"render", "tfu", "bin", "csd", "clean", "CPU");
printw("----------------------------------------------"
"------------------------\n");
"--------------------------------\n");
}

for (int i = 0; i < ncurr; i++) {
Expand All @@ -344,15 +348,17 @@ int main(int argc, char *argv[])
double cpct = wall_dt > 0 ? cpu_d / wall_dt * 100.0 : 0.0;

if (csv)
printf("%.3f,%d,%d,%s,%.1f,%.1f,%.1f,%.1f\n",
printf("%.3f,%d,%d,%s,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f\n",
curr_wall, c->id, c->pid, c->comm,
pcts[ENG_RENDER], pcts[ENG_TFU], pcts[ENG_BIN],
pcts[ENG_CSD], pcts[ENG_CACHE_CLEAN],
cpct);
else
printw("%6d %-8d %-16s"
" %7.1f%% %7.1f%% %7.1f%% %7.1f%%\n",
printw("%6d %-7d %-14s"
" %6.1f%% %6.1f%% %6.1f%% %6.1f%% %6.1f%% %6.1f%%\n",
c->id, c->pid, c->comm,
pcts[ENG_RENDER], pcts[ENG_TFU], pcts[ENG_BIN],
pcts[ENG_CSD], pcts[ENG_CACHE_CLEAN],
cpct);
}

Expand Down
Loading