HP Caliper 5.3 User Guide (5900-1558, February 2011)

NOTE: This feature is not intended to measure a small number of instructions.
Enabling and disabling the PMU are not immediate operations and either operation might take a
few processor cycles to be effective. Processor events occurring during those transitions might or
might not be measured. Avoid using measurement windows so small that those uncertainties will
significantly affect the reported numbers.
To use this feature:
1. Modify the program source code to use the header file provided with HP Caliper.
The location of the header file is include/caliper_control.h in the HP Caliper home
directory.
2. In your source code, add the HP Caliper macros to enable and disable the PMU.
To enable the PMU, insert:
CALIPER_PMU_ENABLE();
Using CALIPER_PMU_ENABLE() enables the PMU for the current thread until the next
CALIPER_PMU_DISABLE().
When the PMU is already enabled, CALIPER_PMU_ENABLE() does not have any effect.
To disable the PMU, insert:
CALIPER_PMU_DISABLE();
When the PMU is already disabled, CALIPER_PMU_DISABLE() does not have any
effect.
3. Use the command-line option --user-regions rum-sum. (Or place
user_regions="rum-sum" in a measurement configuration file.)
This option causes HP Caliper to allow the measured applications to control the PMU. When
you specify --user-regions rum-sum, the PMU is initially disabled, and HP Caliper will
not measure the application until the first CALIPER_PMU_ENABLE() is executed.
The default behavior is to disallow such control and measure the full run (--user-regions
default).
To override the HP Caliper PMU macros, use --user-regions default on the command
line. (Or place user_regions="default" in a measurement configuration file.)
If you do not specify the --user-regions option, CALIPER_PMU_ENABLE() and
CALIPER_PMU_DISABLE() do not have any effect and the instructions behave as no-ops.
When the PMU is programmed to allow control by non-privileged instructions, the instruction
sum 0x4 enables the PMU, while rum 0x4 disables it. The file include/caliper_control.h
in the HP Caliper home directory contains C/C++ macros to inline the rum 0x4 and sum 0x4
instructions.
Figure 32 (page 163) shows how to use the header file and macros.
162 HP Caliper Features Specific to HP-UX