PAPI  5.3.2.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
77 /* Thread related: thread local storage */
78 
79 #define LOWLEVEL_TLS PAPI_NUM_TLS+0
80 #define NUM_INNER_TLS 1
81 #define PAPI_MAX_TLS (NUM_INNER_TLS+PAPI_NUM_TLS)
82 
83 /* Thread related: locks */
84 
85 #define INTERNAL_LOCK PAPI_NUM_LOCK+0 /* papi_internal.c */
86 #define MULTIPLEX_LOCK PAPI_NUM_LOCK+1 /* multiplex.c */
87 #define THREADS_LOCK PAPI_NUM_LOCK+2 /* threads.c */
88 #define HIGHLEVEL_LOCK PAPI_NUM_LOCK+3 /* papi_hl.c */
89 #define MEMORY_LOCK PAPI_NUM_LOCK+4 /* papi_memory.c */
90 #define COMPONENT_LOCK PAPI_NUM_LOCK+5 /* per-component */
91 #define GLOBAL_LOCK PAPI_NUM_LOCK+6 /* papi.c for global variable (static and non) initialization/shutdown */
92 #define CPUS_LOCK PAPI_NUM_LOCK+7 /* cpus.c */
93 #define NAMELIB_LOCK PAPI_NUM_LOCK+8 /* papi_pfm4_events.c */
94 
95 /* extras related */
96 
97 #define NEED_CONTEXT 1
98 #define DONT_NEED_CONTEXT 0
99 
100 #define PAPI_EVENTS_IN_DERIVED_EVENT 8
101 
102 
103 /* these vestigial pointers are to structures defined in the components
104  they are opaque to the framework and defined as void at this level
105  they are remapped to real data in the component routines that use them */
106 #define hwd_context_t void
107 #define hwd_control_state_t void
108 #define hwd_reg_alloc_t void
109 #define hwd_register_t void
110 #define hwd_siginfo_t void
111 #define hwd_ucontext_t void
112 
113 /* DEFINES END HERE */
114 
115 #ifndef NO_CONFI
116 #include "config.h"
117 #endif
118 
119 #include OSCONTEXT
120 #include "papi_preset.h"
121 
122 #ifndef inline_static
123 #define inline_static inline static
124 #endif
125 
126 typedef struct _EventSetDomainInfo {
127  int domain;
129 
130 typedef struct _EventSetGranularityInfo {
133 
134 typedef struct _EventSetOverflowInfo {
135  int flags;
138  long long *deadline;
139  int *threshold;
141  int *EventCode;
143 
144 typedef struct _EventSetAttachInfo {
145  unsigned long tid;
147 
148 typedef struct _EventSetCpuInfo {
149  unsigned int cpu_num;
151 
152 typedef struct _EventSetInheritInfo
153 {
154  int inherit;
156 
158 typedef struct _EventSetProfileInfo {
160  int *count;
161  int *threshold;
163  int *EventCode;
164  int flags;
167 
176 typedef struct _EventInfo {
177  unsigned int event_code;
179  char *ops;
180  int derived;
181 } EventInfo_t;
182 
188 typedef struct _NativeInfo {
189  int ni_event;
193  int ni_owners;
197 } NativeInfo_t;
198 
199 
200 /* Multiplex definitions */
201 
207 typedef struct _papi_info {
208  long long event_type;
209  int domain;
211 } PapiInfo;
212 
213 typedef struct _masterevent {
214  int uses;
215  int active;
219  long long count;
220  long long cycles;
221  long long handler_count;
222  long long prev_total_c;
223  long long count_estimate;
225  struct _threadlist *mythr;
226  struct _masterevent *next;
227 } MasterEvent;
228 
230 typedef struct _threadlist {
231 #ifdef PTHREADS
232  pthread_t thr;
233 #else
234  unsigned long int tid;
235 #endif
236 
237  long long total_c;
243  struct _threadlist *next;
244 } Threadlist;
245 
246 /* Ugh, should move this out and into all callers of papi_internal.h */
247 #include "sw_multiplex.h"
248 
251 struct _ThreadInfo;
252 struct _CpuInfo;
253 
256 typedef struct _EventSetInfo {
257  struct _ThreadInfo *master;
258  struct _CpuInfo *CpuInfo;
260  int state;
273  unsigned long int tid;
278  int CmpIdx;
282  long long *hw_start;
286  long long *sw_stop;
307 
309 typedef struct _dynamic_array {
313  int fullSlots;
316 
317 /* Component option types for _papi_hwd_ctl. */
318 
319 typedef struct _papi_int_attach {
320  unsigned long tid;
323 
324 typedef struct _papi_int_cpu {
325  unsigned int cpu_num;
328 
329 typedef struct _papi_int_multiplex {
330  int flags;
331  unsigned long ns;
334 
335 typedef struct _papi_int_defdomain {
338 
339 typedef struct _papi_int_domain {
340  int domain;
341  int eventset;
344 
345 typedef struct _papi_int_granularity {
347  int eventset;
350 
351 typedef struct _papi_int_overflow {
355 
356 typedef struct _papi_int_profile {
360 
362 /* These shortcuts are only for use code */
363 #undef multiplex_itimer_sig
364 #undef multiplex_itimer_num
365 #undef multiplex_itimer_us
366 
367 typedef struct _papi_int_inherit
368 {
370  int inherit;
372 
374 typedef struct _papi_int_addr_range { /* if both are zero, range is disabled */
376  int domain;
377  caddr_t start;
378  caddr_t end;
379  int start_off;
380  int end_off;
383 
384 typedef union _papi_int_option_t {
396 
399 typedef struct {
403 
405 typedef struct _papi_mdi {
407  pid_t pid;
412 } papi_mdi_t;
413 
415 extern int _papi_hwi_error_level;
416 /* extern const hwi_describe_t _papi_hwi_err[PAPI_NUM_ERRORS]; */
417 /*extern volatile int _papi_hwi_using_signal;*/
419 
421 typedef struct _papi_os_option {
427  int itimer_ns;
430  unsigned long reserved[8]; /* For future expansion */
432 
433 extern PAPI_os_info_t _papi_os_info; /* For internal PAPI use only */
434 
435 #include "papi_lock.h"
436 #include "threads.h"
437 
440 hwd_context_t *_papi_hwi_get_context( EventSetInfo_t * ESI, int *is_dirty );
441 
444 void PAPIERROR( char *format, ... );
449  unsigned int EventCode );
452 int _papi_hwi_add_event( EventSetInfo_t * ESI, int EventCode );
453 int _papi_hwi_remove_event( EventSetInfo_t * ESI, int EventCode );
454 int _papi_hwi_read( hwd_context_t * context, EventSetInfo_t * ESI,
455  long long *values );
458 int _papi_hwi_init_global( void );
460 int _papi_hwi_init_os(void);
461 void _papi_hwi_init_errors(void);
464 void _papi_hwi_dummy_handler( int EventSet, void *address, long long overflow_vector,
465  void *context );
466 int _papi_hwi_get_preset_event_info( int EventCode, PAPI_event_info_t * info );
467 int _papi_hwi_derived_type( char *tmp, int *code );
468 
469 int _papi_hwi_query_native_event( unsigned int EventCode );
470 int _papi_hwi_get_native_event_info( unsigned int EventCode,
471  PAPI_event_info_t * info );
472 int _papi_hwi_native_name_to_code( char *in, int *out );
473 int _papi_hwi_native_code_to_name( unsigned int EventCode, char *hwi_name,
474  int len );
475 
476 
477 int _papi_hwi_invalid_cmp( int cidx );
478 int _papi_hwi_component_index( int event_code );
479 int _papi_hwi_native_to_eventcode(int cidx, int event_code);
480 int _papi_hwi_eventcode_to_native(int event_code);
481 
482 #endif /* PAPI_INTERNAL_H */
int _papi_hwi_is_sw_multiplex(EventSetInfo_t *ESI)
int _papi_hwi_convert_eventset_to_multiplex(_papi_int_multiplex_t *mpx)
_papi_int_inherit_t inherit
int _papi_hwi_using_signal[PAPI_NSIG]
Definition: extras.c:363
int _papi_hwi_init_global_internal(void)
long long total_c
EventSetInfo_t * ESI
Hardware info structure.
Definition: papi.h:775
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)
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
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:56
PAPI_itimer_option_t _papi_int_itimer_t
unsigned int cpu_num
_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_overflow_handler_t)(int EventSet, void *address, long long overflow_vector, void *context)
Definition: papi.h:563
EventSetDomainInfo_t domain
get the executable's info
Definition: papi.h:702
int _papi_hwi_errno
Definition: papi_internal.c:58
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_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
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:680
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:55
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:59
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:57
PAPI_hw_info_t hw_info
int _papi_hwi_native_to_eventcode(int cidx, int event_code)
EventSetMultiplexInfo_t multiplex
EventSetGranularityInfo_t granularity
hwd_context_t * _papi_hwi_get_context(EventSetInfo_t *ESI, int *is_dirty)
EventSetInfo_t ** dataSlotArray
EventSetInfo_t * ESI
int EventSet
long long * sw_stop
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:77
long long event_type
int _papi_hwi_component_index(int event_code)
unsigned int event_code
int _papi_num_compiled_components
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:54
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
EventSetCpuInfo_t cpu