|
Packit |
577717 |
.TH LIBPFM 3 "September, 2009" "" "Linux Programmer's Manual"
|
|
Packit |
577717 |
.SH NAME
|
|
Packit |
577717 |
pfm_get_event_next \- iterate over events
|
|
Packit |
577717 |
.SH SYNOPSIS
|
|
Packit |
577717 |
.nf
|
|
Packit |
577717 |
.B #include <perfmon/pfmlib.h>
|
|
Packit |
577717 |
.sp
|
|
Packit |
577717 |
.BI "int pfm_get_event_next(int "idx ");"
|
|
Packit |
577717 |
.sp
|
|
Packit |
577717 |
.SH DESCRIPTION
|
|
Packit |
577717 |
Events are uniquely identified with opaque integer identifiers.
|
|
Packit |
577717 |
There is no guaranteed order within identifiers. Thus, to list
|
|
Packit |
577717 |
all the events, it is necessary to use iterators.
|
|
Packit |
577717 |
|
|
Packit |
577717 |
Events are grouped in tables within the library. A table usually
|
|
Packit |
577717 |
corresponds to a PMU model or family. The library contains support
|
|
Packit |
577717 |
for multiple PMU models, thus it has multiple tables. Based on the
|
|
Packit |
577717 |
host hardware and software environments, tables get activated when
|
|
Packit |
577717 |
the library is initialized via \fBpfm_initialize()\fR. Events from
|
|
Packit |
577717 |
activated tables are called active events. Events from
|
|
Packit |
577717 |
non-activated tables are called supported events.
|
|
Packit |
577717 |
|
|
Packit |
577717 |
Event identifiers are usually retrieved via \fBpfm_find_event()\fR or
|
|
Packit |
577717 |
when encoding events.
|
|
Packit |
577717 |
|
|
Packit |
577717 |
To iterate over a list of events for a given PMU model, all that is
|
|
Packit |
577717 |
needed is an initial identifier for the PMU. The first event identifier
|
|
Packit |
577717 |
is usually obtained via \fBpfm_get_pmu_info()\fR.
|
|
Packit |
577717 |
|
|
Packit |
577717 |
The \fBpfm_get_event_next()\fR function returns the identifier of
|
|
Packit |
577717 |
next supported event after the one passed in \fBidx\fR. This iterator
|
|
Packit |
577717 |
stops when the last event for the PMU is passed as argument, in which
|
|
Packit |
577717 |
case the function returns \-1.
|
|
Packit |
577717 |
.sp
|
|
Packit |
577717 |
.nf
|
|
Packit |
577717 |
void list_pmu_events(pfm_pmu_t pmu)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
struct pfm_event_info info;
|
|
Packit |
577717 |
struct pfm_pmu_info pinfo;
|
|
Packit |
577717 |
int i, ret;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
memset(&info, 0, sizeof(info));
|
|
Packit |
577717 |
memset(&pinfo, 0, sizeof(pinfo));
|
|
Packit |
577717 |
|
|
Packit |
577717 |
info.size = sizeof(info);
|
|
Packit |
577717 |
pinfo.size = sizeof(pinfo);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
ret = pfm_get_pmu_info(pmu, &pinfo);
|
|
Packit |
577717 |
if (ret != PFM_SUCCESS)
|
|
Packit |
577717 |
errx(1, "cannot get pmu info");
|
|
Packit |
577717 |
|
|
Packit |
577717 |
for (i = pinfo.first_event; i != \-1; i = pfm_get_event_next(i)) {
|
|
Packit |
577717 |
ret = pfm_get_event_info(i, &info;;
|
|
Packit |
577717 |
if (ret != PFM_SUCCESS)
|
|
Packit |
577717 |
errx(1, "cannot get event info");
|
|
Packit |
577717 |
|
|
Packit |
577717 |
printf("%s Event: %s::%s\\n",
|
|
Packit |
577717 |
pinfo.present ? "Active" : "Supported",
|
|
Packit |
577717 |
pinfo.name, info.name);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
.fi
|
|
Packit |
577717 |
|
|
Packit |
577717 |
.SH RETURN
|
|
Packit |
577717 |
The function returns the identifier of the next
|
|
Packit |
577717 |
supported event. It returns \-1 when the argument is already the last
|
|
Packit |
577717 |
event for the PMU.
|
|
Packit |
577717 |
|
|
Packit |
577717 |
.SH ERRORS
|
|
Packit |
577717 |
No error code, besides \-1, is returned by this function.
|
|
Packit |
577717 |
.SH SEE ALSO
|
|
Packit |
577717 |
pfm_find_event(3)
|
|
Packit |
577717 |
.SH AUTHOR
|
|
Packit |
577717 |
Stephane Eranian <eranian@gmail.com>
|
|
Packit |
577717 |
.PP
|