PAPI  5.6.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
overflow_one_and_read.c File Reference
Include dependency graph for overflow_one_and_read.c:

Go to the source code of this file.

Data Structures

struct  ocount_t
 

Macros

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

ocount_t overflow_counts [3] = { {0, 0}, {0, 0}, {0, 0} }
 
int total_unknown = 0
 
long long dummyvalues [2]
 

Macro Definition Documentation

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

Definition at line 22 of file overflow_one_and_read.c.

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

Definition at line 21 of file overflow_one_and_read.c.

Function Documentation

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

Definition at line 38 of file overflow_one_and_read.c.

39 {
40  int retval;
41 
42  ( void ) context;
43 
44  if ( !TESTS_QUIET ) {
45  fprintf( stderr, OVER_FMT, EventSet, address, overflow_vector );
46  }
47 
48  if ( ( retval = PAPI_read( EventSet, dummyvalues ) ) != PAPI_OK )
49  test_fail( __FILE__, __LINE__, "PAPI_read", retval );
50 
51  if ( !TESTS_QUIET ) {
52  fprintf( stderr, TWO12, dummyvalues[0], dummyvalues[1],
53  "(Reading counters)\n" );
54  }
55  if ( dummyvalues[1] == 0 )
56  test_fail( __FILE__, __LINE__, "Total Cycles == 0", 1 );
57 }
#define TWO12
Definition: papi_test.h:93
int EventSet
return PAPI_OK
Definition: linux-nvml.c:497
void
Definition: iozone.c:18627
#define OVER_FMT
long long dummyvalues[2]
int TESTS_QUIET
Definition: test_utils.c:18
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
int PAPI_read(int EventSet, long long *values)
Definition: papi.c:2559
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 60 of file overflow_one_and_read.c.

61 {
62  int EventSet;
63  long long **values = NULL;
64  int retval;
65  int PAPI_event;
67  int num_events1, mask1;
68  int quiet;
69 
70  /* Set TESTS_QUIET variable */
71  quiet=tests_quiet( argc, argv );
72 
74  if ( retval != PAPI_VER_CURRENT ) {
75  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
76  }
77 
78  /* add PAPI_TOT_CYC and one of the events in PAPI_FP_INS, PAPI_FP_OPS or
79  PAPI_TOT_INS, depends on the availability of the event on the
80  platform */
81 /* NOTE: Only adding one overflow on PAPI_event -- no overflow for PAPI_TOT_CYC*/
82  EventSet = add_two_nonderived_events( &num_events1,
83  &PAPI_event, &mask1 );
84  if (num_events1==0) {
85  if (!quiet) printf("Trouble adding events\n");
86  test_skip(__FILE__,__LINE__,"Adding event",1);
87  }
88 
89  values = allocate_test_space( 2, num_events1 );
90 
91  if ( ( retval =
92  PAPI_event_code_to_name( PAPI_event, event_name ) ) != PAPI_OK )
93  test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
94 
95  retval = PAPI_start( EventSet );
96  if ( retval != PAPI_OK )
97  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
98 
100 
101  retval = PAPI_stop( EventSet, values[0] );
102  if ( retval != PAPI_OK )
103  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
104 
105  retval = PAPI_overflow( EventSet, PAPI_event, THRESHOLD, 0, handler );
106  if ( retval != PAPI_OK )
107  test_fail( __FILE__, __LINE__, "PAPI_overflow", retval );
108 
109  retval = PAPI_start( EventSet );
110  if ( retval != PAPI_OK )
111  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
112 
113  do_flops( NUM_FLOPS );
114 
115  retval = PAPI_stop( EventSet, values[1] );
116  if ( retval != PAPI_OK )
117  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
118 
119  remove_test_events( &EventSet, mask1 );
120 
121 
122  if ( !TESTS_QUIET ) {
123  printf
124  ( "Test case: Overflow dispatch of 1st event in set with 2 events.\n" );
125  printf
126  ( "---------------------------------------------------------------\n" );
127  printf( "Threshold for overflow is: %d\n", THRESHOLD );
128  printf( "Using %d iterations of c += a*b\n", NUM_FLOPS );
129  printf( "-----------------------------------------------\n" );
130 
131  printf( "Test type : %16d%16d\n", 1, 2 );
132  printf( OUT_FMT, event_name, ( values[0] )[0], ( values[1] )[0] );
133  printf( OUT_FMT, "PAPI_TOT_CYC", ( values[0] )[1], ( values[1] )[1] );
134  }
135 
136  test_pass( __FILE__ );
137 
138  return 0;
139 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2314
int mask1
Definition: zero_fork.c:48
int PAPI_event[2]
Definition: data_range.c:30
void test_pass(const char *filename)
Definition: test_utils.c:432
int num_events1
Definition: zero_fork.c:49
int EventSet
return PAPI_OK
Definition: linux-nvml.c:497
int PAPI_overflow(int EventSet, int EventCode, int threshold, int flags, PAPI_overflow_handler_t handler)
Definition: papi.c:4788
#define NUM_FLOPS
Definition: sdsc-mpx.c:24
int int argc
Definition: iozone.c:1609
void test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:559
char ** argv
Definition: iozone.c:1610
int PAPI_library_init(int version)
Definition: papi.c:500
int quiet
Definition: rapl_overflow.c:18
void handler(int EventSet, void *address, long long overflow_vector, void *context)
Definition: rapl_overflow.c:20
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:915
#define OUT_FMT
void do_flops(int n)
Definition: multiplex.c:23
printf("\tTry: -i 0 -i 1 \n\n")
int TESTS_QUIET
Definition: test_utils.c:18
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
#define PAPI_MAX_STR_LEN
Definition: papi.h:465
int add_two_nonderived_events(int *num_events, int *papi_event, int *mask)
Definition: test_utils.c:646
int PAPI_start(int EventSet)
Definition: papi.c:2096
#define THRESHOLD
Definition: earprofile.c:37
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
long long ** allocate_test_space(int num_tests, int num_events)
Definition: test_utils.c:46
#define PAPI_VER_CURRENT
Definition: papi.h:225
int remove_test_events(int *EventSet, int mask)
Definition: test_utils.c:201

Here is the call graph for this function:

Variable Documentation

long long dummyvalues[2]

Definition at line 35 of file overflow_one_and_read.c.

ocount_t overflow_counts[3] = { {0, 0}, {0, 0}, {0, 0} }

Definition at line 32 of file overflow_one_and_read.c.

int total_unknown = 0

Definition at line 33 of file overflow_one_and_read.c.