2 * Copyright (C) 2016 Julien Desfossez <jdesfossez@efficios.com>
4 * SPDX-License-Identifier: GPL-2.0-only
9 #include <perfmon/pfmlib.h>
12 int main(int argc
, char **argv
)
19 fprintf(stderr
, "Usage: %s <pmu counter to find>\n"
20 "ex: %s UNHALTED_REFERENCE_CYCLES\n"
21 "Returns the first occurence it finds with "
23 "If not found returns 1, on error returns -1\n",
29 memset(&pinfo
, 0, sizeof(pinfo
));
30 pinfo
.size
= sizeof(pinfo
);
32 ret
= pfm_initialize();
33 if (ret
!= PFM_SUCCESS
) {
34 fprintf(stderr
, "Failed to initialise libpfm: %s",
41 ret
= pfm_get_pmu_info(j
, &pinfo
);
42 if (ret
!= PFM_SUCCESS
) {
46 for (i
= pinfo
.first_event
; i
!= -1; i
= pfm_get_event_next(i
)) {
47 pfm_event_info_t info
=
48 { .size
= sizeof(pfm_event_info_t
) };
50 ret
= pfm_get_event_info(i
, PFM_OS_NONE
, &info
);
51 if (ret
!= PFM_SUCCESS
) {
52 fprintf(stderr
, "Cannot get event info: %s\n",
62 if (strcmp(info
.name
, argv
[1]) == 0) {
63 fprintf(stdout
, "r%" PRIx64
"\n", info
.code
);
This page took 0.034357 seconds and 4 git commands to generate.