mesa/src/panfrost/perf/quick.c
Alyssa Rosenzweig 0afd691f29 panfrost: clang-format the tree
This switches us over to Mesa's code style [1], normalizing us within the tree.
The results aren't perfect, but they bring us a hell of a lot closer to the rest
of the tree. Panfrost doesn't feel so foreign relative to Mesa with this, which
I think (in retrospect after a bunch of years of being "different") is the right
call.

I skipped PanVK because that's paused right now.

  find panfrost/ -type f -name '*.h' | grep -v vulkan | xargs clang-format -i;
  find panfrost/ -type f -name '*.c' | grep -v vulkan | xargs clang-format -i;
  clang-format -i gallium/drivers/panfrost/*.c gallium/drivers/panfrost/*.h ; find
  panfrost/ -type f -name '*.cpp' | grep -v vulkan | xargs clang-format -i

[1] https://docs.mesa3d.org/codingstyle.html

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20425>
2022-12-24 02:22:57 +00:00

56 lines
1.3 KiB
C

#include <stdio.h>
#include <lib/pan_device.h>
#include "pan_perf.h"
int
main(void)
{
int fd = drmOpenWithType("panfrost", NULL, DRM_NODE_RENDER);
if (fd < 0) {
fprintf(stderr, "No panfrost device\n");
exit(1);
}
void *ctx = ralloc_context(NULL);
struct panfrost_perf *perf = rzalloc(ctx, struct panfrost_perf);
struct panfrost_device dev = {};
panfrost_open_device(ctx, fd, &dev);
panfrost_perf_init(perf, &dev);
int ret = panfrost_perf_enable(perf);
if (ret < 0) {
fprintf(stderr, "failed to enable counters (%d)\n", ret);
fprintf(
stderr,
"try `# echo Y > /sys/module/panfrost/parameters/unstable_ioctls`\n");
exit(1);
}
sleep(1);
panfrost_perf_dump(perf);
for (unsigned i = 0; i < perf->cfg->n_categories; ++i) {
const struct panfrost_perf_category *cat = &perf->cfg->categories[i];
printf("%s\n", cat->name);
for (unsigned j = 0; j < cat->n_counters; ++j) {
const struct panfrost_perf_counter *ctr = &cat->counters[j];
uint32_t val = panfrost_perf_counter_read(ctr, perf);
printf("%s (%s): %u\n", ctr->name, ctr->symbol_name, val);
}
printf("\n");
}
if (panfrost_perf_disable(perf) < 0) {
fprintf(stderr, "failed to disable counters\n");
exit(1);
}
panfrost_close_device(&dev);
}