13#define NUM_FLOPS 20000000
14#define NUM_ITERS 100000
15#define THRESHOLD 100000
16#define ERROR_RETURN(retval) { fprintf(stderr, "Error %d %s:line %d: \n", retval,__FILE__,__LINE__); exit(retval); }
18#if (defined(linux) && defined(__ia64__)) || (defined(_AIX))
19#define DO_FLOPS1 (vptr_t)(*(void **)do_flops1)
20#define DO_FLOPS2 (vptr_t)(*(void **)do_flops2)
22#define DO_FLOPS1 (vptr_t)(do_flops1)
23#define DO_FLOPS2 (vptr_t)(do_flops2)
27volatile double t1 = 0.8,
t2 = 0.9;
33 for (
i = 0;
i < n;
i++)
43 for (
i = 0;
i < n;
i++)
50int main(
int argc,
char **argv)
55 unsigned short *profbuf2;
56 unsigned short *profbuf3;
67 printf(
"Library initialization error! \n");
76 length = (end -
start)/
sizeof(
unsigned short) *
sizeof(
unsigned short);
77 printf(
"start= %p end =%p \n",
start, end);
85 profbuf2 = (
unsigned short *) malloc(
length);
89 memset(profbuf2, 0x00,
length );
91 profbuf3 = (
unsigned short *) malloc(1 *
sizeof(
unsigned short));
95 memset(profbuf3, 0x00, 1 *
sizeof(
unsigned short));
101 fprintf(
stderr,
"do_flops is at %p %lx\n", &
do_flops2, strtoul(sprof[0].pr_off,NULL,0));
108 fprintf(
stderr,
"do_flops1 is at %p %lx\n", &
do_flops1, strtoul(sprof[1].pr_off,NULL,0));
151 printf(
"Test case: PAPI_sprofil()\n");
152 printf(
"---------Buffer 1--------\n");
158 printf(
"---------Buffer 2--------\n");
162 printf(
"%#lx\t%d\n", strtoul(
DO_FLOPS1,NULL,0) + 2 *
i, profbuf2[
i]);
164 printf(
"-------------------------\n");
165 printf(
"%u samples fell outside the regions.\n", *profbuf3);
173volatile double a = 0.5,
b = 2.2;
179 for (
i = 0;
i < n;
i++)
add PAPI preset or native hardware event to an event set
Create a new empty PAPI EventSet.
Get the executable's address space info.
initialize the PAPI library.
Finish using PAPI and free all related resources.
Generate PC histogram data from multiple code regions where hardware counter overflow occurs.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
#define ERROR_RETURN(retval)
#define PAPI_PROFIL_POSIX
static long long values[NUM_EVENTS]
static struct timeval start
static double c[MATRIX_SIZE][MATRIX_SIZE]
Return codes and api definitions.
get the executable's info
PAPI_address_map_t address_info