PAPI  5.4.0.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;
195  int ni_owners;
199 } NativeInfo_t;
200 
201 
202 /* Multiplex definitions */
203 
209 typedef struct _papi_info {
210  long long event_type;
211  int domain;
213 } PapiInfo;
214 
215 typedef struct _masterevent {
216  int uses;
217  int active;
221  long long count;
222  long long cycles;
223  long long handler_count;
224  long long prev_total_c;
225  long long count_estimate;
227  struct _threadlist *mythr;
228  struct _masterevent *next;
229 } MasterEvent;
230 
232 typedef struct _threadlist {
233 #ifdef PTHREADS
234  pthread_t thr;
235 #else
236  unsigned long int tid;
237 #endif
238 
239  long long total_c;
245  struct _threadlist *next;
246 } Threadlist;
247 
248 /* Ugh, should move this out and into all callers of papi_internal.h */
249 #include "sw_multiplex.h"
250 
253 struct _ThreadInfo;
254 struct _CpuInfo;
255 
258 typedef struct _EventSetInfo {
259  struct _ThreadInfo *master;
260  struct _CpuInfo *CpuInfo;
262  int state;
275  unsigned long int tid;
280  int CmpIdx;
284  long long *hw_start;
288  long long *sw_stop;
309 
311 typedef struct _dynamic_array {
315  int fullSlots;
318 
319 /* Component option types for _papi_hwd_ctl. */
320 
321 typedef struct _papi_int_attach {
322  unsigned long tid;
325 
326 typedef struct _papi_int_cpu {
327  unsigned int cpu_num;
330 
331 typedef struct _papi_int_multiplex {
332  int flags;
333  unsigned long ns;
336 
337 typedef struct _papi_int_defdomain {
340 
341 typedef struct _papi_int_domain {
342  int domain;
343  int eventset;
346 
347 typedef struct _papi_int_granularity {
349  int eventset;
352 
353 typedef struct _papi_int_overflow {
357 
358 typedef struct _papi_int_profile {
362 
364 /* These shortcuts are only for use code */
365 #undef multiplex_itimer_sig
366 #undef multiplex_itimer_num
367 #undef multiplex_itimer_us
368 
369 typedef struct _papi_int_inherit
370 {
372  int inherit;
374 
376 typedef struct _papi_int_addr_range { /* if both are zero, range is disabled */
378  int domain;
379  caddr_t start;
380  caddr_t end;
381  int start_off;
382  int end_off;
385 
386 typedef union _papi_int_option_t {
398 
401 typedef struct {
405 
407 typedef struct _papi_mdi {
409  pid_t pid;
414 } papi_mdi_t;
415 
417 extern int _papi_hwi_error_level;
418 /* extern const hwi_describe_t _papi_hwi_err[PAPI_NUM_ERRORS]; */
419 /*extern volatile int _papi_hwi_using_signal;*/
421 
423 typedef struct _papi_os_option {
429  int itimer_ns;
432  unsigned long reserved[8]; /* For future expansion */
434 
435 extern PAPI_os_info_t _papi_os_info; /* For internal PAPI use only */
436 
437 #include "papi_lock.h"
438 #include "threads.h"
439 
441 void _papi_hwi_set_papi_event_string (const char *event_string);
444 void _papi_hwi_set_papi_event_code (unsigned int event_code, int update_flag);
445 unsigned int _papi_hwi_get_papi_event_code (void);
446 int _papi_hwi_get_ntv_idx (unsigned int papi_evt_code);
448 hwd_context_t *_papi_hwi_get_context( EventSetInfo_t * ESI, int *is_dirty );
449 
452 void PAPIERROR( char *format, ... );
457  unsigned int EventCode );
460 int _papi_hwi_add_event( EventSetInfo_t * ESI, int EventCode );
461 int _papi_hwi_remove_event( EventSetInfo_t * ESI, int EventCode );
462 int _papi_hwi_read( hwd_context_t * context, EventSetInfo_t * ESI,
463  long long *values );
466 int _papi_hwi_init_global( void );
468 int _papi_hwi_init_os(void);
469 void _papi_hwi_init_errors(void);
472 void _papi_hwi_dummy_handler( int EventSet, void *address, long long overflow_vector,
473  void *context );
474 int _papi_hwi_get_preset_event_info( int EventCode, PAPI_event_info_t * info );
475 int _papi_hwi_derived_type( char *tmp, int *code );
476 
477 int _papi_hwi_query_native_event( unsigned int EventCode );
478 int _papi_hwi_get_native_event_info( unsigned int EventCode,
479  PAPI_event_info_t * info );
480 int _papi_hwi_native_name_to_code( char *in, int *out );
481 int _papi_hwi_native_code_to_name( unsigned int EventCode, char *hwi_name,
482  int len );
483 
484 
485 int _papi_hwi_invalid_cmp( int cidx );
486 int _papi_hwi_component_index( int event_code );
487 int _papi_hwi_native_to_eventcode(int cidx, int event_code, int ntv_idx, const char *event_name);
488 int _papi_hwi_eventcode_to_native(int event_code);
489 
490 #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:56
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: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
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: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
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: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
void _papi_hwi_set_papi_event_string(const char *event_string)
Definition: papi_internal.c:89
EventSetCpuInfo_t cpu