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

Go to the source code of this file.

Functions

void libCSet_do_simple_work (void)
 
void libCSet_dump_set (cset_list_object_t *list_head)
 
int libCSet_count_set_elements (cset_list_object_t *list_head)
 
int libCSet_finalize (void)
 
void setup_PAPI (int *event_set)
 
int main (int argc, char **argv)
 

Function Documentation

◆ libCSet_count_set_elements()

int libCSet_count_set_elements ( cset_list_object_t *  list_head)

Definition at line 114 of file CountingSet_Lib.c.

114 {
115 cset_list_object_t *list_runner;
116 int element_count = 0;
117
118 for(list_runner = list_head; NULL != list_runner; list_runner=list_runner->next){
119 ++element_count;
120 }
121
122 return element_count;
123}
Here is the caller graph for this function:

◆ libCSet_do_simple_work()

void libCSet_do_simple_work ( void  )

Definition at line 21 of file CountingSet_Lib.c.

21 {
22 int i;
23 void *test_set;
24 test_type_t element;
25
26 handle = papi_sde_init("CSET_LIB");
27 papi_sde_create_counting_set( handle, "test counting set", &test_set );
28
29 for(i=0; i<22390; i++){
30 int j = i%5222;
31 element.id = j;
32 element.x = (float)j*1.037/((float)j+32.1);
33 element.y = (double)(element.x)+145.67/((double)j+0.01);
34 papi_sde_counting_set_insert( test_set, sizeof(element), sizeof(element), &element, 0);
35 }
36
37 return;
38}
papi_handle_t handle
int i
papi_handle_t papi_sde_init(const char *name_of_library)
Definition: sde_lib.c:119
int papi_sde_counting_set_insert(void *cset_handle, size_t element_size, size_t hashable_size, const void *element, uint32_t type_id)
Definition: sde_lib.c:766
int papi_sde_create_counting_set(papi_handle_t handle, const char *cset_name, void **cset_handle)
Definition: sde_lib.c:682
Here is the call graph for this function:
Here is the caller graph for this function:

◆ libCSet_dump_set()

void libCSet_dump_set ( cset_list_object_t *  list_head)

Definition at line 90 of file CountingSet_Lib.c.

90 {
91 cset_list_object_t *list_runner;
92
93 for(list_runner = list_head; NULL != list_runner; list_runner=list_runner->next){
94
95 switch(list_runner->type_id){
96 case 0:
97 {
98 test_type_t *ptr = (test_type_t *)(list_runner->ptr);
99 printf("count= %d typesize= %lu {id= %d, x= %f, y= %lf}\n", list_runner->count, list_runner->type_size, ptr->id, ptr->x, ptr->y);
100 break;
101 }
102 case 1:
103 {
104 mem_type_t *ptr = (mem_type_t *)(list_runner->ptr);
105 printf("count= %d typesize= %lu { ptr= %p, line= %d, size= %lu }\n", list_runner->count, list_runner->type_size, ptr->ptr, ptr->line_of_code, ptr->size);
106 break;
107 }
108 }
109 }
110
111 return;
112}
Here is the caller graph for this function:

◆ libCSet_finalize()

int libCSet_finalize ( void  )

Definition at line 40 of file CountingSet_Lib.c.

40 {
42}
int papi_sde_shutdown(papi_handle_t handle)
Definition: sde_lib.c:212
Here is the call graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 15 of file Simple_CountingSet_Driver.c.

15 {
16 int cnt, ret, event_set = PAPI_NULL;
17 long long counter_values[1];
18
19 (void)argc;
20 (void)argv;
21
22 setup_PAPI(&event_set);
23
24 // --- Start PAPI
25 if((ret=PAPI_start(event_set)) != PAPI_OK){
26 test_fail( __FILE__, __LINE__, "PAPI_start", ret );
27 }
28
30
31 // --- Stop PAPI
32 if((ret=PAPI_stop(event_set, counter_values)) != PAPI_OK){
33 test_fail( __FILE__, __LINE__, "PAPI_stop", ret );
34 }
35
36 if( (argc > 1) && !strcmp(argv[1], "-verbose") ){
37 libCSet_dump_set( (cset_list_object_t *)counter_values[0] );
38 }
39
40 cnt = libCSet_count_set_elements( (cset_list_object_t *)counter_values[0] );
41 if( 5222 == cnt )
42 test_pass(__FILE__);
43 else
44 test_fail( __FILE__, __LINE__, "CountingSet contains wrong number of elements", ret );
45
46 return 0;
47}
int libCSet_count_set_elements(cset_list_object_t *list_head)
void libCSet_dump_set(cset_list_object_t *list_head)
void setup_PAPI(int *event_set)
void libCSet_do_simple_work(void)
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 50 of file Simple_CountingSet_Driver.c.

50 {
51 int ret;
52
54 test_fail( __FILE__, __LINE__, "PAPI_library_init", ret );
55 }
56
57 if((ret=PAPI_create_eventset(event_set)) != PAPI_OK){
58 test_fail( __FILE__, __LINE__, "PAPI_create_eventset", ret );
59 }
60
61 if((ret=PAPI_add_named_event(*event_set, "sde:::CSET_LIB::test counting set")) != PAPI_OK){
62 test_fail( __FILE__, __LINE__, "PAPI_add_named_event", ret );
63 }
64
65 return;
66}
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: