18int main(
int argc,
char **argv){
20 long long counter_values[1] = {0};
22 if( (argc > 1) && !strcmp(argv[1],
"-verbose") )
31 test_fail( __FILE__, __LINE__,
"PAPI_start", ret );
40 test_fail( __FILE__, __LINE__,
"PAPI_accum", ret );
42 if(
be_verbose ) printf(
"Epsilon count in cclib_do_work(): %lld\n",counter_values[0]);
43 counter_values[0] = 0;
49 test_fail( __FILE__, __LINE__,
"PAPI_accum", ret );
51 if(
be_verbose ) printf(
"Epsilon count in cclib_do_more_work(): %lld\n",counter_values[0]);
52 counter_values[0] = 0;
58 test_fail( __FILE__, __LINE__,
"PAPI_stop", ret );
64 test_fail( __FILE__, __LINE__,
"SDE overflow handler was not invoked as expected!", 0 );
72void overflow_handler(
int event_set,
void *address,
long long overflow_vector,
void *context){
74 int ret, *event_codes, event_index, number=1;
80 test_fail( __FILE__, __LINE__,
"PAPI_get_overflow_event_index", ret );
83 number = event_index+1;
84 event_codes = (
int *)calloc(number,
sizeof(
int));
87 test_fail( __FILE__, __LINE__,
"PAPI_list_events", ret );
91 test_fail( __FILE__, __LINE__,
"PAPI_event_code_to_name", ret );
96 printf(
"Event \"%s\" at index: %d exceeded its threshold again.\n",
event_name, event_index);
100 if( !strcmp(
event_name,
"sde:::Lib_With_CC::epsilon_count") || !event_index )
111 test_fail( __FILE__, __LINE__,
"PAPI_library_init", ret );
115 test_fail( __FILE__, __LINE__,
"PAPI_create_eventset", ret );
119 test_fail( __FILE__, __LINE__,
"PAPI_event_name_to_code", ret );
123 test_fail( __FILE__, __LINE__,
"PAPI_add_event", ret );
127 test_fail( __FILE__, __LINE__,
"PAPI_overflow", ret );
void overflow_handler(int event_set, void *address, long long overflow_vector, void *context)
void setup_PAPI(int *event_set, int threshold)
int remaining_handler_invocations
void cclib_do_more_work(void)
Accumulate and reset counters in an EventSet.
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.
Convert a name to a numeric hardware event code.
converts an overflow vector into an array of indexes to overflowing events
initialize the PAPI library.
list the events in an event set
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.
char event_name[2][PAPI_MAX_STR_LEN]
#define PAPI_OVERFLOW_HARDWARE
Return codes and api definitions.
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
void PAPI_NORETURN test_pass(const char *filename)