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 (caddr_t)(*(void **)do_flops1) 20 #define DO_FLOPS2 (caddr_t)(*(void **)do_flops2) 22 #define DO_FLOPS1 (caddr_t)(do_flops1) 23 #define DO_FLOPS2 (caddr_t)(do_flops2) 27 volatile double t1 = 0.8,
t2 = 0.9;
33 for (
i = 0;
i < n;
i++)
43 for (
i = 0;
i < n;
i++)
50 int 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);
173 volatile double a = 0.5,
b = 2.2;
179 for (
i = 0;
i < n;
i++)
int PAPI_stop(int EventSet, long long *values)
int PAPI_add_event(int EventSet, int EventCode)
get the executable's info
#define PAPI_PROFIL_POSIX
static struct timeval start
int PAPI_sprofil(PAPI_sprofil_t *prof, int profcnt, int EventSet, int EventCode, int threshold, int flags)
Return codes and api definitions.
int PAPI_library_init(int version)
const PAPI_exe_info_t * PAPI_get_executable_info(void)
int main(int argc, char **argv)
PAPI_address_map_t address_info
int PAPI_create_eventset(int *EventSet)
#define ERROR_RETURN(retval)
int PAPI_start(int EventSet)
static long long values[NUM_EVENTS]