PAPI 7.1.0.0
Loading...
Searching...
No Matches
PAPI_overflow.c File Reference
Include dependency graph for PAPI_overflow.c:

Go to the source code of this file.

Macros

#define OVER_FMT   "handler(%d ) Overflow at %p! bit=%#llx \n"
 
#define THRESHOLD   100000
 
#define ERROR_RETURN(retval)   { fprintf(stderr, "Error %d %s:line %d: \n", retval,__FILE__,__LINE__); exit(retval); }
 

Functions

void handler (int EventSet, void *address, long long overflow_vector, void *context)
 
int main ()
 

Variables

int total = 0
 

Macro Definition Documentation

◆ ERROR_RETURN

#define ERROR_RETURN (   retval)    { fprintf(stderr, "Error %d %s:line %d: \n", retval,__FILE__,__LINE__); exit(retval); }

Definition at line 13 of file PAPI_overflow.c.

◆ OVER_FMT

#define OVER_FMT   "handler(%d ) Overflow at %p! bit=%#llx \n"

Definition at line 11 of file PAPI_overflow.c.

◆ THRESHOLD

#define THRESHOLD   100000

Definition at line 12 of file PAPI_overflow.c.

Function Documentation

◆ handler()

void handler ( int  EventSet,
void *  address,
long long  overflow_vector,
void *  context 
)

Definition at line 19 of file PAPI_overflow.c.

20{
21 fprintf(stderr, OVER_FMT, EventSet, address, overflow_vector);
22 total++;
23}
#define OVER_FMT
Definition: PAPI_overflow.c:11
int total
Definition: PAPI_overflow.c:15
static int EventSet
Definition: init_fini.c:8
FILE * stderr
Here is the caller graph for this function:

◆ main()

int main ( )

Definition at line 26 of file PAPI_overflow.c.

27{
28 int EventSet = PAPI_NULL;
29 /* must be set to null before calling PAPI_create_eventset */
30
31 char errstring[PAPI_MAX_STR_LEN];
32 long long (values[2])[2];
33 int retval, i;
34 double tmp = 0;
35 int PAPI_event; /* a place holder for an event preset */
37
38
39 /****************************************************************************
40 * This part initializes the library and compares the version number of the *
41 * header file, to the version of the library, if these don't match then it *
42 * is likely that PAPI won't work correctly.If there is an error, retval *
43 * keeps track of the version number. *
44 ****************************************************************************/
45
47 {
48 printf("Library initialization error! \n");
49 exit(1);
50 }
51
52 /* Here we create the eventset */
55
57
58 /* Here we are querying for the existence of the PAPI presets */
60 {
62
65
66 printf ("PAPI_TOT_INS not available on this platform.");
67 printf (" so subst PAPI_event with PAPI_TOT_CYC !\n\n");
68
69 }
70
71
72 /* PAPI_event_code_to_name is used to convert a PAPI preset from
73 its integer value to its string name. */
76
77 /* add event to the event set */
80
81 /* register overflow and set up threshold */
82 /* The threshold "THRESHOLD" was set to 100000 */
84 handler)) != PAPI_OK)
86
87 printf ("Here are the addresses at which overflows occurred and overflow vectors \n");
88 printf ("--------------------------------------------------------------\n");
89
90
91 /* Start counting */
92
95
96 for (i = 0; i < 2000000; i++)
97 {
98 tmp = 1.01 + tmp;
99 tmp++;
100 }
101
102 /* Stops the counters and reads the counter values into the values array */
103 if ( (retval=PAPI_stop (EventSet, values[0])) != PAPI_OK)
105
106
107 printf ("The total no of overflows was %d\n", total);
108
109 /* clear the overflow status */
111 handler)) != PAPI_OK)
113
114 /************************************************************************
115 * PAPI_cleanup_eventset can only be used after the counter has been *
116 * stopped then it remove all events in the eventset *
117 ************************************************************************/
120
121 /* Free all memory and data structures, EventSet must be empty. */
124
125 /* free the resources used by PAPI */
127
128 exit(0);
129}
double tmp
int i
#define THRESHOLD
Definition: PAPI_overflow.c:12
#define ERROR_RETURN(retval)
Definition: PAPI_overflow.c:13
void handler(int EventSet, void *address, long long overflow_vector, void *context)
Definition: PAPI_overflow.c:19
add PAPI preset or native hardware event to an event set
Empty and destroy an EventSet.
Create a new empty PAPI EventSet.
Empty and destroy an EventSet.
Convert a numeric hardware event code to a name.
initialize the PAPI library.
Set up an event set to begin registering overflows.
Query if PAPI event exists.
Finish using PAPI and free all related resources.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
int PAPI_event[2]
Definition: data_range.c:30
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_NULL
Definition: f90papi.h:78
#define PAPI_TOT_CYC
Definition: f90papi.h:308
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
#define PAPI_TOT_INS
Definition: f90papi.h:317
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
long long int long long
Definition: sde_internal.h:85
int retval
Definition: zero_fork.c:53
Here is the call graph for this function:

Variable Documentation

◆ total

int total = 0

Definition at line 15 of file PAPI_overflow.c.