50 #define papi_return(a) do { \ 55 APIDBG("EXIT: return: %d\n", b);\ 56 return((_papi_hwi_debug_handler ? _papi_hwi_debug_handler(b) : b)); \ 59 #define papi_return(a) do { \ 64 APIDBG("EXIT: return: %d\n", b);\ 294 if ( ( number == NULL ) || ( tids && ( *number <= 0 ) ) )
297 memset( &
tmp, 0x0,
sizeof (
tmp ) );
382 *ptr =
thread->thread_storage[tag];
451 thread->thread_storage[tag] = ptr;
510 static int _in_papi_library_init_cnt = 0;
519 ++_in_papi_library_init_cnt;
520 while ( _in_papi_library_init_cnt > 1 ) {
521 PAPIERROR(
"Multiple callers of PAPI_library_init" );
529 APIDBG(
"Initializing library: current PID %d, old PID %d\n",
539 if (
getenv(
"PAPI_ALLOW_STOLEN" ) ) {
543 sprintf(
buf,
"%s=%s",
"PAPI_ALLOW_STOLEN",
"stolen" );
552 _in_papi_library_init_cnt--;
559 APIDBG(
"system_info was initialized, but init did not succeed\n" );
562 var = (
char * )
getenv(
"PAPI_DEBUG" );
566 if ( strlen( var ) != 0 ) {
567 if ( strstr( var,
"SUBSTRATE" ) )
569 if ( strstr( var,
"API" ) )
571 if ( strstr( var,
"INTERNAL" ) )
573 if ( strstr( var,
"THREADS" ) )
575 if ( strstr( var,
"MULTIPLEX" ) )
577 if ( strstr( var,
"OVERFLOW" ) )
579 if ( strstr( var,
"PROFILE" ) )
581 if ( strstr( var,
"MEMORY" ) )
583 if ( strstr( var,
"LEAK" ) )
585 if ( strstr( var,
"ALL" ) )
597 _in_papi_library_init_cnt--;
606 _in_papi_library_init_cnt--;
616 _in_papi_library_init_cnt--;
632 _in_papi_library_init_cnt--;
637 _in_papi_library_init_cnt--;
686 APIDBG(
"Entry: EventCode: %#x\n", EventCode);
700 ( (
unsigned int ) EventCode ) );
837 APIDBG(
"Entry: EventCode: 0x%x, info: %p\n", EventCode, info);
852 ( (
unsigned int ) EventCode, info ) );
917 APIDBG(
"Entry: EventCode: %#x, out: %p\n", EventCode, out);
1006 APIDBG(
"Entry: in: %p, name: %s, out: %p\n", in, in, out);
1009 if ( ( in == NULL ) || ( out == NULL ) )
1017 if (strncmp(in,
"PAPI_", 5) == 0) {
1029 APIDBG(
"&user_defined_events[%d]: %p, user_defined_events[%d].symbol: %s, user_defined_events[%d].count: %d\n",
1154 APIDBG(
"Entry: EventCode: %#x, modifier: %d\n", *EventCode, modifier);
1170 APIDBG(
"EXIT: *EventCode: %#x\n", *EventCode);
1176 APIDBG(
"EXIT: PAPI_ENOEVNT\n");
1184 APIDBG(
"EXIT: *EventCode: %#x\n", *EventCode);
1208 APIDBG(
"EXIT: *EventCode: %#x\n", *EventCode);
1214 APIDBG(
"EXIT: PAPI_ENOEVNT\n");
1219 APIDBG(
"EXIT: *EventCode: %#x\n", *EventCode);
1227 APIDBG(
"EXIT: PAPI_ENOEVNT\n");
1233 APIDBG(
"EXIT: PAPI_ENOEVNT\n");
1239 APIDBG(
"EXIT: PAPI_ENOEVNT\n");
1244 APIDBG(
"EXIT: *EventCode: %#x\n", *EventCode);
1359 APIDBG(
"Entry: EventCode: %#x, modifier: %d, cidx: %d\n", *EventCode, modifier,
cidx);
1376 APIDBG(
"EXIT: *EventCode: %#x\n", *EventCode);
1382 APIDBG(
"EXIT: PAPI_ENOEVNT\n");
1390 APIDBG(
"EXIT: *EventCode: %#x\n", *EventCode);
1413 APIDBG(
"EXIT: *EventCode: %#x\n", *EventCode);
1665 APIDBG(
"Entry: EventSet: %d, EventCode: %#x\n",
EventSet, EventCode);
1760 APIDBG(
"Entry: EventSet: %d, EventCode: %#x\n",
EventSet, EventCode);
1878 APIDBG(
"Entry: EventSet: %d, EventName: %s\n",
EventSet, EventName);
1963 APIDBG(
"Entry: EventSet: %d, EventName: %s\n",
EventSet, EventName);
2109 if ( ESI == NULL ) {
2113 APIDBG(
"EventSet: %p\n", ESI);
2131 APIDBG(
"Thread Running already (Only one active Eventset per component)\n");
2842 sizeof (
long long ) );
3128 APIDBG(
"Entry: level: %d\n", level);
3131 memset( &option, 0x0,
sizeof ( option ) );
3141 APIDBG(
"Entry: option: %d, EventSet: %d, tid: %lu\n", option,
EventSet, tid);
3357 memset( &mpx, 0x0,
sizeof ( mpx ) );
3467 APIDBG(
"Entry: option: %d, ptr: %p\n", option, ptr);
3485 if (
internal.
attach.ESI == NULL )
3505 internal.attach.tid =
internal.attach.ESI->attach.tid;
3513 internal.attach.ESI->attach.tid = 0;
3519 if (
internal.
attach.ESI == NULL )
3547 internal.attach.ESI->attach.tid = ptr->
attach.
tid;
3556 if (
internal.cpu.ESI == NULL )
3560 APIDBG(
"internal: %p, ESI: %p, cpu_num: %d\n", &
internal,
internal.cpu.ESI,
internal.cpu.cpu_num);
3599 internal.multiplex.ns = (
unsigned long ) ptr->
multiplex.
ns;
3606 ptr->
multiplex.
ns = (
int )
internal.multiplex.ns;
3615 internal.itimer.ns = ptr->
itimer.
ns;
3620 ptr->
itimer.
ns =
internal.itimer.ns;
3629 memcpy( &
internal.itimer, &ptr->
itimer,
3662 internal.multiplex.ESI = ESI;
3725 if (
internal.domain.ESI == NULL )
3744 internal.domain.domain = dom;
3754 internal.domain.ESI->domain.domain = dom;
3774 if ( grn & ~
_papi_hwd[
cidx]->cmp_info.available_granularities )
3778 if ( grn ^ ( 1 << ( ffs( grn ) - 1 ) ) )
3792 internal.granularity.ESI =
3794 if (
internal.granularity.ESI == NULL )
3803 if ( grn & ~
_papi_hwd[
cidx]->cmp_info.available_granularities )
3807 if ( grn ^ ( 1 << ( ffs( grn ) - 1 ) ) )
3810 internal.granularity.granularity = grn;
3816 internal.granularity.ESI->granularity.granularity = grn;
3840 internal.inherit.ESI = ESI;
3866 internal.address_range.ESI = ESI;
3868 if ( !(
internal.address_range.ESI->state &
PAPI_STOPPED ) )
3874 internal.address_range.start = ptr->
addr.
start;
3875 internal.address_range.end = ptr->
addr.
end;
3880 ptr->
addr.
end_off =
internal.address_range.end_off;
4145 APIDBG(
"Entry: option: %d, ptr: %p\n", option, ptr);
4337 APIDBG(
"Entry: option: %d, ptr: %p, cidx: %d\n", option, ptr,
cidx);
4491 if ( ESI->
master == master ) {
4663 fprintf( stderr,
"%s: ", msg );
4665 fprintf( stderr,
"%s\n", foo );
4796 if ( ESI == NULL ) {
4803 OVFDBG(
"Component Error\n");
4808 OVFDBG(
"Already running\n");
4818 OVFDBG(
"CPU attached\n");
4823 (
unsigned int ) EventCode ) ) < 0 ) {
4828 OVFDBG(
"Threshold below zero\n");
4838 OVFDBG(
"Derived event in overflow\n");
4846 OVFDBG(
"NULL handler\n");
4850 OVFDBG(
"Zero threshold\n");
4867 while ( i < ESI->overflow.event_counter - 1 ) {
4928 APIDBG(
"Overflow using: %s\n",
5045 int EventCode,
int threshold,
int flags )
5047 APIDBG(
"Entry: prof: %p, profcnt: %d, EventSet: %d, EventCode: %#x, threshold: %d, flags: %#x\n", prof, profcnt,
EventSet, EventCode,
threshold, flags);
5055 if ( ESI == NULL ) {
5082 (
unsigned int) EventCode ) ) < 0 ) {
5095 if ( prof == NULL ) {
5107 for(
i = 0;
i < profcnt;
i++ ) {
5108 if ( !( ( prof[
i].pr_scale == 131072 ) ||
5109 ( ( prof[
i].pr_scale <= 65536 && prof[
i].pr_scale > 1 ) ) ) ) {
5110 APIDBG(
"Improper scale factor: %d\n", prof[
i].pr_scale );
5146 while ( i < ESI->profile.event_counter - 1 ) {
5442 APIDBG(
"Entry: buf: %p, bufsiz: %d, offset: %p, scale: %u, EventSet: %d, EventCode: %#x, threshold: %d, flags: %#x\n",
buf, bufsiz,
offset, scale,
EventSet, EventCode,
threshold, flags);
5626 memset( &ptr, 0,
sizeof ( ptr ) );
5762 memset( &ptr, 0,
sizeof ( ptr ) );
5848 if ( (
Events == NULL ) || ( number <= 0 ) )
5851 for (
i = 0;
i < number;
i++ ) {
5936 if ( (
Events == NULL ) || ( number <= 0 ) )
5939 for (
i = 0;
i < number;
i++ ) {
6010 if ( (
Events == NULL ) && ( *number > 0 ) )
6017 if ( (
Events == NULL ) || ( *number == 0 ) ) {
6119 memset( &ptr, 0,
sizeof ( ptr ) );
6149 memset( &ptr, 0,
sizeof ( ptr ) );
6190 memset( &ptr, 0,
sizeof ( ptr ) );
6518 int *
array,
int *number )
6520 APIDBG(
"Entry: EventSet: %d, overflow_vector: %lld, array: %p, number: %p\n",
EventSet, overflow_vector,
array, number);
6522 int set_bit, j, pos;
6525 if ( overflow_vector == (
long long ) 0 )
6528 if ( (
array == NULL ) || ( number == NULL ) )
6542 while ( ( set_bit = ffsll( overflow_vector ) ) ) {
6544 overflow_vector ^= (
long long ) 1 << set_bit;
6546 for ( k = 0, pos = 0; k < PAPI_EVENTS_IN_DERIVED_EVENT && pos >= 0; k++ ) {
6548 if ( ( set_bit == pos ) &&
6552 if (
count == *number )
6585 APIDBG(
"Entry: EventCode: %#x\n", EventCode);
6682 "Disabled by PAPI_disable_component()");
int _papi_hwi_is_sw_multiplex(EventSetInfo_t *ESI)
int PAPI_stop(int EventSet, long long *values)
int PAPI_is_initialized(void)
int _papi_hwi_convert_eventset_to_multiplex(_papi_int_multiplex_t *mpx)
int _papi_hwi_init_global_internal(void)
#define PAPI_CPU_ATTACHED
#define IS_PRESET(EventCode)
char * _papi_hwi_get_papi_event_string()
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
#define PAPI_COMPONENTINFO
unsigned long int(* _papi_hwi_thread_id_fn)(void)
int PAPI_add_event(int EventSet, int EventCode)
inline_static int _papi_set_attach(int option, int EventSet, unsigned long tid)
long long PAPI_get_virt_usec(void)
int PAPI_set_cmp_granularity(int granularity, int cidx)
int PAPI_reset(int EventSet)
#define PAPI_SHUTDOWN_str
#define PAPI_DEF_ITIMER_NS
int _papi_hwi_set_thread_id_fn(unsigned long(*id_fn)(void))
#define IS_USER_DEFINED(EventCode)
const PAPI_shlib_info_t * PAPI_get_shared_lib_info(void)
int PAPI_disable_component_by_name(const char *name)
#define PAPI_INSTR_ADDRESS
int _papi_hwi_query_native_event(unsigned int EventCode)
static int Events[NUM_EVENTS]
int _papi_hwi_cleanup_eventset(EventSetInfo_t *ESI)
EventSetInfo_t ** running_eventset
#define PAPI_PROFIL_BUCKET_16
unsigned long PAPI_thread_id(void)
#define PAPI_PROFIL_DATA_EAR
int PAPI_write(int EventSet, long long *values)
int PAPI_remove_event(int EventSet, int EventCode)
long long PAPI_get_virt_cyc(void)
PAPI_debug_handler_t _papi_hwi_debug_handler
#define PAPI_DATA_ADDRESS
#define PAPI_MULTIPLEX_FORCE_SW
long long(* get_real_usec)(void)
int PAPI_num_components(void)
static double array[ARRAYSIZE]
int PAPI_enum_event(int *EventCode, int modifier)
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
PAPI_granularity_option_t granularity
int MPX_stop(MPX_EventSet *mpx_events, long long *values)
int PAPI_detach(int EventSet)
int(* get_dmem_info)(PAPI_dmem_info_t *)
void _papi_hwi_free_papi_event_string()
#define PAPI_PROFIL_BUCKET_32
EventSetDomainInfo_t domain
get the executable's info
int PAPI_register_thread(void)
int _papi_hwi_remove_EventSet(EventSetInfo_t *ESI)
PAPI_inherit_option_t inherit
PAPI_preload_info_t preload_info
#define PAPI_PROFIL_COMPRESS
int PAPI_event_name_to_code(const char *in, int *out)
#define PAPI_PROFIL_POSIX
int PAPI_overflow(int EventSet, int EventCode, int threshold, int flags, PAPI_overflow_handler_t handler)
A pointer to the following is passed to PAPI_set/get_opt()
int PAPI_remove_events(int EventSet, int *Events, int number)
long long PAPI_get_virt_nsec(void)
long long(* get_virt_usec)(void)
int PAPI_sprofil(PAPI_sprofil_t *prof, int profcnt, int EventSet, int EventCode, int threshold, int flags)
void _papi_hwi_init_errors(void)
int _papi_hwi_remove_event(EventSetInfo_t *ESI, int EventCode)
EventSetInfo_t * _papi_hwi_lookup_EventSet(int eventset)
long long(* get_real_nsec)(void)
int _papi_hwi_get_user_event_info(int EventCode, PAPI_event_info_t *info)
PAPI_user_defined_events_file_t events_file
int PAPI_set_opt(int option, PAPI_option_t *ptr)
int PAPI_add_events(int EventSet, int *Events, int number)
PAPI_shlib_info_t shlib_info
Return codes and api definitions.
int MPX_read(MPX_EventSet *mpx_events, long long *values, int called_by_stop)
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
#define PAPI_MAX_MPX_CTRS
PAPI_addr_range_option_t addr
#define APIDBG(format, args...)
int PAPI_add_named_event(int EventSet, const char *EventName)
int _papi_hwi_shutdown_global_threads(void)
int PAPI_set_cmp_domain(int domain, int cidx)
int PAPI_disable_component(int cidx)
int PAPI_num_cmp_hwctrs(int cidx)
void _papi_mem_cleanup_all()
int PAPI_get_thr_specific(int tag, void **ptr)
int PAPI_accum(int EventSet, long long *values)
void _papi_hwi_shutdown_highlevel()
#define PAPI_TLS_ALL_THREADS
#define PAPI_USER_EVENTS_FILE
#define PAPI_MAX_PRESET_EVENTS
#define PAPI_MAX_USER_EVENTS
int PAPI_thread_init(unsigned long int(*id_fn)(void))
int PAPI_library_init(int version)
int PAPI_profil(void *buf, unsigned bufsiz, caddr_t offset, unsigned scale, int EventSet, int EventCode, int threshold, int flags)
papi_os_vector_t _papi_os_vector
inline_static int _papi_hwi_lock(int lck)
int _papi_hwi_native_to_eventcode(int cidx, int event_code, int ntv_idx, const char *event_name)
EventSetOverflowInfo_t overflow
int PAPI_num_hwctrs(void)
#define PAPI_OVERFLOW_HARDWARE
EventSetInheritInfo_t inherit
#define PAPI_SHUTDOWN_SYNC_str
struct _CpuInfo * CpuInfo
PAPI_os_info_t _papi_os_info
DynamicArray_t global_eventset_map
struct _ThreadInfo * master
A pointer to the following is passed to PAPI_get_dmem_info()
int MPX_start(MPX_EventSet *mpx_events)
#define IS_NATIVE(EventCode)
int PAPI_get_cmp_opt(int option, PAPI_option_t *ptr, int cidx)
const PAPI_exe_info_t * PAPI_get_executable_info(void)
int PAPI_num_events(int EventSet)
int PAPI_get_opt(int option, PAPI_option_t *ptr)
long long(* get_real_cycles)(void)
int PAPI_get_component_index(const char *name)
#define OVFDBG(format, args...)
int _papi_hwi_read(hwd_context_t *context, EventSetInfo_t *ESI, long long *values)
#define PAPI_HUGE_STR_LEN
hwi_presets_t _papi_hwi_presets[PAPI_MAX_PRESET_EVENTS]
int PAPI_state(int EventSet, int *status)
int PAPI_query_named_event(const char *EventName)
inline_static int _papi_hwi_unlock(int lck)
int user_defined_events_count
PAPI_exe_info_t * exe_info
hwi_presets_t user_defined_events[PAPI_MAX_USER_EVENTS]
int MPX_cleanup(MPX_EventSet **mpx_events)
#define PAPI_PROFIL_INST_EAR
int _papi_hwi_lookup_EventCodeIndex(const EventSetInfo_t *ESI, unsigned int EventCode)
#define PAPI_MULTIPLEXING
int _papi_hwi_add_event(EventSetInfo_t *ESI, int EventCode)
int _papi_hwi_get_native_event_info(unsigned int EventCode, PAPI_event_info_t *info)
void PAPIERROR(char *format,...)
void _papi_hwi_shutdown_global_internal(void)
int _papi_hwi_get_preset_event_info(int EventCode, PAPI_event_info_t *info)
int PAPI_set_granularity(int granularity)
char name[PAPI_MAX_STR_LEN]
int _papi_hwi_error_level
int PAPI_enum_cmp_event(int *EventCode, int modifier, int cidx)
PAPI_multiplex_option_t multiplex
long long(* get_virt_cycles)(void)
void handler(int EventSet, void *address, long long overflow_vector, void *context)
inline_static int valid_ESI_component(EventSetInfo_t *ESI)
int PAPI_cleanup_eventset(int EventSet)
int mpx_init(int interval_ns)
int PAPI_assign_eventset_component(int EventSet, int cidx)
NativeInfo_t * NativeInfoArray
int PAPI_create_eventset(int *EventSet)
EventInfo_t * EventInfoArray
int PAPI_event_code_to_name(int EventCode, char *out)
papi_mdi_t _papi_hwi_system_info
int PAPI_get_dmem_info(PAPI_dmem_info_t *dest)
EventSetMultiplexInfo_t multiplex
EventSetGranularityInfo_t granularity
hwd_context_t * _papi_hwi_get_context(EventSetInfo_t *ESI, int *is_dirty)
EventSetInfo_t ** dataSlotArray
int PAPI_query_event(int EventCode)
int pos[PAPI_EVENTS_IN_DERIVED_EVENT]
PAPI_debug_handler_t handler
#define PAPI_PROFIL_RANDOM
int PAPI_get_overflow_event_index(int EventSet, long long overflow_vector, int *array, int *number)
int MPX_reset(MPX_EventSet *mpx_events)
int PAPI_multiplex_init(void)
PAPI_attach_option_t attach
void _papi_hwi_set_papi_event_code(unsigned int event_code, int update_flag)
PAPI_granularity_option_t defgranularity
PAPI_shlib_info_t * shlib_info
long long buckets[BUCKETS]
int PAPI_read_ts(int EventSet, long long *values, long long *cycles)
long long PAPI_get_real_usec(void)
#define PAPI_THREAD_LEVEL_INITED
int _papi_hwi_init_os(void)
#define PAPI_OVERFLOW_FORCE_SW
int PAPI_unregister_thread(void)
int _papi_hwi_lookup_or_create_cpu(CpuInfo_t **here, unsigned int cpu_num)
int PAPI_set_thr_specific(int tag, void *ptr)
char * PAPI_strerror(int errorCode)
int _papi_hwi_assign_eventset(EventSetInfo_t *ESI, int cidx)
int _papi_hwi_init_global(void)
inline_static int _papi_hwi_lookup_or_create_thread(ThreadInfo_t **here, int tid)
int _papi_hwi_gather_all_thrspec_data(int tag, PAPI_all_thr_spec_t *where)
PAPI_debug_option_t debug
long long PAPI_get_real_nsec(void)
int(* update_shlib_info)(papi_mdi_t *mdi)
#define PAPI_MULTIPLEX_DEFAULT
inline_static ThreadInfo_t * _papi_hwi_lookup_thread(int custom_tid)
int _papi_hwi_component_index(int event_code)
#define PAPI_PROFIL_FORCE_SW
int PAPI_set_multiplex(int EventSet)
#define PAPI_PRESET_AND_MASK
unsigned long PAPI_thread_id_t
struct papi_vectors * _papi_hwd[]
#define PAPI_PROFIL_BUCKETS
int PAPI_destroy_eventset(int *EventSet)
int PAPI_remove_named_event(int EventSet, const char *EventName)
#define PAPI_PROFIL_WEIGHTED
PAPI_domain_option_t domain
int _papi_hwi_invalid_cmp(int cidx)
int PAPI_set_domain(int domain)
void _papi_hwi_free_EventSet(EventSetInfo_t *ESI)
int PAPI_attach(int EventSet, unsigned long tid)
int _papi_hwi_eventcode_to_native(int event_code)
static int attach(hwd_control_state_t *ctl, unsigned long tid)
long long PAPI_get_real_cyc(void)
int PAPI_read(int EventSet, long long *values)
#define PAPI_LOW_LEVEL_INITED
int _papi_hwi_shutdown_thread(ThreadInfo_t *thread, int force_shutdown)
int PAPI_start(int EventSet)
EventSetProfileInfo_t profile
PAPI_preload_info_t preload
#define PAPI_PROFIL_BUCKET_64
void PAPI_perror(const char *msg)
hwd_control_state_t * ctl_state
int PAPI_get_multiplex(int EventSet)
const PAPI_hw_info_t * PAPI_get_hardware_info(void)
static long long values[NUM_EVENTS]
volatile int buf[CACHE_FLUSH_BUFFER_SIZE_INTS]
inline_static int valid_component(int cidx)
int _papi_hwi_init_global_threads(void)
int PAPI_list_threads(PAPI_thread_id_t *tids, int *number)
PAPI_itimer_option_t itimer
int PAPI_get_event_component(int EventCode)
static double b[MATRIX_SIZE][MATRIX_SIZE]
long long(* get_virt_nsec)(void)
int PAPI_set_debug(int level)
int mpx_check(int EventSet)
void _papi_hwi_map_events_to_native(EventSetInfo_t *ESI)
PAPI_domain_option_t defdomain
PAPI_overflow_handler_t handler
int _papi_hwi_native_name_to_code(const char *in, int *out)
void(* PAPI_overflow_handler_t)(int EventSet, void *address, long long overflow_vector, void *context)
static double a[MATRIX_SIZE][MATRIX_SIZE]
int _papi_hwi_create_eventset(int *EventSet, ThreadInfo_t *handle)
int PAPI_list_events(int EventSet, int *Events, int *number)
int PAPI_get_eventset_component(int EventSet)
PAPI_component_info_t * cmp_info