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

Go to the source code of this file.

Functions

void recorder_init_ (void)
 
void recorder_do_work_ (void)
 
void setup_PAPI (int *event_set)
 
int main (int argc, char **argv)
 

Variables

long long int expectation [10] = {20674LL, 50122LL, 112964LL, 32904LL, 101565LL, 56993LL, 58388LL, 122543LL, 62312LL, 52433LL}
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 14 of file Recorder_Driver.c.

14 {
15 int i, j, ret, event_set = PAPI_NULL;
16 int discrepancies = 0;
17 int be_verbose = 0;
18 long long counter_values[2];
19
20 if( (argc > 1) && !strcmp(argv[1], "-verbose") )
21 be_verbose = 1;
22
24
25 setup_PAPI(&event_set);
26
27 // --- Start PAPI
28 if((ret=PAPI_start(event_set)) != PAPI_OK){
29 test_fail( __FILE__, __LINE__, "PAPI_start", ret );
30 }
31
32 for(i=0; i<10; i++){
33
35
36 // --- read the event counters
37 if((ret=PAPI_read(event_set, counter_values)) != PAPI_OK){
38 test_fail( __FILE__, __LINE__, "PAPI_read", ret );
39 }
40
41 long long *ptr = (long long *)counter_values[1];
42
43 if( be_verbose ){
44 printf("The number of recordings is: %lld (ptr is: %p)\n",counter_values[0],(void *)counter_values[1]);
45 for(j=0; j<counter_values[0]; j++){
46 printf("%lld ",*(ptr+j));
47 }
48 printf("\n");
49 }
50
51 free(ptr);
52 }
53
54 // --- Stop PAPI
55 if((ret=PAPI_stop(event_set, counter_values)) != PAPI_OK){
56 test_fail( __FILE__, __LINE__, "PAPI_stop", ret );
57 }
58
59 if( counter_values[0] != 10 ){
60 discrepancies++;
61 }
62 long long *ptr = (long long *)counter_values[1];
63 for(j=0; j<10; j++){
64 if( *(ptr+j) != expectation[j] ){
65 discrepancies++;
66 }
67 }
68 free(ptr);
69
70 if( !discrepancies )
71 test_pass(__FILE__);
72 else
73 test_fail( __FILE__, __LINE__, "SDE values in recorder are wrong!", 0 );
74
75 // The following "return" is dead code, because both test_pass() and test_fail() call exit(),
76 // however, we need it to prevent compiler warnings.
77 return 0;
78}
int be_verbose
int i
void setup_PAPI(int *event_set)
void recorder_init_(void)
long long int expectation[10]
void recorder_do_work_(void)
Read hardware counters from an event set.
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:

◆ recorder_do_work_()

void recorder_do_work_ ( void  )

Definition at line 45 of file Lib_With_Recorder.c.

45 {
46 long long r;
47 BRNG();
48 if( result < 0 )
49 result *= -1;
50 r = result%123456;
51 papi_sde_record(rcrd_handle, sizeof(r), &r);
52 return;
53}
#define BRNG()
volatile int result
void * rcrd_handle
int papi_sde_record(void *record_handle, size_t typesize, const void *value)
Definition: sde_lib.c:909
Here is the call graph for this function:
Here is the caller graph for this function:

◆ recorder_init_()

void recorder_init_ ( void  )

Definition at line 31 of file Lib_With_Recorder.c.

31 {
32 papi_handle_t tmp_handle;
33
34 tmp_handle = papi_sde_init("Lib_With_Recorder");
36
37 z1=42;
38 z2=420;
39 z3=42000;
40 z4=424242;
41
42 return;
43}
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_compare_long_long(const void *p1, const void *p2)
Definition: sde_lib.c:1052
int papi_sde_create_recorder(papi_handle_t handle, const char *event_name, size_t typesize, int(*cmpr_func_ptr)(const void *p1, const void *p2), void **record_handle)
Definition: sde_lib.c:794
void * papi_handle_t
Definition: sde_lib.h:100
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setup_PAPI()

void setup_PAPI ( int event_set)

Definition at line 81 of file Recorder_Driver.c.

81 {
82 int ret;
83
85 test_fail( __FILE__, __LINE__, "PAPI_library_init", ret );
86 }
87
88 if((ret=PAPI_create_eventset(event_set)) != PAPI_OK){
89 test_fail( __FILE__, __LINE__, "PAPI_create_eventset", ret );
90 }
91
92 if((ret=PAPI_add_named_event(*event_set, "sde:::Lib_With_Recorder::simple_recording:CNT")) != PAPI_OK){
93 test_fail( __FILE__, __LINE__, "PAPI_add_named_event", ret );
94 }
95
96 if((ret=PAPI_add_named_event(*event_set, "sde:::Lib_With_Recorder::simple_recording")) != PAPI_OK){
97 test_fail( __FILE__, __LINE__, "PAPI_add_named_event", ret );
98 }
99
100 return;
101}
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

◆ expectation

long long int expectation[10] = {20674LL, 50122LL, 112964LL, 32904LL, 101565LL, 56993LL, 58388LL, 122543LL, 62312LL, 52433LL}

Definition at line 12 of file Recorder_Driver.c.