PAPI 7.1.0.0
Loading...
Searching...
No Matches
pfmlib.h File Reference
Include dependency graph for pfmlib.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  pfmlib_regmask_t
 
struct  pfmlib_event_t
 
struct  pfmlib_reg_t
 
struct  pfmlib_input_param_t
 
struct  pfmlib_output_param_t
 
struct  pfmlib_options_t
 

Macros

#define PFMLIB_VERSION   (3 << 16 | 10)
 
#define PFMLIB_MAJ_VERSION(v)   ((v)>>16)
 
#define PFMLIB_MIN_VERSION(v)   ((v) & 0xffff)
 
#define PFMLIB_MAX_PMCS   512 /* maximum number of PMCS supported by the library */
 
#define PFMLIB_MAX_PMDS   512 /* maximum number of PMDS supported by the library */
 
#define PFM_PLM0   0x1 /* priv level 0 */
 
#define PFM_PLM1   0x2 /* priv level 1 */
 
#define PFM_PLM2   0x4 /* priv level 2 */
 
#define PFM_PLM3   0x8 /* priv level 3 */
 
#define PFMLIB_REG_MAX   PFMLIB_MAX_PMDS
 
#define __PFMLIB_REG_BV_BITS   (sizeof(pfmlib_regmask_bits_t)<<3)
 
#define PFMLIB_BVSIZE(x)   (((x)+(__PFMLIB_REG_BV_BITS)-1) / __PFMLIB_REG_BV_BITS)
 
#define PFMLIB_REG_BV   PFMLIB_BVSIZE(PFMLIB_REG_MAX)
 
#define PFMLIB_MAX_MASKS_PER_EVENT   48 /* maximum number of unit masks per event */
 
#define PFMLIB_PFP_SYSTEMWIDE   0x1 /* indicate monitors will be used in a system-wide session */
 
#define PFMLIB_NO_PMU   -1 /* PMU unused (forced) */
 
#define PFMLIB_UNKNOWN_PMU   0 /* type not yet known (dynamic) */
 
#define PFMLIB_GEN_IA64_PMU   1 /* Intel IA-64 architected PMU */
 
#define PFMLIB_ITANIUM_PMU   2 /* Intel Itanium */
 
#define PFMLIB_ITANIUM2_PMU   3 /* Intel Itanium 2 */
 
#define PFMLIB_MONTECITO_PMU   4 /* Intel Dual-Core Itanium 2 9000 */
 
#define PFMLIB_AMD64_PMU   16 /* AMD AMD64 (K7, K8, Families 10h, 15h) */
 
#define PFMLIB_GEN_IA32_PMU   63 /* Intel architectural PMU for X86 */
 
#define PFMLIB_I386_P6_PMU   32 /* Intel PIII (P6 core) */
 
#define PFMLIB_PENTIUM4_PMU   33 /* Intel Pentium4/Xeon/EM64T */
 
#define PFMLIB_COREDUO_PMU   34 /* Intel Core Duo/Core Solo */
 
#define PFMLIB_I386_PM_PMU   35 /* Intel Pentium M */
 
#define PFMLIB_CORE_PMU   36 /* obsolete, use PFMLIB_INTEL_CORE_PMU */
 
#define PFMLIB_INTEL_CORE_PMU   36 /* Intel Core */
 
#define PFMLIB_INTEL_PPRO_PMU   37 /* Intel Pentium Pro */
 
#define PFMLIB_INTEL_PII_PMU   38 /* Intel Pentium II */
 
#define PFMLIB_INTEL_ATOM_PMU   39 /* Intel Atom */
 
#define PFMLIB_INTEL_NHM_PMU   40 /* Intel Nehalem */
 
#define PFMLIB_INTEL_WSM_PMU   41 /* Intel Westmere */
 
#define PFMLIB_MIPS_20KC_PMU   64 /* MIPS 20KC */
 
#define PFMLIB_MIPS_24K_PMU   65 /* MIPS 24K */
 
#define PFMLIB_MIPS_25KF_PMU   66 /* MIPS 25KF */
 
#define PFMLIB_MIPS_34K_PMU   67 /* MIPS 34K */
 
#define PFMLIB_MIPS_5KC_PMU   68 /* MIPS 5KC */
 
#define PFMLIB_MIPS_74K_PMU   69 /* MIPS 74K */
 
#define PFMLIB_MIPS_R10000_PMU   70 /* MIPS R10000 */
 
#define PFMLIB_MIPS_R12000_PMU   71 /* MIPS R12000 */
 
#define PFMLIB_MIPS_RM7000_PMU   72 /* MIPS RM7000 */
 
#define PFMLIB_MIPS_RM9000_PMU   73 /* MIPS RM9000 */
 
#define PFMLIB_MIPS_SB1_PMU   74 /* MIPS SB1/SB1A */
 
#define PFMLIB_MIPS_VR5432_PMU   75 /* MIPS VR5432 */
 
#define PFMLIB_MIPS_VR5500_PMU   76 /* MIPS VR5500 */
 
#define PFMLIB_MIPS_ICE9A_PMU   77 /* SiCortex ICE9A */
 
#define PFMLIB_MIPS_ICE9B_PMU   78 /* SiCortex ICE9B */
 
#define PFMLIB_POWERPC_PMU   90 /* POWERPC */
 
#define PFMLIB_CRAYX2_PMU   96 /* Cray X2 */
 
#define PFMLIB_CELL_PMU   100 /* CELL */
 
#define PFMLIB_PPC970_PMU   110 /* IBM PowerPC 970(FX,GX) */
 
#define PFMLIB_PPC970MP_PMU   111 /* IBM PowerPC 970MP */
 
#define PFMLIB_POWER3_PMU   112 /* IBM POWER3 */
 
#define PFMLIB_POWER4_PMU   113 /* IBM POWER4 */
 
#define PFMLIB_POWER5_PMU   114 /* IBM POWER5 */
 
#define PFMLIB_POWER5p_PMU   115 /* IBM POWER5+ */
 
#define PFMLIB_POWER6_PMU   116 /* IBM POWER6 */
 
#define PFMLIB_POWER7_PMU   117 /* IBM POWER7 */
 
#define PFMLIB_SPARC_ULTRA12_PMU   130 /* UltraSPARC I, II, IIi, and IIe */
 
#define PFMLIB_SPARC_ULTRA3_PMU   131 /* UltraSPARC III */
 
#define PFMLIB_SPARC_ULTRA3I_PMU   132 /* UltraSPARC IIIi and IIIi+ */
 
#define PFMLIB_SPARC_ULTRA3PLUS_PMU   133 /* UltraSPARC III+ and IV */
 
#define PFMLIB_SPARC_ULTRA4PLUS_PMU   134 /* UltraSPARC IV+ */
 
#define PFMLIB_SPARC_NIAGARA1_PMU   135 /* Niagara-1 */
 
#define PFMLIB_SPARC_NIAGARA2_PMU   136 /* Niagara-2 */
 
#define PFMLIB_SUCCESS   0 /* success */
 
#define PFMLIB_ERR_NOTSUPP   -1 /* function not supported */
 
#define PFMLIB_ERR_INVAL   -2 /* invalid parameters */
 
#define PFMLIB_ERR_NOINIT   -3 /* library was not initialized */
 
#define PFMLIB_ERR_NOTFOUND   -4 /* event not found */
 
#define PFMLIB_ERR_NOASSIGN   -5 /* cannot assign events to counters */
 
#define PFMLIB_ERR_FULL   -6 /* buffer is full or too small */
 
#define PFMLIB_ERR_EVTMANY   -7 /* event used more than once */
 
#define PFMLIB_ERR_MAGIC   -8 /* invalid library magic number */
 
#define PFMLIB_ERR_FEATCOMB   -9 /* invalid combination of features */
 
#define PFMLIB_ERR_EVTSET   -10 /* incompatible event sets */
 
#define PFMLIB_ERR_EVTINCOMP   -11 /* incompatible event combination */
 
#define PFMLIB_ERR_TOOMANY   -12 /* too many events or unit masks */
 
#define PFMLIB_ERR_IRRTOOBIG   -13 /* code range too big */
 
#define PFMLIB_ERR_IRREMPTY   -14 /* empty code range */
 
#define PFMLIB_ERR_IRRINVAL   -15 /* invalid code range */
 
#define PFMLIB_ERR_IRRTOOMANY   -16 /* too many code ranges */
 
#define PFMLIB_ERR_DRRINVAL   -17 /* invalid data range */
 
#define PFMLIB_ERR_DRRTOOMANY   -18 /* too many data ranges */
 
#define PFMLIB_ERR_BADHOST   -19 /* not supported by host CPU */
 
#define PFMLIB_ERR_IRRALIGN   -20 /* bad alignment for code range */
 
#define PFMLIB_ERR_IRRFLAGS   -21 /* code range missing flags */
 
#define PFMLIB_ERR_UMASK   -22 /* invalid or missing unit mask */
 
#define PFMLIB_ERR_NOMEM   -23 /* out of memory */
 
#define __PFMLIB_REGMASK_EL(g)   ((g)/__PFMLIB_REG_BV_BITS)
 
#define __PFMLIB_REGMASK_MASK(g)   (((pfmlib_regmask_bits_t)1) << ((g) % __PFMLIB_REG_BV_BITS))
 

Typedefs

typedef unsigned long pfmlib_regmask_bits_t
 
typedef int pfm_err_t
 

Functions

pfm_err_t pfm_set_options (pfmlib_options_t *opt)
 
pfm_err_t pfm_initialize (void)
 
pfm_err_t pfm_list_supported_pmus (int(*pf)(const char *fmt,...))
 
pfm_err_t pfm_get_pmu_name (char *name, int maxlen)
 
pfm_err_t pfm_get_pmu_type (int *type)
 
pfm_err_t pfm_get_pmu_name_bytype (int type, char *name, size_t maxlen)
 
pfm_err_t pfm_is_pmu_supported (int type)
 
pfm_err_t pfm_force_pmu (int type)
 
pfm_err_t pfm_find_event (const char *str, unsigned int *idx)
 
pfm_err_t pfm_find_event_byname (const char *name, unsigned int *idx)
 
pfm_err_t pfm_find_event_bycode (int code, unsigned int *idx)
 
pfm_err_t pfm_find_event_bycode_next (int code, unsigned int start, unsigned int *next)
 
pfm_err_t pfm_find_event_mask (unsigned int event_idx, const char *str, unsigned int *mask_idx)
 
pfm_err_t pfm_find_full_event (const char *str, pfmlib_event_t *e)
 
pfm_err_t pfm_get_max_event_name_len (size_t *len)
 
pfm_err_t pfm_get_num_events (unsigned int *count)
 
pfm_err_t pfm_get_num_event_masks (unsigned int event_idx, unsigned int *count)
 
pfm_err_t pfm_get_event_name (unsigned int idx, char *name, size_t maxlen)
 
pfm_err_t pfm_get_full_event_name (pfmlib_event_t *e, char *name, size_t maxlen)
 
pfm_err_t pfm_get_event_code (unsigned int idx, int *code)
 
pfm_err_t pfm_get_event_mask_code (unsigned int idx, unsigned int mask_idx, unsigned int *code)
 
pfm_err_t pfm_get_event_counters (unsigned int idx, pfmlib_regmask_t *counters)
 
pfm_err_t pfm_get_event_description (unsigned int idx, char **str)
 
pfm_err_t pfm_get_event_code_counter (unsigned int idx, unsigned int cnt, int *code)
 
pfm_err_t pfm_get_event_mask_name (unsigned int event_idx, unsigned int mask_idx, char *name, size_t maxlen)
 
pfm_err_t pfm_get_event_mask_description (unsigned int event_idx, unsigned int mask_idx, char **desc)
 
pfm_err_t pfm_dispatch_events (pfmlib_input_param_t *p, void *model_in, pfmlib_output_param_t *q, void *model_out)
 
pfm_err_t pfm_get_impl_pmcs (pfmlib_regmask_t *impl_pmcs)
 
pfm_err_t pfm_get_impl_pmds (pfmlib_regmask_t *impl_pmds)
 
pfm_err_t pfm_get_impl_counters (pfmlib_regmask_t *impl_counters)
 
pfm_err_t pfm_get_num_pmds (unsigned int *num)
 
pfm_err_t pfm_get_num_pmcs (unsigned int *num)
 
pfm_err_t pfm_get_num_counters (unsigned int *num)
 
pfm_err_t pfm_get_hw_counter_width (unsigned int *width)
 
pfm_err_t pfm_get_version (unsigned int *version)
 
char * pfm_strerror (int code)
 
pfm_err_t pfm_get_cycle_event (pfmlib_event_t *e)
 
pfm_err_t pfm_get_inst_retired_event (pfmlib_event_t *e)
 
static int pfm_regmask_isset (pfmlib_regmask_t *h, unsigned int b)
 
static int pfm_regmask_set (pfmlib_regmask_t *h, unsigned int b)
 
static int pfm_regmask_clr (pfmlib_regmask_t *h, unsigned int b)
 
static int pfm_regmask_weight (pfmlib_regmask_t *h, unsigned int *w)
 
static int pfm_regmask_eq (pfmlib_regmask_t *h1, pfmlib_regmask_t *h2)
 
static int pfm_regmask_and (pfmlib_regmask_t *dst, pfmlib_regmask_t *h1, pfmlib_regmask_t *h2)
 
static int pfm_regmask_andnot (pfmlib_regmask_t *dst, pfmlib_regmask_t *h1, pfmlib_regmask_t *h2)
 
static int pfm_regmask_or (pfmlib_regmask_t *dst, pfmlib_regmask_t *h1, pfmlib_regmask_t *h2)
 
static int pfm_regmask_copy (pfmlib_regmask_t *dst, pfmlib_regmask_t *src)
 
static int pfm_regmask_not (pfmlib_regmask_t *dst)
 

Macro Definition Documentation

◆ __PFMLIB_REG_BV_BITS

#define __PFMLIB_REG_BV_BITS   (sizeof(pfmlib_regmask_bits_t)<<3)

Definition at line 70 of file pfmlib.h.

◆ __PFMLIB_REGMASK_EL

#define __PFMLIB_REGMASK_EL (   g)    ((g)/__PFMLIB_REG_BV_BITS)

Definition at line 309 of file pfmlib.h.

◆ __PFMLIB_REGMASK_MASK

#define __PFMLIB_REGMASK_MASK (   g)    (((pfmlib_regmask_bits_t)1) << ((g) % __PFMLIB_REG_BV_BITS))

Definition at line 310 of file pfmlib.h.

◆ PFM_PLM0

#define PFM_PLM0   0x1 /* priv level 0 */

Definition at line 50 of file pfmlib.h.

◆ PFM_PLM1

#define PFM_PLM1   0x2 /* priv level 1 */

Definition at line 51 of file pfmlib.h.

◆ PFM_PLM2

#define PFM_PLM2   0x4 /* priv level 2 */

Definition at line 52 of file pfmlib.h.

◆ PFM_PLM3

#define PFM_PLM3   0x8 /* priv level 3 */

Definition at line 53 of file pfmlib.h.

◆ PFMLIB_AMD64_PMU

#define PFMLIB_AMD64_PMU   16 /* AMD AMD64 (K7, K8, Families 10h, 15h) */

Definition at line 227 of file pfmlib.h.

◆ PFMLIB_BVSIZE

#define PFMLIB_BVSIZE (   x)    (((x)+(__PFMLIB_REG_BV_BITS)-1) / __PFMLIB_REG_BV_BITS)

Definition at line 71 of file pfmlib.h.

◆ PFMLIB_CELL_PMU

#define PFMLIB_CELL_PMU   100 /* CELL */

Definition at line 261 of file pfmlib.h.

◆ PFMLIB_CORE_PMU

#define PFMLIB_CORE_PMU   36 /* obsolete, use PFMLIB_INTEL_CORE_PMU */

Definition at line 233 of file pfmlib.h.

◆ PFMLIB_COREDUO_PMU

#define PFMLIB_COREDUO_PMU   34 /* Intel Core Duo/Core Solo */

Definition at line 231 of file pfmlib.h.

◆ PFMLIB_CRAYX2_PMU

#define PFMLIB_CRAYX2_PMU   96 /* Cray X2 */

Definition at line 259 of file pfmlib.h.

◆ PFMLIB_ERR_BADHOST

#define PFMLIB_ERR_BADHOST   -19 /* not supported by host CPU */

Definition at line 303 of file pfmlib.h.

◆ PFMLIB_ERR_DRRINVAL

#define PFMLIB_ERR_DRRINVAL   -17 /* invalid data range */

Definition at line 301 of file pfmlib.h.

◆ PFMLIB_ERR_DRRTOOMANY

#define PFMLIB_ERR_DRRTOOMANY   -18 /* too many data ranges */

Definition at line 302 of file pfmlib.h.

◆ PFMLIB_ERR_EVTINCOMP

#define PFMLIB_ERR_EVTINCOMP   -11 /* incompatible event combination */

Definition at line 294 of file pfmlib.h.

◆ PFMLIB_ERR_EVTMANY

#define PFMLIB_ERR_EVTMANY   -7 /* event used more than once */

Definition at line 290 of file pfmlib.h.

◆ PFMLIB_ERR_EVTSET

#define PFMLIB_ERR_EVTSET   -10 /* incompatible event sets */

Definition at line 293 of file pfmlib.h.

◆ PFMLIB_ERR_FEATCOMB

#define PFMLIB_ERR_FEATCOMB   -9 /* invalid combination of features */

Definition at line 292 of file pfmlib.h.

◆ PFMLIB_ERR_FULL

#define PFMLIB_ERR_FULL   -6 /* buffer is full or too small */

Definition at line 289 of file pfmlib.h.

◆ PFMLIB_ERR_INVAL

#define PFMLIB_ERR_INVAL   -2 /* invalid parameters */

Definition at line 285 of file pfmlib.h.

◆ PFMLIB_ERR_IRRALIGN

#define PFMLIB_ERR_IRRALIGN   -20 /* bad alignment for code range */

Definition at line 304 of file pfmlib.h.

◆ PFMLIB_ERR_IRREMPTY

#define PFMLIB_ERR_IRREMPTY   -14 /* empty code range */

Definition at line 298 of file pfmlib.h.

◆ PFMLIB_ERR_IRRFLAGS

#define PFMLIB_ERR_IRRFLAGS   -21 /* code range missing flags */

Definition at line 305 of file pfmlib.h.

◆ PFMLIB_ERR_IRRINVAL

#define PFMLIB_ERR_IRRINVAL   -15 /* invalid code range */

Definition at line 299 of file pfmlib.h.

◆ PFMLIB_ERR_IRRTOOBIG

#define PFMLIB_ERR_IRRTOOBIG   -13 /* code range too big */

Definition at line 297 of file pfmlib.h.

◆ PFMLIB_ERR_IRRTOOMANY

#define PFMLIB_ERR_IRRTOOMANY   -16 /* too many code ranges */

Definition at line 300 of file pfmlib.h.

◆ PFMLIB_ERR_MAGIC

#define PFMLIB_ERR_MAGIC   -8 /* invalid library magic number */

Definition at line 291 of file pfmlib.h.

◆ PFMLIB_ERR_NOASSIGN

#define PFMLIB_ERR_NOASSIGN   -5 /* cannot assign events to counters */

Definition at line 288 of file pfmlib.h.

◆ PFMLIB_ERR_NOINIT

#define PFMLIB_ERR_NOINIT   -3 /* library was not initialized */

Definition at line 286 of file pfmlib.h.

◆ PFMLIB_ERR_NOMEM

#define PFMLIB_ERR_NOMEM   -23 /* out of memory */

Definition at line 307 of file pfmlib.h.

◆ PFMLIB_ERR_NOTFOUND

#define PFMLIB_ERR_NOTFOUND   -4 /* event not found */

Definition at line 287 of file pfmlib.h.

◆ PFMLIB_ERR_NOTSUPP

#define PFMLIB_ERR_NOTSUPP   -1 /* function not supported */

Definition at line 284 of file pfmlib.h.

◆ PFMLIB_ERR_TOOMANY

#define PFMLIB_ERR_TOOMANY   -12 /* too many events or unit masks */

Definition at line 295 of file pfmlib.h.

◆ PFMLIB_ERR_UMASK

#define PFMLIB_ERR_UMASK   -22 /* invalid or missing unit mask */

Definition at line 306 of file pfmlib.h.

◆ PFMLIB_GEN_IA32_PMU

#define PFMLIB_GEN_IA32_PMU   63 /* Intel architectural PMU for X86 */

Definition at line 228 of file pfmlib.h.

◆ PFMLIB_GEN_IA64_PMU

#define PFMLIB_GEN_IA64_PMU   1 /* Intel IA-64 architected PMU */

Definition at line 223 of file pfmlib.h.

◆ PFMLIB_I386_P6_PMU

#define PFMLIB_I386_P6_PMU   32 /* Intel PIII (P6 core) */

Definition at line 229 of file pfmlib.h.

◆ PFMLIB_I386_PM_PMU

#define PFMLIB_I386_PM_PMU   35 /* Intel Pentium M */

Definition at line 232 of file pfmlib.h.

◆ PFMLIB_INTEL_ATOM_PMU

#define PFMLIB_INTEL_ATOM_PMU   39 /* Intel Atom */

Definition at line 237 of file pfmlib.h.

◆ PFMLIB_INTEL_CORE_PMU

#define PFMLIB_INTEL_CORE_PMU   36 /* Intel Core */

Definition at line 234 of file pfmlib.h.

◆ PFMLIB_INTEL_NHM_PMU

#define PFMLIB_INTEL_NHM_PMU   40 /* Intel Nehalem */

Definition at line 238 of file pfmlib.h.

◆ PFMLIB_INTEL_PII_PMU

#define PFMLIB_INTEL_PII_PMU   38 /* Intel Pentium II */

Definition at line 236 of file pfmlib.h.

◆ PFMLIB_INTEL_PPRO_PMU

#define PFMLIB_INTEL_PPRO_PMU   37 /* Intel Pentium Pro */

Definition at line 235 of file pfmlib.h.

◆ PFMLIB_INTEL_WSM_PMU

#define PFMLIB_INTEL_WSM_PMU   41 /* Intel Westmere */

Definition at line 239 of file pfmlib.h.

◆ PFMLIB_ITANIUM2_PMU

#define PFMLIB_ITANIUM2_PMU   3 /* Intel Itanium 2 */

Definition at line 225 of file pfmlib.h.

◆ PFMLIB_ITANIUM_PMU

#define PFMLIB_ITANIUM_PMU   2 /* Intel Itanium */

Definition at line 224 of file pfmlib.h.

◆ PFMLIB_MAJ_VERSION

#define PFMLIB_MAJ_VERSION (   v)    ((v)>>16)

Definition at line 35 of file pfmlib.h.

◆ PFMLIB_MAX_MASKS_PER_EVENT

#define PFMLIB_MAX_MASKS_PER_EVENT   48 /* maximum number of unit masks per event */

Definition at line 80 of file pfmlib.h.

◆ PFMLIB_MAX_PMCS

#define PFMLIB_MAX_PMCS   512 /* maximum number of PMCS supported by the library */

Definition at line 41 of file pfmlib.h.

◆ PFMLIB_MAX_PMDS

#define PFMLIB_MAX_PMDS   512 /* maximum number of PMDS supported by the library */

Definition at line 42 of file pfmlib.h.

◆ PFMLIB_MIN_VERSION

#define PFMLIB_MIN_VERSION (   v)    ((v) & 0xffff)

Definition at line 36 of file pfmlib.h.

◆ PFMLIB_MIPS_20KC_PMU

#define PFMLIB_MIPS_20KC_PMU   64 /* MIPS 20KC */

Definition at line 241 of file pfmlib.h.

◆ PFMLIB_MIPS_24K_PMU

#define PFMLIB_MIPS_24K_PMU   65 /* MIPS 24K */

Definition at line 242 of file pfmlib.h.

◆ PFMLIB_MIPS_25KF_PMU

#define PFMLIB_MIPS_25KF_PMU   66 /* MIPS 25KF */

Definition at line 243 of file pfmlib.h.

◆ PFMLIB_MIPS_34K_PMU

#define PFMLIB_MIPS_34K_PMU   67 /* MIPS 34K */

Definition at line 244 of file pfmlib.h.

◆ PFMLIB_MIPS_5KC_PMU

#define PFMLIB_MIPS_5KC_PMU   68 /* MIPS 5KC */

Definition at line 245 of file pfmlib.h.

◆ PFMLIB_MIPS_74K_PMU

#define PFMLIB_MIPS_74K_PMU   69 /* MIPS 74K */

Definition at line 246 of file pfmlib.h.

◆ PFMLIB_MIPS_ICE9A_PMU

#define PFMLIB_MIPS_ICE9A_PMU   77 /* SiCortex ICE9A */

Definition at line 254 of file pfmlib.h.

◆ PFMLIB_MIPS_ICE9B_PMU

#define PFMLIB_MIPS_ICE9B_PMU   78 /* SiCortex ICE9B */

Definition at line 255 of file pfmlib.h.

◆ PFMLIB_MIPS_R10000_PMU

#define PFMLIB_MIPS_R10000_PMU   70 /* MIPS R10000 */

Definition at line 247 of file pfmlib.h.

◆ PFMLIB_MIPS_R12000_PMU

#define PFMLIB_MIPS_R12000_PMU   71 /* MIPS R12000 */

Definition at line 248 of file pfmlib.h.

◆ PFMLIB_MIPS_RM7000_PMU

#define PFMLIB_MIPS_RM7000_PMU   72 /* MIPS RM7000 */

Definition at line 249 of file pfmlib.h.

◆ PFMLIB_MIPS_RM9000_PMU

#define PFMLIB_MIPS_RM9000_PMU   73 /* MIPS RM9000 */

Definition at line 250 of file pfmlib.h.

◆ PFMLIB_MIPS_SB1_PMU

#define PFMLIB_MIPS_SB1_PMU   74 /* MIPS SB1/SB1A */

Definition at line 251 of file pfmlib.h.

◆ PFMLIB_MIPS_VR5432_PMU

#define PFMLIB_MIPS_VR5432_PMU   75 /* MIPS VR5432 */

Definition at line 252 of file pfmlib.h.

◆ PFMLIB_MIPS_VR5500_PMU

#define PFMLIB_MIPS_VR5500_PMU   76 /* MIPS VR5500 */

Definition at line 253 of file pfmlib.h.

◆ PFMLIB_MONTECITO_PMU

#define PFMLIB_MONTECITO_PMU   4 /* Intel Dual-Core Itanium 2 9000 */

Definition at line 226 of file pfmlib.h.

◆ PFMLIB_NO_PMU

#define PFMLIB_NO_PMU   -1 /* PMU unused (forced) */

Definition at line 221 of file pfmlib.h.

◆ PFMLIB_PENTIUM4_PMU

#define PFMLIB_PENTIUM4_PMU   33 /* Intel Pentium4/Xeon/EM64T */

Definition at line 230 of file pfmlib.h.

◆ PFMLIB_PFP_SYSTEMWIDE

#define PFMLIB_PFP_SYSTEMWIDE   0x1 /* indicate monitors will be used in a system-wide session */

Definition at line 121 of file pfmlib.h.

◆ PFMLIB_POWER3_PMU

#define PFMLIB_POWER3_PMU   112 /* IBM POWER3 */

Definition at line 265 of file pfmlib.h.

◆ PFMLIB_POWER4_PMU

#define PFMLIB_POWER4_PMU   113 /* IBM POWER4 */

Definition at line 266 of file pfmlib.h.

◆ PFMLIB_POWER5_PMU

#define PFMLIB_POWER5_PMU   114 /* IBM POWER5 */

Definition at line 267 of file pfmlib.h.

◆ PFMLIB_POWER5p_PMU

#define PFMLIB_POWER5p_PMU   115 /* IBM POWER5+ */

Definition at line 268 of file pfmlib.h.

◆ PFMLIB_POWER6_PMU

#define PFMLIB_POWER6_PMU   116 /* IBM POWER6 */

Definition at line 269 of file pfmlib.h.

◆ PFMLIB_POWER7_PMU

#define PFMLIB_POWER7_PMU   117 /* IBM POWER7 */

Definition at line 270 of file pfmlib.h.

◆ PFMLIB_POWERPC_PMU

#define PFMLIB_POWERPC_PMU   90 /* POWERPC */

Definition at line 257 of file pfmlib.h.

◆ PFMLIB_PPC970_PMU

#define PFMLIB_PPC970_PMU   110 /* IBM PowerPC 970(FX,GX) */

Definition at line 263 of file pfmlib.h.

◆ PFMLIB_PPC970MP_PMU

#define PFMLIB_PPC970MP_PMU   111 /* IBM PowerPC 970MP */

Definition at line 264 of file pfmlib.h.

◆ PFMLIB_REG_BV

#define PFMLIB_REG_BV   PFMLIB_BVSIZE(PFMLIB_REG_MAX)

Definition at line 72 of file pfmlib.h.

◆ PFMLIB_REG_MAX

#define PFMLIB_REG_MAX   PFMLIB_MAX_PMDS

Definition at line 66 of file pfmlib.h.

◆ PFMLIB_SPARC_NIAGARA1_PMU

#define PFMLIB_SPARC_NIAGARA1_PMU   135 /* Niagara-1 */

Definition at line 277 of file pfmlib.h.

◆ PFMLIB_SPARC_NIAGARA2_PMU

#define PFMLIB_SPARC_NIAGARA2_PMU   136 /* Niagara-2 */

Definition at line 278 of file pfmlib.h.

◆ PFMLIB_SPARC_ULTRA12_PMU

#define PFMLIB_SPARC_ULTRA12_PMU   130 /* UltraSPARC I, II, IIi, and IIe */

Definition at line 272 of file pfmlib.h.

◆ PFMLIB_SPARC_ULTRA3_PMU

#define PFMLIB_SPARC_ULTRA3_PMU   131 /* UltraSPARC III */

Definition at line 273 of file pfmlib.h.

◆ PFMLIB_SPARC_ULTRA3I_PMU

#define PFMLIB_SPARC_ULTRA3I_PMU   132 /* UltraSPARC IIIi and IIIi+ */

Definition at line 274 of file pfmlib.h.

◆ PFMLIB_SPARC_ULTRA3PLUS_PMU

#define PFMLIB_SPARC_ULTRA3PLUS_PMU   133 /* UltraSPARC III+ and IV */

Definition at line 275 of file pfmlib.h.

◆ PFMLIB_SPARC_ULTRA4PLUS_PMU

#define PFMLIB_SPARC_ULTRA4PLUS_PMU   134 /* UltraSPARC IV+ */

Definition at line 276 of file pfmlib.h.

◆ PFMLIB_SUCCESS

#define PFMLIB_SUCCESS   0 /* success */

Definition at line 283 of file pfmlib.h.

◆ PFMLIB_UNKNOWN_PMU

#define PFMLIB_UNKNOWN_PMU   0 /* type not yet known (dynamic) */

Definition at line 222 of file pfmlib.h.

◆ PFMLIB_VERSION

#define PFMLIB_VERSION   (3 << 16 | 10)

Definition at line 34 of file pfmlib.h.

Typedef Documentation

◆ pfm_err_t

typedef int pfm_err_t

Definition at line 151 of file pfmlib.h.

◆ pfmlib_regmask_bits_t

typedef unsigned long pfmlib_regmask_bits_t

Definition at line 58 of file pfmlib.h.

Function Documentation

◆ pfm_dispatch_events()

pfm_err_t pfm_dispatch_events ( pfmlib_input_param_t p,
void *  model_in,
pfmlib_output_param_t q,
void *  model_out 
)

Definition at line 721 of file pfmlib_common.c.

724{
725 unsigned count;
726 unsigned int i;
727 int ret;
728
729 if (PFMLIB_INITIALIZED() == 0)
730 return PFMLIB_ERR_NOINIT;
731
732 /* at least one input and one output set must exist */
733 if (!inp && !model_in)
734 return PFMLIB_ERR_INVAL;
735 if (!outp && !model_out)
736 return PFMLIB_ERR_INVAL;
737
738 if (!inp)
739 count = 0;
740 else if (inp->pfp_dfl_plm == 0)
741 /* the default priv level must be set to something */
742 return PFMLIB_ERR_INVAL;
743 else if (inp->pfp_event_count >= PFMLIB_MAX_PMCS)
744 return PFMLIB_ERR_INVAL;
745 else if (inp->pfp_event_count > pfm_current->num_cnt)
746 return PFMLIB_ERR_NOASSIGN;
747 else
748 count = inp->pfp_event_count;
749
750 /*
751 * check that event and unit masks descriptors are correct
752 */
753 for (i=0; i < count; i++) {
754 ret = __pfm_check_event(inp->pfp_events+i);
755 if (ret != PFMLIB_SUCCESS)
756 return ret;
757 }
758
759 /* reset output data structure */
760 if (outp)
761 memset(outp, 0, sizeof(*outp));
762
763 return pfm_current->dispatch_events(inp, model_in, outp, model_out);
764}
int i
static long count
#define PFMLIB_MAX_PMCS
Definition: pfmlib.h:41
#define PFMLIB_SUCCESS
Definition: pfmlib.h:283
#define PFMLIB_ERR_INVAL
Definition: pfmlib.h:285
#define PFMLIB_ERR_NOINIT
Definition: pfmlib.h:286
#define PFMLIB_ERR_NOASSIGN
Definition: pfmlib.h:288
int __pfm_check_event(pfmlib_event_t *e)
Definition: pfmlib_priv.c:65
#define PFMLIB_INITIALIZED()
Definition: pfmlib_priv.h:72
#define pfm_current
Definition: pfmlib_priv.h:78
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_find_event()

pfm_err_t pfm_find_event ( const char *  str,
unsigned int idx 
)

Definition at line 388 of file pfmlib_common.c.

389{
390 unsigned long number;
391 char *endptr = NULL;
392 int ret = PFMLIB_ERR_INVAL;
393
394 if (PFMLIB_INITIALIZED() == 0)
395 return PFMLIB_ERR_NOINIT;
396
397 if (v == NULL || ev == NULL)
398 return PFMLIB_ERR_INVAL;
399
400 if (isdigit((int)*v)) {
401 number = strtoul(v,&endptr, 0);
402 /* check for errors */
403 if (*endptr!='\0')
404 return PFMLIB_ERR_INVAL;
405
406 if (number <= INT_MAX) {
407 int the_int_number = (int)number;
408 ret = pfm_find_event_bycode(the_int_number, ev);
409 }
410 } else
411 ret = pfm_find_event_byname(v, ev);
412 return ret;
413}
int pfm_find_event_bycode(int code, unsigned int *idx)
int pfm_find_event_byname(const char *n, unsigned int *idx)
int
Definition: sde_internal.h:89
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_find_event_bycode()

pfm_err_t pfm_find_event_bycode ( int  code,
unsigned int idx 
)

Definition at line 351 of file pfmlib_common.c.

352{
353 pfmlib_regmask_t impl_cnt;
354 unsigned int i, j, num_cnt;
355 int code2;
356
357 if (PFMLIB_INITIALIZED() == 0) return PFMLIB_ERR_NOINIT;
358
359 if (idx == NULL) return PFMLIB_ERR_INVAL;
360
361 if (pfm_current->flags & PFMLIB_MULT_CODE_EVENT) {
362 pfm_current->get_impl_counters(&impl_cnt);
363 num_cnt = pfm_current->num_cnt;
364
365 for(i=0; i < pfm_current->pme_count; i++) {
366 for(j=0; num_cnt; j++) {
367 if (pfm_regmask_isset(&impl_cnt, j)) {
368 pfm_current->get_event_code(i, j, &code2);
369 if (code2 == code)
370 goto found;
371 num_cnt--;
372 }
373 }
374 }
375 } else {
376 for(i=0; i < pfm_current->pme_count; i++) {
377 pfm_current->get_event_code(i, PFMLIB_CNT_FIRST, &code2);
378 if (code2 == code) goto found;
379 }
380 }
381 return PFMLIB_ERR_NOTFOUND;
382found:
383 *idx = i;
384 return PFMLIB_SUCCESS;
385}
#define PFMLIB_ERR_NOTFOUND
Definition: pfmlib.h:287
static int pfm_regmask_isset(pfmlib_regmask_t *h, unsigned int b)
Definition: pfmlib.h:313
#define PFMLIB_MULT_CODE_EVENT
Definition: pfmlib_priv.h:60
#define PFMLIB_CNT_FIRST
Definition: pfmlib_priv.h:62
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_find_event_bycode_next()

pfm_err_t pfm_find_event_bycode_next ( int  code,
unsigned int  start,
unsigned int next 
)

Definition at line 416 of file pfmlib_common.c.

417{
418 int code2;
419
420 if (PFMLIB_INITIALIZED() == 0)
421 return PFMLIB_ERR_NOINIT;
422
423 if (!next)
424 return PFMLIB_ERR_INVAL;
425
426 for(++i; i < pfm_current->pme_count; i++) {
427 pfm_current->get_event_code(i, PFMLIB_CNT_FIRST, &code2);
428 if (code2 == code) goto found;
429 }
430 return PFMLIB_ERR_NOTFOUND;
431found:
432 *next = i;
433 return PFMLIB_SUCCESS;
434}

◆ pfm_find_event_byname()

pfm_err_t pfm_find_event_byname ( const char *  name,
unsigned int idx 
)

Definition at line 310 of file pfmlib_common.c.

311{
312 char *p, *e;
313 unsigned int i;
314 size_t len;
315
316 if (PFMLIB_INITIALIZED() == 0)
317 return PFMLIB_ERR_NOINIT;
318
319 if (n == NULL || idx == NULL)
320 return PFMLIB_ERR_INVAL;
321
322 /*
323 * this function ignores any ':' separator
324 */
325 p = strchr(n, ':');
326 if (!p)
327 len = strlen(n);
328 else
329 len = p - n;
330
331 /*
332 * we do case insensitive comparisons
333 *
334 * event names must match completely
335 */
336 for(i=0; i < pfm_current->pme_count; i++) {
337 e = pfm_current->get_event_name(i);
338 if (!e)
339 continue;
340 if (!strncasecmp(e, n, len)
341 && len == strlen(e))
342 goto found;
343 }
344 return PFMLIB_ERR_NOTFOUND;
345found:
346 *idx = i;
347 return PFMLIB_SUCCESS;
348}
Here is the caller graph for this function:

◆ pfm_find_event_mask()

pfm_err_t pfm_find_event_mask ( unsigned int  event_idx,
const char *  str,
unsigned int mask_idx 
)

Definition at line 473 of file pfmlib_common.c.

474{
475 if (PFMLIB_INITIALIZED() == 0)
476 return PFMLIB_ERR_NOINIT;
477
478 if (str == NULL || mask_idx == NULL || ev >= pfm_current->pme_count)
479 return PFMLIB_ERR_INVAL;
480
481 return pfm_do_find_event_mask(ev, str, mask_idx);
482}
static int pfm_do_find_event_mask(unsigned int ev, const char *str, unsigned int *mask_idx)
Here is the call graph for this function:

◆ pfm_find_full_event()

pfm_err_t pfm_find_full_event ( const char *  str,
pfmlib_event_t e 
)

Definition at line 1081 of file pfmlib_common.c.

1082{
1083 char *str, *p, *q;
1084 unsigned int j, mask;
1085 int ret = PFMLIB_SUCCESS;
1086
1087 if (PFMLIB_INITIALIZED() == 0)
1088 return PFMLIB_ERR_NOINIT;
1089
1090 if (v == NULL || e == NULL)
1091 return PFMLIB_ERR_INVAL;
1092
1093 memset(e, 0, sizeof(*e));
1094
1095 /*
1096 * must copy string because we modify it when parsing
1097 */
1098 str = strdup(v);
1099 if (!str)
1100 return PFMLIB_ERR_NOMEM;
1101
1102 /*
1103 * find event. this function ignores ':' separator
1104 */
1105 ret = pfm_find_event_byname(str, &e->event);
1106 if (ret)
1107 goto error;
1108
1109 /*
1110 * get number of unit masks for event
1111 */
1112 j = pfm_num_masks(e->event);
1113
1114 /*
1115 * look for colon (unit mask separator)
1116 */
1117 p = strchr(str, ':');
1118
1119 /* If no unit masks available and none specified, we're done */
1120
1121 if ((j == 0) && (p == NULL)) {
1122 free(str);
1123 return PFMLIB_SUCCESS;
1124 }
1125
1126 ret = PFMLIB_ERR_UMASK;
1127 /*
1128 * error if:
1129 * - event has no unit mask and at least one is passed
1130 */
1131 if (p && !j)
1132 goto error;
1133
1134 /*
1135 * error if:
1136 * - event has unit masks, no default unit mask, and none is passed
1137 */
1138 if (j && !p) {
1139 if (pfm_current->has_umask_default
1140 && pfm_current->has_umask_default(e->event)) {
1141 free(str);
1142 return PFMLIB_SUCCESS;
1143 }
1144 goto error;
1145 }
1146
1147 /* skip : */
1148 p++;
1149 /*
1150 * separator is passed but there is nothing behind it
1151 */
1152 if (!*p)
1153 goto error;
1154
1155 /* parse unit masks */
1156 for( q = p; q ; p = q) {
1157
1158 q = strchr(p,':');
1159 if (q)
1160 *q++ = '\0';
1161
1162 /*
1163 * text or exact unit mask value match
1164 */
1165 ret = pfm_do_find_event_mask(e->event, p, &mask);
1166 if (ret == PFMLIB_ERR_UMASK) {
1167 ret = pfm_add_numeric_masks(e, p);
1168 if (ret != PFMLIB_SUCCESS)
1169 break;
1170 } else if (ret == PFMLIB_SUCCESS) {
1171 /*
1172 * ignore duplicates
1173 */
1174 ret = pfm_check_duplicates(e, mask);
1175 if (ret != PFMLIB_SUCCESS) {
1176 ret = PFMLIB_SUCCESS;
1177 continue;
1178 }
1179
1181 ret = PFMLIB_ERR_TOOMANY;
1182 break;
1183 }
1184 e->unit_masks[e->num_masks] = mask;
1185 e->num_masks++;
1186 }
1187 }
1188error:
1189 free(str);
1190 return ret;
1191}
#define PFMLIB_ERR_UMASK
Definition: pfmlib.h:306
#define PFMLIB_MAX_MASKS_PER_EVENT
Definition: pfmlib.h:80
#define PFMLIB_ERR_NOMEM
Definition: pfmlib.h:307
#define PFMLIB_ERR_TOOMANY
Definition: pfmlib.h:295
static int pfm_add_numeric_masks(pfmlib_event_t *e, const char *str)
static int pfm_check_duplicates(pfmlib_event_t *e, unsigned int u)
static unsigned int pfm_num_masks(int e)
Definition: pfmlib_priv.h:125
unsigned int num_masks
Definition: pfmlib.h:90
unsigned int unit_masks[PFMLIB_MAX_MASKS_PER_EVENT]
Definition: pfmlib.h:89
unsigned int event
Definition: pfmlib.h:86
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_force_pmu()

pfm_err_t pfm_force_pmu ( int  type)

Definition at line 294 of file pfmlib_common.c.

295{
297
298 while (*p) {
299 if ((*p)->pmu_type == type) goto found;
300 p++;
301 }
302 return PFMLIB_ERR_NOTSUPP;
303found:
304 pfm_current = *p;
305
306 return PFMLIB_SUCCESS;
307}
uint16_t type
#define PFMLIB_ERR_NOTSUPP
Definition: pfmlib.h:284
static pfm_pmu_support_t * supported_pmus[]
Definition: pfmlib_common.c:39

◆ pfm_get_cycle_event()

pfm_err_t pfm_get_cycle_event ( pfmlib_event_t e)

Definition at line 943 of file pfmlib_common.c.

944{
945 if (PFMLIB_INITIALIZED() == 0)
946 return PFMLIB_ERR_NOINIT;
947 if (e == NULL)
948 return PFMLIB_ERR_INVAL;
949
950 if (!pfm_current->get_cycle_event)
951 return PFMLIB_ERR_NOTSUPP;
952
953 memset(e, 0, sizeof(*e));
954
955 return pfm_current->get_cycle_event(e);
956}
Here is the caller graph for this function:

◆ pfm_get_event_code()

pfm_err_t pfm_get_event_code ( unsigned int  idx,
int code 
)

Definition at line 598 of file pfmlib_common.c.

599{
600 if (PFMLIB_INITIALIZED() == 0) return PFMLIB_ERR_NOINIT;
601
602 if (i >= pfm_current->pme_count || code == NULL) return PFMLIB_ERR_INVAL;
603
604 return pfm_current->get_event_code(i, PFMLIB_CNT_FIRST, code);
605
606}
Here is the caller graph for this function:

◆ pfm_get_event_code_counter()

pfm_err_t pfm_get_event_code_counter ( unsigned int  idx,
unsigned int  cnt,
int code 
)

Definition at line 609 of file pfmlib_common.c.

610{
611 if (PFMLIB_INITIALIZED() == 0) return PFMLIB_ERR_NOINIT;
612
613 if (i >= pfm_current->pme_count || code == NULL) return PFMLIB_ERR_INVAL;
614
615 return pfm_current->get_event_code(i, cnt, code);
616}
Here is the caller graph for this function:

◆ pfm_get_event_counters()

pfm_err_t pfm_get_event_counters ( unsigned int  idx,
pfmlib_regmask_t counters 
)

Definition at line 619 of file pfmlib_common.c.

620{
621 if (PFMLIB_INITIALIZED() == 0) return PFMLIB_ERR_NOINIT;
622
623 if (i >= pfm_current->pme_count) return PFMLIB_ERR_INVAL;
624
625 pfm_current->get_event_counters(i, counters);
626
627 return PFMLIB_SUCCESS;
628}
Here is the caller graph for this function:

◆ pfm_get_event_description()

pfm_err_t pfm_get_event_description ( unsigned int  idx,
char **  str 
)

Definition at line 978 of file pfmlib_common.c.

979{
980 if (PFMLIB_INITIALIZED() == 0) return PFMLIB_ERR_NOINIT;
981
982 if (i >= pfm_current->pme_count || str == NULL) return PFMLIB_ERR_INVAL;
983
984 if (pfm_current->get_event_desc == NULL) {
985 *str = strdup("no description available");
986 return PFMLIB_SUCCESS;
987 }
988 return pfm_current->get_event_desc(i, str);
989}
Here is the caller graph for this function:

◆ pfm_get_event_mask_code()

pfm_err_t pfm_get_event_mask_code ( unsigned int  idx,
unsigned int  mask_idx,
unsigned int code 
)

Definition at line 1009 of file pfmlib_common.c.

1010{
1011 if (PFMLIB_INITIALIZED() == 0) return PFMLIB_ERR_NOINIT;
1012
1013 if (event_idx >= pfm_current->pme_count || code == NULL) return PFMLIB_ERR_INVAL;
1014
1015 if (pfm_current->get_event_mask_code == NULL) {
1016 *code = 0;
1017 return PFMLIB_SUCCESS;
1018 }
1019 if (mask_idx >= pfm_current->get_num_event_masks(event_idx))
1020 return PFMLIB_ERR_INVAL;
1021
1022 return pfm_current->get_event_mask_code(event_idx, mask_idx, code);
1023}
Here is the caller graph for this function:

◆ pfm_get_event_mask_description()

pfm_err_t pfm_get_event_mask_description ( unsigned int  event_idx,
unsigned int  mask_idx,
char **  desc 
)

Definition at line 992 of file pfmlib_common.c.

993{
994 if (PFMLIB_INITIALIZED() == 0) return PFMLIB_ERR_NOINIT;
995
996 if (event_idx >= pfm_current->pme_count || desc == NULL) return PFMLIB_ERR_INVAL;
997
998 if (pfm_current->get_event_mask_desc == NULL) {
999 *desc = strdup("no description available");
1000 return PFMLIB_SUCCESS;
1001 }
1002 if (mask_idx >= pfm_current->get_num_event_masks(event_idx))
1003 return PFMLIB_ERR_INVAL;
1004
1005 return pfm_current->get_event_mask_desc(event_idx, mask_idx, desc);
1006}
Here is the caller graph for this function:

◆ pfm_get_event_mask_name()

pfm_err_t pfm_get_event_mask_name ( unsigned int  event_idx,
unsigned int  mask_idx,
char *  name,
size_t  maxlen 
)

Definition at line 631 of file pfmlib_common.c.

632{
633 char *str;
634 unsigned int num;
635 size_t l, j;
636
637 if (PFMLIB_INITIALIZED() == 0)
638 return PFMLIB_ERR_NOINIT;
639
640 if (ev >= pfm_current->pme_count || name == NULL || maxlen < 1)
641 return PFMLIB_ERR_INVAL;
642
643 num = pfm_num_masks(ev);
644 if (num == 0)
645 return PFMLIB_ERR_NOTSUPP;
646
647 if (mask >= num)
648 return PFMLIB_ERR_INVAL;
649
650 str = pfm_current->get_event_mask_name(ev, mask);
651 if (!str)
652 return PFMLIB_ERR_BADHOST;
653 l = strlen(str);
654 if (l >= (maxlen-1))
655 return PFMLIB_ERR_FULL;
656
657 strcpy(name, str);
658
659 /*
660 * present nice uniform names
661 */
662 l = strlen(name);
663 for(j=0; j < l; j++)
664 if (islower(name[j]))
665 name[j] = (char)toupper(name[j]);
666 return PFMLIB_SUCCESS;
667}
#define PFMLIB_ERR_BADHOST
Definition: pfmlib.h:303
#define PFMLIB_ERR_FULL
Definition: pfmlib.h:289
const char * name
Definition: rocs.c:225
Here is the call graph for this function:

◆ pfm_get_event_name()

pfm_err_t pfm_get_event_name ( unsigned int  idx,
char *  name,
size_t  maxlen 
)

Definition at line 564 of file pfmlib_common.c.

565{
566 size_t l, j;
567 char *str;
568
569 if (PFMLIB_INITIALIZED() == 0)
570 return PFMLIB_ERR_NOINIT;
571
572 if (i >= pfm_current->pme_count || name == NULL || maxlen < 1)
573 return PFMLIB_ERR_INVAL;
574
575 str = pfm_current->get_event_name(i);
576 if (!str)
577 return PFMLIB_ERR_BADHOST;
578 l = strlen(str);
579
580 /*
581 * we fail if buffer is too small, simply because otherwise we
582 * get partial names which are useless for subsequent calls
583 * users mus invoke pfm_get_event_name_max_len() to correctly size
584 * the buffer for this call
585 */
586 if ((maxlen-1) < l)
587 return PFMLIB_ERR_INVAL;
588
589 for(j=0; j < l; j++)
590 name[j] = (char)toupper(str[j]);
591
592 name[l] = '\0';
593
594 return PFMLIB_SUCCESS;
595}
Here is the caller graph for this function:

◆ pfm_get_full_event_name()

pfm_err_t pfm_get_full_event_name ( pfmlib_event_t e,
char *  name,
size_t  maxlen 
)

Definition at line 1026 of file pfmlib_common.c.

1027{
1028 char *str;
1029 size_t l, j;
1030 int ret;
1031
1032 if (PFMLIB_INITIALIZED() == 0)
1033 return PFMLIB_ERR_NOINIT;
1034
1035 if (e == NULL || name == NULL || maxlen < 1)
1036 return PFMLIB_ERR_INVAL;
1037
1038 ret = __pfm_check_event(e);
1039 if (ret != PFMLIB_SUCCESS)
1040 return ret;
1041
1042 /*
1043 * make sure the string is at least empty
1044 * important for programs that do not check return value
1045 * from this function!
1046 */
1047 *name = '\0';
1048
1049 str = pfm_current->get_event_name(e->event);
1050 if (!str)
1051 return PFMLIB_ERR_BADHOST;
1052 l = strlen(str);
1053 if (l > (maxlen-1))
1054 return PFMLIB_ERR_FULL;
1055
1056 strcpy(name, str);
1057 maxlen -= l + 1;
1058 for(j=0; j < e->num_masks; j++) {
1059 str = pfm_current->get_event_mask_name(e->event, e->unit_masks[j]);
1060 if (!str)
1061 continue;
1062 l = strlen(str);
1063 if (l > (maxlen-1))
1064 return PFMLIB_ERR_FULL;
1065
1066 strcat(name, ":");
1067 strcat(name, str);
1068 maxlen -= l + 1;
1069 }
1070 /*
1071 * present nice uniform names
1072 */
1073 l = strlen(name);
1074 for(j=0; j < l; j++)
1075 if (islower(name[j]))
1076 name[j] = (char)toupper(name[j]);
1077 return PFMLIB_SUCCESS;
1078}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_get_hw_counter_width()

pfm_err_t pfm_get_hw_counter_width ( unsigned int width)

Definition at line 845 of file pfmlib_common.c.

846{
847 if (PFMLIB_INITIALIZED() == 0) return PFMLIB_ERR_NOINIT;
848 if (width == NULL) return PFMLIB_ERR_INVAL;
849
850 pfm_current->get_hw_counter_width(width);
851
852 return PFMLIB_SUCCESS;
853}

◆ pfm_get_impl_counters()

pfm_err_t pfm_get_impl_counters ( pfmlib_regmask_t impl_counters)

Definition at line 832 of file pfmlib_common.c.

833{
834 if (PFMLIB_INITIALIZED() == 0) return PFMLIB_ERR_NOINIT;
835 if (impl_counters == NULL) return PFMLIB_ERR_INVAL;
836
837 memset(impl_counters, 0, sizeof(*impl_counters));
838
839 pfm_current->get_impl_counters(impl_counters);
840
841 return PFMLIB_SUCCESS;
842}
Here is the caller graph for this function:

◆ pfm_get_impl_pmcs()

pfm_err_t pfm_get_impl_pmcs ( pfmlib_regmask_t impl_pmcs)

Definition at line 806 of file pfmlib_common.c.

807{
808 if (PFMLIB_INITIALIZED() == 0) return PFMLIB_ERR_NOINIT;
809 if (impl_pmcs == NULL) return PFMLIB_ERR_INVAL;
810
811 memset(impl_pmcs , 0, sizeof(*impl_pmcs));
812
813 pfm_current->get_impl_pmcs(impl_pmcs);
814
815 return PFMLIB_SUCCESS;
816}

◆ pfm_get_impl_pmds()

pfm_err_t pfm_get_impl_pmds ( pfmlib_regmask_t impl_pmds)

Definition at line 819 of file pfmlib_common.c.

820{
821 if (PFMLIB_INITIALIZED() == 0) return PFMLIB_ERR_NOINIT;
822 if (impl_pmds == NULL) return PFMLIB_ERR_INVAL;
823
824 memset(impl_pmds, 0, sizeof(*impl_pmds));
825
826 pfm_current->get_impl_pmds(impl_pmds);
827
828 return PFMLIB_SUCCESS;
829}

◆ pfm_get_inst_retired_event()

pfm_err_t pfm_get_inst_retired_event ( pfmlib_event_t e)

Definition at line 962 of file pfmlib_common.c.

963{
964 if (PFMLIB_INITIALIZED() == 0)
965 return PFMLIB_ERR_NOINIT;
966 if (e == NULL)
967 return PFMLIB_ERR_INVAL;
968
969 if (!pfm_current->get_inst_retired_event)
970 return PFMLIB_ERR_NOTSUPP;
971
972 memset(e, 0, sizeof(*e));
973
974 return pfm_current->get_inst_retired_event(e);
975}
Here is the caller graph for this function:

◆ pfm_get_max_event_name_len()

pfm_err_t pfm_get_max_event_name_len ( size_t len)

Definition at line 903 of file pfmlib_common.c.

904{
905 unsigned int i, j, num_masks;
906 size_t max = 0, l;
907 char *str;
908
909 if (PFMLIB_INITIALIZED() == 0)
910 return PFMLIB_ERR_NOINIT;
911 if (len == NULL)
912 return PFMLIB_ERR_INVAL;
913
914 for(i=0; i < pfm_current->pme_count; i++) {
915 str = pfm_current->get_event_name(i);
916 if (!str)
917 continue;
918 l = strlen(str);
919 if (l > max) max = l;
920
921 num_masks = pfm_num_masks(i);
922 /*
923 * we need to add up all length because unit masks can
924 * be combined typically. We add 1 to account for ':'
925 * which is inserted as the unit mask separator
926 */
927 for (j = 0; j < num_masks; j++) {
928 str = pfm_current->get_event_mask_name(i, j);
929 if (!str)
930 continue;
931 l += 1 + strlen(str);
932 }
933 if (l > max) max = l;
934 }
935 *len = max;
936 return PFMLIB_SUCCESS;
937}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_get_num_counters()

pfm_err_t pfm_get_num_counters ( unsigned int num)

Definition at line 770 of file pfmlib_common.c.

771{
772 if (PFMLIB_INITIALIZED() == 0) return PFMLIB_ERR_NOINIT;
773
774 if (num == NULL) return PFMLIB_ERR_INVAL;
775
776 *num = pfm_current->num_cnt;
777
778 return PFMLIB_SUCCESS;
779}
Here is the caller graph for this function:

◆ pfm_get_num_event_masks()

pfm_err_t pfm_get_num_event_masks ( unsigned int  event_idx,
unsigned int count 
)

Definition at line 682 of file pfmlib_common.c.

683{
684 if (PFMLIB_INITIALIZED() == 0)
685 return PFMLIB_ERR_NOINIT;
686
687 if (ev >= pfm_current->pme_count || count == NULL)
688 return PFMLIB_ERR_INVAL;
689
690 *count = pfm_num_masks(ev);
691
692 return PFMLIB_SUCCESS;
693}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_get_num_events()

pfm_err_t pfm_get_num_events ( unsigned int count)

Definition at line 670 of file pfmlib_common.c.

671{
672 if (PFMLIB_INITIALIZED() == 0) return PFMLIB_ERR_NOINIT;
673
674 if (count == NULL) return PFMLIB_ERR_INVAL;
675
676 *count = pfm_current->pme_count;
677
678 return PFMLIB_SUCCESS;
679}
Here is the caller graph for this function:

◆ pfm_get_num_pmcs()

pfm_err_t pfm_get_num_pmcs ( unsigned int num)

Definition at line 782 of file pfmlib_common.c.

783{
784 if (PFMLIB_INITIALIZED() == 0) return PFMLIB_ERR_NOINIT;
785
786 if (num == NULL) return PFMLIB_ERR_INVAL;
787
788 *num = pfm_current->pmc_count;
789
790 return PFMLIB_SUCCESS;
791}

◆ pfm_get_num_pmds()

pfm_err_t pfm_get_num_pmds ( unsigned int num)

Definition at line 794 of file pfmlib_common.c.

795{
796 if (PFMLIB_INITIALIZED() == 0) return PFMLIB_ERR_NOINIT;
797
798 if (num == NULL) return PFMLIB_ERR_INVAL;
799
800 *num = pfm_current->pmd_count;
801
802 return PFMLIB_SUCCESS;
803}

◆ pfm_get_pmu_name()

pfm_err_t pfm_get_pmu_name ( char *  name,
int  maxlen 
)

Definition at line 251 of file pfmlib_common.c.

252{
253 if (PFMLIB_INITIALIZED() == 0) return PFMLIB_ERR_NOINIT;
254
255 if (name == NULL || maxlen < 1) return PFMLIB_ERR_INVAL;
256
257 strncpy(name, pfm_current->pmu_name, maxlen-1);
258
259 name[maxlen-1] = '\0';
260
261 return PFMLIB_SUCCESS;
262}
Here is the caller graph for this function:

◆ pfm_get_pmu_name_bytype()

pfm_err_t pfm_get_pmu_name_bytype ( int  type,
char *  name,
size_t  maxlen 
)

Definition at line 212 of file pfmlib_common.c.

213{
215
216 if (name == NULL || maxlen < 1) return PFMLIB_ERR_INVAL;
217
218 while (*p) {
219 if ((*p)->pmu_type == type) goto found;
220 p++;
221 }
222 return PFMLIB_ERR_INVAL;
223found:
224 strncpy(name, (*p)->pmu_name, maxlen-1);
225
226 /* make sure the string is null terminated */
227 name[maxlen-1] = '\0';
228
229 return PFMLIB_SUCCESS;
230}

◆ pfm_get_pmu_type()

pfm_err_t pfm_get_pmu_type ( int type)

Definition at line 265 of file pfmlib_common.c.

266{
267 if (PFMLIB_INITIALIZED() == 0) return PFMLIB_ERR_NOINIT;
268
269 if (type == NULL) return PFMLIB_ERR_INVAL;
270
271 *type = pfm_current->pmu_type;
272
273 return PFMLIB_SUCCESS;
274}
Here is the caller graph for this function:

◆ pfm_get_version()

pfm_err_t pfm_get_version ( unsigned int version)

Definition at line 895 of file pfmlib_common.c.

896{
897 if (version == NULL) return PFMLIB_ERR_INVAL;
899 return 0;
900}
uint8_t version
#define PFMLIB_VERSION
Definition: pfmlib.h:34
Here is the caller graph for this function:

◆ pfm_initialize()

pfm_err_t pfm_initialize ( void  )

Definition at line 144 of file pfmlib_common.c.

145{
147 int ret;
148
150 /*
151 * syscall mapping, no failure on error
152 */
154
155 while(*p) {
156 DPRINT("trying %s\n", (*p)->pmu_name);
157 /*
158 * check for forced_pmu
159 * pmu_type can never be zero
160 */
161 if ((*p)->pmu_type == forced_pmu) {
162 __pfm_vbprintf("PMU forced to %s\n", (*p)->pmu_name);
163 goto found;
164 }
165
166 if (forced_pmu == PFMLIB_NO_PMU && (*p)->pmu_detect() == PFMLIB_SUCCESS)
167 goto found;
168 p++;
169 }
170 return PFMLIB_ERR_NOTSUPP;
171found:
172 DPRINT("found %s\n", (*p)->pmu_name);
173 /*
174 * run a few sanity checks
175 */
176 if ((*p)->pmc_count >= PFMLIB_MAX_PMCS)
177 return PFMLIB_ERR_NOTSUPP;
178
179 if ((*p)->pmd_count >= PFMLIB_MAX_PMDS)
180 return PFMLIB_ERR_NOTSUPP;
181
182 if ((*p)->pmu_init) {
183 ret = (*p)->pmu_init();
184 if (ret != PFMLIB_SUCCESS)
185 return ret;
186 }
187
188 pfm_current = *p;
189
190 return PFMLIB_SUCCESS;
191}
#define PFMLIB_MAX_PMDS
Definition: pfmlib.h:42
#define PFMLIB_NO_PMU
Definition: pfmlib.h:221
static void pfm_check_debug_env(void)
int forced_pmu
void pfm_init_syscalls(void)
void __pfm_vbprintf(const char *fmt,...)
Definition: pfmlib_priv.c:52
#define DPRINT(fmt, a...)
Definition: pfmlib_priv.h:90
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_is_pmu_supported()

pfm_err_t pfm_is_pmu_supported ( int  type)

Definition at line 280 of file pfmlib_common.c.

281{
283
284 if (PFMLIB_INITIALIZED() == 0) return PFMLIB_ERR_NOINIT;
285
286 while (*p) {
287 if ((*p)->pmu_type == type) return PFMLIB_SUCCESS;
288 p++;
289 }
290 return PFMLIB_ERR_NOTSUPP;
291}

◆ pfm_list_supported_pmus()

pfm_err_t pfm_list_supported_pmus ( int(*)(const char *fmt,...)  pf)

Definition at line 233 of file pfmlib_common.c.

234{
236
237 if (pf == NULL) return PFMLIB_ERR_INVAL;
238
239 (*pf)("supported PMU models: ");
240
241 for (p = supported_pmus; *p; p++) {
242 (*pf)("[%s] ", (*p)->pmu_name);;
243 }
244
245 (*pf)("\ndetected host PMU: %s\n", pfm_current ? pfm_current->pmu_name : "not detected yet");
246
247 return PFMLIB_SUCCESS;
248}

◆ pfm_regmask_and()

static int pfm_regmask_and ( pfmlib_regmask_t dst,
pfmlib_regmask_t h1,
pfmlib_regmask_t h2 
)
inlinestatic

Definition at line 373 of file pfmlib.h.

374{
375 unsigned int pos;
376 if (dst == NULL || h1 == NULL || h2 == NULL)
377 return PFMLIB_ERR_INVAL;
378
379 for (pos = 0; pos < PFMLIB_REG_BV; pos++) {
380 dst->bits[pos] = h1->bits[pos] & h2->bits[pos];
381 }
382 return PFMLIB_SUCCESS;
383}
#define PFMLIB_REG_BV
Definition: pfmlib.h:72
pfmlib_regmask_bits_t bits[PFMLIB_REG_BV]
Definition: pfmlib.h:76

◆ pfm_regmask_andnot()

static int pfm_regmask_andnot ( pfmlib_regmask_t dst,
pfmlib_regmask_t h1,
pfmlib_regmask_t h2 
)
inlinestatic

Definition at line 386 of file pfmlib.h.

387{
388 unsigned int pos;
389 if (dst == NULL || h1 == NULL || h2 == NULL)
390 return PFMLIB_ERR_INVAL;
391
392 for (pos = 0; pos < PFMLIB_REG_BV; pos++) {
393 dst->bits[pos] = h1->bits[pos] & ~h2->bits[pos];
394 }
395 return PFMLIB_SUCCESS;
396}
Here is the caller graph for this function:

◆ pfm_regmask_clr()

static int pfm_regmask_clr ( pfmlib_regmask_t h,
unsigned int  b 
)
inlinestatic

Definition at line 332 of file pfmlib.h.

333{
334 if (h == NULL || b >= PFMLIB_REG_MAX)
335 return PFMLIB_ERR_INVAL;
336
337 h->bits[__PFMLIB_REGMASK_EL(b)] &= ~ __PFMLIB_REGMASK_MASK(b);
338
339 return PFMLIB_SUCCESS;
340}
static double b[MATRIX_SIZE][MATRIX_SIZE]
Definition: libmsr_basic.c:39
#define __PFMLIB_REGMASK_EL(g)
Definition: pfmlib.h:309
#define PFMLIB_REG_MAX
Definition: pfmlib.h:66
Here is the caller graph for this function:

◆ pfm_regmask_copy()

static int pfm_regmask_copy ( pfmlib_regmask_t dst,
pfmlib_regmask_t src 
)
inlinestatic

Definition at line 412 of file pfmlib.h.

413{
414 unsigned int pos;
415 if (dst == NULL || src == NULL)
416 return PFMLIB_ERR_INVAL;
417
418 for (pos = 0; pos < PFMLIB_REG_BV; pos++) {
419 dst->bits[pos] = src->bits[pos];
420 }
421 return PFMLIB_SUCCESS;
422}

◆ pfm_regmask_eq()

static int pfm_regmask_eq ( pfmlib_regmask_t h1,
pfmlib_regmask_t h2 
)
inlinestatic

Definition at line 359 of file pfmlib.h.

360{
361 unsigned int pos;
362
363 if (h1 == NULL || h2 == NULL)
364 return 0;
365
366 for (pos = 0; pos < PFMLIB_REG_BV; pos++) {
367 if (h1->bits[pos] != h2->bits[pos]) return 0;
368 }
369 return 1;
370}

◆ pfm_regmask_isset()

static int pfm_regmask_isset ( pfmlib_regmask_t h,
unsigned int  b 
)
inlinestatic

Definition at line 313 of file pfmlib.h.

314{
315 if (b >= PFMLIB_REG_MAX)
316 return 0;
317 return (h->bits[__PFMLIB_REGMASK_EL(b)] & __PFMLIB_REGMASK_MASK(b)) != 0;
318}
#define __PFMLIB_REGMASK_MASK(g)
Definition: pfmlib.h:310
Here is the caller graph for this function:

◆ pfm_regmask_not()

static int pfm_regmask_not ( pfmlib_regmask_t dst)
inlinestatic

Definition at line 424 of file pfmlib.h.

425{
426 unsigned int pos;
427 if (dst == NULL)
428 return PFMLIB_ERR_INVAL;
429
430 for (pos = 0; pos < PFMLIB_REG_BV; pos++) {
431 dst->bits[pos] = ~dst->bits[pos];
432 }
433 return PFMLIB_SUCCESS;
434}

◆ pfm_regmask_or()

static int pfm_regmask_or ( pfmlib_regmask_t dst,
pfmlib_regmask_t h1,
pfmlib_regmask_t h2 
)
inlinestatic

Definition at line 399 of file pfmlib.h.

400{
401 unsigned int pos;
402 if (dst == NULL || h1 == NULL || h2 == NULL)
403 return PFMLIB_ERR_INVAL;
404
405 for (pos = 0; pos < PFMLIB_REG_BV; pos++) {
406 dst->bits[pos] = h1->bits[pos] | h2->bits[pos];
407 }
408 return PFMLIB_SUCCESS;
409}
Here is the caller graph for this function:

◆ pfm_regmask_set()

static int pfm_regmask_set ( pfmlib_regmask_t h,
unsigned int  b 
)
inlinestatic

Definition at line 321 of file pfmlib.h.

322{
323 if (b >= PFMLIB_REG_MAX)
324 return PFMLIB_ERR_INVAL;
325
327
328 return PFMLIB_SUCCESS;
329}

◆ pfm_regmask_weight()

static int pfm_regmask_weight ( pfmlib_regmask_t h,
unsigned int w 
)
inlinestatic

Definition at line 343 of file pfmlib.h.

344{
345 unsigned int pos;
346 unsigned int weight = 0;
347
348 if (h == NULL || w == NULL)
349 return PFMLIB_ERR_INVAL;
350
351 for (pos = 0; pos < PFMLIB_REG_BV; pos++) {
352 weight += (unsigned int)pfmlib_popcnt(h->bits[pos]);
353 }
354 *w = weight;
355 return PFMLIB_SUCCESS;
356}
#define pfmlib_popcnt
Here is the caller graph for this function:

◆ pfm_set_options()

pfm_err_t pfm_set_options ( pfmlib_options_t opt)

Definition at line 194 of file pfmlib_common.c.

195{
196 if (opt == NULL)
197 return PFMLIB_ERR_INVAL;
198 /*
199 * environment variables override program presets
200 */
202 pfm_config.options = *opt;
203
204 return PFMLIB_SUCCESS;
205}
pfm_config_t pfm_config
int options_env_set
Definition: pfmlib_priv.h:69
pfmlib_options_t options
Definition: pfmlib_priv.h:67
Here is the caller graph for this function:

◆ pfm_strerror()

char * pfm_strerror ( int  code)

Definition at line 887 of file pfmlib_common.c.

888{
889 code = -code;
890 if (code <0 || code >= pfmlib_err_count) return "unknown error code";
891 return pfmlib_err_list[code];
892}
static char * pfmlib_err_list[]
static size_t pfmlib_err_count
Here is the caller graph for this function: