I'm using libpfm4 to determine Intel performance monitor counter encodings (e.g., to map between a human-readable name and the encoding).
Intel PMUs have a number of "fixed counters" which can be enabled or disabled, but when enabled always count the same event. libpfc exposes the number of fixed counters in pfm_pmu_info_t.num_fixed_cntrs
, but how can I determine what events these fixed counters map too?
The events that the fixed counters cover are listed in the event lists, but it's the general encoding so you'd have to waste a general purpose counter to program it that way.
For Intel, there are generally 3 fixed counters on all recent0 chips:
INST_RETIRED.ANY
CPU_CLK_UNHALTED.THREAD
CPU_CLK_UNHALTED.REF_TSC
Details can be found in table 18-2 of Vol. 3B of the Intel SDM1.
0 In particular, anything that supports at least Architecural PMU version 2, which are Intel Core 2 Duo processor T7700 and newer processors based on Intel Core microarchitecture.
1 The table is Table 18-2. Association of Fixed-Function Performance Counters with Architectural Performance Events, in the December 2016 edition.