2 * Copyright (c) 2016 Julien Desfossez <jdesfossez@efficios.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * as published by the Free Software Foundation; only version 2
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include <perfmon/pfmlib.h>
23 int main(int argc
, char **argv
)
30 fprintf(stderr
, "Usage: %s <pmu counter to find>\n"
31 "ex: %s UNHALTED_REFERENCE_CYCLES\n"
32 "Returns the first occurence it finds with "
34 "If not found returns 1, on error returns -1\n",
40 memset(&pinfo
, 0, sizeof(pinfo
));
41 pinfo
.size
= sizeof(pinfo
);
43 ret
= pfm_initialize();
44 if (ret
!= PFM_SUCCESS
) {
45 fprintf(stderr
, "Failed to initialise libpfm: %s",
52 ret
= pfm_get_pmu_info(j
, &pinfo
);
53 if (ret
!= PFM_SUCCESS
) {
57 for (i
= pinfo
.first_event
; i
!= -1; i
= pfm_get_event_next(i
)) {
58 pfm_event_info_t info
=
59 { .size
= sizeof(pfm_event_info_t
) };
61 ret
= pfm_get_event_info(i
, PFM_OS_NONE
, &info
);
62 if (ret
!= PFM_SUCCESS
) {
63 fprintf(stderr
, "Cannot get event info: %s\n",
73 if (strcmp(info
.name
, argv
[1]) == 0) {
74 fprintf(stdout
, "r%" PRIx64
"\n", info
.code
);
This page took 0.030888 seconds and 4 git commands to generate.