PAPI 7.1.0.0
Loading...
Searching...
No Matches
overflow_one_and_read.c
Go to the documentation of this file.
1/*
2* File: overflow_one_and_read.c : based on overflow_twoevents.c
3* Mods: Philip Mucci
4* mucci@cs.utk.edu
5* Kevin London
6* london@cs.utk.edu
7*/
8
9/* This file performs the following test: overflow dispatch on 1 counter.
10 * In the handler read events.
11*/
12
13#include <stdio.h>
14#include <stdlib.h>
15
16#include "papi.h"
17#include "papi_test.h"
18
19#include "do_loops.h"
20
21#define OVER_FMT "handler(%d) Overflow at %p! vector=%#llx\n"
22#define OUT_FMT "%-12s : %16lld%16lld\n"
23
24typedef struct
25{
26 long long mask;
27 int count;
28} ocount_t;
29
30/* there are three possible vectors, one counter overflows, the other
31 counter overflows, both overflow */
32/*not used*/ ocount_t overflow_counts[3] = { {0, 0}, {0, 0}, {0, 0} };
33/*not used*/ int total_unknown = 0;
34
35/*added*/ long long dummyvalues[2];
36
37void
38handler( int EventSet, void *address, long long overflow_vector, void *context )
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}
58
59int
60main( int argc, char **argv )
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*/
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
90
91 if ( ( retval =
93 test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
94
96 if ( retval != PAPI_OK )
97 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
98
100
102 if ( retval != PAPI_OK )
103 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
104
106 if ( retval != PAPI_OK )
107 test_fail( __FILE__, __LINE__, "PAPI_overflow", retval );
108
110 if ( retval != PAPI_OK )
111 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
112
114
116 if ( retval != PAPI_OK )
117 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
118
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}
static long count
Convert a numeric hardware event code to a name.
initialize the PAPI library.
Set up an event set to begin registering overflows.
Read hardware counters from an event set.
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 THRESHOLD
Definition: earprofile.c:37
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
static int EventSet
Definition: init_fini.c:8
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
void do_flops(int n)
Definition: multiplex.c:23
int TESTS_QUIET
Definition: test_utils.c:18
#define OVER_FMT
long long dummyvalues[2]
int total_unknown
ocount_t overflow_counts[3]
void handler(int EventSet, void *address, long long overflow_vector, void *context)
#define OUT_FMT
Return codes and api definitions.
FILE * stderr
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
int add_two_nonderived_events(int *num_events, int *papi_event, int *mask)
Definition: test_utils.c:671
#define TWO12
Definition: papi_test.h:103
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:491
long long ** allocate_test_space(int num_tests, int num_events)
Definition: test_utils.c:46
void PAPI_NORETURN test_pass(const char *filename)
Definition: test_utils.c:432
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:584
int remove_test_events(int *EventSet, int mask)
Definition: test_utils.c:201
int main()
Definition: pernode.c:20
int quiet
Definition: rapl_overflow.c:19
#define NUM_FLOPS
Definition: sdsc-mpx.c:24
int num_events1
Definition: zero_fork.c:49
int mask1
Definition: zero_fork.c:48
int retval
Definition: zero_fork.c:53