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

Go to the source code of this file.

Macros

#define OVER_FMT   "handler(%d ) Overflow at %p overflow_vector=%#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

static int total = 0
 

Macro Definition Documentation

◆ OUT_FMT

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

Definition at line 32 of file overflow_single_event.c.

◆ OVER_FMT

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

Definition at line 31 of file overflow_single_event.c.

Function Documentation

◆ handler()

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

Definition at line 37 of file overflow_single_event.c.

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

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 49 of file overflow_single_event.c.

50{
51 int EventSet = PAPI_NULL;
52 long long values[2] = { 0, 0 };
53 long long min, max;
54 int num_flops = NUM_FLOPS, retval;
55 int PAPI_event = 0, mythreshold;
57 const PAPI_hw_info_t *hw_info = NULL;
58 int quiet;
59
60 /* Set TESTS_QUIET variable */
61 quiet=tests_quiet( argc, argv );
62
64 if ( retval != PAPI_VER_CURRENT ) {
65 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
66 }
67
69 if ( hw_info == NULL )
70 test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
71
72 /* Ugh */
73 if ( ( !strncmp( hw_info->model_string, "UltraSPARC", 10 ) &&
74 !( strncmp( hw_info->vendor_string, "SUN", 3 ) ) ) ||
75 ( !strncmp( hw_info->model_string, "AMD K7", 6 ) ) ||
76 ( !strncmp( hw_info->vendor_string, "Cray", 4 ) ) ||
77 ( strstr( hw_info->model_string, "POWER3" ) ) ) {
78 /* query and set up the right instruction to monitor */
81 } else {
82 test_fail( __FILE__, __LINE__,
83 "PAPI_TOT_INS not available on this Sun platform!", 0 );
84 }
85 } else {
86 /* query and set up the right instruction to monitor */
88 }
89
90 if (PAPI_event==0) {
91 if (!quiet) printf("Trouble adding event\n");
92 test_skip(__FILE__,__LINE__,"Event trouble",1);
93 }
94
95 if (( PAPI_event == PAPI_FP_OPS ) || ( PAPI_event == PAPI_FP_INS )) {
97 }
98 else {
99#if defined(linux)
100 mythreshold = ( int ) hw_info->cpu_max_mhz * 20000;
101#else
103#endif
104 }
105
107 if ( retval != PAPI_OK ) {
108 test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
109 }
110
112 if ( retval != PAPI_OK ) {
113 test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
114 }
115
117 if ( retval != PAPI_OK ) {
118 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
119 }
120
122
124 if ( retval != PAPI_OK ) {
125 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
126 }
127
129 if ( retval != PAPI_OK ) {
130 test_fail( __FILE__, __LINE__, "PAPI_overflow", retval );
131 }
132
134 if ( retval != PAPI_OK ) {
135 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
136 }
137
139
141 if ( retval != PAPI_OK ) {
142 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
143 }
144
145 /* double ugh */
146#if defined(linux) || defined(__ia64__) || defined(_POWER4)
147 num_flops *= 2;
148#endif
149
150 if ( !quiet ) {
151 if ( ( retval =
153 test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
154
155 printf
156 ( "Test case: Overflow dispatch of 1st event in set with 1 event.\n" );
157 printf
158 ( "--------------------------------------------------------------\n" );
159 printf( "Threshold for overflow is: %d\n", mythreshold );
160 printf( "Using %d iterations of c += a*b\n", NUM_FLOPS );
161 printf( "-----------------------------------------------\n" );
162
163 printf( "Test type : %16d%16d\n", 1, 2 );
164 printf( OUT_FMT, event_name, values[0], values[1] );
165 printf( "Overflows : %16s%16d\n", "", total );
166 printf( "-----------------------------------------------\n" );
167
168 printf( "Verification:\n" );
169/*
170 if (PAPI_event == PAPI_FP_INS)
171 printf("Row 1 approximately equals %d %d\n", num_flops, num_flops);
172 printf("Column 1 approximately equals column 2\n");
173*/
174 printf( "Row 3 approximately equals %u +- %u %%\n",
175 ( unsigned ) ( ( values[0] ) / ( long long ) mythreshold ),
176 ( unsigned ) ( OVR_TOLERANCE * 100.0 ) );
177
178 }
179
180/*
181 min = (long long)(values[0]*(1.0-TOLERANCE));
182 max = (long long)(values[0]*(1.0+TOLERANCE));
183 if ( values[1] > max || values[1] < min )
184 test_fail(__FILE__, __LINE__, event_name, 1);
185*/
186
187 min =
188 ( long long ) ( ( ( double ) values[0] * ( 1.0 - OVR_TOLERANCE ) ) /
189 ( double ) mythreshold );
190 max =
191 ( long long ) ( ( ( double ) values[0] * ( 1.0 + OVR_TOLERANCE ) ) /
192 ( double ) mythreshold );
193 if ( total > max || total < min )
194 test_fail( __FILE__, __LINE__, "Overflows", 1 );
195
196 test_pass( __FILE__ );
197
198 return 0;
199}
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.
Query if PAPI event exists.
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_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)
#define OUT_FMT
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
char vendor_string[PAPI_MAX_STR_LEN]
Definition: papi.h:782
char model_string[PAPI_MAX_STR_LEN]
Definition: papi.h:784
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
static

Definition at line 34 of file overflow_single_event.c.