freedreno/fdperf: support dumping counters
This is useful for comparing two workloads. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16488>
This commit is contained in:
parent
267786be60
commit
e9e8c649cd
|
@ -49,8 +49,10 @@
|
|||
|
||||
static struct {
|
||||
int refresh_ms;
|
||||
bool dump;
|
||||
} options = {
|
||||
.refresh_ms = REFRESH_MS,
|
||||
.dump = false,
|
||||
};
|
||||
|
||||
/* NOTE first counter group should always be CP, since we unconditionally
|
||||
|
@ -113,6 +115,16 @@ gettime_us(void)
|
|||
return (ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
|
||||
}
|
||||
|
||||
static void
|
||||
sleep_us(uint32_t us)
|
||||
{
|
||||
const struct timespec ts = {
|
||||
.tv_sec = us / 1000000,
|
||||
.tv_nsec = (us % 1000000) * 1000,
|
||||
};
|
||||
clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, NULL);
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
delta(uint32_t a, uint32_t b)
|
||||
{
|
||||
|
@ -705,6 +717,39 @@ out:
|
|||
refresh();
|
||||
}
|
||||
|
||||
static void
|
||||
dump_counters(void)
|
||||
{
|
||||
resample();
|
||||
sleep_us(options.refresh_ms * 1000);
|
||||
resample();
|
||||
|
||||
for (unsigned i = 0; i < dev.ngroups; i++) {
|
||||
const struct counter_group *group = &dev.groups[i];
|
||||
for (unsigned j = 0; j < group->group->num_counters; j++) {
|
||||
const char *label = group->label[j];
|
||||
float val = group->current[j];
|
||||
|
||||
/* we did not config the first CP counter */
|
||||
if (i == 0 && j == 0)
|
||||
label = group->group->countables[0].name;
|
||||
|
||||
int n = printf("%s: ", label) - 2;
|
||||
while (n++ < ctr_width)
|
||||
fputc(' ', stdout);
|
||||
|
||||
if (strstr(label, "CYCLE") ||
|
||||
strstr(label, "BUSY") ||
|
||||
strstr(label, "IDLE")) {
|
||||
val = val / dev.max_freq * 100.0f;
|
||||
printf("%.2f%%\n", val);
|
||||
} else {
|
||||
printf("%'.2f\n", val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
restore_counter_groups(void)
|
||||
{
|
||||
|
@ -846,6 +891,7 @@ print_usage(const char *argv0)
|
|||
"Usage: %s [OPTION]...\n"
|
||||
"\n"
|
||||
" -r <N> refresh every N milliseconds\n"
|
||||
" -d dump counters and exit\n"
|
||||
" -h show this message\n",
|
||||
argv0);
|
||||
exit(2);
|
||||
|
@ -856,11 +902,14 @@ parse_options(int argc, char **argv)
|
|||
{
|
||||
int c;
|
||||
|
||||
while ((c = getopt(argc, argv, "r:")) != -1) {
|
||||
while ((c = getopt(argc, argv, "r:d")) != -1) {
|
||||
switch (c) {
|
||||
case 'r':
|
||||
options.refresh_ms = atoi(optarg);
|
||||
break;
|
||||
case 'd':
|
||||
options.dump = true;
|
||||
break;
|
||||
default:
|
||||
print_usage(argv[0]);
|
||||
break;
|
||||
|
@ -897,7 +946,10 @@ main(int argc, char **argv)
|
|||
config_restore();
|
||||
flush_ring();
|
||||
|
||||
main_ui();
|
||||
if (options.dump)
|
||||
dump_counters();
|
||||
else
|
||||
main_ui();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue