PAPI  5.4.1.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
papi_internal.h
Go to the documentation of this file.
1 /****************************/
2 /* THIS IS OPEN SOURCE CODE */
3 /****************************/
16 #ifndef _PAPI_INTERNAL_H
17 #define _PAPI_INTERNAL_H
18 
19 /* AIX's C compiler does not recognize the inline keyword */
20 #ifdef _AIX
21 #define inline
22 #endif
23 
24 #include "papi_debug.h"
25 
26 #define DEADBEEF 0xdedbeef
27 extern int papi_num_components;
29 extern int init_level;
30 extern int _papi_hwi_errno;
31 extern int _papi_hwi_num_errors;
32 extern char **_papi_errlist;
33 
34 
35 /********************************************************/
36 /* This block provides general strings used in PAPI */
37 /* If a new string is needed for PAPI prompts */
38 /* it should be placed in this file and referenced by */
39 /* label. */
40 /********************************************************/
41 #define PAPI_ERROR_CODE_str "Error Code"
42 #define PAPI_SHUTDOWN_str "PAPI_shutdown: PAPI is not initialized"
43 #define PAPI_SHUTDOWN_SYNC_str "PAPI_shutdown: other threads still have running EventSets"
44 
45 
46 /* some members of structs and/or function parameters may or may not be
47  necessary, but at this point, we have included anything that might
48  possibly be useful later, and will remove them as we progress */
49 
50 /* Signal used for overflow delivery */
51 
52 #define PAPI_INT_MPX_SIGNAL SIGPROF
53 #define PAPI_INT_SIGNAL SIGPROF
54 #define PAPI_INT_ITIMER ITIMER_PROF
55 
56 #define PAPI_INT_ITIMER_MS 1
57 #if defined(linux)
58 #define PAPI_NSIG _NSIG
59 #else
60 #define PAPI_NSIG 128
61 #endif
62 
63 /* Multiplex definitions */
64 
65 #define PAPI_INT_MPX_DEF_US 10000 /*Default resolution in us. of mpx handler */
66 
67 /* Commands used to compute derived events */
68 
69 #define NOT_DERIVED 0x0
70 #define DERIVED_ADD 0x1
71 #define DERIVED_PS 0x2
72 #define DERIVED_ADD_PS 0x4
73 #define DERIVED_CMPD 0x8
74 #define DERIVED_SUB 0x10
75 #define DERIVED_POSTFIX 0x20
76 #define DERIVED_INFIX 0x40
78 /* Thread related: thread local storage */
79 
80 #define LOWLEVEL_TLS PAPI_NUM_TLS+0
81 #define NUM_INNER_TLS 1
82 #define PAPI_MAX_TLS (NUM_INNER_TLS+PAPI_NUM_TLS)
83 
84 /* Thread related: locks */
85 
86 #define INTERNAL_LOCK PAPI_NUM_LOCK+0 /* papi_internal.c */
87 #define MULTIPLEX_LOCK PAPI_NUM_LOCK+1 /* multiplex.c */
88 #define THREADS_LOCK PAPI_NUM_LOCK+2 /* threads.c */
89 #define HIGHLEVEL_LOCK PAPI_NUM_LOCK+3 /* papi_hl.c */
90 #define MEMORY_LOCK PAPI_NUM_LOCK+4 /* papi_memory.c */
91 #define COMPONENT_LOCK PAPI_NUM_LOCK+5 /* per-component */
92 #define GLOBAL_LOCK PAPI_NUM_LOCK+6 /* papi.c for global variable (static and non) initialization/shutdown */
93 #define CPUS_LOCK PAPI_NUM_LOCK+7 /* cpus.c */
94 #define NAMELIB_LOCK PAPI_NUM_LOCK+8 /* papi_pfm4_events.c */
95 
96 /* extras related */
97 
98 #define NEED_CONTEXT 1
99 #define DONT_NEED_CONTEXT 0
100 
101 #define PAPI_EVENTS_IN_DERIVED_EVENT 8
102 
103 
104 /* these vestigial pointers are to structures defined in the components
105  they are opaque to the framework and defined as void at this level
106  they are remapped to real data in the component routines that use them */
107 #define hwd_context_t void
108 #define hwd_control_state_t void
109 #define hwd_reg_alloc_t void
110 #define hwd_register_t void
111 #define hwd_siginfo_t void
112 #define hwd_ucontext_t void
113 
114 /* DEFINES END HERE */
115 
116 #ifndef NO_CONFI
117 #include "config.h"
118 #endif
119 
120 #include OSCONTEXT
121 #include "papi_preset.h"
122 
123 #ifndef inline_static
124 #define inline_static inline static
125 #endif
126 
127 typedef struct _EventSetDomainInfo {
128  int domain;
130 
131 typedef struct _EventSetGranularityInfo {
134 
135 typedef struct _EventSetOverflowInfo {
136  int flags;
139  long long *deadline;
140  int *threshold;
142  int *EventCode;
144 
145 typedef struct _EventSetAttachInfo {
146  unsigned long tid;
148 
149 typedef struct _EventSetCpuInfo {
150  unsigned int cpu_num;
152 
153 typedef struct _EventSetInheritInfo
154 {
155  int inherit;
157 
159 typedef struct _EventSetProfileInfo {
161  int *count;
162  int *threshold;
164  int *EventCode;
165  int flags;
168 
177 typedef struct _EventInfo {
178  unsigned int event_code;
180  char *ops;
181  int derived;
182 } EventInfo_t;
183 
189 typedef struct _NativeInfo {
190  int ni_event;
196  int ni_owners;
200 } NativeInfo_t;
201 
202 
203 /* Multiplex definitions */
204 
210 typedef struct _papi_info {
211  long long event_type;
212  int domain;
214 } PapiInfo;
215 
216 typedef struct _masterevent {
217  int uses;
218  int active;
222  long long count;
223  long long cycles;
224  long long handler_count;
225  long long prev_total_c;
226  long long count_estimate;
228  struct _threadlist *mythr;
229  struct _masterevent *next;
230 } MasterEvent;
231 
233 typedef struct _threadlist {
234 #ifdef PTHREADS
235  pthread_t thr;
236 #else
237  unsigned long int tid;
238 #endif
239 
240  long long total_c;
246  struct _threadlist *next;
247 } Threadlist;
248 
249 /* Ugh, should move this out and into all callers of papi_internal.h */
250 #include "sw_multiplex.h"
251 
254 struct _ThreadInfo;
255 struct _CpuInfo;
256 
259 typedef struct _EventSetInfo {
260  struct _ThreadInfo *master;
261  struct _CpuInfo *CpuInfo;
263  int state;
276  unsigned long int tid;
281  int CmpIdx;
285  long long *hw_start;
289  long long *sw_stop;
310 
312 typedef struct _dynamic_array {
316  int fullSlots;
319 
320 /* Component option types for _papi_hwd_ctl. */
321 
322 typedef struct _papi_int_attach {
323  unsigned long tid;
326 
327 typedef struct _papi_int_cpu {
328  unsigned int cpu_num;
331 
332 typedef struct _papi_int_multiplex {
333  int flags;
334  unsigned long ns;
337 
338 typedef struct _papi_int_defdomain {
341 
342 typedef struct _papi_int_domain {
343  int domain;
344  int eventset;
347 
348 typedef struct _papi_int_granularity {
350  int eventset;
353 
354 typedef struct _papi_int_overflow {
358 
359 typedef struct _papi_int_profile {
363 
365 /* These shortcuts are only for use code */
366 #undef multiplex_itimer_sig
367 #undef multiplex_itimer_num
368 #undef multiplex_itimer_us
369 
370 typedef struct _papi_int_inherit
371 {
373  int inherit;
375 
377 typedef struct _papi_int_addr_range { /* if both are zero, range is disabled */
379  int domain;
380  caddr_t start;
381  caddr_t end;
382  int start_off;
383  int end_off;
386 
387 typedef union _papi_int_option_t {
399 
402 typedef struct {
406 
408 typedef struct _papi_mdi {
410  pid_t pid;
415 } papi_mdi_t;
416 
418 extern int _papi_hwi_error_level;
419 /* extern const hwi_describe_t _papi_hwi_err[PAPI_NUM_ERRORS]; */
420 /*extern volatile int _papi_hwi_using_signal;*/
422 
424 typedef struct _papi_os_option {
430  int itimer_ns;
433  unsigned long reserved[8]; /* For future expansion */
435 
436 extern PAPI_os_info_t _papi_os_info; /* For internal PAPI use only */
437 
438 #include "papi_lock.h"
439 #include "threads.h"
440 
442 void _papi_hwi_set_papi_event_string (const char *event_string);
445 void _papi_hwi_set_papi_event_code (unsigned int event_code, int update_flag);
446 unsigned int _papi_hwi_get_papi_event_code (void);
447 int _papi_hwi_get_ntv_idx (unsigned int papi_evt_code);
449 hwd_context_t *_papi_hwi_get_context( EventSetInfo_t * ESI, int *is_dirty );
450 
453 void PAPIERROR( char *format, ... );
458  unsigned int EventCode );
461 int _papi_hwi_add_event( EventSetInfo_t * ESI, int EventCode );
462 int _papi_hwi_remove_event( EventSetInfo_t * ESI, int EventCode );
463 int _papi_hwi_read( hwd_context_t * context, EventSetInfo_t * ESI,
464  long long *values );
467 int _papi_hwi_init_global( void );
469 int _papi_hwi_init_os(void);
470 void _papi_hwi_init_errors(void);
473 void _papi_hwi_dummy_handler( int EventSet, void *address, long long overflow_vector,
474  void *context );
475 int _papi_hwi_get_preset_event_info( int EventCode, PAPI_event_info_t * info );
476 int _papi_hwi_get_user_event_info( int EventCode, PAPI_event_info_t * info );
477 int _papi_hwi_derived_type( char *tmp, int *code );
478 
479 int _papi_hwi_query_native_event( unsigned int EventCode );
480 int _papi_hwi_get_native_event_info( unsigned int EventCode,
481  PAPI_event_info_t * info );
482 int _papi_hwi_native_name_to_code( char *in, int *out );
483 int _papi_hwi_native_code_to_name( unsigned int EventCode, char *hwi_name,
484  int len );
485 
486 
487 int _papi_hwi_invalid_cmp( int cidx );
488 int _papi_hwi_component_index( int event_code );
489 int _papi_hwi_native_to_eventcode(int cidx, int event_code, int ntv_idx, const char *event_name);
490 int _papi_hwi_eventcode_to_native(int event_code);
491 
492 #endif /* PAPI_INTERNAL_H */
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:23
int _papi_hwi_is_sw_multiplex(EventSetInfo_t *ESI)
int _papi_hwi_convert_eventset_to_multiplex(_papi_int_multiplex_t *mpx)
int _papi_hwi_get_ntv_idx(unsigned int papi_evt_code)
_papi_int_inherit_t inherit
int _papi_hwi_using_signal[PAPI_NSIG]
Definition: extras.c:363
int _papi_hwi_init_global_internal(void)
unsigned int _papi_hwi_get_papi_event_code()
char * _papi_hwi_get_papi_event_string()
long long total_c
EventSetInfo_t * ESI
Hardware info structure.
Definition: papi.h:777
hwd_register_t * ni_bits
EventSetInfo_t * ESI
int _papi_hwi_query_native_event(unsigned int EventCode)
int _papi_hwi_cleanup_eventset(EventSetInfo_t *ESI)
PAPI_os_info_t * _papi_hwi_get_os_info(void)
_papi_int_addr_range_t address_range
double rate_estimate
PAPI_debug_handler_t _papi_hwi_debug_handler
Definition: papi_internal.c:54
PAPI_itimer_option_t _papi_int_itimer_t
unsigned int cpu_num
int EventSet
Definition: data_range.c:25
_papi_int_profile_t profile
int _papi_hwi_native_code_to_name(unsigned int EventCode, char *hwi_name, int len)
void _papi_hwi_dummy_handler(int EventSet, void *address, long long overflow_vector, void *context)
EventSetAttachInfo_t attach
EventSetInfo_t * ESI
hwd_register_t * NativeBits
void _papi_hwi_free_papi_event_string()
void(* PAPI_overflow_handler_t)(int EventSet, void *address, long long overflow_vector, void *context)
Definition: papi.h:564
EventSetDomainInfo_t domain
get the executable's info
Definition: papi.h:704
int _papi_hwi_errno
Definition: papi_internal.c:56
int _papi_hwi_remove_EventSet(EventSetInfo_t *ESI)
int _papi_hwi_derived_type(char *tmp, int *code)
PAPI_preload_info_t preload_info
PAPI_exe_info_t exe_info
void _papi_hwi_init_errors(void)
int _papi_hwi_remove_event(EventSetInfo_t *ESI, int EventCode)
EventSetInfo_t * _papi_hwi_lookup_EventSet(int eventset)
int _papi_hwi_get_user_event_info(int EventCode, PAPI_event_info_t *info)
int _papi_hwi_native_name_to_code(char *in, int *out)
PAPI_shlib_info_t shlib_info
EventSetOverflowInfo_t overflow
_papi_int_itimer_t itimer
_papi_int_attach_t attach
unsigned long tid
EventSetInfo_t * ESI
EventSetProfileInfo_t profile
_papi_int_cpu_t cpu
int _papi_hwi_native_to_eventcode(int cidx, int event_code, int ntv_idx, const char *event_name)
EventSetOverflowInfo_t overflow
EventSetInheritInfo_t inherit
struct _CpuInfo * CpuInfo
PAPI_os_info_t _papi_os_info
Definition: aix.c:1210
DynamicArray_t global_eventset_map
struct _ThreadInfo * master
static int cidx
Definition: event_info.c:40
int _papi_hwi_read(hwd_context_t *context, EventSetInfo_t *ESI, long long *values)
hwd_ucontext_t * ucontext
PAPI_sprofil_t ** prof
MasterEvent * cur_event
MasterEvent * head
int _papi_hwi_lookup_EventCodeIndex(const EventSetInfo_t *ESI, unsigned int EventCode)
int _papi_hwi_add_event(EventSetInfo_t *ESI, int EventCode)
_papi_int_granularity_t granularity
long long cycles
int granularity
int _papi_hwi_get_native_event_info(unsigned int EventCode, PAPI_event_info_t *info)
EventSetInfo_t * ESI
void PAPIERROR(char *format,...)
int(* PAPI_debug_handler_t)(int code)
Definition: papi.h:682
void _papi_hwi_shutdown_global_internal(void)
int _papi_hwi_get_preset_event_info(int EventCode, PAPI_event_info_t *info)
_papi_int_overflow_t overflow
#define PAPI_NSIG
Definition: papi_internal.h:60
int _papi_hwi_error_level
Definition: papi_internal.c:53
nvmlDevice_t handle
Definition: linux-nvml.c:399
struct _masterevent * next
EventSetInfo_t * ESI
pthread_t
Definition: iozone.c:18557
_papi_int_multiplex_t multiplex
NativeInfo_t * NativeInfoArray
int _papi_hwi_num_errors
Definition: papi_internal.c:57
char version[]
Definition: fileop.c:134
EventInfo_t * EventInfoArray
long long handler_count
long long * hw_start
PapiInfo pi
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:55
PAPI_hw_info_t hw_info
EventSetMultiplexInfo_t multiplex
goto out
Definition: pscanf.h:20
EventSetGranularityInfo_t granularity
hwd_context_t * _papi_hwi_get_context(EventSetInfo_t *ESI, int *is_dirty)
EventSetInfo_t ** dataSlotArray
EventSetInfo_t * ESI
long long * sw_stop
void _papi_hwi_set_papi_event_code(unsigned int event_code, int update_flag)
struct sigcontext hwd_ucontext_t
Definition: aix-context.h:10
unsigned int cpu_num
int papi_num_components
int _papi_hwi_init_os(void)
Definition: aix.c:1213
char * name
Definition: iozone.c:23648
int _papi_hwi_assign_eventset(EventSetInfo_t *ESI, int cidx)
struct _threadlist * next
int _papi_hwi_init_global(void)
char ** _papi_errlist
Definition: papi_internal.c:80
long long event_type
int _papi_hwi_component_index(int event_code)
unsigned int event_code
int _papi_num_compiled_components
#define PAPI_MAX_STR_LEN
Definition: papi.h:463
int _papi_hwi_invalid_cmp(int cidx)
#define PAPI_EVENTS_IN_DERIVED_EVENT
_papi_int_domain_t domain
void _papi_hwi_free_EventSet(EventSetInfo_t *ESI)
int _papi_hwi_eventcode_to_native(int event_code)
hwd_siginfo_t * si
unsigned long int tid
long long count
unsigned long int tid
EventSetInfo_t * ESI
EventSetProfileInfo_t profile
int init_level
Definition: papi_internal.c:52
hwd_control_state_t * ctl_state
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
long long tmp
Definition: iozone.c:12031
struct _threadlist * mythr
long long count_estimate
long long prev_total_c
void _papi_hwi_map_events_to_native(EventSetInfo_t *ESI)
PAPI_overflow_handler_t handler
int _papi_hwi_create_eventset(int *EventSet, ThreadInfo_t *handle)
EventSetInfo_t * ESI
void _papi_hwi_set_papi_event_string(const char *event_string)
Definition: papi_internal.c:89
EventSetCpuInfo_t cpu