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

Go to the source code of this file.

Macros

#define OVER_FMT   "handler(%d ) Overflow at %p! bit=%#llx \n"
 
#define OUT_FMT   "%-12s : %16lld%16lld\n"
 

Functions

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

Variables

int total = 0
 

Macro Definition Documentation

◆ OUT_FMT

#define OUT_FMT   "%-12s : %16lld%16lld\n"

Definition at line 31 of file overflow2.c.

◆ OVER_FMT

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

Definition at line 30 of file overflow2.c.

Function Documentation

◆ handler()

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

Definition at line 36 of file overflow2.c.

37{
38 ( void ) context;
39
40 if ( !TESTS_QUIET ) {
41 fprintf( stderr, OVER_FMT, EventSet, address, overflow_vector );
42 }
43 total++;
44}
static int EventSet
Definition: init_fini.c:8
int TESTS_QUIET
Definition: test_utils.c:18
#define OVER_FMT
Definition: overflow2.c:30
int total
Definition: overflow2.c:33
FILE * stderr
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 47 of file overflow2.c.

48{
49 int EventSet = PAPI_NULL;
50 long long ( values[2] )[2];
51 long long min, max;
52 int num_flops, retval;
55 const PAPI_hw_info_t *hw_info = NULL;
56 int quiet;
57
58 /* Set TESTS_QUIET variable */
59 quiet = tests_quiet( argc, argv );
60
62 if ( retval != PAPI_VER_CURRENT ) {
63 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
64 }
65
67 if ( hw_info == NULL ) {
68 test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
69 }
70
71#if defined(POWER3) || defined(__sparc__)
73#else
74 /* query and set up the right instruction to monitor */
76#endif
77
78 if (PAPI_event==0) {
79 if (!quiet) printf("Trouble creating events\n");
80 test_skip(__FILE__,__LINE__,"Creating event",1);
81 }
82
83 if (( PAPI_event == PAPI_FP_OPS ) || ( PAPI_event == PAPI_FP_INS ))
85 else
86#if defined(linux)
87 mythreshold = ( int ) hw_info->cpu_max_mhz * 10000 * 2;
88#else
90#endif
91
93 if ( retval != PAPI_OK )
94 test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
95
97 if ( retval != PAPI_OK )
98 test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
99
101 if ( retval != PAPI_OK )
102 test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
103
105 if ( retval != PAPI_OK )
106 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
107
109
111 if ( retval != PAPI_OK )
112 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
113
115 if ( retval != PAPI_OK )
116 test_fail( __FILE__, __LINE__, "PAPI_overflow", retval );
117
119 if ( retval != PAPI_OK )
120 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
121
123
125 if ( retval != PAPI_OK )
126 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
127
129 if ( retval != PAPI_OK )
130 test_fail( __FILE__, __LINE__, "PAPI_overflow", retval );
131
132 num_flops = NUM_FLOPS;
133#if defined(linux) || defined(__ia64__) || defined(_POWER4)
134 num_flops *= 2;
135#endif
136
137 if ( !quiet ) {
138 if ( ( retval =
140 test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
141
142 printf
143 ( "Test case: Overflow dispatch of 1st event in set with 2 events.\n" );
144 printf
145 ( "---------------------------------------------------------------\n" );
146 printf( "Threshold for overflow is: %d\n", mythreshold );
147 printf( "Using %d iterations of c += a*b\n", NUM_FLOPS );
148 printf( "-----------------------------------------------\n" );
149
150 printf( "Test type : %16d%16d\n", 1, 2 );
151 printf( OUT_FMT, event_name, ( values[0] )[0], ( values[1] )[0] );
152 printf( OUT_FMT, "PAPI_TOT_CYC", ( values[0] )[1], ( values[1] )[1] );
153 printf( "Overflows : %16s%16d\n", "", total );
154 printf( "-----------------------------------------------\n" );
155
156 printf( "Verification:\n" );
157/*
158 if (PAPI_event == PAPI_FP_INS)
159 printf("Row 1 approximately equals %d %d\n", num_flops, num_flops);
160*/
161 /* Note that the second run prints output on stdout. On some systems
162 * this is costly. PAPI_TOT_INS or PAPI_TOT_CYC are likely to be _very_
163 * different between the two runs.
164 * printf("Column 1 approximately equals column 2\n");
165 */
166 printf( "Row 3 approximately equals %u +- %u %%\n",
167 ( unsigned ) ( ( values[0] )[0] / ( long long ) mythreshold ),
168 ( unsigned ) ( OVR_TOLERANCE * 100.0 ) );
169 }
170/*
171 min = (long long)((values[0])[0]*(1.0-TOLERANCE));
172 max = (long long)((values[0])[0]*(1.0+TOLERANCE));
173 if ( (values[1])[0] > max || (values[1])[0] < min )
174 test_fail(__FILE__, __LINE__, event_name, 1);
175*/
176
177 min =
178 ( long long ) ( ( ( double ) values[0][0] * ( 1.0 - OVR_TOLERANCE ) ) /
179 ( double ) mythreshold );
180 max =
181 ( long long ) ( ( ( double ) values[0][0] * ( 1.0 + OVR_TOLERANCE ) ) /
182 ( double ) mythreshold );
183 if ( total > max || total < min )
184 test_fail( __FILE__, __LINE__, "Overflows", 1 );
185
186 test_pass( __FILE__ );
187
188 return 0;
189}
static const PAPI_hw_info_t * hw_info
Definition: byte_profile.c:28
add PAPI preset or native hardware event to an event set
Create a new empty PAPI EventSet.
Convert a numeric hardware event code to a name.
get information about the system hardware
initialize the PAPI library.
Set up an event set to begin registering overflows.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
static long long mythreshold
#define min(x, y)
Definition: darwin-common.h:4
int PAPI_event[2]
Definition: data_range.c:30
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
#define OVR_TOLERANCE
Definition: do_loops.h:14
#define THRESHOLD
Definition: earprofile.c:37
#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_FP_INS
Definition: f90papi.h:366
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
#define PAPI_FP_OPS
Definition: f90papi.h:319
#define PAPI_TOT_INS
Definition: f90papi.h:317
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
void do_flops(int n)
Definition: multiplex.c:23
void handler(int EventSet, void *address, long long overflow_vector, void *context)
Definition: overflow2.c:36
#define OUT_FMT
Definition: overflow2.c:31
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:491
void PAPI_NORETURN test_pass(const char *filename)
Definition: test_utils.c:432
int find_nonderived_event(void)
Definition: test_utils.c:98
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:584
int quiet
Definition: rapl_overflow.c:19
int
Definition: sde_internal.h:89
long long int long long
Definition: sde_internal.h:85
#define NUM_FLOPS
Definition: sdsc-mpx.c:24
Hardware info structure.
Definition: papi.h:774
int cpu_max_mhz
Definition: papi.h:790
int retval
Definition: zero_fork.c:53
Here is the call graph for this function:

Variable Documentation

◆ total

int total = 0

Definition at line 33 of file overflow2.c.