HP Caliper User's Guide

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 13-5 “Restricting PMU Measurement to Specific Code” shows how to use the
header file and macros.
Figure 13-5 Restricting PMU Measurement to Specific Code
#include <stdio.h>
#include </opt/caliper/include/caliper_control.h>
int main (void)
{
int i;
printf("Starting\n");
CALIPER_PMU_ENABLE();
for (i=0; i<10; i++)
{
printf("Hello world! [%d]\n", i);
}
CALIPER_PMU_DISABLE();
printf("Done\n");
return;
}
Taking PMU Samples in Your Code 213