I can not find any instructions on how to compile a list
of human readable event mappings that libpfm4's pfm_get_os_event_encoding()
will map to the corresponding values that i can pass to rdpmc
. Every time i try anything but cycles
or instructions
from e.g the output of perf list
libpfm4 can't find it.
I can not find any instructions on how to compile a list
of human readable event mappings that libpfm4's pfm_get_os_event_encoding()
will map to the corresponding values that i can pass to rdpmc
. Every time i try anything but cycles
or instructions
from e.g the output of perf list
libpfm4 can't find it.
EDIT/SOLUTION: There is example code hidden in the docs to list available events for every PMU:
void list_pmu_events(pfm_pmu_t pmu)
{
pfm_event_info_t info;
pfm_pmu_info_t pinfo;
int i, ret;
memset(&info, 0, sizeof(info));
memset(&pinfo, 0, sizeof(pinfo));
info.size = sizeof(info);
pinfo.size = sizeof(pinfo);
ret = pfm_get_pmu_info(pmu, &pinfo);
if (ret != PFM_SUCCESS)
return;
errx(1, "cannot get pmu info");
for (i = pinfo.first_event; i != -1; i = pfm_get_event_next(i)) {
ret = pfm_get_event_info(i, PFM_OS_PERF_EVENT_EXT, &info);
if (ret != PFM_SUCCESS)
errx(1, "cannot get event info");
if (pfm_find_event(info.name) && pinfo.is_present) {
printf("Event: %s::%s\n",
pinfo.name, info.name);
}
}
}
cycles
and one toinstructions
. So the same numbers in ECX forrdpmc
will always work. The other counters are programmable, with the kernel having to program one of the other counters with the event and mask (documentation specific to each microarchitecture).rdpmc
can index one of those, too, but you have to know which counter is programmed to count what. And If you didn't program them to count an event withperf
orpfm
functions, they won't be counting anything. I haven't used libpfm, but you can't just use ECX values. – Peter Cordes Commented Feb 4 at 3:32