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

Go to the source code of this file.

Functions

void cclib_init (void)
 
void cclib_do_work (void)
 
void cclib_do_more_work (void)
 
void setup_PAPI (int *event_set)
 
int main (int argc, char **argv)
 

Variables

long long int epsilon_v [10] = {14LL, 11LL, 8LL, 13LL, 8LL, 10LL, 12LL, 11LL, 6LL, 8LL}
 
int be_verbose = 0
 

Function Documentation

◆ cclib_do_more_work()

void cclib_do_more_work ( void  )

Definition at line 66 of file Lib_With_Created_Counter.c.

66 {
67 int i;
68
69 for(i=0; i<500*1000; i++){
70 BRNG();
71 double r = (1.0*result)/(1.0*INT_MAX);
72 if( r < MY_EPSILON && r > -MY_EPSILON ){
74 }
75 // Do some usefull work here
76 if( !(i%20) )
77 (void)usleep(1);
78 }
79
80 return;
81}
#define MY_EPSILON
void * cntr_handle
#define BRNG()
volatile int result
int i
int papi_sde_inc_counter(papi_handle_t cntr_handle, long long int increment)
Definition: sde_lib.c:637
Here is the call graph for this function:

◆ cclib_do_work()

void cclib_do_work ( void  )

Definition at line 49 of file Lib_With_Created_Counter.c.

49 {
50 int i;
51
52 for(i=0; i<100*1000; i++){
53 BRNG();
54 double r = (1.0*result)/(1.0*INT_MAX);
55 if( r < MY_EPSILON && r > -MY_EPSILON ){
57 }
58 // Do some usefull work here
59 if( !(i%100) )
60 (void)usleep(1);
61 }
62
63 return;
64}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cclib_init()

void cclib_init ( void  )

Definition at line 35 of file Lib_With_Created_Counter.c.

35 {
36 papi_handle_t sde_handle;
37
38 sde_handle = papi_sde_init("Lib_With_CC");
40
41 z1=42;
42 z2=420;
43 z3=42000;
44 z4=424242;
45
46 return;
47}
volatile unsigned int z1
static const char * event_names[1]
volatile unsigned int z2
volatile unsigned int z3
volatile unsigned int z4
papi_handle_t papi_sde_init(const char *name_of_library)
Definition: sde_lib.c:119
int papi_sde_create_counter(papi_handle_t handle, const char *event_name, int cntr_mode, void **cntr_handle)
Definition: sde_lib.c:576
void * papi_handle_t
Definition: sde_lib.h:100
#define PAPI_SDE_DELTA
Definition: sde_lib.h:25
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 16 of file Created_Counter_Driver.c.

16 {
17 int i, ret, event_set = PAPI_NULL;
18 int discrepancies = 0;
19 long long counter_values[1] = {0};
20
21 if( (argc > 1) && !strcmp(argv[1], "-verbose") )
22 be_verbose = 1;
23
24 cclib_init();
25
26 setup_PAPI(&event_set);
27
28 // --- Start PAPI
29 if((ret=PAPI_start(event_set)) != PAPI_OK){
30 test_fail( __FILE__, __LINE__, "PAPI_start", ret );
31 }
32
33 for(i=0; i<10; i++){
34
36
37 // --- Read the event counters _and_ reset them
38 if((ret=PAPI_accum(event_set, counter_values)) != PAPI_OK){
39 test_fail( __FILE__, __LINE__, "PAPI_accum", ret );
40 }
41 if( be_verbose ) printf("Epsilon count in cclib_do_work(): %lld\n",counter_values[0]);
42 if( counter_values[0] != epsilon_v[i] ){
43 discrepancies++;
44 }
45 counter_values[0] = 0;
46
47 }
48
49 // --- Stop PAPI
50 if((ret=PAPI_stop(event_set, counter_values)) != PAPI_OK){
51 test_fail( __FILE__, __LINE__, "PAPI_stop", ret );
52 }
53
54 if( !discrepancies )
55 test_pass(__FILE__);
56 else
57 test_fail( __FILE__, __LINE__, "SDE counter values are wrong!", 0 );
58
59 // The following "return" is dead code, because both test_pass() and test_fail() call exit(),
60 // however, we need it to prevent compiler warnings.
61 return 0;
62}
void setup_PAPI(int *event_set)
int be_verbose
void cclib_init(void)
long long int epsilon_v[10]
void cclib_do_work(void)
Accumulate and reset counters in an EventSet.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_NULL
Definition: f90papi.h:78
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
Here is the call graph for this function:

◆ setup_PAPI()

void setup_PAPI ( int event_set)

Definition at line 65 of file Created_Counter_Driver.c.

65 {
66 int ret;
67
69 test_fail( __FILE__, __LINE__, "PAPI_library_init", ret );
70 }
71
72 if((ret=PAPI_create_eventset(event_set)) != PAPI_OK){
73 test_fail( __FILE__, __LINE__, "PAPI_create_eventset", ret );
74 }
75
76 if((ret=PAPI_add_named_event(*event_set, "sde:::Lib_With_CC::epsilon_count")) != PAPI_OK){
77 test_fail( __FILE__, __LINE__, "PAPI_add_named_event", ret );
78 }
79
80 return;
81}
add PAPI preset or native hardware event by name to an EventSet
Create a new empty PAPI EventSet.
initialize the PAPI library.
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ be_verbose

int be_verbose = 0

Definition at line 14 of file Created_Counter_Driver.c.

◆ epsilon_v

long long int epsilon_v[10] = {14LL, 11LL, 8LL, 13LL, 8LL, 10LL, 12LL, 11LL, 6LL, 8LL}

Definition at line 13 of file Created_Counter_Driver.c.