PAPI 7.1.0.0
Loading...
Searching...
No Matches
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
27extern int papi_num_components;
29extern int init_level;
30extern int _papi_hwi_errno;
31extern int _papi_hwi_num_errors;
32extern char **_papi_errlist;
33
34/********************************************************/
35/* This block provides general strings used in PAPI */
36/* If a new string is needed for PAPI prompts */
37/* it should be placed in this file and referenced by */
38/* label. */
39/********************************************************/
40#define PAPI_ERROR_CODE_str "Error Code"
41#define PAPI_SHUTDOWN_str "PAPI_shutdown: PAPI is not initialized"
42#define PAPI_SHUTDOWN_SYNC_str "PAPI_shutdown: other threads still have running EventSets"
43
44
45/* some members of structs and/or function parameters may or may not be
46 necessary, but at this point, we have included anything that might
47 possibly be useful later, and will remove them as we progress */
48
49/* Signal used for overflow delivery */
50
51#define PAPI_INT_MPX_SIGNAL SIGPROF
52#define PAPI_INT_SIGNAL SIGPROF
53#define PAPI_INT_ITIMER ITIMER_PROF
54
55#define PAPI_INT_ITIMER_MS 1
56#if defined(linux)
57#define PAPI_NSIG _NSIG
58#else
59#define PAPI_NSIG 128
60#endif
61
62/* Multiplex definitions */
63
64#define PAPI_INT_MPX_DEF_US 10000 /*Default resolution in us. of mpx handler */
65
66/* Commands used to compute derived events */
67
68#define NOT_DERIVED 0x0
69#define DERIVED_ADD 0x1
70#define DERIVED_PS 0x2
71#define DERIVED_ADD_PS 0x4
72#define DERIVED_CMPD 0x8
73#define DERIVED_SUB 0x10
74#define DERIVED_POSTFIX 0x20
75#define DERIVED_INFIX 0x40
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
126typedef struct _EventSetDomainInfo {
129
130typedef struct _EventSetGranularityInfo {
133
134typedef struct _EventSetOverflowInfo {
135 int flags;
138 long long *deadline;
143
144typedef struct _EventSetAttachInfo {
145 unsigned long tid;
147
148typedef struct _EventSetCpuInfo {
149 unsigned int cpu_num;
151
152typedef struct _EventSetInheritInfo
153{
156
158typedef struct _EventSetProfileInfo {
160 int *count;
164 int flags;
167
176typedef struct _EventInfo {
177 unsigned int event_code;
179 char *ops;
182
188typedef struct _NativeInfo {
200
201
202/* Multiplex definitions */
203
209typedef struct _papi_info {
210 long long event_type;
213} PapiInfo;
214
215typedef struct _masterevent {
216 int uses;
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;
230
232typedef struct _threadlist {
233#ifdef PTHREADS
234 pthread_t thr;
235#else
236 unsigned long int tid;
237#endif
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
253struct _ThreadInfo;
254struct _CpuInfo;
255
258typedef 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
311typedef struct _dynamic_array {
318
319/* Component option types for _papi_hwd_ctl. */
320
321typedef struct _papi_int_attach {
322 unsigned long tid;
325
326typedef struct _papi_int_cpu {
327 unsigned int cpu_num;
330
331typedef struct _papi_int_multiplex {
332 int flags;
333 unsigned long ns;
336
337typedef struct _papi_int_defdomain {
340
341typedef struct _papi_int_domain {
346
347typedef struct _papi_int_granularity {
352
353typedef struct _papi_int_overflow {
357
358typedef 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
369typedef struct _papi_int_inherit
370{
374
376typedef struct _papi_int_addr_range { /* if both are zero, range is disabled */
385
386typedef union _papi_int_option_t {
398
401typedef struct {
405
407typedef struct _papi_mdi {
409 pid_t pid;
414} papi_mdi_t;
415
417extern 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
423typedef struct _papi_os_option {
432 unsigned long reserved[8]; /* For future expansion */
434
435extern PAPI_os_info_t _papi_os_info; /* For internal PAPI use only */
436
437#include "papi_lock.h"
438#include "threads.h"
439
442
444void _papi_hwi_set_papi_event_string (const char *event_string);
447void _papi_hwi_set_papi_event_code (unsigned int event_code, int update_flag);
448unsigned int _papi_hwi_get_papi_event_code (void);
449int _papi_hwi_get_ntv_idx (unsigned int papi_evt_code);
451hwd_context_t *_papi_hwi_get_context( EventSetInfo_t * ESI, int *is_dirty );
452
455void PAPIERROR( char *format, ... );
456void PAPIWARN( char *format, ... );
461 unsigned int EventCode );
464int _papi_hwi_add_event( EventSetInfo_t * ESI, int EventCode );
465int _papi_hwi_remove_event( EventSetInfo_t * ESI, int EventCode );
466int _papi_hwi_read( hwd_context_t * context, EventSetInfo_t * ESI,
467 long long *values );
470int _papi_hwi_init_global( int PE_OR_PEU );
472int _papi_hwi_init_os(void);
473void _papi_hwi_init_errors(void);
476void _papi_hwi_dummy_handler( int EventSet, void *address, long long overflow_vector,
477 void *context );
478int _papi_hwi_get_preset_event_info( int EventCode, PAPI_event_info_t * info );
479int _papi_hwi_get_user_event_info( int EventCode, PAPI_event_info_t * info );
480int _papi_hwi_derived_type( char *tmp, int *code );
481
482int _papi_hwi_query_native_event( unsigned int EventCode );
483int _papi_hwi_get_native_event_info( unsigned int EventCode,
484 PAPI_event_info_t * info );
485int _papi_hwi_native_name_to_code( const char *in, int *out );
486int _papi_hwi_native_code_to_name( unsigned int EventCode, char *hwi_name,
487 int len );
488
489
490int _papi_hwi_invalid_cmp( int cidx );
491int _papi_hwi_component_index( int event_code );
492int _papi_hwi_native_to_eventcode(int cidx, int event_code, int ntv_idx, const char *event_name);
493int _papi_hwi_eventcode_to_native(int event_code);
494
495enum {
499};
500
501typedef struct {
503 union {
504 struct {
506 } enumerate;
507
508 struct {
509 void *handle;
511 } dev_type;
512
513 struct {
514 void *handle;
515 int id;
517 } dev;
518 } query;
520
521int _papi_hwi_enum_dev_type(int enum_modifier, void **handle);
523int _papi_hwi_get_dev_attr(void *handle, int id, PAPI_dev_attr_e attr, void *val);
524
525#endif /* PAPI_INTERNAL_H */
static papi_handle_t handle
Definition: Gamum.c:21
double tmp
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
PAPI_dev_type_attr_e
Definition: papi.h:1049
PAPI_dev_attr_e
Definition: papi.h:1068
static int EventSet
Definition: init_fini.c:8
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
uint16_t reserved
uint8_t version
void(* PAPI_overflow_handler_t)(int EventSet, void *address, long long overflow_vector, void *context)
Definition: papi.h:573
int(* PAPI_debug_handler_t)(int code)
Definition: papi.h:674
void * vptr_t
Definition: papi.h:576
unsigned long int pthread_t
int _papi_hwi_enum_dev_type(int enum_modifier, void **handle)
int _papi_hwi_get_user_event_info(int EventCode, PAPI_event_info_t *info)
int init_level
Definition: papi_internal.c:53
PAPI_os_info_t * _papi_hwi_get_os_info(void)
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:56
int _papi_hwi_native_to_eventcode(int cidx, int event_code, int ntv_idx, const char *event_name)
#define PAPI_EVENTS_IN_DERIVED_EVENT
int _papi_hwi_add_event(EventSetInfo_t *ESI, int EventCode)
int _papi_hwi_using_signal[PAPI_NSIG]
Definition: extras.c:365
void _papi_hwi_shutdown_global_internal(void)
int _papi_hwi_get_native_event_info(unsigned int EventCode, PAPI_event_info_t *info)
void _papi_hwi_free_EventSet(EventSetInfo_t *ESI)
void _papi_hwi_dummy_handler(int EventSet, void *address, long long overflow_vector, void *context)
int _papi_num_compiled_components
#define PAPI_NSIG
Definition: papi_internal.h:59
unsigned int _papi_hwi_get_papi_event_code(void)
void PAPIERROR(char *format,...)
THREAD_LOCAL_STORAGE_KEYWORD int _papi_hl_events_running
Definition: papi_internal.c:63
char * _papi_hwi_get_papi_event_string(void)
int _papi_hwi_is_sw_multiplex(EventSetInfo_t *ESI)
int _papi_hwi_native_code_to_name(unsigned int EventCode, char *hwi_name, int len)
void _papi_hwi_init_errors(void)
int _papi_hwi_derived_type(char *tmp, int *code)
int _papi_hwi_eventcode_to_native(int event_code)
int _papi_hwi_errno
Definition: papi_internal.c:57
@ PAPI_SYSDETECT_QUERY__DEV_TYPE_ENUM
@ PAPI_SYSDETECT_QUERY__DEV_ATTR
@ PAPI_SYSDETECT_QUERY__DEV_TYPE_ATTR
int _papi_hwi_error_level
int _papi_hwi_init_os(void)
Definition: aix.c:1213
void _papi_hwi_free_papi_event_string()
EventSetInfo_t * _papi_hwi_lookup_EventSet(int eventset)
int _papi_hwi_num_errors
Definition: papi_internal.c:58
int _papi_hwi_lookup_EventCodeIndex(const EventSetInfo_t *ESI, unsigned int EventCode)
int _papi_hwi_init_global(int PE_OR_PEU)
hwd_context_t * _papi_hwi_get_context(EventSetInfo_t *ESI, int *is_dirty)
int _papi_hwi_init_global_internal(void)
PAPI_debug_handler_t _papi_hwi_debug_handler
Definition: papi_internal.c:55
PAPI_itimer_option_t _papi_int_itimer_t
int _papi_hwi_remove_EventSet(EventSetInfo_t *ESI)
PAPI_os_info_t _papi_os_info
Definition: aix.c:1210
int _papi_hwi_native_name_to_code(const char *in, int *out)
int _papi_hwi_create_eventset(int *EventSet, ThreadInfo_t *handle)
int _papi_hwi_component_index(int event_code)
int _papi_hwi_get_preset_event_info(int EventCode, PAPI_event_info_t *info)
int _papi_hwi_convert_eventset_to_multiplex(_papi_int_multiplex_t *mpx)
int _papi_hwi_get_dev_type_attr(void *handle, PAPI_dev_type_attr_e attr, void *val)
void _papi_hwi_set_papi_event_string(const char *event_string)
Definition: papi_internal.c:93
THREAD_LOCAL_STORAGE_KEYWORD int _papi_rate_events_running
Definition: papi_internal.c:62
void PAPIWARN(char *format,...)
int _papi_hwi_read(hwd_context_t *context, EventSetInfo_t *ESI, long long *values)
char ** _papi_errlist
Definition: papi_internal.c:84
int _papi_hwi_assign_eventset(EventSetInfo_t *ESI, int cidx)
int papi_num_components
int _papi_hwi_get_dev_attr(void *handle, int id, PAPI_dev_attr_e attr, void *val)
int _papi_hwi_remove_event(EventSetInfo_t *ESI, int EventCode)
int _papi_hwi_invalid_cmp(int cidx)
void _papi_hwi_set_papi_event_code(unsigned int event_code, int update_flag)
int _papi_hwi_cleanup_eventset(EventSetInfo_t *ESI)
int _papi_hwi_get_ntv_idx(unsigned int papi_evt_code)
int _papi_hwi_query_native_event(unsigned int EventCode)
void _papi_hwi_map_events_to_native(EventSetInfo_t *ESI)
static int cidx
const char * name
Definition: rocs.c:225
EventSetInfo_t ** dataSlotArray
unsigned int event_code
unsigned int cpu_num
EventSetInheritInfo_t inherit
unsigned long int tid
EventSetMultiplexInfo_t multiplex
EventSetProfileInfo_t profile
long long * sw_stop
struct _ThreadInfo * master
long long * hw_start
EventSetAttachInfo_t attach
hwd_register_t * NativeBits
EventSetCpuInfo_t cpu
struct _CpuInfo * CpuInfo
EventSetGranularityInfo_t granularity
EventInfo_t * EventInfoArray
hwd_control_state_t * ctl_state
NativeInfo_t * NativeInfoArray
EventSetOverflowInfo_t overflow
EventSetDomainInfo_t domain
PAPI_overflow_handler_t handler
PAPI_sprofil_t ** prof
struct _threadlist * mythr
struct _masterevent * next
long long handler_count
long long prev_total_c
double rate_estimate
long long count
long long count_estimate
long long cycles
PapiInfo pi
hwd_register_t * ni_bits
get the executable's info
Definition: papi.h:696
Hardware info structure.
Definition: papi.h:774
int granularity
long long event_type
struct _threadlist * next
MasterEvent * head
unsigned long int tid
MasterEvent * cur_event
long long total_c
hwd_siginfo_t * si
hwd_ucontext_t * ucontext
PAPI_dev_type_attr_e attr
PAPI_dev_attr_e attr
EventSetInfo_t * ESI
EventSetInfo_t * ESI
unsigned long tid
EventSetInfo_t * ESI
unsigned int cpu_num
EventSetInfo_t * ESI
EventSetInfo_t * ESI
EventSetInfo_t * ESI
EventSetInfo_t * ESI
EventSetOverflowInfo_t overflow
EventSetInfo_t * ESI
EventSetInfo_t * ESI
EventSetProfileInfo_t profile
DynamicArray_t global_eventset_map
PAPI_exe_info_t exe_info
PAPI_hw_info_t hw_info
PAPI_preload_info_t preload_info
PAPI_shlib_info_t shlib_info
#define THREAD_LOCAL_STORAGE_KEYWORD
Definition: threads.h:16
_papi_int_domain_t domain
_papi_int_multiplex_t multiplex
_papi_int_granularity_t granularity
_papi_int_attach_t attach
_papi_int_inherit_t inherit
_papi_int_cpu_t cpu
_papi_int_overflow_t overflow
_papi_int_profile_t profile
_papi_int_itimer_t itimer
_papi_int_addr_range_t address_range