PAPI 7.1.0.0
Loading...
Searching...
No Matches
sde_lib.h
Go to the documentation of this file.
1
12#if !defined(PAPI_SDE_LIB_H)
13#define PAPI_SDE_LIB_H
14
15#include <stdio.h>
16#include <stdint.h>
17#include <stddef.h>
18#include <stdarg.h>
19
20#define PAPI_SDE_VERSION_NUMBER(_maj,_min) ( ((_maj)<<16) | (_min) )
21#define PAPI_SDE_VERSION PAPI_SDE_VERSION_NUMBER(1,0)
22
23#define PAPI_SDE_RO 0x00
24#define PAPI_SDE_RW 0x01
25#define PAPI_SDE_DELTA 0x00
26#define PAPI_SDE_INSTANT 0x10
27
28#define PAPI_SDE_long_long 0x0
29#define PAPI_SDE_int 0x1
30#define PAPI_SDE_double 0x2
31#define PAPI_SDE_float 0x3
32
33#define PAPI_SDE_SUM 0x0
34#define PAPI_SDE_MAX 0x1
35#define PAPI_SDE_MIN 0x2
36
37// The following values have been defined such that they match the
38// corresponding PAPI values from papi.h
39#define SDE_OK 0
40#define SDE_EINVAL -1
41#define SDE_ENOMEM -2
42#define SDE_ECMP -4
43#define SDE_ENOEVNT -7
44#define SDE_EMISC -14
46#define register_fp_counter register_counter_cb
47#define papi_sde_register_fp_counter papi_sde_register_counter_cb
48
49#define destroy_counter unregister_counter
50#define destroy_counting_set unregister_counter
51#define papi_sde_destroy_counter papi_sde_unregister_counter
52#define papi_sde_destroy_counting_set papi_sde_unregister_counter
53
54#pragma GCC visibility push(default)
55
56extern int _sde_be_verbose;
57extern int _sde_debug;
58#define SDEDBG(format, args...) { if(_sde_debug){fprintf(stderr,format, ## args);} }
59
60static inline void SDE_ERROR( const char *format, ... ){
61 va_list args;
62 if ( _sde_be_verbose ) {
63 va_start( args, format );
64 fprintf( stderr, "PAPI SDE Error: " );
65 vfprintf( stderr, format, args );
66 fprintf( stderr, "\n" );
67 va_end( args );
68 }
69}
70
71#ifdef __cplusplus
72extern "C" {
73#endif
74
75#define GET_FLOAT_SDE(x) *((float *)&x)
76#define GET_DOUBLE_SDE(x) *((double *)&x)
77/*
78 * GET_SDE_RECORDER_ADDRESS() USAGE EXAMPLE:
79 * If SDE recorder logs values of type 'double':
80 * double *ptr = GET_SDE_RECORDER_ADDRESS(papi_event_value[6], double);
81 * for (j=0; j<CNT; j++)
82 * printf(" %d: %.4e\n",j, ptr[j]);
83 */
84#define GET_SDE_RECORDER_ADDRESS(x,rcrd_type) ((rcrd_type *)x)
85
86// The following type needs to be declared here, instead of
87// sde_lib_internal.h because we need to expose it to the user.
88
89typedef struct cset_list_object_s cset_list_object_t;
91 uint32_t count;
92 uint32_t type_id;
93 size_t type_size;
94 void *ptr;
95 cset_list_object_t *next;
96};
97
98typedef long long int (*papi_sde_fptr_t)( void * );
99typedef int (*papi_sde_cmpr_fptr_t)( void * );
100typedef void * papi_handle_t;
101
102typedef struct papi_sde_fptr_struct_s {
103 papi_handle_t (*init)(const char *lib_name );
105 int (*register_counter)( papi_handle_t handle, const char *event_name, int mode, int type, void *counter );
106 int (*register_counter_cb)( papi_handle_t handle, const char *event_name, int mode, int type, papi_sde_fptr_t callback, void *param );
107 int (*unregister_counter)( papi_handle_t handle, const char *event_name );
108 int (*describe_counter)( papi_handle_t handle, const char *event_name, const char *event_description );
109 int (*add_counter_to_group)( papi_handle_t handle, const char *event_name, const char *group_name, uint32_t group_flags );
110 int (*create_counter)( papi_handle_t handle, const char *event_name, int cntr_type, void **cntr_handle );
111 int (*inc_counter)( papi_handle_t cntr_handle, long long int increment );
112 int (*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 );
113 int (*create_counting_set)( papi_handle_t handle, const char *cset_name, void **cset_handle );
114 int (*counting_set_insert)( void *cset_handle, size_t element_size, size_t hashable_size, const void *element, uint32_t type_id );
115 int (*counting_set_remove)( void *cset_handle, size_t hashable_size, const void *element, uint32_t type_id );
116 int (*record)( void *record_handle, size_t typesize, const void *value );
117 int (*reset_recorder)(void *record_handle );
118 int (*reset_counter)( void *cntr_handle );
119 void *(*get_counter_handle)(papi_handle_t handle, const char *event_name);
121
122
123papi_handle_t papi_sde_init(const char *name_of_library );
125int papi_sde_register_counter(papi_handle_t handle, const char *event_name, int cntr_mode, int cntr_type, void *counter );
126int papi_sde_register_counter_cb(papi_handle_t handle, const char *event_name, int cntr_mode, int cntr_type, papi_sde_fptr_t callback, void *param );
127int papi_sde_unregister_counter( void *handle, const char *event_name );
128int papi_sde_describe_counter(papi_handle_t handle, const char *event_name, const char *event_description );
129int papi_sde_add_counter_to_group(papi_handle_t handle, const char *event_name, const char *group_name, uint32_t group_flags );
130int papi_sde_create_counter( papi_handle_t handle, const char *event_name, int cntr_mode, void **cntr_handle );
131int papi_sde_inc_counter( void *cntr_handle, long long int increment );
132int 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 );
133int papi_sde_create_counting_set( papi_handle_t handle, const char *cset_name, void **cset_handle );
134int papi_sde_counting_set_insert( void *cset_handle, size_t element_size, size_t hashable_size, const void *element, uint32_t type_id );
135int papi_sde_counting_set_remove( void *cset_handle, size_t hashable_size, const void *element, uint32_t type_id );
136int papi_sde_record( void *record_handle, size_t typesize, const void *value );
137int papi_sde_reset_recorder(void *record_handle );
140
141int papi_sde_compare_long_long(const void *p1, const void *p2);
142int papi_sde_compare_int(const void *p1, const void *p2);
143int papi_sde_compare_double(const void *p1, const void *p2);
144int papi_sde_compare_float(const void *p1, const void *p2);
145
147
148#define POPULATE_SDE_FPTR_STRUCT( _A_ ) do{\
149 _A_.init = papi_sde_init;\
150 _A_.shutdown = papi_sde_shutdown;\
151 _A_.register_counter = papi_sde_register_counter;\
152 _A_.register_counter_cb = papi_sde_register_counter_cb;\
153 _A_.unregister_counter = papi_sde_unregister_counter;\
154 _A_.describe_counter = papi_sde_describe_counter;\
155 _A_.add_counter_to_group = papi_sde_add_counter_to_group;\
156 _A_.create_counter = papi_sde_create_counter;\
157 _A_.inc_counter = papi_sde_inc_counter;\
158 _A_.create_recorder = papi_sde_create_recorder;\
159 _A_.create_counting_set = papi_sde_create_counting_set;\
160 _A_.record = papi_sde_record;\
161 _A_.reset_recorder = papi_sde_reset_recorder;\
162 _A_.reset_counter = papi_sde_reset_counter;\
163 _A_.get_counter_handle = papi_sde_get_counter_handle;\
164}while(0)
165
166#ifdef __cplusplus
167}
168#endif
169
170#pragma GCC visibility pop
171
172#endif // !defined(PAPI_SDE_LIB_H)
static void * cntr_handle
Definition: Gamum.c:22
static papi_handle_t handle
Definition: Gamum.c:21
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
uint16_t type
__gnuc_va_list va_list
FILE * stderr
va_end(arg_list)
va_start(arg_list, fmt)
int
Definition: sde_internal.h:89
int papi_sde_compare_int(const void *p1, const void *p2)
Definition: sde_lib.c:1063
papi_handle_t papi_sde_init(const char *name_of_library)
Definition: sde_lib.c:119
void * papi_handle_t
Definition: sde_lib.h:100
int _sde_be_verbose
Definition: sde_lib_misc.c:19
int papi_sde_reset_recorder(void *record_handle)
Definition: sde_lib.c:940
papi_handle_t papi_sde_hook_list_events(papi_sde_fptr_struct_t *fptr_struct)
Definition: Gamum.c:44
int papi_sde_describe_counter(papi_handle_t handle, const char *event_name, const char *event_description)
Definition: sde_lib.c:398
int papi_sde_inc_counter(void *cntr_handle, long long int increment)
Definition: sde_lib.c:637
int papi_sde_counting_set_remove(void *cset_handle, size_t hashable_size, const void *element, uint32_t type_id)
Definition: sde_lib.c:737
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_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_sde_get_counter_handle(papi_handle_t handle, const char *event_name)
Definition: sde_lib.c:1016
int(* papi_sde_cmpr_fptr_t)(void *)
Definition: sde_lib.h:99
int papi_sde_register_counter(papi_handle_t handle, const char *event_name, int cntr_mode, int cntr_type, void *counter)
Definition: sde_lib.c:276
int papi_sde_compare_float(const void *p1, const void *p2)
Definition: sde_lib.c:1085
static void SDE_ERROR(const char *format,...)
Definition: sde_lib.h:60
int papi_sde_unregister_counter(void *handle, const char *event_name)
Definition: sde_lib.c:342
int _sde_debug
Definition: sde_lib_misc.c:20
int papi_sde_reset_counter(void *cntr_handle)
Definition: sde_lib.c:973
int papi_sde_shutdown(papi_handle_t handle)
Definition: sde_lib.c:212
int papi_sde_compare_double(const void *p1, const void *p2)
Definition: sde_lib.c:1074
int papi_sde_add_counter_to_group(papi_handle_t handle, const char *event_name, const char *group_name, uint32_t group_flags)
Definition: sde_lib.c:449
int papi_sde_record(void *record_handle, size_t typesize, const void *value)
Definition: sde_lib.c:909
int papi_sde_create_counting_set(papi_handle_t handle, const char *cset_name, void **cset_handle)
Definition: sde_lib.c:682
int papi_sde_register_counter_cb(papi_handle_t handle, const char *event_name, int cntr_mode, int cntr_type, papi_sde_fptr_t callback, void *param)
Definition: sde_lib.c:312
int papi_sde_create_counter(papi_handle_t handle, const char *event_name, int cntr_mode, void **cntr_handle)
Definition: sde_lib.c:576
long long int(* papi_sde_fptr_t)(void *)
Definition: sde_lib.h:98
uint32_t count
Definition: sde_lib.h:91
cset_list_object_t * next
Definition: sde_lib.h:95
size_t type_size
Definition: sde_lib.h:93
uint32_t type_id
Definition: sde_lib.h:92