
Name
pfm_get_impl_pmcs, pfm_get_impl_pmds, pfm_get_impl_counters, pfm_get_num_counters, pfm_get_num_pmcs, pfm_get_num_pmds - return
bitmask of implemented PMU registers or the number of PMU registers
Synopsis
#include <perfmon/pfmlib.h>
int pfm_get_impl_pmcs(pfmlib_regmask_t *impl_pmcs]);
int pfm_get_impl_pmds(pfmlib_regmask_t *impl_pmds]);
int pfm_get_impl_counters(pfmlib_regmask_t *impl_counters);
int pfm_get_num_counters(unsigned int *num);
int pfm_get_num_pmcs(unsigned int *num);
int pfm_get_num_pmds(unsigned int *num);
int pfm_get_hw_counter_width(unsigned int *width);
unsigned int pfmlib_regmask_weight(pfmlib_regmask_t *mask);
int pfmlib_regmask_eq(pfmlib_regmask_t *mask1, pfmlib_regmask_t *mask2);
Description
The pfm_get_impl_* functions can be used to figure out which
PMU registers are implemented on the host CPU. They all return a
bitmask of registers corresponding to the query. The number of
implemented PMU registers (PMDS, PMCS) can vary from one
implementation to another. Similarly, the number of PMD register
which can be used as counters can vary.
The pfm_get_impl_pmcs returns in impl_pmcs the bitmask of implemented PMCS.
The pfm_get_impl_pmds returns in impl_pmds the bitmask of implemented PMDS.
The pfm_get_impl_counters returns in impl_counters a bitmask of the PMD/PMC pairs
which can be used as counters. PMU registers can be used for very different purposes: control,
counting, buffers. The counters are used to accumulate the number of occurrences of events
and are typically the one used by monitoring tools.
The returned bitmask must be accessed using the following accessor macros and functions:
- PFMLIB_REGMASK_ISSET(bmask, idx):
A macro which returns true if register idx is set in the bitmask pointed by bmask.
- PFMLIB_REGMASK_SET(bmask, idx):
A macro which sets the bit corresponding to register idx in the bitmask pointed by bmask.
- PFMLIB_REGMASK_CLR(bmask, idx):
A macro which clears the bit corresponding to register idx in the bitmask pointed by bmask.
- pfmlib_regmask_weight(mask):
A function which returns the number of bits set in mask, i.e., the number of register implemented.
- pfmlib_regmask_eq(mask1, mask2):
A function which returns 1 if mask1 and mask2 are equal, otherwise it returns 0.
The pfm_get_num_counters function puts the number of
counters implemented by the host PMU in num. The same results can be obtained
by counting the number of bits set in the bitmask returned by pfm_get_impl_counters.
The pfm_get_hw_counter_width function puts the width in bits of the counters
in width. PMU implementations can have different number of bits implemented.
For instance, Itanium has 32-bit counters, while Itanium 2 has 47-bits. Depending
on the OS interface, you may not have to care about the width and assume counters are 64
bits. This is the case for the Linux/ia64 perfmon subsystem where the interface exports
all counters as 64-bit wide.
Return
The function returns whether or not
it was successful. A return value of PFMLIB_SUCCESS indicates success,
otherwise the value is the error code.
Errors
PFMLIB_ERR_NOINIT the library
has not been initialized properly.
Author
Stephane Eranian <eranian@hpl.hp.com>

|