HP Caliper User's Guide
1. Modify your source code to add trigger statements to take the samples.
Use the macros in include/caliper_control.h in the HP Caliper home
directory. The macros are named CALIPER_PMU_TAKE_SAMPLE_n, with n varying
from 1 to 8. The report shows the value of n next to each Sample Origin column.
Figure 13-3 “Using Macros to Trigger PMU Samples” shows an example of how
to use the macros.
Figure 13-3 Using Macros to Trigger PMU Samples
#include <caliper_control.h>
....
void my_function (void)
{
CALIPER_PMU_TAKE_SAMPLE_1();
[... code to be measured ...]
CALIPER_PMU_TAKE_SAMPLE_2();
}
2. Make a copy of the pmu_trace measurement configuration file under a new name,
for example my_pmu_trace.
3. Edit the copy of the measurement configuration file to enable the samples you
have specified. Change the value of collect_sample_desc to True.
This setting causes HP Caliper to collect and present information for each sample
to identify the origin of the sample.
4. To create a report that shows samples only at the points in your code where you
explicitly set the CALIPER_PMU_TAKE_SAMPLE_x instructions, you must change
the sampling_counter setting in the measurement configuration file.
Setting the counter to NO_EVENT or None disables statistical sampling:
sampling_counter = “NO_EVENT”
If you don't change this setting, then the samples you have marked will be included
with whatever sampling results HP Caliper is set to generate.
You can instead run HP Caliper, specifying -s ,,NO_EVENT or -s "" on the
command line.
5. Run your application under HP Caliper using that modified measurement
configuration file:
$ caliper my_pmu_trace myprogram
Figure 13-4 “Example of PMU Trace Report” shows part of the resulting report.
Taking PMU Samples in Your Code 209