|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* ita2_rr.c - example of how to use data range restriction with the Itanium2 PMU
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* Copyright (c) 2002-2006 Hewlett-Packard Development Company, L.P.
|
|
Packit |
577717 |
* Contributed by Stephane Eranian <eranian@hpl.hp.com>
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
Packit |
577717 |
* of this software and associated documentation files (the "Software"), to deal
|
|
Packit |
577717 |
* in the Software without restriction, including without limitation the rights
|
|
Packit |
577717 |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
Packit |
577717 |
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
Packit |
577717 |
* subject to the following conditions:
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* The above copyright notice and this permission notice shall be included in all
|
|
Packit |
577717 |
* copies or substantial portions of the Software.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
Packit |
577717 |
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
Packit |
577717 |
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
Packit |
577717 |
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
Packit |
577717 |
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
|
Packit |
577717 |
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* This file is part of libpfm, a performance monitoring support library for
|
|
Packit |
577717 |
* applications on Linux/ia64.
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
#include <sys/types.h>
|
|
Packit |
577717 |
#include <stdio.h>
|
|
Packit |
577717 |
#include <stdlib.h>
|
|
Packit |
577717 |
#include <stdarg.h>
|
|
Packit |
577717 |
#include <errno.h>
|
|
Packit |
577717 |
#include <unistd.h>
|
|
Packit |
577717 |
#include <string.h>
|
|
Packit |
577717 |
#include <signal.h>
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#include <perfmon/perfmon.h>
|
|
Packit |
577717 |
#include <perfmon/pfmlib_itanium2.h>
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#if defined(__ECC) && defined(__INTEL_COMPILER)
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* if you do not have this file, your compiler is too old */
|
|
Packit |
577717 |
#include <ia64intrin.h>
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#define clear_psr_ac() __rum(1UL<<3)
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#elif defined(__GNUC__)
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static inline void
|
|
Packit |
577717 |
clear_psr_ac(void)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
__asm__ __volatile__("rum psr.ac;;" ::: "memory" );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
#else
|
|
Packit |
577717 |
#error "You need to define clear_psr_ac() for your compiler"
|
|
Packit |
577717 |
#endif
|
|
Packit |
577717 |
|
|
Packit |
577717 |
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#define TEST_DATA_COUNT 16
|
|
Packit |
577717 |
#define N_LOOP 100000000UL
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#define NUM_PMCS PFMLIB_MAX_PMCS
|
|
Packit |
577717 |
#define NUM_PMDS PFMLIB_MAX_PMDS
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#define MAX_EVT_NAME_LEN 128
|
|
Packit |
577717 |
#define MAX_PMU_NAME_LEN 32
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* here we capture only misaligned_loads because it cannot
|
|
Packit |
577717 |
* be measured with misaligned_stores_retired at the same time
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
static char *event_list[]={
|
|
Packit |
577717 |
"misaligned_loads_retired",
|
|
Packit |
577717 |
NULL
|
|
Packit |
577717 |
};
|
|
Packit |
577717 |
|
|
Packit |
577717 |
|
|
Packit |
577717 |
typedef union {
|
|
Packit |
577717 |
unsigned long l_tab[2];
|
|
Packit |
577717 |
unsigned int i_tab[4];
|
|
Packit |
577717 |
unsigned short s_tab[8];
|
|
Packit |
577717 |
unsigned char c_tab[16];
|
|
Packit |
577717 |
} test_data_t;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static int
|
|
Packit |
577717 |
do_test(test_data_t *data)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
unsigned int *l, v;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
l = (unsigned int *)(data->c_tab+1);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (((unsigned long)l & 0x1) == 0) {
|
|
Packit |
577717 |
printf("Data is not unaligned, can't run test\n");
|
|
Packit |
577717 |
return -1;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
v = *l;
|
|
Packit |
577717 |
v++;
|
|
Packit |
577717 |
*l = v;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
return 0;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static void fatal_error(char *fmt,...) __attribute__((noreturn));
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static void
|
|
Packit |
577717 |
fatal_error(char *fmt, ...)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
va_list ap;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
va_start(ap, fmt);
|
|
Packit |
577717 |
vfprintf(stderr, fmt, ap);
|
|
Packit |
577717 |
va_end(ap);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
exit(1);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
int
|
|
Packit |
577717 |
main(int argc, char **argv)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
char **p;
|
|
Packit |
577717 |
test_data_t *test_data, *test_data_fake;
|
|
Packit |
577717 |
unsigned long range_start, range_end;
|
|
Packit |
577717 |
int ret, type = 0;
|
|
Packit |
577717 |
pfmlib_input_param_t inp;
|
|
Packit |
577717 |
pfmlib_output_param_t outp;
|
|
Packit |
577717 |
pfmlib_ita2_input_param_t ita2_inp;
|
|
Packit |
577717 |
pfmlib_ita2_output_param_t ita2_outp;
|
|
Packit |
577717 |
pfarg_reg_t pd[NUM_PMDS];
|
|
Packit |
577717 |
pfarg_reg_t pc[NUM_PMCS];
|
|
Packit |
577717 |
pfarg_dbreg_t dbrs[8];
|
|
Packit |
577717 |
pfarg_context_t ctx[1];
|
|
Packit |
577717 |
pfarg_load_t load_args;
|
|
Packit |
577717 |
pfmlib_options_t pfmlib_options;
|
|
Packit |
577717 |
unsigned int i;
|
|
Packit |
577717 |
int id;
|
|
Packit |
577717 |
char name[MAX_EVT_NAME_LEN];
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* Initialize pfm library (required before we can use it)
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
if (pfm_initialize() != PFMLIB_SUCCESS) {
|
|
Packit |
577717 |
fatal_error("Can't initialize library\n");
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* Let's make sure we run this on the right CPU family
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
pfm_get_pmu_type(&type);
|
|
Packit |
577717 |
if (type != PFMLIB_ITANIUM2_PMU) {
|
|
Packit |
577717 |
char model[MAX_PMU_NAME_LEN];
|
|
Packit |
577717 |
pfm_get_pmu_name(model, MAX_PMU_NAME_LEN);
|
|
Packit |
577717 |
fatal_error("this program does not work with %s PMU\n", model);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* pass options to library (optional)
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
memset(&pfmlib_options, 0, sizeof(pfmlib_options));
|
|
Packit |
577717 |
pfmlib_options.pfm_debug = 0; /* set to 1 for debug */
|
|
Packit |
577717 |
pfmlib_options.pfm_verbose = 0; /* set to 1 for debug */
|
|
Packit |
577717 |
pfm_set_options(&pfmlib_options);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* now let's allocate the data structure we will be monitoring
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
test_data = (test_data_t *)malloc(sizeof(test_data_t)*TEST_DATA_COUNT);
|
|
Packit |
577717 |
if (test_data == NULL) {
|
|
Packit |
577717 |
fatal_error("cannot allocate test data structure");
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
test_data_fake = (test_data_t *)malloc(sizeof(test_data_t)*TEST_DATA_COUNT);
|
|
Packit |
577717 |
if (test_data_fake == NULL) {
|
|
Packit |
577717 |
fatal_error("cannot allocate test data structure");
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* Compute the range we are interested in
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
range_start = (unsigned long)test_data;
|
|
Packit |
577717 |
range_end = range_start + sizeof(test_data_t)*TEST_DATA_COUNT;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
memset(pd, 0, sizeof(pd));
|
|
Packit |
577717 |
memset(pc, 0, sizeof(pc));
|
|
Packit |
577717 |
memset(ctx, 0, sizeof(ctx));
|
|
Packit |
577717 |
memset(dbrs, 0, sizeof(dbrs));
|
|
Packit |
577717 |
memset(&load_args, 0, sizeof(load_args));
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* prepare parameters to library. we don't use any Itanium
|
|
Packit |
577717 |
* specific features here. so the pfp_model is NULL.
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
memset(&inp,0, sizeof(inp));
|
|
Packit |
577717 |
memset(&outp,0, sizeof(outp));
|
|
Packit |
577717 |
memset(&ita2_inp,0, sizeof(ita2_inp));
|
|
Packit |
577717 |
memset(&ita2_outp,0, sizeof(ita2_outp));
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* find requested event
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
p = event_list;
|
|
Packit |
577717 |
for (i=0; *p ; i++, p++) {
|
|
Packit |
577717 |
if (pfm_find_event(*p, &inp.pfp_events[i].event) != PFMLIB_SUCCESS) {
|
|
Packit |
577717 |
fatal_error("Cannot find %s event\n", *p);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* set the privilege mode:
|
|
Packit |
577717 |
* PFM_PLM3 : user level only
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
inp.pfp_dfl_plm = PFM_PLM3;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* how many counters we use
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
inp.pfp_event_count = i;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* We use the library to figure out how to program the debug registers
|
|
Packit |
577717 |
* to cover the data range we are interested in. The rr_end parameter
|
|
Packit |
577717 |
* must point to the byte after the last element of the range (C-style range).
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* Because of the masking mechanism and therefore alignment constraints used to implement
|
|
Packit |
577717 |
* this feature, it may not be possible to exactly cover a given range. It may be that
|
|
Packit |
577717 |
* the coverage exceeds the desired range. So it is possible to capture noise if
|
|
Packit |
577717 |
* the surrounding addresses are also heavily used. You can figure out by how much the
|
|
Packit |
577717 |
* actual range is off compared to the requested range by checking the rr_soff and rr_eoff
|
|
Packit |
577717 |
* fields in rr_infos on return from the library call.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* Upon return, the rr_dbr array is programmed and the number of debug registers (not pairs)
|
|
Packit |
577717 |
* used to cover the range is in rr_nbr_used.
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
|
|
Packit |
577717 |
ita2_inp.pfp_ita2_drange.rr_used = 1;
|
|
Packit |
577717 |
ita2_inp.pfp_ita2_drange.rr_limits[0].rr_start = range_start;
|
|
Packit |
577717 |
ita2_inp.pfp_ita2_drange.rr_limits[0].rr_end = range_end;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* let the library figure out the values for the PMCS
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
if ((ret=pfm_dispatch_events(&inp, &ita2_inp, &outp, &ita2_outp)) != PFMLIB_SUCCESS) {
|
|
Packit |
577717 |
fatal_error("cannot configure events: %s\n", pfm_strerror(ret));
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
printf("data range : [0x%016lx-0x%016lx): %d pair of debug registers used\n"
|
|
Packit |
577717 |
"start_offset:-0x%lx end_offset:+0x%lx\n",
|
|
Packit |
577717 |
range_start,
|
|
Packit |
577717 |
range_end,
|
|
Packit |
577717 |
ita2_outp.pfp_ita2_drange.rr_nbr_used >> 1,
|
|
Packit |
577717 |
ita2_outp.pfp_ita2_drange.rr_infos[0].rr_soff,
|
|
Packit |
577717 |
ita2_outp.pfp_ita2_drange.rr_infos[0].rr_eoff);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
printf("fake data range: [0x%016lx-0x%016lx)\n",
|
|
Packit |
577717 |
(unsigned long)test_data_fake,
|
|
Packit |
577717 |
(unsigned long)test_data_fake+sizeof(test_data_t)*TEST_DATA_COUNT);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* now create the context for self monitoring/per-task
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
if (perfmonctl(0, PFM_CREATE_CONTEXT, ctx, 1) == -1) {
|
|
Packit |
577717 |
if (errno == ENOSYS) {
|
|
Packit |
577717 |
fatal_error("Your kernel does not have performance monitoring support!\n");
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
fatal_error("Can't create PFM context %s\n", strerror(errno));
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* extract the unique identifier for our context, a regular file descriptor
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
id = ctx[0].ctx_fd;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* Now prepare the argument to initialize the PMDs and PMCS.
|
|
Packit |
577717 |
* We must pfp_pmc_count to determine the number of PMC to intialize.
|
|
Packit |
577717 |
* We must use pfp_event_count to determine the number of PMD to initialize.
|
|
Packit |
577717 |
* Some events causes extra PMCs to be used, so pfp_pmc_count may be >= pfp_event_count.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* This step is new compared to libpfm-2.x. It is necessary because the library no
|
|
Packit |
577717 |
* longer knows about the kernel data structures.
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
|
|
Packit |
577717 |
for (i=0; i < outp.pfp_pmc_count; i++) {
|
|
Packit |
577717 |
pc[i].reg_num = outp.pfp_pmcs[i].reg_num;
|
|
Packit |
577717 |
pc[i].reg_value = outp.pfp_pmcs[i].reg_value;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* the PMC controlling the event ALWAYS come first, that's why this loop
|
|
Packit |
577717 |
* is safe even when extra PMC are needed to support a particular event.
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
for (i=0; i < inp.pfp_event_count; i++) {
|
|
Packit |
577717 |
pd[i].reg_num = pc[i].reg_num;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* propagate the setup for the debug registers from the library to the arguments
|
|
Packit |
577717 |
* to the perfmonctl() syscall. The library does not know the type of the syscall
|
|
Packit |
577717 |
* anymore.
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
for (i=0; i < ita2_outp.pfp_ita2_drange.rr_nbr_used; i++) {
|
|
Packit |
577717 |
dbrs[i].dbreg_num = ita2_outp.pfp_ita2_drange.rr_br[i].reg_num;
|
|
Packit |
577717 |
dbrs[i].dbreg_value = ita2_outp.pfp_ita2_drange.rr_br[i].reg_value;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* Program the data debug registers.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* IMPORTANT: programming the debug register MUST always be done before the PMCs
|
|
Packit |
577717 |
* otherwise the kernel will fail on PFM_WRITE_PMCS. This is for security reasons.
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
if (perfmonctl(id, PFM_WRITE_DBRS, dbrs, ita2_outp.pfp_ita2_drange.rr_nbr_used) == -1) {
|
|
Packit |
577717 |
fatal_error( "child: perfmonctl error PFM_WRITE_DBRS errno %d\n",errno);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* Now program the registers
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* We don't use the save variable to indicate the number of elements passed to
|
|
Packit |
577717 |
* the kernel because, as we said earlier, pc may contain more elements than
|
|
Packit |
577717 |
* the number of events we specified, i.e., contains more than coutning monitors.
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
if (perfmonctl(id, PFM_WRITE_PMCS, pc, outp.pfp_pmc_count) == -1) {
|
|
Packit |
577717 |
fatal_error("child: perfmonctl error PFM_WRITE_PMCS errno %d\n",errno);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (perfmonctl(id, PFM_WRITE_PMDS, pd, inp.pfp_event_count) == -1) {
|
|
Packit |
577717 |
fatal_error( "child: perfmonctl error PFM_WRITE_PMDS errno %d\n",errno);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* now we load (i.e., attach) the context to ourself
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
load_args.load_pid = getpid();
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (perfmonctl(id, PFM_LOAD_CONTEXT, &load_args, 1) == -1) {
|
|
Packit |
577717 |
fatal_error("perfmonctl error PFM_LOAD_CONTEXT errno %d\n",errno);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* Let's make sure that the hardware does the unaligned accesses (do not use the
|
|
Packit |
577717 |
* kernel software handler otherwise the PMU won't see the unaligned fault).
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
clear_psr_ac();
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* Let's roll now.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* The idea behind this test is to have two dynamically allocated data structures
|
|
Packit |
577717 |
* which are access in a unaligned fashion. But we want to capture only the unaligned
|
|
Packit |
577717 |
* accesses on one of the two. So the debug registers are programmed to cover the
|
|
Packit |
577717 |
* first one ONLY. Then we activate monotoring and access the two data structures.
|
|
Packit |
577717 |
* This is an artificial example just to demonstrate how to use data address range
|
|
Packit |
577717 |
* restrictions.
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
pfm_self_start(id);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
for(i=0; i < N_LOOP; i++) {
|
|
Packit |
577717 |
do_test(test_data);
|
|
Packit |
577717 |
do_test(test_data_fake);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
pfm_self_stop(id);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* now read the results
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
if (perfmonctl(id, PFM_READ_PMDS, pd, inp.pfp_event_count) == -1) {
|
|
Packit |
577717 |
fatal_error( "perfmonctl error READ_PMDS errno %d\n",errno);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* print the results
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* It is important to realize, that the first event we specified may not
|
|
Packit |
577717 |
* be in PMD4. Not all events can be measured by any monitor. That's why
|
|
Packit |
577717 |
* we need to use the pc[] array to figure out where event i was allocated.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* For this example, we expect to see a value of 1 for misaligned loads.
|
|
Packit |
577717 |
* But it can be two when the test_data and test_data_fake
|
|
Packit |
577717 |
* are allocated very close from each other and the range created with the debug
|
|
Packit |
577717 |
* registers is larger then test_data.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
for (i=0; i < inp.pfp_event_count; i++) {
|
|
Packit |
577717 |
pfm_get_full_event_name(&inp.pfp_events[i], name, MAX_EVT_NAME_LEN);
|
|
Packit |
577717 |
printf("PMD%u %20lu %s (expected %lu)\n",
|
|
Packit |
577717 |
pd[i].reg_num,
|
|
Packit |
577717 |
pd[i].reg_value,
|
|
Packit |
577717 |
name, N_LOOP);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (pd[i].reg_value != N_LOOP) {
|
|
Packit |
577717 |
printf("error: Result should be 1 for %s\n", name);
|
|
Packit |
577717 |
break;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* let's stop this now
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
close(id);
|
|
Packit |
577717 |
free(test_data);
|
|
Packit |
577717 |
free(test_data_fake);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
return 0;
|
|
Packit |
577717 |
}
|