PAPI  5.4.1.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
The Low Level API

Functions

int PAPI_accum (int EventSet, long long *values)
 
int PAPI_add_event (int EventSet, int Event)
 
int PAPI_add_named_event (int EventSet, char *EventName)
 
int PAPI_add_events (int EventSet, int *Events, int number)
 
int PAPI_assign_eventset_component (int EventSet, int cidx)
 
int PAPI_attach (int EventSet, unsigned long tid)
 
int PAPI_cleanup_eventset (int EventSet)
 
int PAPI_create_eventset (int *EventSet)
 
int PAPI_detach (int EventSet)
 
int PAPI_destroy_eventset (int *EventSet)
 
int PAPI_enum_event (int *EventCode, int modifier)
 
int PAPI_enum_cmp_event (int *EventCode, int modifier, int cidx)
 
int PAPI_event_code_to_name (int EventCode, char *out)
 
int PAPI_event_name_to_code (char *in, int *out)
 
int PAPI_get_dmem_info (PAPI_dmem_info_t *dest)
 
int PAPI_get_event_info (int EventCode, PAPI_event_info_t *info)
 
const PAPI_exe_info_tPAPI_get_executable_info (void)
 
const PAPI_hw_info_tPAPI_get_hardware_info (void)
 
const PAPI_component_info_tPAPI_get_component_info (int cidx)
 
int PAPI_get_multiplex (int EventSet)
 
int PAPI_get_opt (int option, PAPI_option_t *ptr)
 
int PAPI_get_cmp_opt (int option, PAPI_option_t *ptr, int cidx)
 
long long PAPI_get_real_cyc (void)
 
long long PAPI_get_real_nsec (void)
 
long long PAPI_get_real_usec (void)
 
const PAPI_shlib_info_tPAPI_get_shared_lib_info (void)
 
int PAPI_get_thr_specific (int tag, void **ptr)
 
int PAPI_get_overflow_event_index (int Eventset, long long overflow_vector, int *array, int *number)
 
long long PAPI_get_virt_cyc (void)
 
long long PAPI_get_virt_nsec (void)
 
long long PAPI_get_virt_usec (void)
 
int PAPI_is_initialized (void)
 
int PAPI_library_init (int version)
 
int PAPI_list_events (int EventSet, int *Events, int *number)
 
int PAPI_list_threads (unsigned long *tids, int *number)
 
int PAPI_lock (int)
 
int PAPI_multiplex_init (void)
 
int PAPI_num_cmp_hwctrs (int cidx)
 
int PAPI_num_events (int EventSet)
 
int PAPI_overflow (int EventSet, int EventCode, int threshold, int flags, PAPI_overflow_handler_t handler)
 
void PAPI_perror (char *msg)
 
int PAPI_profil (void *buf, unsigned bufsiz, caddr_t offset, unsigned scale, int EventSet, int EventCode, int threshold, int flags)
 
int PAPI_query_event (int EventCode)
 
int PAPI_query_named_event (char *EventName)
 
int PAPI_read (int EventSet, long long *values)
 
int PAPI_read_ts (int EventSet, long long *values, long long *cyc)
 
int PAPI_register_thread (void)
 
int PAPI_remove_event (int EventSet, int EventCode)
 
int PAPI_remove_named_event (int EventSet, char *EventName)
 
int PAPI_remove_events (int EventSet, int *Events, int number)
 
int PAPI_reset (int EventSet)
 
int PAPI_set_debug (int level)
 
int PAPI_set_cmp_domain (int domain, int cidx)
 
int PAPI_set_domain (int domain)
 
int PAPI_set_cmp_granularity (int granularity, int cidx)
 
int PAPI_set_granularity (int granularity)
 
int PAPI_set_multiplex (int EventSet)
 
int PAPI_set_opt (int option, PAPI_option_t *ptr)
 
int PAPI_set_thr_specific (int tag, void *ptr)
 
void PAPI_shutdown (void)
 
int PAPI_sprofil (PAPI_sprofil_t *prof, int profcnt, int EventSet, int EventCode, int threshold, int flags)
 
int PAPI_start (int EventSet)
 
int PAPI_state (int EventSet, int *status)
 
int PAPI_stop (int EventSet, long long *values)
 
char * PAPI_strerror (int)
 
unsigned long PAPI_thread_id (void)
 
int PAPI_thread_init (unsigned long(*id_fn)(void))
 
int PAPI_unlock (int)
 
int PAPI_unregister_thread (void)
 
int PAPI_write (int EventSet, long long *values)
 
int PAPI_get_event_component (int EventCode)
 
int PAPI_get_eventset_component (int EventSet)
 
int PAPI_get_component_index (char *name)
 
int PAPI_disable_component (int cidx)
 
int PAPI_disable_component_by_name (char *name)
 

Detailed Description

Function Documentation

int PAPI_accum ( int  EventSet,
long long values 
)

accumulate and reset hardware events from an event set

Definition at line 2736 of file papi.c.

2737 {
2738  APIDBG("Entry: EventSet: %d, values: %p\n", EventSet, values);
2739  EventSetInfo_t *ESI;
2740  hwd_context_t *context;
2741  int i, cidx, retval;
2742  long long a, b, c;
2743 
2745  if ( ESI == NULL )
2747 
2748  cidx = valid_ESI_component( ESI );
2749  if ( cidx < 0 )
2750  papi_return( cidx );
2751 
2752  if ( values == NULL )
2754 
2755  if ( ESI->state & PAPI_RUNNING ) {
2756  if ( _papi_hwi_is_sw_multiplex( ESI ) ) {
2757  retval = MPX_read( ESI->multiplex.mpx_evset, ESI->sw_stop, 0 );
2758  } else {
2759  /* get the context we should use for this event set */
2760  context = _papi_hwi_get_context( ESI, NULL );
2761  retval = _papi_hwi_read( context, ESI, ESI->sw_stop );
2762  }
2763  if ( retval != PAPI_OK )
2764  papi_return( retval );
2765  }
2766 
2767  for ( i = 0; i < ESI->NumberOfEvents; i++ ) {
2768  a = ESI->sw_stop[i];
2769  b = values[i];
2770  c = a + b;
2771  values[i] = c;
2772  }
2773 
2775 }
int _papi_hwi_is_sw_multiplex(EventSetInfo_t *ESI)
int PAPI_reset(int EventSet)
Definition: papi.c:2450
#define papi_return(a)
Definition: papi.c:50
MPX_EventSet * mpx_evset
Definition: sw_multiplex.h:32
int EventSet
Definition: data_range.c:25
return PAPI_OK
Definition: linux-nvml.c:458
return PAPI_EINVAL
Definition: linux-nvml.c:408
EventSetInfo_t * _papi_hwi_lookup_EventSet(int eventset)
double c
Definition: multiplex.c:22
static double a[MATRIX_SIZE][MATRIX_SIZE]
Definition: rapl_basic.c:37
int MPX_read(MPX_EventSet *mpx_events, long long *values, int called_by_stop)
Definition: sw_multiplex.c:823
#define APIDBG(format, args...)
Definition: papi_debug.h:64
int i
Definition: fileop.c:140
#define PAPI_ENOEVST
Definition: papi.h:262
static int cidx
Definition: event_info.c:40
int _papi_hwi_read(hwd_context_t *context, EventSetInfo_t *ESI, long long *values)
inline_static int valid_ESI_component(EventSetInfo_t *ESI)
Definition: papi.c:94
EventSetMultiplexInfo_t multiplex
hwd_context_t * _papi_hwi_get_context(EventSetInfo_t *ESI, int *is_dirty)
long long * sw_stop
static double b[MATRIX_SIZE][MATRIX_SIZE]
Definition: rapl_basic.c:38
#define PAPI_RUNNING
Definition: papi.h:373
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_add_event ( int  EventSet,
int  Event 
)

add single PAPI preset or native hardware event to an event set

Definition at line 1668 of file papi.c.

1669 {
1670  APIDBG("Entry: EventSet: %d, EventCode: %#x\n", EventSet, EventCode);
1671  EventSetInfo_t *ESI;
1672 
1673  /* Is the EventSet already in existence? */
1674 
1676  if ( ESI == NULL )
1678 
1679  /* Check argument for validity */
1680 
1681  if ( ( ( EventCode & PAPI_PRESET_MASK ) == 0 ) &&
1682  ( EventCode & PAPI_NATIVE_MASK ) == 0 )
1684 
1685  /* Of course, it must be stopped in order to modify it. */
1686 
1687  if ( ESI->state & PAPI_RUNNING )
1689 
1690  /* Now do the magic. */
1691  int retval = _papi_hwi_add_event( ESI, EventCode );
1692  papi_return( retval );
1693 }
#define PAPI_NATIVE_MASK
#define papi_return(a)
Definition: papi.c:50
int EventSet
Definition: data_range.c:25
#define PAPI_PRESET_MASK
return PAPI_EINVAL
Definition: linux-nvml.c:408
EventSetInfo_t * _papi_hwi_lookup_EventSet(int eventset)
#define APIDBG(format, args...)
Definition: papi_debug.h:64
#define PAPI_ENOEVST
Definition: papi.h:262
int _papi_hwi_add_event(EventSetInfo_t *ESI, int EventCode)
#define PAPI_EISRUN
Definition: papi.h:261
#define PAPI_RUNNING
Definition: papi.h:373
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_add_events ( int  EventSet,
int Events,
int  number 
)

add array of PAPI preset or native hardware events to an event set

Definition at line 5834 of file papi.c.

5835 {
5836  APIDBG( "Entry: EventSet: %d, Events: %p, number: %d\n", EventSet, Events, number);
5837  int i, retval;
5838 
5839  if ( ( Events == NULL ) || ( number <= 0 ) )
5841 
5842  for ( i = 0; i < number; i++ ) {
5843  retval = PAPI_add_event( EventSet, Events[i] );
5844  if ( retval != PAPI_OK ) {
5845  if ( i == 0 )
5846  papi_return( retval );
5847  else
5848  return ( i );
5849  }
5850  }
5851  return ( PAPI_OK );
5852 }
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1668
static int Events[NUM_EVENTS]
Definition: init_fini.c:8
#define papi_return(a)
Definition: papi.c:50
int EventSet
Definition: data_range.c:25
return PAPI_OK
Definition: linux-nvml.c:458
return PAPI_EINVAL
Definition: linux-nvml.c:408
#define APIDBG(format, args...)
Definition: papi_debug.h:64
int i
Definition: fileop.c:140
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_add_named_event ( int  EventSet,
char *  EventName 
)

add an event by name to a PAPI event set

Definition at line 1881 of file papi.c.

1882 {
1883  APIDBG("Entry: EventSet: %d, EventName: %s\n", EventSet, EventName);
1884 
1885  int ret, code;
1886 
1887  ret = PAPI_event_name_to_code( EventName, &code );
1888  if ( ret != PAPI_OK ) {
1889  APIDBG("EXIT: return: %d\n", ret);
1890  return ret; // do not use papi_return here because if there was an error PAPI_event_name_to_code already reported it
1891  }
1892 
1893  ret = PAPI_add_event( EventSet, code );
1894  APIDBG("EXIT: return: %d\n", ret);
1895  return ret; // do not use papi_return here because if there was an error PAPI_add_event already reported it
1896 }
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1668
int EventSet
Definition: data_range.c:25
return PAPI_OK
Definition: linux-nvml.c:458
#define APIDBG(format, args...)
Definition: papi_debug.h:64
long long ret
Definition: iozone.c:1346
int PAPI_event_name_to_code(char *in, int *out)
Definition: papi.c:1013

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_assign_eventset_component ( int  EventSet,
int  cidx 
)

assign a component index to an existing but empty eventset

Definition at line 1531 of file papi.c.

1532 {
1533  EventSetInfo_t *ESI;
1534  int retval;
1535 
1537  if ( ESI == NULL )
1539 
1540 /* validate cidx */
1541  retval = valid_component( cidx );
1542  if ( retval < 0 )
1543  papi_return( retval );
1544 
1545 /* cowardly refuse to reassign eventsets */
1546  if ( ESI->CmpIdx >= 0 )
1547  return PAPI_EINVAL;
1548 
1549  return ( _papi_hwi_assign_eventset( ESI, cidx ) );
1550 }
#define papi_return(a)
Definition: papi.c:50
int EventSet
Definition: data_range.c:25
return PAPI_EINVAL
Definition: linux-nvml.c:408
EventSetInfo_t * _papi_hwi_lookup_EventSet(int eventset)
#define PAPI_ENOEVST
Definition: papi.h:262
static int cidx
Definition: event_info.c:40
int _papi_hwi_assign_eventset(EventSetInfo_t *ESI, int cidx)
ssize_t retval
Definition: libasync.c:338
inline_static int valid_component(int cidx)
Definition: papi.c:86

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_attach ( int  EventSet,
unsigned long  tid 
)

attach specified event set to a specific process or thread id

Definition at line 3192 of file papi.c.

3193 {
3194  APIDBG( "Entry: EventSet: %d, tid: %lu\n", EventSet, tid);
3195  return ( _papi_set_attach( PAPI_ATTACH, EventSet, tid ) );
3196 }
inline_static int _papi_set_attach(int option, int EventSet, unsigned long tid)
Definition: papi.c:3130
int EventSet
Definition: data_range.c:25
#define APIDBG(format, args...)
Definition: papi_debug.h:64
void *long long tid
Definition: iozone.c:18586
#define PAPI_ATTACH
Definition: papi.h:445

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_cleanup_eventset ( int  EventSet)

remove all PAPI events from an event set

Definition at line 2881 of file papi.c.

2882 {
2883  APIDBG("Entry: EventSet: %d\n",EventSet);
2884 
2885  EventSetInfo_t *ESI;
2886  int i, cidx, total, retval;
2887 
2888  /* Is the EventSet already in existence? */
2889 
2891  if ( ESI == NULL )
2893 
2894  /* if the eventset has no index and no events, return OK
2895  otherwise return NOCMP */
2896  cidx = valid_ESI_component( ESI );
2897  if ( cidx < 0 ) {
2898  if ( ESI->NumberOfEvents )
2899  papi_return( cidx );
2900  papi_return( PAPI_OK );
2901  }
2902 
2903  /* Of course, it must be stopped in order to modify it. */
2904 
2905  if ( ESI->state & PAPI_RUNNING )
2907 
2908  /* clear overflow flag and turn off hardware overflow handler */
2909  if ( ESI->state & PAPI_OVERFLOWING ) {
2910  total = ESI->overflow.event_counter;
2911  for ( i = 0; i < total; i++ ) {
2912  retval = PAPI_overflow( EventSet,
2913  ESI->overflow.EventCode[0], 0, 0, NULL );
2914  if ( retval != PAPI_OK )
2915  papi_return( retval );
2916  }
2917  }
2918 
2919  /* clear profile flag and turn off hardware profile handler */
2920  if ( ( ESI->state & PAPI_PROFILING ) &&
2921  _papi_hwd[cidx]->cmp_info.hardware_intr &&
2922  !( ESI->profile.flags & PAPI_PROFIL_FORCE_SW ) ) {
2923  total = ESI->profile.event_counter;
2924  for ( i = 0; i < total; i++ ) {
2925  retval =
2926  PAPI_sprofil( NULL, 0, EventSet, ESI->profile.EventCode[0], 0,
2928  if ( retval != PAPI_OK )
2929  papi_return( retval );
2930  }
2931  }
2932 
2933  if ( _papi_hwi_is_sw_multiplex( ESI ) ) {
2934  retval = MPX_cleanup( &ESI->multiplex.mpx_evset );
2935  if ( retval != PAPI_OK )
2936  papi_return( retval );
2937  }
2938 
2939  retval = _papi_hwd[cidx]->cleanup_eventset( ESI->ctl_state );
2940  if ( retval != PAPI_OK )
2941  papi_return( retval );
2942 
2943  /* Now do the magic */
2945 }
int _papi_hwi_is_sw_multiplex(EventSetInfo_t *ESI)
#define PAPI_OVERFLOWING
Definition: papi.h:376
int _papi_hwi_cleanup_eventset(EventSetInfo_t *ESI)
#define papi_return(a)
Definition: papi.c:50
MPX_EventSet * mpx_evset
Definition: sw_multiplex.h:32
int EventSet
Definition: data_range.c:25
return PAPI_OK
Definition: linux-nvml.c:458
int PAPI_overflow(int EventSet, int EventCode, int threshold, int flags, PAPI_overflow_handler_t handler)
Definition: papi.c:4779
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
int PAPI_sprofil(PAPI_sprofil_t *prof, int profcnt, int EventSet, int EventCode, int threshold, int flags)
Definition: papi.c:5035
EventSetInfo_t * _papi_hwi_lookup_EventSet(int eventset)
papi_vector_t * _papi_hwd[]
#define APIDBG(format, args...)
Definition: papi_debug.h:64
int i
Definition: fileop.c:140
EventSetOverflowInfo_t overflow
#define PAPI_ENOEVST
Definition: papi.h:262
static int cidx
Definition: event_info.c:40
int MPX_cleanup(MPX_EventSet **mpx_events)
#define PAPI_EISRUN
Definition: papi.h:261
inline_static int valid_ESI_component(EventSetInfo_t *ESI)
Definition: papi.c:94
unsigned int hardware_intr
Definition: papi.h:649
EventSetMultiplexInfo_t multiplex
int(* cleanup_eventset)(hwd_control_state_t *)
Definition: papi_vector.h:33
#define PAPI_PROFIL_POSIX
Definition: papi.h:394
#define PAPI_PROFILING
Definition: papi.h:377
static int total
Definition: rapl_overflow.c:5
#define PAPI_RUNNING
Definition: papi.h:373
#define PAPI_PROFIL_FORCE_SW
Definition: papi.h:401
EventSetProfileInfo_t profile
hwd_control_state_t * ctl_state
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_create_eventset ( int EventSet)

create a new empty PAPI event set

Definition at line 1469 of file papi.c.

1470 {
1471  APIDBG("Entry: EventSet: %p\n", EventSet);
1472 
1473  ThreadInfo_t *master;
1474  int retval;
1475 
1476  if ( init_level == PAPI_NOT_INITED )
1478  retval = _papi_hwi_lookup_or_create_thread( &master, 0 );
1479  if ( retval )
1480  papi_return( retval );
1481 
1483 }
#define papi_return(a)
Definition: papi.c:50
int EventSet
Definition: data_range.c:25
#define PAPI_NOT_INITED
Definition: papi.h:278
#define APIDBG(format, args...)
Definition: papi_debug.h:64
inline_static int _papi_hwi_lookup_or_create_thread(ThreadInfo_t **here, int tid)
Definition: threads.h:145
#define PAPI_ENOINIT
Definition: papi.h:267
int init_level
Definition: papi_internal.c:52
ssize_t retval
Definition: libasync.c:338
int _papi_hwi_create_eventset(int *EventSet, ThreadInfo_t *handle)

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_destroy_eventset ( int EventSet)

deallocates memory associated with an empty PAPI event set

Definition at line 2018 of file papi.c.

2019 {
2020  APIDBG("Entry: EventSet: %p, *EventSet: %d\n", EventSet, *EventSet);
2021 
2022  EventSetInfo_t *ESI;
2023 
2024  /* check for pre-existing ESI */
2025 
2026  if ( EventSet == NULL )
2028 
2030  if ( ESI == NULL )
2032 
2033  if ( !( ESI->state & PAPI_STOPPED ) )
2035 
2036  if ( ESI->NumberOfEvents )
2038 
2040  *EventSet = PAPI_NULL;
2041 
2042  return PAPI_OK;
2043 }
#define papi_return(a)
Definition: papi.c:50
#define PAPI_NULL
Definition: papi.h:290
int EventSet
Definition: data_range.c:25
int _papi_hwi_remove_EventSet(EventSetInfo_t *ESI)
return PAPI_OK
Definition: linux-nvml.c:458
return PAPI_EINVAL
Definition: linux-nvml.c:408
EventSetInfo_t * _papi_hwi_lookup_EventSet(int eventset)
#define APIDBG(format, args...)
Definition: papi_debug.h:64
#define PAPI_ENOEVST
Definition: papi.h:262
#define PAPI_EISRUN
Definition: papi.h:261
#define PAPI_STOPPED
Definition: papi.h:372

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_detach ( int  EventSet)

detach specified event set from a previously specified process or thread id

Definition at line 3249 of file papi.c.

3250 {
3251  APIDBG( "Entry: EventSet: %d\n", EventSet);
3252  return ( _papi_set_attach( PAPI_DETACH, EventSet, 0 ) );
3253 }
inline_static int _papi_set_attach(int option, int EventSet, unsigned long tid)
Definition: papi.c:3130
int EventSet
Definition: data_range.c:25
#define APIDBG(format, args...)
Definition: papi_debug.h:64
#define PAPI_DETACH
Definition: papi.h:427

Here is the call graph for this function:

Disables a component before init

Definition at line 6657 of file papi.c.

6658 {
6659  APIDBG( "Entry: cidx: %d\n", cidx);
6660 
6661  const PAPI_component_info_t *cinfo;
6662 
6663  /* Can only run before PAPI_library_init() is called */
6664  if (init_level != PAPI_NOT_INITED) {
6665  return PAPI_ENOINIT;
6666  }
6667 
6668  cinfo=PAPI_get_component_info(cidx);
6669  if (cinfo==NULL) return PAPI_ENOCMP;
6670 
6671  ((PAPI_component_info_t *)cinfo)->disabled=1;
6672  strcpy(((PAPI_component_info_t *)cinfo)->disabled_reason,
6673  "Disabled by PAPI_disable_component()");
6674 
6675  return PAPI_OK;
6676 
6677 }
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
Definition: papi.c:805
return PAPI_OK
Definition: linux-nvml.c:458
#define PAPI_NOT_INITED
Definition: papi.h:278
#define APIDBG(format, args...)
Definition: papi_debug.h:64
static int cidx
Definition: event_info.c:40
strcpy(filename, default_filename)
#define PAPI_ENOCMP
Definition: papi.h:268
#define PAPI_ENOINIT
Definition: papi.h:267
int init_level
Definition: papi_internal.c:52

Here is the call graph for this function:

Here is the caller graph for this function:

Disable, before library init, a component by name.

Definition at line 6708 of file papi.c.

6709 {
6710  APIDBG( "Entry: name: %s\n", name);
6711  int cidx;
6712 
6713  /* I can only be called before init time */
6714  if (init_level!=PAPI_NOT_INITED) {
6715  return PAPI_ENOINIT;
6716  }
6717 
6719  if (cidx>=0) {
6720  return PAPI_disable_component(cidx);
6721  }
6722 
6723  return PAPI_ENOCMP;
6724 }
#define PAPI_NOT_INITED
Definition: papi.h:278
#define APIDBG(format, args...)
Definition: papi_debug.h:64
int PAPI_disable_component(int cidx)
Definition: papi.c:6657
static int cidx
Definition: event_info.c:40
int PAPI_get_component_index(char *name)
Definition: papi.c:6601
#define PAPI_ENOCMP
Definition: papi.h:268
char * name
Definition: iozone.c:23648
#define PAPI_ENOINIT
Definition: papi.h:267
int init_level
Definition: papi_internal.c:52

Here is the call graph for this function:

int PAPI_enum_cmp_event ( int EventCode,
int  modifier,
int  cidx 
)

return the event code for the next available component event

Definition at line 1362 of file papi.c.

1363 {
1364  APIDBG( "Entry: EventCode: %#x, modifier: %d, cidx: %d\n", *EventCode, modifier, cidx);
1365  int i = *EventCode;
1366  int retval;
1367  int event_code;
1368  char *evt_name;
1369 
1370  if ( _papi_hwi_invalid_cmp(cidx) || ( (IS_PRESET(i)) && cidx > 0 ) ) {
1371  return PAPI_ENOCMP;
1372  }
1373 
1374  if (_papi_hwd[cidx]->cmp_info.disabled) {
1375  return PAPI_ENOCMP;
1376  }
1377 
1378  if ( IS_PRESET(i) ) {
1379  if ( modifier == PAPI_ENUM_FIRST ) {
1380  *EventCode = ( int ) PAPI_PRESET_MASK;
1381  APIDBG("EXIT: *EventCode: %#x\n", *EventCode);
1382  return PAPI_OK;
1383  }
1384  i &= PAPI_PRESET_AND_MASK;
1385  while ( ++i < PAPI_MAX_PRESET_EVENTS ) {
1386  if ( _papi_hwi_presets[i].symbol == NULL ) {
1387  APIDBG("EXIT: PAPI_ENOEVNT\n");
1388  return ( PAPI_ENOEVNT ); /* NULL pointer terminates list */
1389  }
1390  if ( modifier & PAPI_PRESET_ENUM_AVAIL ) {
1391  if ( _papi_hwi_presets[i].count == 0 )
1392  continue;
1393  }
1394  *EventCode = ( int ) ( i | PAPI_PRESET_MASK );
1395  APIDBG("EXIT: *EventCode: %#x\n", *EventCode);
1396  return PAPI_OK;
1397  }
1399  }
1400 
1401  if ( IS_NATIVE(i) ) {
1402  // save event code so components can get it with call to: _papi_hwi_get_papi_event_code()
1403  _papi_hwi_set_papi_event_code(*EventCode, 0);
1404 
1405  /* Should we check against num native events here? */
1406  event_code=_papi_hwi_eventcode_to_native(*EventCode);
1407  retval = _papi_hwd[cidx]->ntv_enum_events((unsigned int *)&event_code, modifier );
1408 
1409  if (retval!=PAPI_OK) {
1410  APIDBG("EXIT: PAPI_EINVAL retval=%d\n",retval);
1411  return PAPI_EINVAL;
1412  }
1413 
1414  evt_name = _papi_hwi_get_papi_event_string();
1415  *EventCode = _papi_hwi_native_to_eventcode(cidx, event_code, -1, evt_name);
1417 
1418  APIDBG("EXIT: *EventCode: %#x\n", *EventCode);
1419  return retval;
1420  }
1421 
1423 }
#define PAPI_ENOEVNT
Definition: papi.h:258
#define IS_PRESET(EventCode)
Definition: papi.h:227
char * _papi_hwi_get_papi_event_string()
#define papi_return(a)
Definition: papi.c:50
#define PAPI_MAX_PRESET_EVENTS
void _papi_hwi_free_papi_event_string()
return PAPI_OK
Definition: linux-nvml.c:458
int count
Definition: iozone.c:22422
#define PAPI_PRESET_MASK
return PAPI_EINVAL
Definition: linux-nvml.c:408
papi_vector_t * _papi_hwd[]
#define APIDBG(format, args...)
Definition: papi_debug.h:64
int i
Definition: fileop.c:140
int _papi_hwi_native_to_eventcode(int cidx, int event_code, int ntv_idx, const char *event_name)
#define IS_NATIVE(EventCode)
Definition: papi.h:226
static int cidx
Definition: event_info.c:40
hwi_presets_t _papi_hwi_presets[PAPI_MAX_PRESET_EVENTS]
#define PAPI_ENOCMP
Definition: papi.h:268
void _papi_hwi_set_papi_event_code(unsigned int event_code, int update_flag)
int(* ntv_enum_events)(unsigned int *, int)
Definition: papi_vector.h:43
int
Definition: iozone.c:18528
#define PAPI_PRESET_AND_MASK
int _papi_hwi_invalid_cmp(int cidx)
int _papi_hwi_eventcode_to_native(int event_code)
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_enum_event ( int EventCode,
int  modifier 
)

return the event code for the next available preset or natvie event

Definition at line 1161 of file papi.c.

1162 {
1163  APIDBG( "Entry: EventCode: %#x, modifier: %d\n", *EventCode, modifier);
1164  int i = *EventCode;
1165  int retval;
1166  int cidx;
1167  int event_code;
1168  char *evt_name;
1169 
1170  cidx = _papi_hwi_component_index( *EventCode );
1171  if (cidx < 0) return PAPI_ENOCMP;
1172 
1173  /* Do we handle presets in componets other than CPU? */
1174  /* if (( IS_PRESET(i) ) && cidx > 0 )) return PAPI_ENOCMP; */
1175 
1176  if ( IS_PRESET(i) ) {
1177  if ( modifier == PAPI_ENUM_FIRST ) {
1178  *EventCode = ( int ) PAPI_PRESET_MASK;
1179  APIDBG("EXIT: *EventCode: %#x\n", *EventCode);
1180  return ( PAPI_OK );
1181  }
1182  i &= PAPI_PRESET_AND_MASK;
1183  while ( ++i < PAPI_MAX_PRESET_EVENTS ) {
1184  if ( _papi_hwi_presets[i].symbol == NULL ) {
1185  APIDBG("EXIT: PAPI_ENOEVNT\n");
1186  return ( PAPI_ENOEVNT ); /* NULL pointer terminates list */
1187  }
1188  if ( modifier & PAPI_PRESET_ENUM_AVAIL ) {
1189  if ( _papi_hwi_presets[i].count == 0 )
1190  continue;
1191  }
1192  *EventCode = ( int ) ( i | PAPI_PRESET_MASK );
1193  APIDBG("EXIT: *EventCode: %#x\n", *EventCode);
1194  return ( PAPI_OK );
1195  }
1197  }
1198 
1199  if ( IS_NATIVE(i) ) {
1200  // save event code so components can get it with call to: _papi_hwi_get_papi_event_code()
1201  _papi_hwi_set_papi_event_code(*EventCode, 0);
1202 
1203  /* Should check against num native events here */
1204 
1205  event_code=_papi_hwi_eventcode_to_native((int)*EventCode);
1206  retval = _papi_hwd[cidx]->ntv_enum_events((unsigned int *)&event_code, modifier );
1207 
1208  if (retval!=PAPI_OK) {
1209  APIDBG("VMW: retval=%d\n",retval);
1210  return PAPI_EINVAL;
1211  }
1212 
1213  evt_name = _papi_hwi_get_papi_event_string();
1214  *EventCode = _papi_hwi_native_to_eventcode(cidx, event_code, -1, evt_name);
1216 
1217  APIDBG("EXIT: *EventCode: %#x\n", *EventCode);
1218  return retval;
1219  }
1220 
1221  if ( IS_USER_DEFINED(i) ) {
1222  if ( modifier == PAPI_ENUM_FIRST ) {
1223  *EventCode = (int) (0 | PAPI_UE_MASK);
1224  APIDBG("EXIT: *EventCode: %#x\n", *EventCode);
1225  return ( PAPI_OK );
1226  }
1227 
1228  i &= PAPI_UE_AND_MASK;
1229  ++i;
1230 
1231  if ( i <= 0 || i >= user_defined_events_count ) {
1232  APIDBG("EXIT: PAPI_ENOEVNT\n");
1233  return ( PAPI_ENOEVNT );
1234  }
1235 
1236  // if next entry does not have an event name, we are done
1237  if (user_defined_events[i].symbol == NULL) {
1238  APIDBG("EXIT: PAPI_ENOEVNT\n");
1239  return ( PAPI_ENOEVNT );
1240  }
1241 
1242  // if next entry does not map to any other events, we are done
1243  if (user_defined_events[i].count == 0) {
1244  APIDBG("EXIT: PAPI_ENOEVNT\n");
1245  return ( PAPI_ENOEVNT );
1246  }
1247 
1248  *EventCode = (int) (i | PAPI_UE_MASK);
1249  APIDBG("EXIT: *EventCode: %#x\n", *EventCode);
1250  return ( PAPI_OK );
1251  }
1252 
1254 }
#define PAPI_ENOEVNT
Definition: papi.h:258
#define IS_PRESET(EventCode)
Definition: papi.h:227
char * _papi_hwi_get_papi_event_string()
#define IS_USER_DEFINED(EventCode)
Definition: papi.h:228
#define PAPI_UE_AND_MASK
#define papi_return(a)
Definition: papi.c:50
#define PAPI_MAX_PRESET_EVENTS
void _papi_hwi_free_papi_event_string()
return PAPI_OK
Definition: linux-nvml.c:458
int count
Definition: iozone.c:22422
#define PAPI_PRESET_MASK
return PAPI_EINVAL
Definition: linux-nvml.c:408
papi_vector_t * _papi_hwd[]
#define APIDBG(format, args...)
Definition: papi_debug.h:64
int i
Definition: fileop.c:140
int _papi_hwi_native_to_eventcode(int cidx, int event_code, int ntv_idx, const char *event_name)
#define IS_NATIVE(EventCode)
Definition: papi.h:226
static int cidx
Definition: event_info.c:40
hwi_presets_t _papi_hwi_presets[PAPI_MAX_PRESET_EVENTS]
int user_defined_events_count
Definition: papi_internal.c:59
hwi_presets_t user_defined_events[PAPI_MAX_USER_EVENTS]
Definition: papi_internal.c:58
#define PAPI_ENOCMP
Definition: papi.h:268
void _papi_hwi_set_papi_event_code(unsigned int event_code, int update_flag)
int(* ntv_enum_events)(unsigned int *, int)
Definition: papi_vector.h:43
int
Definition: iozone.c:18528
int _papi_hwi_component_index(int event_code)
#define PAPI_PRESET_AND_MASK
int _papi_hwi_eventcode_to_native(int event_code)
#define PAPI_UE_MASK
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_event_code_to_name ( int  EventCode,
char *  out 
)

translate an integer PAPI event code into an ASCII PAPI preset or native name

Definition at line 924 of file papi.c.

925 {
926  APIDBG( "Entry: EventCode: %#x, out: %p\n", EventCode, out);
927  if ( out == NULL )
929 
930  if ( IS_PRESET(EventCode) ) {
931  EventCode &= PAPI_PRESET_AND_MASK;
932  if ( EventCode < 0 || EventCode >= PAPI_MAX_PRESET_EVENTS )
934 
935  if (_papi_hwi_presets[EventCode].symbol == NULL )
937 
938  strncpy( out, _papi_hwi_presets[EventCode].symbol, PAPI_MAX_STR_LEN-1 );
939  out[PAPI_MAX_STR_LEN-1] = '\0';
940  papi_return( PAPI_OK );
941  }
942 
943  if ( IS_NATIVE(EventCode) ) {
945  ( ( unsigned int ) EventCode, out, PAPI_MAX_STR_LEN ) );
946  }
947 
948  if ( IS_USER_DEFINED(EventCode) ) {
949  EventCode &= PAPI_UE_AND_MASK;
950 
951  if ( EventCode < 0 || EventCode >= user_defined_events_count )
953 
954  if (user_defined_events[EventCode].symbol == NULL )
956 
957  strncpy( out, user_defined_events[EventCode].symbol, PAPI_MAX_STR_LEN-1);
958  out[PAPI_MAX_STR_LEN-1] = '\0';
959  papi_return( PAPI_OK );
960  }
961 
963 }
#define PAPI_ENOEVNT
Definition: papi.h:258
#define IS_PRESET(EventCode)
Definition: papi.h:227
#define IS_USER_DEFINED(EventCode)
Definition: papi.h:228
#define PAPI_UE_AND_MASK
#define papi_return(a)
Definition: papi.c:50
#define PAPI_MAX_PRESET_EVENTS
int _papi_hwi_native_code_to_name(unsigned int EventCode, char *hwi_name, int len)
return PAPI_OK
Definition: linux-nvml.c:458
return PAPI_EINVAL
Definition: linux-nvml.c:408
#define PAPI_ENOTPRESET
Definition: papi.h:263
#define APIDBG(format, args...)
Definition: papi_debug.h:64
#define IS_NATIVE(EventCode)
Definition: papi.h:226
hwi_presets_t _papi_hwi_presets[PAPI_MAX_PRESET_EVENTS]
int user_defined_events_count
Definition: papi_internal.c:59
hwi_presets_t user_defined_events[PAPI_MAX_USER_EVENTS]
Definition: papi_internal.c:58
goto out
Definition: pscanf.h:20
#define PAPI_PRESET_AND_MASK
#define PAPI_MAX_STR_LEN
Definition: papi.h:463

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_event_name_to_code ( char *  in,
int out 
)

translate an ASCII PAPI preset or native name into an integer PAPI event code

Definition at line 1013 of file papi.c.

1014 {
1015  APIDBG("Entry: in: %p, name: %s, out: %p\n", in, in, out);
1016  int i;
1017 
1018  if ( ( in == NULL ) || ( out == NULL ) )
1020 
1021  if ( init_level == PAPI_NOT_INITED )
1023 
1024  /* All presets start with "PAPI_" so no need to */
1025  /* do an exhaustive search if that's not there */
1026  if (strncmp(in, "PAPI_", 5) == 0) {
1027  for(i = 0; i < PAPI_MAX_PRESET_EVENTS; i++ ) {
1028  if ( ( _papi_hwi_presets[i].symbol )
1029  && ( strcasecmp( _papi_hwi_presets[i].symbol, in ) == 0) ) {
1030  *out = ( int ) ( i | PAPI_PRESET_MASK );
1031  papi_return( PAPI_OK );
1032  }
1033  }
1034  }
1035 
1036  // check to see if it is a user defined event
1037  for ( i=0; i < user_defined_events_count ; i++ ) {
1038  APIDBG("&user_defined_events[%d]: %p, user_defined_events[%d].symbol: %s, user_defined_events[%d].count: %d\n",
1040  if (user_defined_events[i].symbol == NULL)
1041  break;
1042  if (user_defined_events[i].count == 0)
1043  break;
1044  if ( strcasecmp( user_defined_events[i].symbol, in ) == 0 ) {
1045  *out = (int) ( i | PAPI_UE_MASK );
1046  papi_return( PAPI_OK );
1047  }
1048  }
1049 
1050  // go look for native events defined by one of the components
1052 }
#define papi_return(a)
Definition: papi.c:50
#define PAPI_MAX_PRESET_EVENTS
return PAPI_OK
Definition: linux-nvml.c:458
int count
Definition: iozone.c:22422
#define PAPI_PRESET_MASK
return PAPI_EINVAL
Definition: linux-nvml.c:408
#define PAPI_NOT_INITED
Definition: papi.h:278
int _papi_hwi_native_name_to_code(char *in, int *out)
#define APIDBG(format, args...)
Definition: papi_debug.h:64
int i
Definition: fileop.c:140
hwi_presets_t _papi_hwi_presets[PAPI_MAX_PRESET_EVENTS]
int user_defined_events_count
Definition: papi_internal.c:59
hwi_presets_t user_defined_events[PAPI_MAX_USER_EVENTS]
Definition: papi_internal.c:58
goto out
Definition: pscanf.h:20
int
Definition: iozone.c:18528
#define PAPI_ENOINIT
Definition: papi.h:267
int init_level
Definition: papi_internal.c:52
#define PAPI_UE_MASK

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_get_cmp_opt ( int  option,
PAPI_option_t ptr,
int  cidx 
)

query the component specific option settings of a specific event set

Definition at line 4326 of file papi.c.

4327 {
4328  APIDBG( "Entry: option: %d, ptr: %p, cidx: %d\n", option, ptr, cidx);
4329 
4330  if (_papi_hwi_invalid_cmp(cidx)) {
4331  return PAPI_ECMP;
4332  }
4333 
4334  switch ( option ) {
4335  /* For now, MAX_HWCTRS and MAX CTRS are identical.
4336  At some future point, they may map onto different values.
4337  */
4338  case PAPI_MAX_HWCTRS:
4339  return ( _papi_hwd[cidx]->cmp_info.num_cntrs );
4340  case PAPI_MAX_MPX_CTRS:
4341  return ( _papi_hwd[cidx]->cmp_info.num_mpx_cntrs );
4342  case PAPI_DEFDOM:
4343  return ( _papi_hwd[cidx]->cmp_info.default_domain );
4344  case PAPI_DEFGRN:
4345  return ( _papi_hwd[cidx]->cmp_info.default_granularity );
4346  case PAPI_SHLIBINFO:
4347  {
4348  int retval;
4349  if ( ptr == NULL )
4353  papi_return( retval );
4354  }
4355  case PAPI_COMPONENTINFO:
4356  if ( ptr == NULL )
4358  ptr->cmp_info = &( _papi_hwd[cidx]->cmp_info );
4359  return PAPI_OK;
4360  default:
4362  }
4363  return PAPI_OK;
4364 }
#define papi_return(a)
Definition: papi.c:50
int(* update_shlib_info)(papi_mdi_t *mdi)
Definition: papi_vector.h:67
return PAPI_OK
Definition: linux-nvml.c:458
return PAPI_EINVAL
Definition: linux-nvml.c:408
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
papi_vector_t * _papi_hwd[]
PAPI_shlib_info_t shlib_info
#define APIDBG(format, args...)
Definition: papi_debug.h:64
papi_os_vector_t _papi_os_vector
Definition: aix.c:1288
static int cidx
Definition: event_info.c:40
#define PAPI_DEFGRN
Definition: papi.h:432
#define PAPI_ECMP
Definition: papi.h:254
#define PAPI_MAX_MPX_CTRS
Definition: papi.h:437
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:55
#define PAPI_COMPONENTINFO
Definition: papi.h:448
#define PAPI_MAX_HWCTRS
Definition: papi.h:441
#define PAPI_DEFDOM
Definition: papi.h:430
int _papi_hwi_invalid_cmp(int cidx)
PAPI_shlib_info_t * shlib_info
Definition: papi.h:859
ssize_t retval
Definition: libasync.c:338
PAPI_component_info_t * cmp_info
Definition: papi.h:861
#define PAPI_SHLIBINFO
Definition: papi.h:446

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_get_component_index ( char *  name)

Return component index for component with matching name

Definition at line 6601 of file papi.c.

6602 {
6603  APIDBG( "Entry: name: %s\n", name);
6604  int cidx;
6605 
6606  const PAPI_component_info_t *cinfo;
6607 
6608  for(cidx=0;cidx<papi_num_components;cidx++) {
6609 
6610  cinfo=PAPI_get_component_info(cidx);
6611  if (cinfo==NULL) return PAPI_ENOCMP;
6612 
6613  if (!strcmp(name,cinfo->name)) {
6614  return cidx;
6615  }
6616  }
6617 
6618  return PAPI_ENOCMP;
6619 }
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:626
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
Definition: papi.c:805
#define APIDBG(format, args...)
Definition: papi_debug.h:64
static int cidx
Definition: event_info.c:40
#define PAPI_ENOCMP
Definition: papi.h:268
int papi_num_components
char * name
Definition: iozone.c:23648

Here is the call graph for this function:

Here is the caller graph for this function:

get information about the component features

Definition at line 805 of file papi.c.

806 {
807  APIDBG( "Entry: Component Index %d\n", cidx);
808  if ( _papi_hwi_invalid_cmp( cidx ) )
809  return ( NULL );
810  else
811  return ( &( _papi_hwd[cidx]->cmp_info ) );
812 }
papi_vector_t * _papi_hwd[]
#define APIDBG(format, args...)
Definition: papi_debug.h:64
static int cidx
Definition: event_info.c:40
int _papi_hwi_invalid_cmp(int cidx)

Here is the call graph for this function:

Here is the caller graph for this function:

get dynamic memory usage information

Definition at line 6054 of file papi.c.

6055 {
6056  if ( dest == NULL )
6057  return PAPI_EINVAL;
6058 
6059  memset( ( void * ) dest, 0x0, sizeof ( PAPI_dmem_info_t ) );
6060  return ( _papi_os_vector.get_dmem_info( dest ) );
6061 }
return PAPI_EINVAL
Definition: linux-nvml.c:408
papi_os_vector_t _papi_os_vector
Definition: aix.c:1288
A pointer to the following is passed to PAPI_get_dmem_info()
Definition: papi.h:868
int(* get_dmem_info)(PAPI_dmem_info_t *)
Definition: papi_vector.h:70

Here is the caller graph for this function:

return which component an EventCode belongs to

Definition at line 6574 of file papi.c.

6575 {
6576  APIDBG( "Entry: EventCode: %#x\n", EventCode);
6577  return _papi_hwi_component_index( EventCode);
6578 }
#define APIDBG(format, args...)
Definition: papi_debug.h:64
int _papi_hwi_component_index(int event_code)

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_get_event_info ( int  EventCode,
PAPI_event_info_t info 
)

get the name and descriptions for a given preset or native event code

Definition at line 844 of file papi.c.

845 {
846  APIDBG( "Entry: EventCode: 0x%x, info: %p\n", EventCode, info);
847  int i;
848 
849  if ( info == NULL )
851 
852  if ( IS_PRESET(EventCode) ) {
853  i = EventCode & PAPI_PRESET_AND_MASK;
854  if ( i >= PAPI_MAX_PRESET_EVENTS )
856  papi_return( _papi_hwi_get_preset_event_info( EventCode, info ) );
857  }
858 
859  if ( IS_NATIVE(EventCode) ) {
861  ( ( unsigned int ) EventCode, info ) );
862  }
863 
864  if ( IS_USER_DEFINED(EventCode) ) {
865  papi_return( _papi_hwi_get_user_event_info( EventCode, info ));
866  }
868 }
#define IS_PRESET(EventCode)
Definition: papi.h:227
#define IS_USER_DEFINED(EventCode)
Definition: papi.h:228
#define papi_return(a)
Definition: papi.c:50
#define PAPI_MAX_PRESET_EVENTS
return PAPI_EINVAL
Definition: linux-nvml.c:408
int _papi_hwi_get_user_event_info(int EventCode, PAPI_event_info_t *info)
#define PAPI_ENOTPRESET
Definition: papi.h:263
#define APIDBG(format, args...)
Definition: papi_debug.h:64
int i
Definition: fileop.c:140
#define IS_NATIVE(EventCode)
Definition: papi.h:226
int _papi_hwi_get_native_event_info(unsigned int EventCode, PAPI_event_info_t *info)
int _papi_hwi_get_preset_event_info(int EventCode, PAPI_event_info_t *info)
#define PAPI_PRESET_AND_MASK

Here is the call graph for this function:

Here is the caller graph for this function:

return which component an EventSet is assigned to

Definition at line 1574 of file papi.c.

1575 {
1576  EventSetInfo_t *ESI;
1577  int retval;
1578 
1579 /* validate eventset */
1581  if ( ESI == NULL )
1583 
1584 /* check if a component has been assigned */
1585  if ( ESI->CmpIdx < 0 )
1587 
1588 /* validate CmpIdx */
1589  retval = valid_component( ESI->CmpIdx );
1590  if ( retval < 0 )
1591  papi_return( retval );
1592 
1593 /* return the index */
1594  return ( ESI->CmpIdx );
1595 }
#define papi_return(a)
Definition: papi.c:50
int EventSet
Definition: data_range.c:25
EventSetInfo_t * _papi_hwi_lookup_EventSet(int eventset)
#define PAPI_ENOEVST
Definition: papi.h:262
#define PAPI_ENOCMP
Definition: papi.h:268
ssize_t retval
Definition: libasync.c:338
inline_static int valid_component(int cidx)
Definition: papi.c:86

Here is the call graph for this function:

get the executable's address space information

Definition at line 6105 of file papi.c.

6106 {
6108  int retval;
6109 
6110  memset( &ptr, 0, sizeof ( ptr ) );
6111  retval = PAPI_get_opt( PAPI_EXEINFO, &ptr );
6112  if ( retval == PAPI_OK )
6113  return ( ptr.exe_info );
6114  else
6115  return ( NULL );
6116 }
return PAPI_OK
Definition: linux-nvml.c:458
A pointer to the following is passed to PAPI_set/get_opt()
Definition: papi.h:845
int PAPI_get_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:4134
#define PAPI_EXEINFO
Definition: papi.h:443
PAPI_exe_info_t * exe_info
Definition: papi.h:860
ssize_t retval
Definition: libasync.c:338
char * ptr
Definition: iozone.c:23586

Here is the call graph for this function:

Here is the caller graph for this function:

get information about the system hardware

Definition at line 6176 of file papi.c.

6177 {
6179  int retval;
6180 
6181  memset( &ptr, 0, sizeof ( ptr ) );
6182  retval = PAPI_get_opt( PAPI_HWINFO, &ptr );
6183  if ( retval == PAPI_OK )
6184  return ( ptr.hw_info );
6185  else
6186  return ( NULL );
6187 }
return PAPI_OK
Definition: linux-nvml.c:458
A pointer to the following is passed to PAPI_set/get_opt()
Definition: papi.h:845
PAPI_hw_info_t * hw_info
Definition: papi.h:858
int PAPI_get_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:4134
#define PAPI_HWINFO
Definition: papi.h:442
ssize_t retval
Definition: libasync.c:338
char * ptr
Definition: iozone.c:23586

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_get_multiplex ( int  EventSet)

get the multiplexing status of specified event set

Definition at line 4019 of file papi.c.

4020 {
4021  APIDBG( "Entry: EventSet: %d\n", EventSet);
4022  PAPI_option_t popt;
4023  int retval;
4024 
4025  popt.multiplex.eventset = EventSet;
4026  retval = PAPI_get_opt( PAPI_MULTIPLEX, &popt );
4027  if ( retval < 0 )
4028  retval = 0;
4029  return retval;
4030 }
int EventSet
Definition: data_range.c:25
A pointer to the following is passed to PAPI_set/get_opt()
Definition: papi.h:845
#define APIDBG(format, args...)
Definition: papi_debug.h:64
int PAPI_get_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:4134
PAPI_multiplex_option_t multiplex
Definition: papi.h:856
#define PAPI_MULTIPLEX
Definition: papi.h:429
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_get_opt ( int  option,
PAPI_option_t ptr 
)

query the option settings of the PAPI library or a specific event set

Definition at line 4134 of file papi.c.

4135 {
4136  APIDBG( "Entry: option: %d, ptr: %p\n", option, ptr);
4137  EventSetInfo_t *ESI;
4138 
4139  if ( ( option != PAPI_DEBUG ) && ( init_level == PAPI_NOT_INITED ) )
4141 
4142  switch ( option ) {
4143  case PAPI_DETACH:
4144  {
4145  if ( ptr == NULL )
4148  if ( ESI == NULL )
4150  ptr->attach.tid = ESI->attach.tid;
4151  return ( ( ESI->state & PAPI_ATTACHED ) == 0 );
4152  }
4153  case PAPI_ATTACH:
4154  {
4155  if ( ptr == NULL )
4158  if ( ESI == NULL )
4160  ptr->attach.tid = ESI->attach.tid;
4161  return ( ( ESI->state & PAPI_ATTACHED ) != 0 );
4162  }
4163  case PAPI_CPU_ATTACH:
4164  {
4165  if ( ptr == NULL )
4168  if ( ESI == NULL )
4170  ptr->cpu.cpu_num = ESI->CpuInfo->cpu_num;
4171  return ( ( ESI->state & PAPI_CPU_ATTACHED ) != 0 );
4172  }
4173  case PAPI_DEF_MPX_NS:
4174  {
4175  /* xxxx for now, assume we only check against cpu component */
4176  if ( ptr == NULL )
4179  return ( PAPI_OK );
4180  }
4181  case PAPI_DEF_ITIMER_NS:
4182  {
4183  /* xxxx for now, assume we only check against cpu component */
4184  if ( ptr == NULL )
4187  return ( PAPI_OK );
4188  }
4189  case PAPI_DEF_ITIMER:
4190  {
4191  /* xxxx for now, assume we only check against cpu component */
4192  if ( ptr == NULL )
4197  ptr->itimer.flags = 0;
4198  return ( PAPI_OK );
4199  }
4200  case PAPI_MULTIPLEX:
4201  {
4202  if ( ptr == NULL )
4205  if ( ESI == NULL )
4207  ptr->multiplex.ns = ESI->multiplex.ns;
4208  ptr->multiplex.flags = ESI->multiplex.flags;
4209  return ( ESI->state & PAPI_MULTIPLEXING ) != 0;
4210  }
4211  case PAPI_PRELOAD:
4212  if ( ptr == NULL )
4214  memcpy( &ptr->preload, &_papi_hwi_system_info.preload_info,
4216  break;
4217  case PAPI_DEBUG:
4218  if ( ptr == NULL )
4222  break;
4223  case PAPI_CLOCKRATE:
4224  return ( ( int ) _papi_hwi_system_info.hw_info.cpu_max_mhz );
4225  case PAPI_MAX_CPUS:
4226  return ( _papi_hwi_system_info.hw_info.ncpu );
4227  /* For now, MAX_HWCTRS and MAX CTRS are identical.
4228  At some future point, they may map onto different values.
4229  */
4230  case PAPI_INHERIT:
4231  {
4232  if ( ptr == NULL )
4235  if ( ESI == NULL )
4237  ptr->inherit.inherit = ESI->inherit.inherit;
4238  return ( PAPI_OK );
4239  }
4240  case PAPI_GRANUL:
4241  if ( ptr == NULL )
4244  if ( ESI == NULL )
4247  break;
4248  case PAPI_EXEINFO:
4249  if ( ptr == NULL )
4252  break;
4253  case PAPI_HWINFO:
4254  if ( ptr == NULL )
4257  break;
4258 
4259  case PAPI_DOMAIN:
4260  if ( ptr == NULL )
4263  if ( ESI == NULL )
4265  ptr->domain.domain = ESI->domain.domain;
4266  return ( PAPI_OK );
4267  case PAPI_LIB_VERSION:
4268  return ( PAPI_VERSION );
4269 /* The following cases all require a component index
4270  and are handled by PAPI_get_cmp_opt() with cidx == 0*/
4271  case PAPI_MAX_HWCTRS:
4272  case PAPI_MAX_MPX_CTRS:
4273  case PAPI_DEFDOM:
4274  case PAPI_DEFGRN:
4275  case PAPI_SHLIBINFO:
4276  case PAPI_COMPONENTINFO:
4277  return ( PAPI_get_cmp_opt( option, ptr, 0 ) );
4278  default:
4280  }
4281  return ( PAPI_OK );
4282 }
#define PAPI_ATTACHED
Definition: papi.h:379
#define PAPI_CPU_ATTACH
Definition: papi.h:455
#define PAPI_DEF_ITIMER_NS
Definition: papi.h:453
#define papi_return(a)
Definition: papi.c:50
#define PAPI_DEF_MPX_NS
Definition: papi.h:434
PAPI_debug_handler_t _papi_hwi_debug_handler
Definition: papi_internal.c:54
EventSetAttachInfo_t attach
PAPI_granularity_option_t granularity
Definition: papi.h:850
#define PAPI_MULTIPLEXING
Definition: papi.h:378
EventSetDomainInfo_t domain
return PAPI_OK
Definition: linux-nvml.c:458
PAPI_inherit_option_t inherit
Definition: papi.h:849
PAPI_preload_info_t preload_info
PAPI_exe_info_t exe_info
return PAPI_EINVAL
Definition: linux-nvml.c:408
#define PAPI_NOT_INITED
Definition: papi.h:278
EventSetInfo_t * _papi_hwi_lookup_EventSet(int eventset)
PAPI_hw_info_t * hw_info
Definition: papi.h:858
unsigned int cpu_num
Definition: papi.h:821
#define PAPI_INHERIT
Definition: papi.h:456
#define PAPI_PRELOAD
Definition: papi.h:439
#define PAPI_CPU_ATTACHED
Definition: papi.h:380
#define APIDBG(format, args...)
Definition: papi_debug.h:64
EventSetInheritInfo_t inherit
struct _CpuInfo * CpuInfo
PAPI_os_info_t _papi_os_info
Definition: aix.c:1210
#define PAPI_ENOEVST
Definition: papi.h:262
#define PAPI_LIB_VERSION
Definition: papi.h:447
int PAPI_get_cmp_opt(int option, PAPI_option_t *ptr, int cidx)
Definition: papi.c:4326
#define PAPI_EXEINFO
Definition: papi.h:443
#define PAPI_GRANUL
Definition: papi.h:433
#define PAPI_MAX_CPUS
Definition: papi.h:444
#define PAPI_DEFGRN
Definition: papi.h:432
#define PAPI_DETACH
Definition: papi.h:427
PAPI_cpu_option_t cpu
Definition: papi.h:855
#define PAPI_ATTACH
Definition: papi.h:445
#define PAPI_MAX_MPX_CTRS
Definition: papi.h:437
int _papi_hwi_error_level
Definition: papi_internal.c:53
PAPI_multiplex_option_t multiplex
Definition: papi.h:856
#define PAPI_MULTIPLEX
Definition: papi.h:429
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:55
PAPI_hw_info_t hw_info
again struct sockaddr sizeof(struct sockaddr_in))
#define PAPI_DOMAIN
Definition: papi.h:431
EventSetMultiplexInfo_t multiplex
EventSetGranularityInfo_t granularity
#define PAPI_COMPONENTINFO
Definition: papi.h:448
PAPI_debug_handler_t handler
Definition: papi.h:687
unsigned long tid
Definition: papi.h:815
PAPI_attach_option_t attach
Definition: papi.h:854
PAPI_exe_info_t * exe_info
Definition: papi.h:860
#define PAPI_DEF_ITIMER
Definition: papi.h:452
#define PAPI_VERSION
Definition: papi.h:222
#define PAPI_HWINFO
Definition: papi.h:442
#define PAPI_CLOCKRATE
Definition: papi.h:440
PAPI_debug_option_t debug
Definition: papi.h:848
int cpu_max_mhz
Definition: papi.h:793
#define PAPI_MAX_HWCTRS
Definition: papi.h:441
#define PAPI_DEFDOM
Definition: papi.h:430
#define PAPI_ENOINIT
Definition: papi.h:267
PAPI_domain_option_t domain
Definition: papi.h:852
PAPI_preload_info_t preload
Definition: papi.h:847
int init_level
Definition: papi_internal.c:52
PAPI_itimer_option_t itimer
Definition: papi.h:857
#define PAPI_DEBUG
Definition: papi.h:428
int ncpu
Definition: papi.h:778
#define PAPI_SHLIBINFO
Definition: papi.h:446

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_get_overflow_event_index ( int  Eventset,
long long  overflow_vector,
int array,
int number 
)

decomposes an overflow_vector into an event index array

Definition at line 6508 of file papi.c.

6510 {
6511  APIDBG( "Entry: EventSet: %d, overflow_vector: %lld, array: %p, number: %p\n", EventSet, overflow_vector, array, number);
6512  EventSetInfo_t *ESI;
6513  int set_bit, j, pos;
6514  int count = 0, k;
6515 
6516  if ( overflow_vector == ( long long ) 0 )
6518 
6519  if ( ( array == NULL ) || ( number == NULL ) )
6521 
6522  if ( *number < 1 )
6524 
6526  if ( ESI == NULL )
6528 
6529  /* in case the eventset is empty */
6530  if ( ESI->NumberOfEvents == 0 )
6532 
6533  while ( ( set_bit = ffsll( overflow_vector ) ) ) {
6534  set_bit -= 1;
6535  overflow_vector ^= ( long long ) 1 << set_bit;
6536  for ( j = 0; j < ESI->NumberOfEvents; j++ ) {
6537  for ( k = 0, pos = 0; k < PAPI_EVENTS_IN_DERIVED_EVENT && pos >= 0; k++ ) {
6538  pos = ESI->EventInfoArray[j].pos[k];
6539  if ( ( set_bit == pos ) &&
6540  ( ( ESI->EventInfoArray[j].derived == NOT_DERIVED ) ||
6541  ( ESI->EventInfoArray[j].derived == DERIVED_CMPD ) ) ) {
6542  array[count++] = j;
6543  if ( count == *number )
6544  return PAPI_OK;
6545 
6546  break;
6547  }
6548  }
6549  }
6550  }
6551  *number = count;
6552  return PAPI_OK;
6553 }
#define papi_return(a)
Definition: papi.c:50
int EventSet
Definition: data_range.c:25
return PAPI_OK
Definition: linux-nvml.c:458
int count
Definition: iozone.c:22422
return PAPI_EINVAL
Definition: linux-nvml.c:408
EventSetInfo_t * _papi_hwi_lookup_EventSet(int eventset)
#define DERIVED_CMPD
Definition: papi_internal.h:73
#define APIDBG(format, args...)
Definition: papi_debug.h:64
#define PAPI_ENOEVST
Definition: papi.h:262
#define NOT_DERIVED
Definition: papi_internal.h:69
int ffsll(long long lli)
Definition: extras.c:497
int k
Definition: iozone.c:19136
long long
Definition: iozone.c:19827
EventInfo_t * EventInfoArray
int pos[PAPI_EVENTS_IN_DERIVED_EVENT]
long j
Definition: iozone.c:19135

Here is the call graph for this function:

Here is the caller graph for this function:

return the total number of cycles since some arbitrary starting point

Definition at line 6208 of file papi.c.

6209 {
6210  return ( _papi_os_vector.get_real_cycles( ) );
6211 }
long long(* get_real_cycles)(void)
Definition: papi_vector.h:61
papi_os_vector_t _papi_os_vector
Definition: aix.c:1288

Here is the caller graph for this function:

return the total number of nanoseconds since some arbitrary starting point

Definition at line 6228 of file papi.c.

6229 {
6230  return ( ( _papi_os_vector.get_real_nsec( )));
6231 
6232 }
long long(* get_real_nsec)(void)
Definition: papi_vector.h:65
papi_os_vector_t _papi_os_vector
Definition: aix.c:1288

Here is the caller graph for this function:

return the total number of microseconds since some arbitrary starting point

Definition at line 6255 of file papi.c.

6256 {
6257  return ( _papi_os_vector.get_real_usec( ) );
6258 }
long long(* get_real_usec)(void)
Definition: papi_vector.h:63
papi_os_vector_t _papi_os_vector
Definition: aix.c:1288

Here is the caller graph for this function:

get information about the shared libraries used by the process

Definition at line 6135 of file papi.c.

6136 {
6138  int retval;
6139 
6140  memset( &ptr, 0, sizeof ( ptr ) );
6141  retval = PAPI_get_opt( PAPI_SHLIBINFO, &ptr );
6142  if ( retval == PAPI_OK )
6143  return ( ptr.shlib_info );
6144  else
6145  return ( NULL );
6146 }
return PAPI_OK
Definition: linux-nvml.c:458
A pointer to the following is passed to PAPI_set/get_opt()
Definition: papi.h:845
int PAPI_get_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:4134
PAPI_shlib_info_t * shlib_info
Definition: papi.h:859
ssize_t retval
Definition: libasync.c:338
char * ptr
Definition: iozone.c:23586
#define PAPI_SHLIBINFO
Definition: papi.h:446

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_get_thr_specific ( int  tag,
void **  ptr 
)

return a pointer to a thread specific stored data structure

Definition at line 362 of file papi.c.

363 {
365  int doall = 0, retval = PAPI_OK;
366 
367  if ( init_level == PAPI_NOT_INITED )
369  if ( tag & PAPI_TLS_ALL_THREADS ) {
370  tag = tag ^ PAPI_TLS_ALL_THREADS;
371  doall = 1;
372  }
373  if ( ( tag < 0 ) || ( tag > PAPI_TLS_NUM ) )
375 
376  if ( doall )
378  ( tag, ( PAPI_all_thr_spec_t * ) ptr ) );
379 
381  if ( retval == PAPI_OK )
382  *ptr = thread->thread_storage[tag];
383  else
384  papi_return( retval );
385 
386  return ( PAPI_OK );
387 }
#define papi_return(a)
Definition: papi.c:50
#define PAPI_TLS_NUM
Definition: papi.h:324
return PAPI_OK
Definition: linux-nvml.c:458
return PAPI_EINVAL
Definition: linux-nvml.c:408
#define PAPI_NOT_INITED
Definition: papi.h:278
void * thread_storage[PAPI_MAX_TLS]
Definition: threads.h:29
#define PAPI_TLS_ALL_THREADS
Definition: papi.h:325
void * thread(void *arg)
Definition: kufrin.c:31
inline_static int _papi_hwi_lookup_or_create_thread(ThreadInfo_t **here, int tid)
Definition: threads.h:145
int _papi_hwi_gather_all_thrspec_data(int tag, PAPI_all_thr_spec_t *where)
Definition: threads.c:554
#define PAPI_ENOINIT
Definition: papi.h:267
int init_level
Definition: papi_internal.c:52
ssize_t retval
Definition: libasync.c:338
char * ptr
Definition: iozone.c:23586

Here is the call graph for this function:

Here is the caller graph for this function:

return the process cycles since some arbitrary starting point

Definition at line 6291 of file papi.c.

6292 {
6293 
6294  return ( ( long long ) _papi_os_vector.get_virt_cycles( ) );
6295 }
papi_os_vector_t _papi_os_vector
Definition: aix.c:1288
long long(* get_virt_cycles)(void)
Definition: papi_vector.h:62

Here is the caller graph for this function:

return the process nanoseconds since some arbitrary starting point

Definition at line 6321 of file papi.c.

6322 {
6323 
6324  return ( ( _papi_os_vector.get_virt_nsec()));
6325 
6326 }
papi_os_vector_t _papi_os_vector
Definition: aix.c:1288
long long(* get_virt_nsec)(void)
Definition: papi_vector.h:66

return the process microseconds since some arbitrary starting point

Definition at line 6363 of file papi.c.

6364 {
6365 
6366  return ( ( long long ) _papi_os_vector.get_virt_usec() );
6367 }
long long(* get_virt_usec)(void)
Definition: papi_vector.h:64
papi_os_vector_t _papi_os_vector
Definition: aix.c:1288

Here is the caller graph for this function:

return the initialized state of the PAPI library

Definition at line 6454 of file papi.c.

6455 {
6456  return ( init_level );
6457 }
int init_level
Definition: papi_internal.c:52

Here is the caller graph for this function:

int PAPI_library_init ( int  version)

initialize the PAPI library

Definition at line 500 of file papi.c.

501 {
502  APIDBG( "Entry: version: %#x\n", version);
503 
504  int tmp = 0, tmpel;
505 
506  /* This is a poor attempt at a lock.
507  For 3.1 this should be replaced with a
508  true UNIX semaphore. We cannot use PAPI
509  locks here because they are not initialized yet */
510  static int _in_papi_library_init_cnt = 0;
511 #ifdef DEBUG
512  char *var;
513 #endif
515 
516  if ( version != PAPI_VER_CURRENT )
518 
519  ++_in_papi_library_init_cnt;
520  while ( _in_papi_library_init_cnt > 1 ) {
521  PAPIERROR( "Multiple callers of PAPI_library_init" );
522  sleep( 1 );
523  }
524 
525  /* This checks to see if we have forked or called init more than once.
526  If we have forked, then we continue to init. If we have not forked,
527  we check to see the status of initialization. */
528 
529  APIDBG( "Initializing library: current PID %d, old PID %d\n",
530  getpid( ), _papi_hwi_system_info.pid );
531 
532  if ( _papi_hwi_system_info.pid == getpid( ) ) {
533  /* If the magic environment variable PAPI_ALLOW_STOLEN is set,
534  we call shutdown if PAPI has been initialized. This allows
535  tools that use LD_PRELOAD to run on applications that use PAPI.
536  In this circumstance, PAPI_ALLOW_STOLEN will be set to 'stolen'
537  so the tool can check for this case. */
538 
539  if ( getenv( "PAPI_ALLOW_STOLEN" ) ) {
540  char buf[PAPI_HUGE_STR_LEN];
541  if ( init_level != PAPI_NOT_INITED )
542  PAPI_shutdown( );
543  sprintf( buf, "%s=%s", "PAPI_ALLOW_STOLEN", "stolen" );
544  putenv( buf );
545  }
546 
547  /* If the library has been successfully initialized *OR*
548  the library attempted initialization but failed. */
549 
550  else if ( ( init_level != PAPI_NOT_INITED ) ||
551  ( init_retval != DEADBEEF ) ) {
552  _in_papi_library_init_cnt--;
553  if ( init_retval < PAPI_OK )
555  else
556  return ( init_retval );
557  }
558 
559  APIDBG( "system_info was initialized, but init did not succeed\n" );
560  }
561 #ifdef DEBUG
562  var = ( char * ) getenv( "PAPI_DEBUG" );
563  _papi_hwi_debug = 0;
564 
565  if ( var != NULL ) {
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" ) )
587  }
588 
589  if ( _papi_hwi_debug == 0 )
591  }
592 #endif
593 
594  /* Be verbose for now */
595 
596  tmpel = _papi_hwi_error_level;
598 
599  /* Initialize internal globals */
601  _in_papi_library_init_cnt--;
602  _papi_hwi_error_level = tmpel;
604  }
605 
606  /* Initialize OS */
607  tmp = _papi_hwi_init_os();
608  if ( tmp ) {
609  init_retval = tmp;
611  _in_papi_library_init_cnt--;
612  _papi_hwi_error_level = tmpel;
614  }
615 
616  /* Initialize component globals */
617 
618  tmp = _papi_hwi_init_global( );
619  if ( tmp ) {
620  init_retval = tmp;
622  _in_papi_library_init_cnt--;
623  _papi_hwi_error_level = tmpel;
625  }
626 
627  /* Initialize thread globals, including the main threads */
628 
630  if ( tmp ) {
631  int i;
632  init_retval = tmp;
634  for ( i = 0; i < papi_num_components; i++ ) {
635  if (!_papi_hwd[i]->cmp_info.disabled) {
637  }
638  }
639  _in_papi_library_init_cnt--;
640  _papi_hwi_error_level = tmpel;
642  }
643 
645  _in_papi_library_init_cnt--;
646  _papi_hwi_error_level = tmpel;
647 
648  return ( init_retval = PAPI_VER_CURRENT );
649 }
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
#define DEBUG_MULTIPLEX
Definition: papi_debug.h:31
int _papi_hwi_init_global_internal(void)
#define DEBUG_PROFILE
Definition: papi_debug.h:33
char * getenv()
#define PAPI_VERB_ECONT
Definition: papi.h:387
sleep(1)
int _papi_hwi_debug
Definition: papi.c:79
#define papi_return(a)
Definition: papi.c:50
#define PAPI_LOW_LEVEL_INITED
Definition: papi.h:279
return PAPI_OK
Definition: linux-nvml.c:458
return PAPI_EINVAL
Definition: linux-nvml.c:408
void _papi_hwi_init_errors(void)
#define PAPI_NOT_INITED
Definition: papi.h:278
#define DEBUG_MEMORY
Definition: papi_debug.h:34
papi_vector_t * _papi_hwd[]
#define DEBUG_API
Definition: papi_debug.h:28
#define PAPI_HUGE_STR_LEN
Definition: papi.h:465
#define APIDBG(format, args...)
Definition: papi_debug.h:64
int(* shutdown_component)(void)
Definition: papi_vector.h:54
#define DEADBEEF
Definition: papi_internal.h:26
#define DEBUG_ALL
Definition: papi_debug.h:36
int i
Definition: fileop.c:140
char buf[200]
Definition: iozone.c:19609
void PAPI_shutdown(void)
Definition: papi.c:4452
#define DEBUG_LEAK
Definition: papi_debug.h:35
void PAPIERROR(char *format,...)
void _papi_hwi_shutdown_global_internal(void)
#define DEBUG_INTERNAL
Definition: papi_debug.h:29
int _papi_hwi_error_level
Definition: papi_internal.c:53
char version[]
Definition: fileop.c:134
static int init_retval
Definition: papi.c:83
#define DEBUG_OVERFLOW
Definition: papi_debug.h:32
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:55
int papi_num_components
int _papi_hwi_init_os(void)
Definition: aix.c:1213
int _papi_hwi_init_global(void)
#define DEBUG_THREADS
Definition: papi_debug.h:30
int init_level
Definition: papi_internal.c:52
long long tmp
Definition: iozone.c:12031
#define PAPI_VER_CURRENT
Definition: papi.h:223
int _papi_hwi_init_global_threads(void)
Definition: threads.c:527
#define DEBUG_SUBSTRATE
Definition: papi_debug.h:27

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_list_events ( int  EventSet,
int Events,
int number 
)

list the events that are members of an event set

Definition at line 5992 of file papi.c.

5993 {
5994  APIDBG( "Entry: EventSet: %d, Events: %p, number: %p\n", EventSet, Events, number);
5995  EventSetInfo_t *ESI;
5996  int i, j;
5997 
5998  if ( *number < 0 )
6000 
6001  if ( ( Events == NULL ) && ( *number > 0 ) )
6003 
6005  if ( !ESI )
6007 
6008  if ( ( Events == NULL ) || ( *number == 0 ) ) {
6009  *number = ESI->NumberOfEvents;
6010  papi_return( PAPI_OK );
6011  }
6012 
6013  for ( i = 0, j = 0; j < ESI->NumberOfEvents; i++ ) {
6014  if ( ( int ) ESI->EventInfoArray[i].event_code != PAPI_NULL ) {
6015  Events[j] = ( int ) ESI->EventInfoArray[i].event_code;
6016  j++;
6017  if ( j == *number )
6018  break;
6019  }
6020  }
6021 
6022  *number = j;
6023 
6024  return ( PAPI_OK );
6025 }
static int Events[NUM_EVENTS]
Definition: init_fini.c:8
#define papi_return(a)
Definition: papi.c:50
#define PAPI_NULL
Definition: papi.h:290
int EventSet
Definition: data_range.c:25
return PAPI_OK
Definition: linux-nvml.c:458
return PAPI_EINVAL
Definition: linux-nvml.c:408
EventSetInfo_t * _papi_hwi_lookup_EventSet(int eventset)
#define APIDBG(format, args...)
Definition: papi_debug.h:64
int i
Definition: fileop.c:140
#define PAPI_ENOEVST
Definition: papi.h:262
EventInfo_t * EventInfoArray
int
Definition: iozone.c:18528
unsigned int event_code
long j
Definition: iozone.c:19135
if(gettimeofday(&tp,(struct timezone *) NULL)==-1) perror("gettimeofday")

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_list_threads ( unsigned long tids,
int number 
)

list the thread ids currently known to PAPI

Definition at line 286 of file papi.c.

287 {
289  int retval;
290 
291  /* If tids == NULL, then just count the threads, don't gather a list. */
292  /* If tids != NULL, then we need the length of the tids array in num. */
293 
294  if ( ( number == NULL ) || ( tids && ( *number <= 0 ) ) )
296 
297  memset( &tmp, 0x0, sizeof ( tmp ) );
298 
299  /* data == NULL, since we don't want the thread specific pointers. */
300  /* tids may be NULL, if the user doesn't want the thread IDs. */
301 
302  tmp.num = *number;
303  tmp.id = tids;
304  tmp.data = NULL;
305 
306  retval = _papi_hwi_gather_all_thrspec_data( 0, &tmp );
307  if ( retval == PAPI_OK )
308  *number = tmp.num;
309 
310  papi_return( retval );
311 }
void ** data
Definition: papi.h:561
#define papi_return(a)
Definition: papi.c:50
return PAPI_OK
Definition: linux-nvml.c:458
return PAPI_EINVAL
Definition: linux-nvml.c:408
PAPI_thread_id_t * id
Definition: papi.h:560
int _papi_hwi_gather_all_thrspec_data(int tag, PAPI_all_thr_spec_t *where)
Definition: threads.c:554
ssize_t retval
Definition: libasync.c:338
long long tmp
Definition: iozone.c:12031

Here is the call graph for this function:

int PAPI_lock ( int  )

lock one of two PAPI internal user mutex variables

Definition at line 6392 of file papi.c.

6393 {
6394  if ( ( lck < 0 ) || ( lck >= PAPI_NUM_LOCK ) )
6396 
6397  papi_return( _papi_hwi_lock( lck ) );
6398 }
#define PAPI_NUM_LOCK
Definition: papi.h:333
#define papi_return(a)
Definition: papi.c:50
return PAPI_EINVAL
Definition: linux-nvml.c:408
inline_static int _papi_hwi_lock(int lck)
Definition: threads.h:64

Here is the call graph for this function:

Here is the caller graph for this function:

initialize multiplex support in the PAPI library

Definition at line 2973 of file papi.c.

2974 {
2975  APIDBG("Entry:\n");
2976 
2977  int retval;
2978 
2979  retval = mpx_init( _papi_os_info.itimer_ns );
2980  papi_return( retval );
2981 }
#define papi_return(a)
Definition: papi.c:50
#define APIDBG(format, args...)
Definition: papi_debug.h:64
PAPI_os_info_t _papi_os_info
Definition: aix.c:1210
int mpx_init(int interval_ns)
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function:

return the number of hardware counters for a specified component

Definition at line 3956 of file papi.c.

3957 {
3958  APIDBG( "Entry: cidx: %d\n", cidx);
3959  return ( PAPI_get_cmp_opt( PAPI_MAX_HWCTRS, NULL, cidx ) );
3960 }
#define APIDBG(format, args...)
Definition: papi_debug.h:64
int PAPI_get_cmp_opt(int option, PAPI_option_t *ptr, int cidx)
Definition: papi.c:4326
static int cidx
Definition: event_info.c:40
#define PAPI_MAX_HWCTRS
Definition: papi.h:441

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_num_events ( int  EventSet)

return the number of events in an event set

Definition at line 4417 of file papi.c.

4418 {
4419  APIDBG( "Entry: EventSet: %d\n", EventSet);
4420  EventSetInfo_t *ESI;
4421 
4423  if ( !ESI )
4425 
4426 #ifdef DEBUG
4427  /* Not necessary */
4428  if ( ESI->NumberOfEvents == 0 )
4430 #endif
4431 
4432  return ( ESI->NumberOfEvents );
4433 }
#define papi_return(a)
Definition: papi.c:50
int EventSet
Definition: data_range.c:25
return PAPI_EINVAL
Definition: linux-nvml.c:408
EventSetInfo_t * _papi_hwi_lookup_EventSet(int eventset)
#define APIDBG(format, args...)
Definition: papi_debug.h:64
#define PAPI_ENOEVST
Definition: papi.h:262

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_overflow ( int  EventSet,
int  EventCode,
int  threshold,
int  flags,
PAPI_overflow_handler_t  handler 
)

set up an event set to begin registering overflows

< Using Hardware

< Force using Software

Definition at line 4779 of file papi.c.

4781 {
4782  APIDBG( "Entry: EventSet: %d, EventCode: %#x, threshold: %d, flags: %#x, handler: %p\n", EventSet, EventCode, threshold, flags, handler);
4783  int retval, cidx, index, i;
4784  EventSetInfo_t *ESI;
4785 
4787  if ( ESI == NULL ) {
4788  OVFDBG("No EventSet\n");
4790  }
4791 
4792  cidx = valid_ESI_component( ESI );
4793  if ( cidx < 0 ) {
4794  OVFDBG("Component Error\n");
4795  papi_return( cidx );
4796  }
4797 
4798  if ( ( ESI->state & PAPI_STOPPED ) != PAPI_STOPPED ) {
4799  OVFDBG("Already running\n");
4801  }
4802 
4803  if ( ESI->state & PAPI_ATTACHED ) {
4804  OVFDBG("Attached\n");
4806  }
4807 
4808  if ( ESI->state & PAPI_CPU_ATTACHED ) {
4809  OVFDBG("CPU attached\n");
4811  }
4812 
4813  if ( ( index = _papi_hwi_lookup_EventCodeIndex( ESI,
4814  ( unsigned int ) EventCode ) ) < 0 ) {
4816  }
4817 
4818  if ( threshold < 0 ) {
4819  OVFDBG("Threshold below zero\n");
4821  }
4822 
4823  /* We do not support derived events in overflow */
4824  /* Unless it's DERIVED_CMPD in which no calculations are done */
4825 
4826  if ( !( flags & PAPI_OVERFLOW_FORCE_SW ) && threshold != 0 &&
4827  ( ESI->EventInfoArray[index].derived ) &&
4828  ( ESI->EventInfoArray[index].derived != DERIVED_CMPD ) ) {
4829  OVFDBG("Derived event in overflow\n");
4831  }
4832 
4833  /* the first time to call PAPI_overflow function */
4834 
4835  if ( !( ESI->state & PAPI_OVERFLOWING ) ) {
4836  if ( handler == NULL ) {
4837  OVFDBG("NULL handler\n");
4839  }
4840  if ( threshold == 0 ) {
4841  OVFDBG("Zero threshold\n");
4843  }
4844  }
4845  if ( threshold > 0 &&
4848 
4849  if ( threshold == 0 ) {
4850  for ( i = 0; i < ESI->overflow.event_counter; i++ ) {
4851  if ( ESI->overflow.EventCode[i] == EventCode )
4852  break;
4853  }
4854  /* EventCode not found */
4855  if ( i == ESI->overflow.event_counter )
4857  /* compact these arrays */
4858  while ( i < ESI->overflow.event_counter - 1 ) {
4859  ESI->overflow.deadline[i] = ESI->overflow.deadline[i + 1];
4860  ESI->overflow.threshold[i] = ESI->overflow.threshold[i + 1];
4861  ESI->overflow.EventIndex[i] = ESI->overflow.EventIndex[i + 1];
4862  ESI->overflow.EventCode[i] = ESI->overflow.EventCode[i + 1];
4863  i++;
4864  }
4865  ESI->overflow.deadline[i] = 0;
4866  ESI->overflow.threshold[i] = 0;
4867  ESI->overflow.EventIndex[i] = 0;
4868  ESI->overflow.EventCode[i] = 0;
4869  ESI->overflow.event_counter--;
4870  } else {
4871  if ( ESI->overflow.event_counter > 0 ) {
4872  if ( ( flags & PAPI_OVERFLOW_FORCE_SW ) &&
4875  if ( !( flags & PAPI_OVERFLOW_FORCE_SW ) &&
4876  ( ESI->overflow.flags & PAPI_OVERFLOW_FORCE_SW ) )
4878  }
4879  for ( i = 0; i < ESI->overflow.event_counter; i++ ) {
4880  if ( ESI->overflow.EventCode[i] == EventCode )
4881  break;
4882  }
4883  /* A new entry */
4884  if ( i == ESI->overflow.event_counter ) {
4885  ESI->overflow.EventCode[i] = EventCode;
4886  ESI->overflow.event_counter++;
4887  }
4888  /* New or existing entry */
4889  ESI->overflow.deadline[i] = threshold;
4890  ESI->overflow.threshold[i] = threshold;
4891  ESI->overflow.EventIndex[i] = index;
4892  ESI->overflow.flags = flags;
4893 
4894  }
4895 
4896  /* If overflowing is already active, we should check to
4897  make sure that we don't specify a different handler
4898  or different flags here. You can't mix them. */
4899 
4900  ESI->overflow.handler = handler;
4901 
4902  /* Set up the option structure for the low level.
4903  If we have hardware interrupts and we are not using
4904  forced software emulated interrupts */
4905 
4906  if ( _papi_hwd[cidx]->cmp_info.hardware_intr &&
4907  !( ESI->overflow.flags & PAPI_OVERFLOW_FORCE_SW ) ) {
4908  retval = _papi_hwd[cidx]->set_overflow( ESI, index, threshold );
4909  if ( retval == PAPI_OK )
4911  else {
4912  papi_return( retval ); /* We should undo stuff here */
4913  }
4914  } else {
4915  /* Make sure hardware overflow is not set */
4916  ESI->overflow.flags &= ~( PAPI_OVERFLOW_HARDWARE );
4917  }
4918 
4919  APIDBG( "Overflow using: %s\n",
4920  ( ESI->overflow.
4921  flags & PAPI_OVERFLOW_HARDWARE ? "[Hardware]" : ESI->overflow.
4922  flags & PAPI_OVERFLOW_FORCE_SW ? "[Forced Software]" :
4923  "[Software]" ) );
4924 
4925  /* Toggle the overflow flags and ESI state */
4926 
4927  if ( ESI->overflow.event_counter >= 1 )
4928  ESI->state |= PAPI_OVERFLOWING;
4929  else {
4930  ESI->state ^= PAPI_OVERFLOWING;
4931  ESI->overflow.flags = 0;
4932  ESI->overflow.handler = NULL;
4933  }
4934 
4935  return PAPI_OK;
4936 }
#define PAPI_ATTACHED
Definition: papi.h:379
#define PAPI_ENOEVNT
Definition: papi.h:258
#define PAPI_OVERFLOWING
Definition: papi.h:376
long long flags
Definition: iozone.c:12330
#define papi_return(a)
Definition: papi.c:50
int EventSet
Definition: data_range.c:25
return PAPI_OK
Definition: linux-nvml.c:458
return PAPI_EINVAL
Definition: linux-nvml.c:408
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
EventSetInfo_t * _papi_hwi_lookup_EventSet(int eventset)
#define DERIVED_CMPD
Definition: papi_internal.h:73
papi_vector_t * _papi_hwd[]
#define PAPI_CPU_ATTACHED
Definition: papi.h:380
#define APIDBG(format, args...)
Definition: papi_debug.h:64
int i
Definition: fileop.c:140
EventSetOverflowInfo_t overflow
#define PAPI_OVERFLOW_HARDWARE
Definition: papi.h:410
#define PAPI_ENOEVST
Definition: papi.h:262
static int cidx
Definition: event_info.c:40
#define OVFDBG(format, args...)
Definition: papi_debug.h:68
int _papi_hwi_lookup_EventCodeIndex(const EventSetInfo_t *ESI, unsigned int EventCode)
#define PAPI_ECNFLCT
Definition: papi.h:259
#define PAPI_EISRUN
Definition: papi.h:261
void handler(int EventSet, void *address, long long overflow_vector, void *context)
Definition: rapl_overflow.c:16
inline_static int valid_ESI_component(EventSetInfo_t *ESI)
Definition: papi.c:94
EventInfo_t * EventInfoArray
int threshold
#define PAPI_OVERFLOW_FORCE_SW
Definition: papi.h:409
#define PAPI_STOPPED
Definition: papi.h:372
ssize_t retval
Definition: libasync.c:338
PAPI_overflow_handler_t handler
int(* set_overflow)(EventSetInfo_t *, int, int)
Definition: papi_vector.h:40

Here is the call graph for this function:

Here is the caller graph for this function:

void PAPI_perror ( char *  msg)

Print a PAPI error message

Definition at line 4644 of file papi.c.

4645 {
4646  char *foo;
4647 
4648  foo = PAPI_strerror( _papi_hwi_errno );
4649  if ( foo == NULL )
4650  return;
4651 
4652  if ( msg )
4653  if ( *msg )
4654  fprintf( stderr, "%s: ", msg );
4655 
4656  fprintf( stderr, "%s\n", foo );
4657 }
int _papi_hwi_errno
Definition: papi_internal.c:56
pthread_attr_t foo
Definition: iozone.c:18592
char * PAPI_strerror(int errorCode)
Definition: papi.c:4594

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_profil ( void buf,
unsigned  bufsiz,
caddr_t  offset,
unsigned  scale,
int  EventSet,
int  EventCode,
int  threshold,
int  flags 
)

generate PC histogram data where hardware counter overflow occurs

Definition at line 5429 of file papi.c.

5432 {
5433  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);
5434  EventSetInfo_t *ESI;
5435  int i;
5436  int retval;
5437 
5439  if ( ESI == NULL )
5441 
5442  /* scale factors are checked for validity in PAPI_sprofil */
5443 
5444  if ( threshold > 0 ) {
5445  PAPI_sprofil_t *prof;
5446 
5447  for ( i = 0; i < ESI->profile.event_counter; i++ ) {
5448  if ( ESI->profile.EventCode[i] == EventCode )
5449  break;
5450  }
5451 
5452  if ( i == ESI->profile.event_counter ) {
5453  prof =
5454  ( PAPI_sprofil_t * ) papi_malloc( sizeof ( PAPI_sprofil_t ) );
5455  memset( prof, 0x0, sizeof ( PAPI_sprofil_t ) );
5456  prof->pr_base = buf;
5457  prof->pr_size = bufsiz;
5458  prof->pr_off = offset;
5459  prof->pr_scale = scale;
5460 
5461  retval =
5462  PAPI_sprofil( prof, 1, EventSet, EventCode, threshold, flags );
5463 
5464  if ( retval != PAPI_OK )
5465  papi_free( prof );
5466  } else {
5467  prof = ESI->profile.prof[i];
5468  prof->pr_base = buf;
5469  prof->pr_size = bufsiz;
5470  prof->pr_off = offset;
5471  prof->pr_scale = scale;
5472  retval =
5473  PAPI_sprofil( prof, 1, EventSet, EventCode, threshold, flags );
5474  }
5475  papi_return( retval );
5476  }
5477 
5478  for ( i = 0; i < ESI->profile.event_counter; i++ ) {
5479  if ( ESI->profile.EventCode[i] == EventCode )
5480  break;
5481  }
5482  /* EventCode not found */
5483  if ( i == ESI->profile.event_counter )
5485 
5486  papi_free( ESI->profile.prof[i] );
5487  ESI->profile.prof[i] = NULL;
5488 
5489  papi_return( PAPI_sprofil( NULL, 0, EventSet, EventCode, 0, flags ) );
5490 }
long long flags
Definition: iozone.c:12330
#define papi_free(a)
Definition: papi_memory.h:35
#define papi_return(a)
Definition: papi.c:50
#define papi_malloc(a)
Definition: papi_memory.h:34
off64_t offset
Definition: iozone.c:1279
int EventSet
Definition: data_range.c:25
caddr_t pr_off
Definition: papi.h:581
return PAPI_OK
Definition: linux-nvml.c:458
return PAPI_EINVAL
Definition: linux-nvml.c:408
int PAPI_sprofil(PAPI_sprofil_t *prof, int profcnt, int EventSet, int EventCode, int threshold, int flags)
Definition: papi.c:5035
EventSetInfo_t * _papi_hwi_lookup_EventSet(int eventset)
unsigned pr_scale
Definition: papi.h:582
#define APIDBG(format, args...)
Definition: papi_debug.h:64
unsigned pr_size
Definition: papi.h:580
int i
Definition: fileop.c:140
char buf[200]
Definition: iozone.c:19609
#define PAPI_ENOEVST
Definition: papi.h:262
PAPI_sprofil_t ** prof
int threshold
void * pr_base
Definition: papi.h:579
EventSetProfileInfo_t profile
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_query_event ( int  EventCode)

query if a PAPI event exists

Definition at line 693 of file papi.c.

694 {
695  APIDBG( "Entry: EventCode: %#x\n", EventCode);
696  if ( IS_PRESET(EventCode) ) {
697  EventCode &= PAPI_PRESET_AND_MASK;
698  if ( EventCode < 0 || EventCode >= PAPI_MAX_PRESET_EVENTS )
700 
701  if ( _papi_hwi_presets[EventCode].count )
703  else
704  return PAPI_ENOEVNT;
705  }
706 
707  if ( IS_NATIVE(EventCode) ) {
709  ( ( unsigned int ) EventCode ) );
710  }
711 
712  if ( IS_USER_DEFINED(EventCode) ) {
713  EventCode &= PAPI_UE_AND_MASK;
714  if ( EventCode < 0 || EventCode >= PAPI_MAX_USER_EVENTS)
716 
717  if ( user_defined_events[EventCode].count )
719  else
721  }
722 
724 }
#define PAPI_ENOEVNT
Definition: papi.h:258
#define IS_PRESET(EventCode)
Definition: papi.h:227
#define IS_USER_DEFINED(EventCode)
Definition: papi.h:228
#define PAPI_UE_AND_MASK
int _papi_hwi_query_native_event(unsigned int EventCode)
#define papi_return(a)
Definition: papi.c:50
#define PAPI_MAX_PRESET_EVENTS
return PAPI_OK
Definition: linux-nvml.c:458
int count
Definition: iozone.c:22422
#define PAPI_ENOTPRESET
Definition: papi.h:263
#define APIDBG(format, args...)
Definition: papi_debug.h:64
#define PAPI_MAX_USER_EVENTS
#define IS_NATIVE(EventCode)
Definition: papi.h:226
hwi_presets_t _papi_hwi_presets[PAPI_MAX_PRESET_EVENTS]
hwi_presets_t user_defined_events[PAPI_MAX_USER_EVENTS]
Definition: papi_internal.c:58
#define PAPI_PRESET_AND_MASK

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_query_named_event ( char *  EventName)

query if a named PAPI event exists

Definition at line 765 of file papi.c.

766 {
767  int ret, code;
768 
769  ret = PAPI_event_name_to_code( EventName, &code );
770  if ( ret == PAPI_OK ) ret = PAPI_query_event( code );
771  papi_return( ret);
772 }
#define papi_return(a)
Definition: papi.c:50
return PAPI_OK
Definition: linux-nvml.c:458
long long ret
Definition: iozone.c:1346
int PAPI_event_name_to_code(char *in, int *out)
Definition: papi.c:1013
int PAPI_query_event(int EventCode)
Definition: papi.c:693

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_read ( int  EventSet,
long long values 
)

read hardware events from an event set with no reset

Definition at line 2550 of file papi.c.

2551 {
2552  APIDBG( "Entry: EventSet: %d, values: %p\n", EventSet, values);
2553  EventSetInfo_t *ESI;
2554  hwd_context_t *context;
2555  int cidx, retval = PAPI_OK;
2556 
2558  if ( ESI == NULL )
2560 
2561  cidx = valid_ESI_component( ESI );
2562  if ( cidx < 0 )
2563  papi_return( cidx );
2564 
2565  if ( values == NULL )
2567 
2568  if ( ESI->state & PAPI_RUNNING ) {
2569  if ( _papi_hwi_is_sw_multiplex( ESI ) ) {
2570  retval = MPX_read( ESI->multiplex.mpx_evset, values, 0 );
2571  } else {
2572  /* get the context we should use for this event set */
2573  context = _papi_hwi_get_context( ESI, NULL );
2574  retval = _papi_hwi_read( context, ESI, values );
2575  }
2576  if ( retval != PAPI_OK )
2577  papi_return( retval );
2578  } else {
2579  memcpy( values, ESI->sw_stop,
2580  ( size_t ) ESI->NumberOfEvents * sizeof ( long long ) );
2581  }
2582 
2583 #if defined(DEBUG)
2584  if ( ISLEVEL( DEBUG_API ) ) {
2585  int i;
2586  for ( i = 0; i < ESI->NumberOfEvents; i++ ) {
2587  APIDBG( "PAPI_read values[%d]:\t%lld\n", i, values[i] );
2588  }
2589  }
2590 #endif
2591 
2592  APIDBG( "PAPI_read returns %d\n", retval );
2593  return ( PAPI_OK );
2594 }
int _papi_hwi_is_sw_multiplex(EventSetInfo_t *ESI)
#define papi_return(a)
Definition: papi.c:50
MPX_EventSet * mpx_evset
Definition: sw_multiplex.h:32
int EventSet
Definition: data_range.c:25
return PAPI_OK
Definition: linux-nvml.c:458
return PAPI_EINVAL
Definition: linux-nvml.c:408
EventSetInfo_t * _papi_hwi_lookup_EventSet(int eventset)
#define DEBUG_API
Definition: papi_debug.h:28
int MPX_read(MPX_EventSet *mpx_events, long long *values, int called_by_stop)
Definition: sw_multiplex.c:823
#define APIDBG(format, args...)
Definition: papi_debug.h:64
int i
Definition: fileop.c:140
#define PAPI_ENOEVST
Definition: papi.h:262
static int cidx
Definition: event_info.c:40
int _papi_hwi_read(hwd_context_t *context, EventSetInfo_t *ESI, long long *values)
inline_static int valid_ESI_component(EventSetInfo_t *ESI)
Definition: papi.c:94
again struct sockaddr sizeof(struct sockaddr_in))
EventSetMultiplexInfo_t multiplex
hwd_context_t * _papi_hwi_get_context(EventSetInfo_t *ESI, int *is_dirty)
long long * sw_stop
#define PAPI_RUNNING
Definition: papi.h:373
#define ISLEVEL(a)
Definition: papi_debug.h:54
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_read_ts ( int  EventSet,
long long values,
long long cyc 
)

read from an eventset with a real-time cycle timestamp

Definition at line 2639 of file papi.c.

2640 {
2641  APIDBG( "Entry: EventSet: %d, values: %p, cycles: %p\n", EventSet, values, cycles);
2642  EventSetInfo_t *ESI;
2643  hwd_context_t *context;
2644  int cidx, retval = PAPI_OK;
2645 
2647  if ( ESI == NULL )
2649 
2650  cidx = valid_ESI_component( ESI );
2651  if ( cidx < 0 )
2652  papi_return( cidx );
2653 
2654  if ( values == NULL )
2656 
2657  if ( ESI->state & PAPI_RUNNING ) {
2658  if ( _papi_hwi_is_sw_multiplex( ESI ) ) {
2659  retval = MPX_read( ESI->multiplex.mpx_evset, values, 0 );
2660  } else {
2661  /* get the context we should use for this event set */
2662  context = _papi_hwi_get_context( ESI, NULL );
2663  retval = _papi_hwi_read( context, ESI, values );
2664  }
2665  if ( retval != PAPI_OK )
2666  papi_return( retval );
2667  } else {
2668  memcpy( values, ESI->sw_stop,
2669  ( size_t ) ESI->NumberOfEvents * sizeof ( long long ) );
2670  }
2671 
2672  *cycles = _papi_os_vector.get_real_cycles( );
2673 
2674 #if defined(DEBUG)
2675  if ( ISLEVEL( DEBUG_API ) ) {
2676  int i;
2677  for ( i = 0; i < ESI->NumberOfEvents; i++ ) {
2678  APIDBG( "PAPI_read values[%d]:\t%lld\n", i, values[i] );
2679  }
2680  }
2681 #endif
2682 
2683  APIDBG( "PAPI_read_ts returns %d\n", retval );
2684  return PAPI_OK;
2685 }
int _papi_hwi_is_sw_multiplex(EventSetInfo_t *ESI)
#define papi_return(a)
Definition: papi.c:50
MPX_EventSet * mpx_evset
Definition: sw_multiplex.h:32
int EventSet
Definition: data_range.c:25
return PAPI_OK
Definition: linux-nvml.c:458
return PAPI_EINVAL
Definition: linux-nvml.c:408
EventSetInfo_t * _papi_hwi_lookup_EventSet(int eventset)
#define DEBUG_API
Definition: papi_debug.h:28
long long(* get_real_cycles)(void)
Definition: papi_vector.h:61
int MPX_read(MPX_EventSet *mpx_events, long long *values, int called_by_stop)
Definition: sw_multiplex.c:823
#define APIDBG(format, args...)
Definition: papi_debug.h:64
papi_os_vector_t _papi_os_vector
Definition: aix.c:1288
int i
Definition: fileop.c:140
#define PAPI_ENOEVST
Definition: papi.h:262
static int cidx
Definition: event_info.c:40
int _papi_hwi_read(hwd_context_t *context, EventSetInfo_t *ESI, long long *values)
inline_static int valid_ESI_component(EventSetInfo_t *ESI)
Definition: papi.c:94
again struct sockaddr sizeof(struct sockaddr_in))
EventSetMultiplexInfo_t multiplex
hwd_context_t * _papi_hwi_get_context(EventSetInfo_t *ESI, int *is_dirty)
long long * sw_stop
#define PAPI_RUNNING
Definition: papi.h:373
#define ISLEVEL(a)
Definition: papi_debug.h:54
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function:

inform PAPI of the existence of a new thread

Definition at line 208 of file papi.c.

209 {
211 
212  if ( init_level == PAPI_NOT_INITED )
215 }
#define papi_return(a)
Definition: papi.c:50
#define PAPI_NOT_INITED
Definition: papi.h:278
void * thread(void *arg)
Definition: kufrin.c:31
inline_static int _papi_hwi_lookup_or_create_thread(ThreadInfo_t **here, int tid)
Definition: threads.h:145
#define PAPI_ENOINIT
Definition: papi.h:267
int init_level
Definition: papi_internal.c:52

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_remove_event ( int  EventSet,
int  EventCode 
)

remove a hardware event from a PAPI event set

Definition at line 1763 of file papi.c.

1764 {
1765  APIDBG("Entry: EventSet: %d, EventCode: %#x\n", EventSet, EventCode);
1766  EventSetInfo_t *ESI;
1767  int i,retval;
1768 
1769  /* check for pre-existing ESI */
1770 
1772  if ( ESI == NULL )
1774 
1775  /* Check argument for validity */
1776 
1777  if ( ( !IS_PRESET(EventCode) ) &&
1778  ( !IS_NATIVE(EventCode) ) &&
1779  ( !IS_USER_DEFINED(EventCode) ))
1781 
1782  /* Of course, it must be stopped in order to modify it. */
1783 
1784  if ( !( ESI->state & PAPI_STOPPED ) )
1786 
1787  /* if the state is PAPI_OVERFLOWING, you must first call
1788  PAPI_overflow with threshold=0 to remove the overflow flag */
1789 
1790  /* Turn off the event that is overflowing */
1791  if ( ESI->state & PAPI_OVERFLOWING ) {
1792  for ( i = 0; i < ESI->overflow.event_counter; i++ ) {
1793  if ( ESI->overflow.EventCode[i] == EventCode ) {
1794  retval = PAPI_overflow( EventSet, EventCode, 0, 0,
1795  ESI->overflow.handler );
1796  if (retval!=PAPI_OK) return retval;
1797  break;
1798  }
1799  }
1800  }
1801 
1802  /* force the user to call PAPI_profil to clear the PAPI_PROFILING flag */
1803  if ( ESI->state & PAPI_PROFILING ) {
1804  for ( i = 0; i < ESI->profile.event_counter; i++ ) {
1805  if ( ESI->profile.EventCode[i] == EventCode ) {
1806  PAPI_sprofil( NULL, 0, EventSet, EventCode, 0, 0 );
1807  break;
1808  }
1809  }
1810  }
1811 
1812  /* Now do the magic. */
1813 
1814  papi_return( _papi_hwi_remove_event( ESI, EventCode ) );
1815 }
#define PAPI_OVERFLOWING
Definition: papi.h:376
#define IS_PRESET(EventCode)
Definition: papi.h:227
#define IS_USER_DEFINED(EventCode)
Definition: papi.h:228
#define papi_return(a)
Definition: papi.c:50
int EventSet
Definition: data_range.c:25
return PAPI_OK
Definition: linux-nvml.c:458
int PAPI_overflow(int EventSet, int EventCode, int threshold, int flags, PAPI_overflow_handler_t handler)
Definition: papi.c:4779
return PAPI_EINVAL
Definition: linux-nvml.c:408
int PAPI_sprofil(PAPI_sprofil_t *prof, int profcnt, int EventSet, int EventCode, int threshold, int flags)
Definition: papi.c:5035
int _papi_hwi_remove_event(EventSetInfo_t *ESI, int EventCode)
EventSetInfo_t * _papi_hwi_lookup_EventSet(int eventset)
#define APIDBG(format, args...)
Definition: papi_debug.h:64
int i
Definition: fileop.c:140
EventSetOverflowInfo_t overflow
#define PAPI_ENOEVST
Definition: papi.h:262
#define IS_NATIVE(EventCode)
Definition: papi.h:226
#define PAPI_EISRUN
Definition: papi.h:261
#define PAPI_PROFILING
Definition: papi.h:377
#define PAPI_STOPPED
Definition: papi.h:372
EventSetProfileInfo_t profile
ssize_t retval
Definition: libasync.c:338
PAPI_overflow_handler_t handler

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_remove_events ( int  EventSet,
int Events,
int  number 
)

remove an array of hardware events from a PAPI event set

Definition at line 5922 of file papi.c.

5923 {
5924  APIDBG( "Entry: EventSet: %d, Events: %p, number: %d\n", EventSet, Events, number);
5925  int i, retval;
5926 
5927  if ( ( Events == NULL ) || ( number <= 0 ) )
5929 
5930  for ( i = 0; i < number; i++ ) {
5931  retval = PAPI_remove_event( EventSet, Events[i] );
5932  if ( retval != PAPI_OK ) {
5933  if ( i == 0 )
5934  papi_return( retval );
5935  else
5936  return ( i );
5937  }
5938  }
5939  return ( PAPI_OK );
5940 }
static int Events[NUM_EVENTS]
Definition: init_fini.c:8
#define papi_return(a)
Definition: papi.c:50
int PAPI_remove_event(int EventSet, int EventCode)
Definition: papi.c:1763
int EventSet
Definition: data_range.c:25
return PAPI_OK
Definition: linux-nvml.c:458
return PAPI_EINVAL
Definition: linux-nvml.c:408
#define APIDBG(format, args...)
Definition: papi_debug.h:64
int i
Definition: fileop.c:140
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_remove_named_event ( int  EventSet,
char *  EventName 
)

remove a named event from a PAPI event set

Definition at line 1966 of file papi.c.

1967 {
1968  APIDBG("Entry: EventSet: %d, EventName: %s\n", EventSet, EventName);
1969  int ret, code;
1970 
1971  ret = PAPI_event_name_to_code( EventName, &code );
1972  if ( ret == PAPI_OK ) ret = PAPI_remove_event( EventSet, code );
1973  papi_return( ret );
1974 }
#define papi_return(a)
Definition: papi.c:50
int PAPI_remove_event(int EventSet, int EventCode)
Definition: papi.c:1763
int EventSet
Definition: data_range.c:25
return PAPI_OK
Definition: linux-nvml.c:458
#define APIDBG(format, args...)
Definition: papi_debug.h:64
long long ret
Definition: iozone.c:1346
int PAPI_event_name_to_code(char *in, int *out)
Definition: papi.c:1013

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_reset ( int  EventSet)

reset the hardware event counts in an event set

Definition at line 2450 of file papi.c.

2451 {
2452  APIDBG("Entry: EventSet: %d\n", EventSet);
2453  int retval = PAPI_OK;
2454  EventSetInfo_t *ESI;
2455  hwd_context_t *context;
2456  int cidx;
2457 
2459  if ( ESI == NULL )
2461 
2462  cidx = valid_ESI_component( ESI );
2463  if ( cidx < 0 )
2464  papi_return( cidx );
2465 
2466  if ( ESI->state & PAPI_RUNNING ) {
2467  if ( _papi_hwi_is_sw_multiplex( ESI ) ) {
2468  retval = MPX_reset( ESI->multiplex.mpx_evset );
2469  } else {
2470  /* If we're not the only one running, then just
2471  read the current values into the ESI->start
2472  array. This holds the starting value for counters
2473  that are shared. */
2474  /* get the context we should use for this event set */
2475  context = _papi_hwi_get_context( ESI, NULL );
2476  retval = _papi_hwd[cidx]->reset( context, ESI->ctl_state );
2477  }
2478  } else {
2479 #ifdef __bgp__
2480  // For BG/P, we always want to reset the 'real' hardware counters. The counters
2481  // can be controlled via multiple interfaces, and we need to ensure that the values
2482  // are truly zero...
2483  /* get the context we should use for this event set */
2484  context = _papi_hwi_get_context( ESI, NULL );
2485  retval = _papi_hwd[cidx]->reset( context, ESI->ctl_state );
2486 #endif
2487  memset( ESI->sw_stop, 0x00,
2488  ( size_t ) ESI->NumberOfEvents * sizeof ( long long ) );
2489  }
2490 
2491  APIDBG( "EXIT: retval %d\n", retval );
2492  papi_return( retval );
2493 }
int _papi_hwi_is_sw_multiplex(EventSetInfo_t *ESI)
#define papi_return(a)
Definition: papi.c:50
MPX_EventSet * mpx_evset
Definition: sw_multiplex.h:32
int EventSet
Definition: data_range.c:25
return PAPI_OK
Definition: linux-nvml.c:458
EventSetInfo_t * _papi_hwi_lookup_EventSet(int eventset)
papi_vector_t * _papi_hwd[]
#define APIDBG(format, args...)
Definition: papi_debug.h:64
#define PAPI_ENOEVST
Definition: papi.h:262
static int cidx
Definition: event_info.c:40
int(* reset)(hwd_context_t *, hwd_control_state_t *)
Definition: papi_vector.h:31
inline_static int valid_ESI_component(EventSetInfo_t *ESI)
Definition: papi.c:94
again struct sockaddr sizeof(struct sockaddr_in))
EventSetMultiplexInfo_t multiplex
hwd_context_t * _papi_hwi_get_context(EventSetInfo_t *ESI, int *is_dirty)
int MPX_reset(MPX_EventSet *mpx_events)
Definition: sw_multiplex.c:937
long long * sw_stop
#define PAPI_RUNNING
Definition: papi.h:373
hwd_control_state_t * ctl_state
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_set_cmp_domain ( int  domain,
int  cidx 
)

set the component specific default execution domain for new event sets

Definition at line 5749 of file papi.c.

5750 {
5752 
5753  memset( &ptr, 0, sizeof ( ptr ) );
5754  ptr.defdomain.def_cidx = cidx;
5755  ptr.defdomain.domain = domain;
5756  papi_return( PAPI_set_opt( PAPI_DEFDOM, &ptr ) );
5757 }
#define papi_return(a)
Definition: papi.c:50
A pointer to the following is passed to PAPI_set/get_opt()
Definition: papi.h:845
int PAPI_set_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:3456
static int cidx
Definition: event_info.c:40
#define PAPI_DEFDOM
Definition: papi.h:430
PAPI_domain_option_t defdomain
Definition: papi.h:853
char * ptr
Definition: iozone.c:23586

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_set_cmp_granularity ( int  granularity,
int  cidx 
)

set the component specific default granularity for new event sets

Definition at line 5613 of file papi.c.

5614 {
5616 
5617  memset( &ptr, 0, sizeof ( ptr ) );
5619  ptr.defgranularity.granularity = granularity;
5620  papi_return( PAPI_set_opt( PAPI_DEFGRN, &ptr ) );
5621 }
#define papi_return(a)
Definition: papi.c:50
A pointer to the following is passed to PAPI_set/get_opt()
Definition: papi.h:845
int PAPI_set_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:3456
static int cidx
Definition: event_info.c:40
#define PAPI_DEFGRN
Definition: papi.h:432
PAPI_granularity_option_t defgranularity
Definition: papi.h:851
char * ptr
Definition: iozone.c:23586

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_set_debug ( int  level)

set the current debug level for PAPI

Definition at line 3117 of file papi.c.

3118 {
3119  APIDBG("Entry: level: %d\n", level);
3120  PAPI_option_t option;
3121 
3122  memset( &option, 0x0, sizeof ( option ) );
3123  option.debug.level = level;
3125  return ( PAPI_set_opt( PAPI_DEBUG, &option ) );
3126 }
PAPI_debug_handler_t _papi_hwi_debug_handler
Definition: papi_internal.c:54
A pointer to the following is passed to PAPI_set/get_opt()
Definition: papi.h:845
int PAPI_set_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:3456
#define APIDBG(format, args...)
Definition: papi_debug.h:64
PAPI_debug_handler_t handler
Definition: papi.h:687
PAPI_debug_option_t debug
Definition: papi.h:848
#define PAPI_DEBUG
Definition: papi.h:428

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_set_domain ( int  domain)

set the default execution domain for new event sets

Definition at line 5679 of file papi.c.

5680 {
5681  return ( PAPI_set_cmp_domain( domain, 0 ) );
5682 }
int PAPI_set_cmp_domain(int domain, int cidx)
Definition: papi.c:5749

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_set_granularity ( int  granularity)

set the default granularity for new event sets

Definition at line 5548 of file papi.c.

5549 {
5550  return ( PAPI_set_cmp_granularity( granularity, 0 ) );
5551 }
int PAPI_set_cmp_granularity(int granularity, int cidx)
Definition: papi.c:5613

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_set_multiplex ( int  EventSet)

convert a standard event set to a multiplexed event set

Definition at line 3324 of file papi.c.

3325 {
3326  APIDBG( "Entry: EventSet: %d\n", EventSet);
3327 
3328  PAPI_option_t mpx;
3329  EventSetInfo_t *ESI;
3330  int cidx;
3331  int ret;
3332 
3333  /* Is the EventSet already in existence? */
3334 
3336 
3337  if ( ESI == NULL )
3339 
3340  /* if the eventset has no index return NOCMP */
3341  cidx = valid_ESI_component( ESI );
3342  if ( cidx < 0 )
3343  papi_return( cidx );
3344 
3345  if ( ( ret = mpx_check( EventSet ) ) != PAPI_OK )
3346  papi_return( ret );
3347 
3348  memset( &mpx, 0x0, sizeof ( mpx ) );
3349  mpx.multiplex.eventset = EventSet;
3352  return ( PAPI_set_opt( PAPI_MULTIPLEX, &mpx ) );
3353 }
#define papi_return(a)
Definition: papi.c:50
int EventSet
Definition: data_range.c:25
return PAPI_OK
Definition: linux-nvml.c:458
A pointer to the following is passed to PAPI_set/get_opt()
Definition: papi.h:845
EventSetInfo_t * _papi_hwi_lookup_EventSet(int eventset)
int PAPI_set_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:3456
#define APIDBG(format, args...)
Definition: papi_debug.h:64
long long ret
Definition: iozone.c:1346
PAPI_os_info_t _papi_os_info
Definition: aix.c:1210
#define PAPI_ENOEVST
Definition: papi.h:262
static int cidx
Definition: event_info.c:40
#define PAPI_MULTIPLEX_DEFAULT
Definition: papi.h:416
PAPI_multiplex_option_t multiplex
Definition: papi.h:856
#define PAPI_MULTIPLEX
Definition: papi.h:429
inline_static int valid_ESI_component(EventSetInfo_t *ESI)
Definition: papi.c:94
int mpx_check(int EventSet)

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_set_opt ( int  option,
PAPI_option_t ptr 
)

change the option settings of the PAPI library or a specific event set

Definition at line 3456 of file papi.c.

3457 {
3458  APIDBG("Entry: option: %d, ptr: %p\n", option, ptr);
3459 
3460  _papi_int_option_t internal;
3461  int retval = PAPI_OK;
3462  hwd_context_t *context;
3463  int cidx;
3464 
3465  if ( ( option != PAPI_DEBUG ) && ( init_level == PAPI_NOT_INITED ) )
3467  if ( ptr == NULL )
3469 
3470  memset( &internal, 0x0, sizeof ( _papi_int_option_t ) );
3471 
3472  switch ( option ) {
3473  case PAPI_DETACH:
3474  {
3475  internal.attach.ESI = _papi_hwi_lookup_EventSet( ptr->attach.eventset );
3476  if ( internal.attach.ESI == NULL )
3478 
3479  cidx = valid_ESI_component( internal.attach.ESI );
3480  if ( cidx < 0 )
3481  papi_return( cidx );
3482 
3483  if ( _papi_hwd[cidx]->cmp_info.attach == 0 )
3485 
3486  /* if attached to a cpu, return an error */
3487  if (internal.attach.ESI->state & PAPI_CPU_ATTACHED)
3489 
3490  if ( ( internal.attach.ESI->state & PAPI_STOPPED ) == 0 )
3492 
3493  if ( ( internal.attach.ESI->state & PAPI_ATTACHED ) == 0 )
3495 
3496  internal.attach.tid = internal.attach.ESI->attach.tid;
3497  /* get the context we should use for this event set */
3498  context = _papi_hwi_get_context( internal.attach.ESI, NULL );
3499  retval = _papi_hwd[cidx]->ctl( context, PAPI_DETACH, &internal );
3500  if ( retval != PAPI_OK )
3501  papi_return( retval );
3502 
3503  internal.attach.ESI->state ^= PAPI_ATTACHED;
3504  internal.attach.ESI->attach.tid = 0;
3505  return ( PAPI_OK );
3506  }
3507  case PAPI_ATTACH:
3508  {
3509  internal.attach.ESI = _papi_hwi_lookup_EventSet( ptr->attach.eventset );
3510  if ( internal.attach.ESI == NULL )
3512 
3513  cidx = valid_ESI_component( internal.attach.ESI );
3514  if ( cidx < 0 )
3515  papi_return( cidx );
3516 
3517  if ( _papi_hwd[cidx]->cmp_info.attach == 0 )
3519 
3520  if ( ( internal.attach.ESI->state & PAPI_STOPPED ) == 0 )
3522 
3523  if ( internal.attach.ESI->state & PAPI_ATTACHED )
3525 
3526  /* if attached to a cpu, return an error */
3527  if (internal.attach.ESI->state & PAPI_CPU_ATTACHED)
3529 
3530  internal.attach.tid = ptr->attach.tid;
3531  /* get the context we should use for this event set */
3532  context = _papi_hwi_get_context( internal.attach.ESI, NULL );
3533  retval = _papi_hwd[cidx]->ctl( context, PAPI_ATTACH, &internal );
3534  if ( retval != PAPI_OK )
3535  papi_return( retval );
3536 
3537  internal.attach.ESI->state |= PAPI_ATTACHED;
3538  internal.attach.ESI->attach.tid = ptr->attach.tid;
3539 
3541  &(internal.attach.ESI->master), ptr->attach.tid ));
3542  }
3543  case PAPI_CPU_ATTACH:
3544  {
3545  APIDBG("eventset: %d, cpu_num: %d\n", ptr->cpu.eventset, ptr->cpu.cpu_num);
3546  internal.cpu.ESI = _papi_hwi_lookup_EventSet( ptr->cpu.eventset );
3547  if ( internal.cpu.ESI == NULL )
3549 
3550  internal.cpu.cpu_num = ptr->cpu.cpu_num;
3551  APIDBG("internal: %p, ESI: %p, cpu_num: %d\n", &internal, internal.cpu.ESI, internal.cpu.cpu_num);
3552 
3553  cidx = valid_ESI_component( internal.cpu.ESI );
3554  if ( cidx < 0 )
3555  papi_return( cidx );
3556 
3557  if ( _papi_hwd[cidx]->cmp_info.cpu == 0 )
3559 
3560  // can not attach to a cpu if already attached to a process or
3561  // counters set to be inherited by child processes
3562  if ( internal.cpu.ESI->state & (PAPI_ATTACHED | PAPI_INHERIT) )
3564 
3565  if ( ( internal.cpu.ESI->state & PAPI_STOPPED ) == 0 )
3567 
3568  retval = _papi_hwi_lookup_or_create_cpu(&internal.cpu.ESI->CpuInfo, internal.cpu.cpu_num);
3569  if( retval != PAPI_OK) {
3570  papi_return( retval );
3571  }
3572 
3573  /* get the context we should use for this event set */
3574  context = _papi_hwi_get_context( internal.cpu.ESI, NULL );
3575  retval = _papi_hwd[cidx]->ctl( context, PAPI_CPU_ATTACH, &internal );
3576  if ( retval != PAPI_OK )
3577  papi_return( retval );
3578 
3579  /* set to show this event set is attached to a cpu not a thread */
3580  internal.cpu.ESI->state |= PAPI_CPU_ATTACHED;
3581  return ( PAPI_OK );
3582  }
3583  case PAPI_DEF_MPX_NS:
3584  {
3585  cidx = 0; /* xxxx for now, assume we only check against cpu component */
3586  if ( ptr->multiplex.ns < 0 )
3588  /* We should check the resolution here with the system, either
3589  component if kernel multiplexing or PAPI if SW multiplexing. */
3590  internal.multiplex.ns = ( unsigned long ) ptr->multiplex.ns;
3591  /* get the context we should use for this event set */
3592  context = _papi_hwi_get_context( internal.cpu.ESI, NULL );
3593  /* Low level just checks/adjusts the args for this component */
3594  retval = _papi_hwd[cidx]->ctl( context, PAPI_DEF_MPX_NS, &internal );
3595  if ( retval == PAPI_OK ) {
3596  _papi_os_info.itimer_ns = ( int ) internal.multiplex.ns;
3597  ptr->multiplex.ns = ( int ) internal.multiplex.ns;
3598  }
3599  papi_return( retval );
3600  }
3601  case PAPI_DEF_ITIMER_NS:
3602  {
3603  cidx = 0; /* xxxx for now, assume we only check against cpu component */
3604  if ( ptr->itimer.ns < 0 )
3606  internal.itimer.ns = ptr->itimer.ns;
3607  /* Low level just checks/adjusts the args for this component */
3608  retval = _papi_hwd[cidx]->ctl( NULL, PAPI_DEF_ITIMER_NS, &internal );
3609  if ( retval == PAPI_OK ) {
3610  _papi_os_info.itimer_ns = internal.itimer.ns;
3611  ptr->itimer.ns = internal.itimer.ns;
3612  }
3613  papi_return( retval );
3614  }
3615  case PAPI_DEF_ITIMER:
3616  {
3617  cidx = 0; /* xxxx for now, assume we only check against cpu component */
3618  if ( ptr->itimer.ns < 0 )
3620  memcpy( &internal.itimer, &ptr->itimer,
3622  /* Low level just checks/adjusts the args for this component */
3623  retval = _papi_hwd[cidx]->ctl( NULL, PAPI_DEF_ITIMER, &internal );
3624  if ( retval == PAPI_OK ) {
3627  if ( ptr->itimer.ns > 0 )
3629  /* flags are currently ignored, eventually the flags will be able
3630  to specify whether or not we use POSIX itimers (clock_gettimer) */
3631  }
3632  papi_return( retval );
3633  }
3634  case PAPI_MULTIPLEX:
3635  {
3636  EventSetInfo_t *ESI;
3638 
3639  if ( ESI == NULL )
3641 
3642  cidx = valid_ESI_component( ESI );
3643  if ( cidx < 0 )
3644  papi_return( cidx );
3645 
3646  if ( !( ESI->state & PAPI_STOPPED ) )
3648  if ( ESI->state & PAPI_MULTIPLEXING )
3650 
3651  if ( ptr->multiplex.ns < 0 )
3653  internal.multiplex.ESI = ESI;
3654  internal.multiplex.ns = ( unsigned long ) ptr->multiplex.ns;
3655  internal.multiplex.flags = ptr->multiplex.flags;
3656  if ( ( _papi_hwd[cidx]->cmp_info.kernel_multiplex ) &&
3657  ( ( ptr->multiplex.flags & PAPI_MULTIPLEX_FORCE_SW ) == 0 ) ) {
3658  /* get the context we should use for this event set */
3659  context = _papi_hwi_get_context( ESI, NULL );
3660  retval = _papi_hwd[cidx]->ctl( context, PAPI_MULTIPLEX, &internal );
3661  }
3662  /* Kernel or PAPI may have changed this value so send it back out to the user */
3663  ptr->multiplex.ns = ( int ) internal.multiplex.ns;
3664  if ( retval == PAPI_OK )
3666  ( &internal.multiplex ) );
3667  return ( retval );
3668  }
3669  case PAPI_DEBUG:
3670  {
3671  int level = ptr->debug.level;
3672  switch ( level ) {
3673  case PAPI_QUIET:
3674  case PAPI_VERB_ESTOP:
3675  case PAPI_VERB_ECONT:
3677  break;
3678  default:
3680  }
3682  return ( PAPI_OK );
3683  }
3684  case PAPI_DEFDOM:
3685  {
3686  int dom = ptr->defdomain.domain;
3687  if ( ( dom < PAPI_DOM_MIN ) || ( dom > PAPI_DOM_MAX ) )
3689 
3690  /* Change the global structure. The _papi_hwd_init_control_state function
3691  in the components gets information from the global structure instead of
3692  per-thread information. */
3693  cidx = valid_component( ptr->defdomain.def_cidx );
3694  if ( cidx < 0 )
3695  papi_return( cidx );
3696 
3697  /* Check what the component supports */
3698 
3699  if ( dom == PAPI_DOM_ALL )
3701 
3702  if ( dom & ~_papi_hwd[cidx]->cmp_info.available_domains )
3704 
3706 
3707  return ( PAPI_OK );
3708  }
3709  case PAPI_DOMAIN:
3710  {
3711  int dom = ptr->domain.domain;
3712  if ( ( dom < PAPI_DOM_MIN ) || ( dom > PAPI_DOM_MAX ) )
3714 
3715  internal.domain.ESI = _papi_hwi_lookup_EventSet( ptr->domain.eventset );
3716  if ( internal.domain.ESI == NULL )
3718 
3719  cidx = valid_ESI_component( internal.domain.ESI );
3720  if ( cidx < 0 )
3721  papi_return( cidx );
3722 
3723  /* Check what the component supports */
3724 
3725  if ( dom == PAPI_DOM_ALL )
3727 
3728  if ( dom & ~_papi_hwd[cidx]->cmp_info.available_domains )
3730 
3731  if ( !( internal.domain.ESI->state & PAPI_STOPPED ) )
3733 
3734  /* Try to change the domain of the eventset in the hardware */
3735  internal.domain.domain = dom;
3736  internal.domain.eventset = ptr->domain.eventset;
3737  /* get the context we should use for this event set */
3738  context = _papi_hwi_get_context( internal.domain.ESI, NULL );
3739  retval = _papi_hwd[cidx]->ctl( context, PAPI_DOMAIN, &internal );
3740  if ( retval < PAPI_OK )
3741  papi_return( retval );
3742 
3743  /* Change the domain of the eventset in the library */
3744 
3745  internal.domain.ESI->domain.domain = dom;
3746 
3747  return ( retval );
3748  }
3749  case PAPI_DEFGRN:
3750  {
3751  int grn = ptr->defgranularity.granularity;
3752  if ( ( grn < PAPI_GRN_MIN ) || ( grn > PAPI_GRN_MAX ) )
3754 
3755  cidx = valid_component( ptr->defgranularity.def_cidx );
3756  if ( cidx < 0 )
3757  papi_return( cidx );
3758 
3759  /* Change the component structure. The _papi_hwd_init_control_state function
3760  in the components gets information from the global structure instead of
3761  per-thread information. */
3762 
3763  /* Check what the component supports */
3764 
3765  if ( grn & ~_papi_hwd[cidx]->cmp_info.available_granularities )
3767 
3768  /* Make sure there is only 1 set. */
3769  if ( grn ^ ( 1 << ( ffs( grn ) - 1 ) ) )
3771 
3773 
3774  return ( PAPI_OK );
3775  }
3776  case PAPI_GRANUL:
3777  {
3778  int grn = ptr->granularity.granularity;
3779 
3780  if ( ( grn < PAPI_GRN_MIN ) || ( grn > PAPI_GRN_MAX ) )
3782 
3783  internal.granularity.ESI =
3785  if ( internal.granularity.ESI == NULL )
3787 
3788  cidx = valid_ESI_component( internal.granularity.ESI );
3789  if ( cidx < 0 )
3790  papi_return( cidx );
3791 
3792  /* Check what the component supports */
3793 
3794  if ( grn & ~_papi_hwd[cidx]->cmp_info.available_granularities )
3796 
3797  /* Make sure there is only 1 set. */
3798  if ( grn ^ ( 1 << ( ffs( grn ) - 1 ) ) )
3800 
3801  internal.granularity.granularity = grn;
3802  internal.granularity.eventset = ptr->granularity.eventset;
3803  retval = _papi_hwd[cidx]->ctl( NULL, PAPI_GRANUL, &internal );
3804  if ( retval < PAPI_OK )
3805  return ( retval );
3806 
3807  internal.granularity.ESI->granularity.granularity = grn;
3808  return ( retval );
3809  }
3810  case PAPI_INHERIT:
3811  {
3812  EventSetInfo_t *ESI;
3814  if ( ESI == NULL )
3816 
3817  cidx = valid_ESI_component( ESI );
3818  if ( cidx < 0 )
3819  papi_return( cidx );
3820 
3821  if ( _papi_hwd[cidx]->cmp_info.inherit == 0 )
3823 
3824  if ( ( ESI->state & PAPI_STOPPED ) == 0 )
3826 
3827  /* if attached to a cpu, return an error */
3828  if (ESI->state & PAPI_CPU_ATTACHED)
3830 
3831  internal.inherit.ESI = ESI;
3832  internal.inherit.inherit = ptr->inherit.inherit;
3833 
3834  /* get the context we should use for this event set */
3835  context = _papi_hwi_get_context( internal.inherit.ESI, NULL );
3836  retval = _papi_hwd[cidx]->ctl( context, PAPI_INHERIT, &internal );
3837  if ( retval < PAPI_OK )
3838  return ( retval );
3839 
3840  ESI->inherit.inherit = ptr->inherit.inherit;
3841  return ( retval );
3842  }
3843  case PAPI_DATA_ADDRESS:
3844  case PAPI_INSTR_ADDRESS:
3845  {
3846 
3847  EventSetInfo_t *ESI;
3848 
3849  ESI = _papi_hwi_lookup_EventSet( ptr->addr.eventset );
3850  if ( ESI == NULL )
3852 
3853  cidx = valid_ESI_component( ESI );
3854  if ( cidx < 0 )
3855  papi_return( cidx );
3856 
3857  internal.address_range.ESI = ESI;
3858 
3859  if ( !( internal.address_range.ESI->state & PAPI_STOPPED ) )
3861 
3862  /*set domain to be PAPI_DOM_USER */
3863  internal.address_range.domain = PAPI_DOM_USER;
3864 
3865  internal.address_range.start = ptr->addr.start;
3866  internal.address_range.end = ptr->addr.end;
3867  /* get the context we should use for this event set */
3868  context = _papi_hwi_get_context( internal.address_range.ESI, NULL );
3869  retval = _papi_hwd[cidx]->ctl( context, option, &internal );
3870  ptr->addr.start_off = internal.address_range.start_off;
3871  ptr->addr.end_off = internal.address_range.end_off;
3872  papi_return( retval );
3873  }
3874  case PAPI_USER_EVENTS_FILE:
3875  {
3876  APIDBG("User Events Filename is -%s-\n", ptr->events_file);
3877 
3878  // go load the user defined event definitions from the applications event definition file
3879  // do not know how to find a pmu name and type for this operation yet
3880 // retval = papi_load_derived_events(pmu_str, pmu_type, cidx, 0);
3881 
3882 // _papi_user_defined_events_setup(ptr->events_file);
3883  return( PAPI_OK );
3884  }
3885  default:
3887  }
3888 }
#define PAPI_ATTACHED
Definition: papi.h:379
i inherit inherit
int _papi_hwi_convert_eventset_to_multiplex(_papi_int_multiplex_t *mpx)
#define PAPI_CPU_ATTACH
Definition: papi.h:455
#define PAPI_VERB_ECONT
Definition: papi.h:387
#define PAPI_DEF_ITIMER_NS
Definition: papi.h:453
#define PAPI_INSTR_ADDRESS
Definition: papi.h:451
#define papi_return(a)
Definition: papi.c:50
#define PAPI_DEF_MPX_NS
Definition: papi.h:434
cpu
Definition: iozone.c:3872
int default_granularity
Definition: papi.h:642
PAPI_debug_handler_t _papi_hwi_debug_handler
Definition: papi_internal.c:54
#define PAPI_DATA_ADDRESS
Definition: papi.h:450
#define PAPI_DOM_MIN
Definition: papi.h:297
PAPI_granularity_option_t granularity
Definition: papi.h:850
#define PAPI_MULTIPLEXING
Definition: papi.h:378
#define PAPI_MULTIPLEX_FORCE_SW
Definition: papi.h:417
#define PAPI_DOM_ALL
Definition: papi.h:301
return PAPI_OK
Definition: linux-nvml.c:458
PAPI_inherit_option_t inherit
Definition: papi.h:849
#define PAPI_DOM_USER
Definition: papi.h:296
return PAPI_EINVAL
Definition: linux-nvml.c:408
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
#define PAPI_NOT_INITED
Definition: papi.h:278
EventSetInfo_t * _papi_hwi_lookup_EventSet(int eventset)
PAPI_user_defined_events_file_t events_file
Definition: papi.h:863
papi_vector_t * _papi_hwd[]
unsigned int cpu_num
Definition: papi.h:821
#define PAPI_INHERIT
Definition: papi.h:456
#define PAPI_CPU_ATTACHED
Definition: papi.h:380
PAPI_addr_range_option_t addr
Definition: papi.h:862
#define APIDBG(format, args...)
Definition: papi_debug.h:64
int multiplex(void)
Definition: multiplex.c:35
#define PAPI_USER_EVENTS_FILE
Definition: papi.h:457
EventSetInheritInfo_t inherit
PAPI_os_info_t _papi_os_info
Definition: aix.c:1210
#define PAPI_ENOEVST
Definition: papi.h:262
static int cidx
Definition: event_info.c:40
#define PAPI_GRANUL
Definition: papi.h:433
#define PAPI_DEFGRN
Definition: papi.h:432
long long
Definition: iozone.c:19827
#define PAPI_DETACH
Definition: papi.h:427
PAPI_cpu_option_t cpu
Definition: papi.h:855
#define PAPI_ATTACH
Definition: papi.h:445
#define PAPI_ECMP
Definition: papi.h:254
int(* ctl)(hwd_context_t *, int, _papi_int_option_t *)
Definition: papi_vector.h:39
#define PAPI_GRN_MAX
Definition: papi.h:366
#define PAPI_EISRUN
Definition: papi.h:261
int _papi_hwi_error_level
Definition: papi_internal.c:53
PAPI_multiplex_option_t multiplex
Definition: papi.h:856
#define PAPI_MULTIPLEX
Definition: papi.h:429
inline_static int valid_ESI_component(EventSetInfo_t *ESI)
Definition: papi.c:94
again struct sockaddr sizeof(struct sockaddr_in))
#define PAPI_DOMAIN
Definition: papi.h:431
EventSetMultiplexInfo_t multiplex
hwd_context_t * _papi_hwi_get_context(EventSetInfo_t *ESI, int *is_dirty)
PAPI_debug_handler_t handler
Definition: papi.h:687
unsigned long tid
Definition: papi.h:815
PAPI_attach_option_t attach
Definition: papi.h:854
PAPI_granularity_option_t defgranularity
Definition: papi.h:851
#define PAPI_DEF_ITIMER
Definition: papi.h:452
int _papi_hwi_lookup_or_create_cpu(CpuInfo_t **here, unsigned int cpu_num)
Definition: cpus.c:59
inline_static int _papi_hwi_lookup_or_create_thread(ThreadInfo_t **here, int tid)
Definition: threads.h:145
PAPI_debug_option_t debug
Definition: papi.h:848
#define PAPI_EINVAL_DOM
Definition: papi.h:272
int
Definition: iozone.c:18528
#define PAPI_QUIET
Definition: papi.h:386
#define PAPI_DEFDOM
Definition: papi.h:430
#define PAPI_STOPPED
Definition: papi.h:372
#define PAPI_ENOINIT
Definition: papi.h:267
PAPI_domain_option_t domain
Definition: papi.h:852
static int attach(hwd_control_state_t *ctl, unsigned long tid)
Definition: perfctr.c:242
#define PAPI_VERB_ESTOP
Definition: papi.h:388
int init_level
Definition: papi_internal.c:52
ssize_t retval
Definition: libasync.c:338
#define PAPI_GRN_MIN
Definition: papi.h:361
#define PAPI_DOM_MAX
Definition: papi.h:303
inline_static int valid_component(int cidx)
Definition: papi.c:86
PAPI_itimer_option_t itimer
Definition: papi.h:857
PAPI_domain_option_t defdomain
Definition: papi.h:853
if(gettimeofday(&tp,(struct timezone *) NULL)==-1) perror("gettimeofday")
#define PAPI_DEBUG
Definition: papi.h:428

Here is the call graph for this function:

Here is the caller graph for this function:

int PAPI_set_thr_specific ( int  tag,
void ptr 
)

save a pointer as a thread specific stored data structure

Definition at line 438 of file papi.c.

439 {
441  int retval = PAPI_OK;
442 
443  if ( init_level == PAPI_NOT_INITED )
445  if ( ( tag < 0 ) || ( tag > PAPI_NUM_TLS ) )
447 
448  retval = _papi_hwi_lookup_or_create_thread( &thread, 0 );
449  if ( retval == PAPI_OK ) {
451  thread->thread_storage[tag] = ptr;
453  }
454  else
455  return ( retval );
456 
457  return ( PAPI_OK );
458 }
#define papi_return(a)
Definition: papi.c:50
return PAPI_OK
Definition: linux-nvml.c:458
return PAPI_EINVAL
Definition: linux-nvml.c:408
#define PAPI_NOT_INITED
Definition: papi.h:278
void * thread_storage[PAPI_MAX_TLS]
Definition: threads.h:29
inline_static int _papi_hwi_lock(int lck)
Definition: threads.h:64
inline_static int _papi_hwi_unlock(int lck)
Definition: threads.h:78
void * thread(void *arg)
Definition: kufrin.c:31
#define THREADS_LOCK
Definition: papi_internal.h:88
#define PAPI_NUM_TLS
Definition: papi.h:320
inline_static int _papi_hwi_lookup_or_create_thread(ThreadInfo_t **here, int tid)
Definition: threads.h:145
#define PAPI_ENOINIT
Definition: papi.h:267
int init_level
Definition: papi_internal.c:52
ssize_t retval
Definition: libasync.c:338
char * ptr
Definition: iozone.c:23586

Here is the call graph for this function:

Here is the caller graph for this function:

finish using PAPI and free all related resources

Definition at line 4452 of file papi.c.

4453 {
4454  APIDBG( "Entry:\n");
4455 
4456  EventSetInfo_t *ESI;
4457  ThreadInfo_t *master;
4459  int i, j = 0, k, retval;
4460 
4461 
4462  if ( init_retval == DEADBEEF ) {
4464  return;
4465  }
4466 
4467  MPX_shutdown( );
4468 
4469  /* Free all EventSets for this thread */
4470 
4471  master = _papi_hwi_lookup_thread( 0 );
4472 
4473  /* Count number of running EventSets AND */
4474  /* Stop any running EventSets in this thread */
4475 
4476 #ifdef DEBUG
4477 again:
4478 #endif
4479  for( i = 0; i < map->totalSlots; i++ ) {
4480  ESI = map->dataSlotArray[i];
4481  if ( ESI ) {
4482  if ( ESI->master == master ) {
4483  if ( ESI->state & PAPI_RUNNING ) {
4484  if((retval = PAPI_stop( i, NULL )) != PAPI_OK) {
4485  APIDBG("Call to PAPI_stop failed: %d\n", retval);
4486  }
4487  }
4488  retval=PAPI_cleanup_eventset( i );
4489  if (retval!=PAPI_OK) PAPIERROR("Error during cleanup.");
4490  _papi_hwi_free_EventSet( ESI );
4491  }
4492  else {
4493  if ( ESI->state & PAPI_RUNNING ) {
4494  j++;
4495  }
4496  }
4497  }
4498  }
4499 
4500  /* No locking required, we're just waiting for the others
4501  to call shutdown or stop their eventsets. */
4502 
4503 #ifdef DEBUG
4504  if ( j != 0 ) {
4506  sleep( 1 );
4507  j = 0;
4508  goto again;
4509  }
4510 #endif
4511 
4512  // if we have some user events defined, release the space they allocated
4513  // give back the strings which were allocated when each event was created
4514  for ( i=0 ; i<user_defined_events_count ; i++) {
4515  papi_free (user_defined_events[i].symbol);
4516  papi_free (user_defined_events[i].postfix);
4517  papi_free (user_defined_events[i].long_descr);
4518  papi_free (user_defined_events[i].short_descr);
4519  papi_free (user_defined_events[i].note);
4520  for ( k=0 ; k<(int)(user_defined_events[i].count) ; k++) {
4522  }
4523  }
4524  // make sure the user events list is empty
4525  memset (user_defined_events, '\0' , sizeof(user_defined_events));
4526  user_defined_events_count = 0;
4527 
4528  /*