PAPI  5.4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
papi_internal.h File Reference
Include dependency graph for papi_internal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  EventSetDomainInfo_t
 
struct  EventSetGranularityInfo_t
 
struct  EventSetOverflowInfo_t
 
struct  EventSetAttachInfo_t
 
struct  EventSetCpuInfo_t
 
struct  EventSetInheritInfo_t
 
struct  EventSetProfileInfo_t
 
struct  EventInfo_t
 
struct  NativeInfo_t
 
struct  PapiInfo
 
struct  MasterEvent
 
struct  Threadlist
 
struct  EventSetInfo_t
 
struct  DynamicArray_t
 
struct  _papi_int_attach_t
 
struct  _papi_int_cpu_t
 
struct  _papi_int_multiplex_t
 
struct  _papi_int_defdomain_t
 
struct  _papi_int_domain_t
 
struct  _papi_int_granularity_t
 
struct  _papi_int_overflow_t
 
struct  _papi_int_profile_t
 
struct  _papi_int_inherit_t
 
struct  _papi_int_addr_range_t
 
union  _papi_int_option_t
 
struct  _papi_hwi_context_t
 
struct  papi_mdi_t
 
struct  PAPI_os_info_t
 

Macros

#define DEADBEEF   0xdedbeef
 
#define PAPI_ERROR_CODE_str   "Error Code"
 
#define PAPI_SHUTDOWN_str   "PAPI_shutdown: PAPI is not initialized"
 
#define PAPI_SHUTDOWN_SYNC_str   "PAPI_shutdown: other threads still have running EventSets"
 
#define PAPI_INT_MPX_SIGNAL   SIGPROF
 
#define PAPI_INT_SIGNAL   SIGPROF
 
#define PAPI_INT_ITIMER   ITIMER_PROF
 
#define PAPI_INT_ITIMER_MS   1
 
#define PAPI_NSIG   128
 
#define PAPI_INT_MPX_DEF_US   10000 /*Default resolution in us. of mpx handler */
 
#define NOT_DERIVED   0x0
 
#define DERIVED_ADD   0x1
 
#define DERIVED_PS   0x2
 
#define DERIVED_ADD_PS   0x4
 
#define DERIVED_CMPD   0x8
 
#define DERIVED_SUB   0x10
 
#define DERIVED_POSTFIX   0x20
 
#define LOWLEVEL_TLS   PAPI_NUM_TLS+0
 
#define NUM_INNER_TLS   1
 
#define PAPI_MAX_TLS   (NUM_INNER_TLS+PAPI_NUM_TLS)
 
#define INTERNAL_LOCK   PAPI_NUM_LOCK+0 /* papi_internal.c */
 
#define MULTIPLEX_LOCK   PAPI_NUM_LOCK+1 /* multiplex.c */
 
#define THREADS_LOCK   PAPI_NUM_LOCK+2 /* threads.c */
 
#define HIGHLEVEL_LOCK   PAPI_NUM_LOCK+3 /* papi_hl.c */
 
#define MEMORY_LOCK   PAPI_NUM_LOCK+4 /* papi_memory.c */
 
#define COMPONENT_LOCK   PAPI_NUM_LOCK+5 /* per-component */
 
#define GLOBAL_LOCK   PAPI_NUM_LOCK+6 /* papi.c for global variable (static and non) initialization/shutdown */
 
#define CPUS_LOCK   PAPI_NUM_LOCK+7 /* cpus.c */
 
#define NAMELIB_LOCK   PAPI_NUM_LOCK+8 /* papi_pfm4_events.c */
 
#define NEED_CONTEXT   1
 
#define DONT_NEED_CONTEXT   0
 
#define PAPI_EVENTS_IN_DERIVED_EVENT   8
 
#define hwd_context_t   void
 
#define hwd_control_state_t   void
 
#define hwd_reg_alloc_t   void
 
#define hwd_register_t   void
 
#define hwd_siginfo_t   void
 
#define hwd_ucontext_t   void
 
#define inline_static   inline static
 

Typedefs

typedef PAPI_itimer_option_t _papi_int_itimer_t
 

Functions

EventSetInfo_t_papi_hwi_lookup_EventSet (int eventset)
 
void _papi_hwi_set_papi_event_string (const char *event_string)
 
char * _papi_hwi_get_papi_event_string (void)
 
void _papi_hwi_free_papi_event_string ()
 
void _papi_hwi_set_papi_event_code (unsigned int event_code, int update_flag)
 
unsigned int _papi_hwi_get_papi_event_code (void)
 
int _papi_hwi_get_ntv_idx (unsigned int papi_evt_code)
 
int _papi_hwi_is_sw_multiplex (EventSetInfo_t *ESI)
 
hwd_context_t_papi_hwi_get_context (EventSetInfo_t *ESI, int *is_dirty)
 
void PAPIERROR (char *format,...)
 
int _papi_hwi_assign_eventset (EventSetInfo_t *ESI, int cidx)
 
void _papi_hwi_free_EventSet (EventSetInfo_t *ESI)
 
int _papi_hwi_create_eventset (int *EventSet, ThreadInfo_t *handle)
 
int _papi_hwi_lookup_EventCodeIndex (const EventSetInfo_t *ESI, unsigned int EventCode)
 
int _papi_hwi_remove_EventSet (EventSetInfo_t *ESI)
 
void _papi_hwi_map_events_to_native (EventSetInfo_t *ESI)
 
int _papi_hwi_add_event (EventSetInfo_t *ESI, int EventCode)
 
int _papi_hwi_remove_event (EventSetInfo_t *ESI, int EventCode)
 
int _papi_hwi_read (hwd_context_t *context, EventSetInfo_t *ESI, long long *values)
 
int _papi_hwi_cleanup_eventset (EventSetInfo_t *ESI)
 
int _papi_hwi_convert_eventset_to_multiplex (_papi_int_multiplex_t *mpx)
 
int _papi_hwi_init_global (void)
 
int _papi_hwi_init_global_internal (void)
 
int _papi_hwi_init_os (void)
 
void _papi_hwi_init_errors (void)
 
PAPI_os_info_t_papi_hwi_get_os_info (void)
 
void _papi_hwi_shutdown_global_internal (void)
 
void _papi_hwi_dummy_handler (int EventSet, void *address, long long overflow_vector, void *context)
 
int _papi_hwi_get_preset_event_info (int EventCode, PAPI_event_info_t *info)
 
int _papi_hwi_derived_type (char *tmp, int *code)
 
int _papi_hwi_query_native_event (unsigned int EventCode)
 
int _papi_hwi_get_native_event_info (unsigned int EventCode, PAPI_event_info_t *info)
 
int _papi_hwi_native_name_to_code (char *in, int *out)
 
int _papi_hwi_native_code_to_name (unsigned int EventCode, char *hwi_name, int len)
 
int _papi_hwi_invalid_cmp (int cidx)
 
int _papi_hwi_component_index (int event_code)
 
int _papi_hwi_native_to_eventcode (int cidx, int event_code, int ntv_idx, const char *event_name)
 
int _papi_hwi_eventcode_to_native (int event_code)
 

Variables

int papi_num_components
 
int _papi_num_compiled_components
 
int init_level
 
int _papi_hwi_errno
 
int _papi_hwi_num_errors
 
char ** _papi_errlist
 
papi_mdi_t _papi_hwi_system_info
 
int _papi_hwi_error_level
 
int _papi_hwi_using_signal [PAPI_NSIG]
 
PAPI_os_info_t _papi_os_info
 
PAPI_debug_handler_t _papi_hwi_debug_handler
 

Detailed Description

Author
Philip Mucci mucci.nosp@m.@cs..nosp@m.utk.e.nosp@m.du
Dan Terpstra terpstra.utk.edu
Kevin London londo.nosp@m.n@cs.nosp@m..utk..nosp@m.edu
Haihang You you@c.nosp@m.s.ut.nosp@m.k.edu

Definition in file papi_internal.h.

Macro Definition Documentation

#define COMPONENT_LOCK   PAPI_NUM_LOCK+5 /* per-component */

Definition at line 90 of file papi_internal.h.

#define CPUS_LOCK   PAPI_NUM_LOCK+7 /* cpus.c */

Definition at line 92 of file papi_internal.h.

#define DEADBEEF   0xdedbeef

Definition at line 26 of file papi_internal.h.

#define DERIVED_ADD   0x1

Add counters

Definition at line 70 of file papi_internal.h.

#define DERIVED_ADD_PS   0x4

Add 2 counters then divide by the cycle counter and xl8 to secs.

Definition at line 72 of file papi_internal.h.

#define DERIVED_CMPD   0x8

Event lives in operand index but takes 2 or more codes

Definition at line 73 of file papi_internal.h.

#define DERIVED_POSTFIX   0x20

Process counters based on specified postfix string

Definition at line 75 of file papi_internal.h.

#define DERIVED_PS   0x2

Divide by the cycle counter and convert to seconds

Definition at line 71 of file papi_internal.h.

#define DERIVED_SUB   0x10

Sub all counters from counter with operand_index

Definition at line 74 of file papi_internal.h.

#define DONT_NEED_CONTEXT   0

Definition at line 98 of file papi_internal.h.

#define GLOBAL_LOCK   PAPI_NUM_LOCK+6 /* papi.c for global variable (static and non) initialization/shutdown */

Definition at line 91 of file papi_internal.h.

#define HIGHLEVEL_LOCK   PAPI_NUM_LOCK+3 /* papi_hl.c */

Definition at line 88 of file papi_internal.h.

#define hwd_context_t   void

Definition at line 106 of file papi_internal.h.

#define hwd_control_state_t   void

Definition at line 107 of file papi_internal.h.

#define hwd_reg_alloc_t   void

Definition at line 108 of file papi_internal.h.

#define hwd_register_t   void

Definition at line 109 of file papi_internal.h.

#define hwd_siginfo_t   void

Definition at line 110 of file papi_internal.h.

#define hwd_ucontext_t   void

Definition at line 111 of file papi_internal.h.

#define inline_static   inline static

Definition at line 123 of file papi_internal.h.

#define INTERNAL_LOCK   PAPI_NUM_LOCK+0 /* papi_internal.c */

Definition at line 85 of file papi_internal.h.

#define LOWLEVEL_TLS   PAPI_NUM_TLS+0

Definition at line 79 of file papi_internal.h.

#define MEMORY_LOCK   PAPI_NUM_LOCK+4 /* papi_memory.c */

Definition at line 89 of file papi_internal.h.

#define MULTIPLEX_LOCK   PAPI_NUM_LOCK+1 /* multiplex.c */

Definition at line 86 of file papi_internal.h.

#define NAMELIB_LOCK   PAPI_NUM_LOCK+8 /* papi_pfm4_events.c */

Definition at line 93 of file papi_internal.h.

#define NEED_CONTEXT   1

Definition at line 97 of file papi_internal.h.

#define NOT_DERIVED   0x0

Do nothing

Definition at line 69 of file papi_internal.h.

#define NUM_INNER_TLS   1

Definition at line 80 of file papi_internal.h.

#define PAPI_ERROR_CODE_str   "Error Code"

Definition at line 41 of file papi_internal.h.

#define PAPI_EVENTS_IN_DERIVED_EVENT   8

Definition at line 100 of file papi_internal.h.

#define PAPI_INT_ITIMER   ITIMER_PROF

Definition at line 54 of file papi_internal.h.

#define PAPI_INT_ITIMER_MS   1

Definition at line 56 of file papi_internal.h.

#define PAPI_INT_MPX_DEF_US   10000 /*Default resolution in us. of mpx handler */

Definition at line 65 of file papi_internal.h.

#define PAPI_INT_MPX_SIGNAL   SIGPROF

Definition at line 52 of file papi_internal.h.

#define PAPI_INT_SIGNAL   SIGPROF

Definition at line 53 of file papi_internal.h.

#define PAPI_MAX_TLS   (NUM_INNER_TLS+PAPI_NUM_TLS)

Definition at line 81 of file papi_internal.h.

#define PAPI_NSIG   128

Definition at line 60 of file papi_internal.h.

#define PAPI_SHUTDOWN_str   "PAPI_shutdown: PAPI is not initialized"

Definition at line 42 of file papi_internal.h.

#define PAPI_SHUTDOWN_SYNC_str   "PAPI_shutdown: other threads still have running EventSets"

Definition at line 43 of file papi_internal.h.

#define THREADS_LOCK   PAPI_NUM_LOCK+2 /* threads.c */

Definition at line 87 of file papi_internal.h.

Typedef Documentation

Definition at line 363 of file papi_internal.h.

Function Documentation

int _papi_hwi_add_event ( EventSetInfo_t ESI,
int  EventCode 
)

Definition at line 1299 of file papi_internal.c.

1300 {
1301  int i, j, thisindex, remap, retval = PAPI_OK;
1302  int cidx;
1303 
1304  cidx=_papi_hwi_component_index( EventCode );
1305  if (cidx<0) return PAPI_ENOCMP;
1306 
1307  /* Sanity check that the new EventCode is from the same component */
1308  /* as previous events. */
1309 
1310  if ( ESI->CmpIdx < 0 ) {
1311  if ( ( retval = _papi_hwi_assign_eventset( ESI, cidx)) != PAPI_OK ) {
1312  return retval;
1313  }
1314  } else {
1315  if ( ESI->CmpIdx != cidx ) {
1316  return PAPI_EINVAL;
1317  }
1318  }
1319 
1320  /* Make sure the event is not present and get the next free slot. */
1321  thisindex = get_free_EventCodeIndex( ESI, ( unsigned int ) EventCode );
1322  if ( thisindex < PAPI_OK ) {
1323  return thisindex;
1324  }
1325 
1326  INTDBG("Adding event to slot %d of EventSet %d\n",thisindex,ESI->EventSetIndex);
1327 
1328  /* If it is a software MPX EventSet, add it to the multiplex data structure */
1329  /* and this thread's multiplex list */
1330 
1331  if ( !_papi_hwi_is_sw_multiplex( ESI ) ) {
1332 
1333  /* Handle preset case */
1334  if ( IS_PRESET(EventCode) ) {
1335  int count;
1336  int preset_index = EventCode & ( int ) PAPI_PRESET_AND_MASK;
1337 
1338  /* Check if it's within the valid range */
1339  if ( ( preset_index < 0 ) || ( preset_index >= PAPI_MAX_PRESET_EVENTS ) ) {
1340  return PAPI_EINVAL;
1341  }
1342 
1343  /* count the number of native events in this preset */
1344  count = ( int ) _papi_hwi_presets[preset_index].count;
1345 
1346  /* Check if event exists */
1347  if ( !count ) {
1348  return PAPI_ENOEVNT;
1349  }
1350 
1351  /* check if the native events have been used as overflow events */
1352  /* this is not allowed */
1353  if ( ESI->state & PAPI_OVERFLOWING ) {
1354  for( i = 0; i < count; i++ ) {
1355  for( j = 0; j < ESI->overflow.event_counter; j++ ) {
1356  if ( ESI->overflow.EventCode[j] ==(int)
1357  ( _papi_hwi_presets[preset_index].code[i] ) ) {
1358  return PAPI_ECNFLCT;
1359  }
1360  }
1361  }
1362  }
1363 
1364  /* Try to add the preset. */
1365 
1366  remap = add_native_events( ESI,
1367  _papi_hwi_presets[preset_index].code,
1368  count, &ESI->EventInfoArray[thisindex] );
1369  if ( remap < 0 ) {
1370  return remap;
1371  }
1372  else {
1373  /* Fill in the EventCode (machine independent) information */
1374  ESI->EventInfoArray[thisindex].event_code =
1375  ( unsigned int ) EventCode;
1376  ESI->EventInfoArray[thisindex].derived =
1377  _papi_hwi_presets[preset_index].derived_int;
1378  ESI->EventInfoArray[thisindex].ops =
1379  _papi_hwi_presets[preset_index].postfix;
1380  ESI->NumberOfEvents++;
1382 
1383  }
1384  }
1385  /* Handle adding Native events */
1386  else if ( IS_NATIVE(EventCode) ) {
1387 
1388  /* Check if native event exists */
1389  if ( _papi_hwi_query_native_event( ( unsigned int ) EventCode ) != PAPI_OK ) {
1390  return PAPI_ENOEVNT;
1391  }
1392 
1393  /* check if the native events have been used as overflow events */
1394  /* This is not allowed */
1395  if ( ESI->state & PAPI_OVERFLOWING ) {
1396  for( j = 0; j < ESI->overflow.event_counter; j++ ) {
1397  if ( EventCode == ESI->overflow.EventCode[j] ) {
1398  return PAPI_ECNFLCT;
1399  }
1400  }
1401  }
1402 
1403  /* Try to add the native event. */
1404 
1405  remap = add_native_events( ESI, (unsigned int *)&EventCode, 1,
1406  &ESI->EventInfoArray[thisindex] );
1407 
1408  if ( remap < 0 ) {
1409  return remap;
1410  } else {
1411 
1412  /* Fill in the EventCode (machine independent) information */
1413  ESI->EventInfoArray[thisindex].event_code =
1414  ( unsigned int ) EventCode;
1415  ESI->NumberOfEvents++;
1417 
1418  }
1419  } else if ( IS_USER_DEFINED( EventCode ) ) {
1420  int count;
1421  int index = EventCode & PAPI_UE_AND_MASK;
1422 
1423  if ( index < 0 || index >= (int)_papi_user_events_count )
1424  return ( PAPI_EINVAL );
1425 
1426  count = ( int ) _papi_user_events[index].count;
1427 
1428  for ( i = 0; i < count; i++ ) {
1429  for ( j = 0; j < ESI->overflow.event_counter; j++ ) {
1430  if ( ESI->overflow.EventCode[j] ==
1431  _papi_user_events[index].events[i] ) {
1432  return ( PAPI_EBUG );
1433  }
1434  }
1435  }
1436 
1437  remap = add_native_events( ESI,
1438  (unsigned int*)_papi_user_events[index].events,
1439  count, &ESI->EventInfoArray[thisindex] );
1440 
1441  if ( remap < 0 ) {
1442  return remap;
1443  } else {
1444  ESI->EventInfoArray[thisindex].event_code
1445  = (unsigned int) EventCode;
1446  ESI->EventInfoArray[thisindex].derived
1447  = DERIVED_POSTFIX;
1448  ESI->EventInfoArray[thisindex].ops
1449  = _papi_user_events[index].operation;
1450  ESI->NumberOfEvents++;
1452  }
1453  } else {
1454 
1455  /* not Native, Preset, or User events */
1456 
1457  return PAPI_EBUG;
1458  }
1459  }
1460  else {
1461 
1462  /* Multiplexing is special. See multiplex.c */
1463 
1464  retval = mpx_add_event( &ESI->multiplex.mpx_evset, EventCode,
1465  ESI->domain.domain,
1466  ESI->granularity.granularity );
1467 
1468 
1469  if ( retval < PAPI_OK ) {
1470  return retval;
1471  }
1472 
1473  /* Relevant (???) */
1474  ESI->EventInfoArray[thisindex].event_code = ( unsigned int ) EventCode;
1475  ESI->EventInfoArray[thisindex].derived = NOT_DERIVED;
1476 
1477  ESI->NumberOfEvents++;
1478 
1479  /* event is in the EventInfoArray but not mapped to the NativeEvents */
1480  /* this causes issues if you try to set overflow on the event. */
1481  /* in theory this wouldn't matter anyway. */
1482  }
1483 
1484  /* reinstate the overflows if any */
1485  retval=update_overflow( ESI );
1486 
1487  return retval;
1488 }
int _papi_hwi_is_sw_multiplex(EventSetInfo_t *ESI)
#define PAPI_ENOEVNT
Definition: papi.h:258
#define PAPI_OVERFLOWING
Definition: papi.h:376
#define IS_PRESET(EventCode)
Definition: papi.h:227
#define IS_USER_DEFINED(EventCode)
Definition: papi.h:228
int _papi_hwi_query_native_event(unsigned int EventCode)
MPX_EventSet * mpx_evset
Definition: sw_multiplex.h:32
#define PAPI_MAX_PRESET_EVENTS
int events[PAPI_EVENTS_IN_DERIVED_EVENT]
EventSetDomainInfo_t domain
#define PAPI_EBUG
Definition: papi.h:257
return PAPI_OK
Definition: linux-nvml.c:458
int count
Definition: iozone.c:22422
return PAPI_EINVAL
Definition: linux-nvml.c:408
#define INTDBG(format, args...)
Definition: papi_debug.h:65
char events[MAX_EVENTS][BUFSIZ]
int i
Definition: fileop.c:140
EventSetOverflowInfo_t overflow
#define IS_NATIVE(EventCode)
Definition: papi.h:226
#define NOT_DERIVED
Definition: papi_internal.h:69
static int cidx
Definition: event_info.c:40
hwi_presets_t _papi_hwi_presets[PAPI_MAX_PRESET_EVENTS]
static int update_overflow(EventSetInfo_t *ESI)
#define PAPI_ECNFLCT
Definition: papi.h:259
int mpx_add_event(MPX_EventSet **mpx_events, int EventCode, int domain, int granularity)
Definition: sw_multiplex.c:305
EventInfo_t * EventInfoArray
#define PAPI_ENOCMP
Definition: papi.h:268
EventSetMultiplexInfo_t multiplex
EventSetGranularityInfo_t granularity
char operation[USER_EVENT_OPERATION_LEN]
int _papi_hwi_assign_eventset(EventSetInfo_t *ESI, int cidx)
int
Definition: iozone.c:18528
unsigned int code[PAPI_MAX_INFO_TERMS]
Definition: papi_preset.h:32
int _papi_hwi_component_index(int event_code)
unsigned int event_code
#define PAPI_UE_AND_MASK
#define PAPI_PRESET_AND_MASK
user_defined_event_t * _papi_user_events
static int add_native_events(EventSetInfo_t *ESI, unsigned int *nevt, int size, EventInfo_t *out)
long j
Definition: iozone.c:19135
ssize_t retval
Definition: libasync.c:338
unsigned int _papi_user_events_count
#define DERIVED_POSTFIX
Definition: papi_internal.h:75
static int get_free_EventCodeIndex(const EventSetInfo_t *ESI, unsigned int EventCode)
void _papi_hwi_map_events_to_native(EventSetInfo_t *ESI)
char * postfix
Definition: papi_preset.h:31

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_hwi_assign_eventset ( EventSetInfo_t ESI,
int  cidx 
)

Definition at line 734 of file papi_internal.c.

735 {
736  int retval;
737  size_t max_counters;
738  char *ptr;
739  unsigned int i, j;
740 
741  /* If component doesn't exist... */
742  if (_papi_hwi_invalid_cmp(cidx)) return PAPI_ECMP;
743 
744  /* Assigned at create time */
746  ESI->granularity.granularity =
748  ESI->CmpIdx = cidx;
749 
750  /* ??? */
751  max_counters = ( size_t ) _papi_hwd[cidx]->cmp_info.num_mpx_cntrs;
752 
753  ESI->ctl_state = (hwd_control_state_t *) papi_calloc( 1, (size_t)
754  _papi_hwd[cidx]->size.control_state );
755  ESI->sw_stop = (long long *) papi_calloc( ( size_t ) max_counters,
756  sizeof ( long long ) );
757  ESI->hw_start = ( long long * ) papi_calloc( ( size_t ) max_counters,
758  sizeof ( long long ) );
759  ESI->EventInfoArray = ( EventInfo_t * ) papi_calloc( (size_t) max_counters,
760  sizeof ( EventInfo_t ) );
761 
762  /* allocate room for the native events and for the component-private */
763  /* register structures */
764  /* ugh is there a cleaner way to allocate this? vmw */
765  ESI->NativeInfoArray = ( NativeInfo_t * )
766  papi_calloc( ( size_t ) max_counters, sizeof ( NativeInfo_t ));
767 
768  ESI->NativeBits = papi_calloc(( size_t ) max_counters,
769  ( size_t ) _papi_hwd[cidx]->size.reg_value );
770 
771  /* NOTE: the next two malloc allocate blocks of memory that are later */
772  /* parcelled into overflow and profile arrays */
773  ESI->overflow.deadline = ( long long * )
774  papi_malloc( ( sizeof ( long long ) +
775  sizeof ( int ) * 3 ) * ( size_t ) max_counters );
776 
777  ESI->profile.prof = ( PAPI_sprofil_t ** )
778  papi_malloc( ( sizeof ( PAPI_sprofil_t * ) * ( size_t ) max_counters +
779  ( size_t ) max_counters * sizeof ( int ) * 4 ) );
780 
781  /* If any of these allocations failed, free things up and fail */
782 
783  if ( ( ESI->ctl_state == NULL ) ||
784  ( ESI->sw_stop == NULL ) ||
785  ( ESI->hw_start == NULL ) ||
786  ( ESI->NativeInfoArray == NULL ) ||
787  ( ESI->NativeBits == NULL ) ||
788  ( ESI->EventInfoArray == NULL ) ||
789  ( ESI->profile.prof == NULL ) ||
790  ( ESI->overflow.deadline == NULL ) ) {
791 
792  if ( ESI->sw_stop ) papi_free( ESI->sw_stop );
793  if ( ESI->hw_start ) papi_free( ESI->hw_start );
794  if ( ESI->EventInfoArray ) papi_free( ESI->EventInfoArray );
795  if ( ESI->NativeInfoArray ) papi_free( ESI->NativeInfoArray );
796  if ( ESI->NativeBits ) papi_free( ESI->NativeBits );
797  if ( ESI->ctl_state ) papi_free( ESI->ctl_state );
798  if ( ESI->overflow.deadline ) papi_free( ESI->overflow.deadline );
799  if ( ESI->profile.prof ) papi_free( ESI->profile.prof );
800  papi_free( ESI );
801  return PAPI_ENOMEM;
802  }
803 
804 
805  /* Carve up the overflow block into separate arrays */
806  ptr = ( char * ) ESI->overflow.deadline;
807  ptr += sizeof ( long long ) * max_counters;
808  ESI->overflow.threshold = ( int * ) ptr;
809  ptr += sizeof ( int ) * max_counters;
810  ESI->overflow.EventIndex = ( int * ) ptr;
811  ptr += sizeof ( int ) * max_counters;
812  ESI->overflow.EventCode = ( int * ) ptr;
813 
814  /* Carve up the profile block into separate arrays */
815  ptr = ( char * ) ESI->profile.prof +
816  ( sizeof ( PAPI_sprofil_t * ) * max_counters );
817  ESI->profile.count = ( int * ) ptr;
818  ptr += sizeof ( int ) * max_counters;
819  ESI->profile.threshold = ( int * ) ptr;
820  ptr += sizeof ( int ) * max_counters;
821  ESI->profile.EventIndex = ( int * ) ptr;
822  ptr += sizeof ( int ) * max_counters;
823  ESI->profile.EventCode = ( int * ) ptr;
824 
825  /* initialize_EventInfoArray */
826 
827  for ( i = 0; i < max_counters; i++ ) {
828  ESI->EventInfoArray[i].event_code=( unsigned int ) PAPI_NULL;
829  ESI->EventInfoArray[i].ops = NULL;
831  for ( j = 0; j < PAPI_EVENTS_IN_DERIVED_EVENT; j++ ) {
832  ESI->EventInfoArray[i].pos[j] = PAPI_NULL;
833  }
834  }
835 
836  /* initialize_NativeInfoArray */
837  for( i = 0; i < max_counters; i++ ) {
838  ESI->NativeInfoArray[i].ni_event = -1;
839  ESI->NativeInfoArray[i].ni_position = -1;
840  ESI->NativeInfoArray[i].ni_papi_code = -1;
841  ESI->NativeInfoArray[i].ni_owners = 0;
842  ESI->NativeInfoArray[i].ni_bits = ((unsigned char*)ESI->NativeBits) +
844  }
845 
846  ESI->NativeCount = 0;
847 
848  ESI->state = PAPI_STOPPED;
849 
850  /* these used to be init_config */
851  retval = _papi_hwd[cidx]->init_control_state( ESI->ctl_state );
852  retval |= _papi_hwd[cidx]->set_domain( ESI->ctl_state, ESI->domain.domain);
853 
854  return retval;
855 }
#define PAPI_EVENTS_IN_DERIVED_EVENT
Definition: genpapifdef.c:39
hwd_register_t * ni_bits
#define papi_free(a)
Definition: papi_memory.h:35
#define papi_malloc(a)
Definition: papi_memory.h:34
int default_granularity
Definition: papi.h:642
#define PAPI_NULL
Definition: papi.h:290
int(* init_control_state)(hwd_control_state_t *ptr)
Definition: papi_vector.h:37
hwd_register_t * NativeBits
EventSetDomainInfo_t domain
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
papi_vector_t * _papi_hwd[]
int i
Definition: fileop.c:140
EventSetOverflowInfo_t overflow
#define NOT_DERIVED
Definition: papi_internal.h:69
char *long long size
Definition: iozone.c:12023
static int cidx
Definition: event_info.c:40
PAPI_sprofil_t ** prof
long long
Definition: iozone.c:19827
#define PAPI_ECMP
Definition: papi.h:254
NativeInfo_t * NativeInfoArray
EventInfo_t * EventInfoArray
#define PAPI_ENOMEM
Definition: papi.h:252
long long * hw_start
int(* set_domain)(hwd_control_state_t *, int)
Definition: papi_vector.h:42
again struct sockaddr sizeof(struct sockaddr_in))
cmp_struct_sizes_t size
Definition: papi_vector.h:23
EventSetGranularityInfo_t granularity
int pos[PAPI_EVENTS_IN_DERIVED_EVENT]
long long * sw_stop
int
Definition: iozone.c:18528
unsigned int event_code
#define PAPI_STOPPED
Definition: papi.h:372
int _papi_hwi_invalid_cmp(int cidx)
EventSetProfileInfo_t profile
hwd_control_state_t * ctl_state
long j
Definition: iozone.c:19135
ssize_t retval
Definition: libasync.c:338
#define papi_calloc(a, b)
Definition: papi_memory.h:37
char * ptr
Definition: iozone.c:23586

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_hwi_cleanup_eventset ( EventSetInfo_t ESI)

Definition at line 1711 of file papi_internal.c.

1712 {
1713  int i, j, num_cntrs, retval;
1714  hwd_context_t *context;
1715  int EventCode;
1717  if ( !_papi_hwi_invalid_cmp( ESI->CmpIdx ) ) {
1718  num_cntrs = _papi_hwd[ESI->CmpIdx]->cmp_info.num_mpx_cntrs;
1719 
1720  for(i=0;i<num_cntrs;i++) {
1721 
1722  EventCode=ESI->EventInfoArray[i].event_code;
1723 
1724  /* skip if event not there */
1725  if ( EventCode == PAPI_NULL ) continue;
1726 
1727  /* If it is a MPX EventSet, remove it from the multiplex */
1728  /* data structure and this thread's multiplex list */
1729 
1730  if ( _papi_hwi_is_sw_multiplex( ESI ) ) {
1731  retval = mpx_remove_event( &ESI->multiplex.mpx_evset, EventCode );
1732  if ( retval < PAPI_OK )
1733  return retval;
1734  } else {
1735 
1736  native = ESI->NativeInfoArray;
1737 
1738  /* clear out ESI->NativeInfoArray */
1739  /* do we really need to do this, seeing as we free() it later? */
1740 
1741  for( j = 0; j < ESI->NativeCount; j++ ) {
1742  native[j].ni_event = -1;
1743  native[j].ni_position = -1;
1744  native[j].ni_owners = 0;
1745  /* native[j].ni_bits?? */
1746  }
1747  }
1748 
1749  /* do we really need to do this, seeing as we free() it later? */
1750  ESI->EventInfoArray[i].event_code= ( unsigned int ) PAPI_NULL;
1751  for( j = 0; j < PAPI_EVENTS_IN_DERIVED_EVENT; j++ ) {
1752  ESI->EventInfoArray[i].pos[j] = PAPI_NULL;
1753  }
1754  ESI->EventInfoArray[i].ops = NULL;
1756  }
1757 
1758  context = _papi_hwi_get_context( ESI, NULL );
1759  /* calling with count of 0 equals a close? */
1760  retval = _papi_hwd[ESI->CmpIdx]->update_control_state( ESI->ctl_state,
1761  NULL, 0, context);
1762  if (retval!=PAPI_OK) {
1763  return retval;
1764  }
1765  }
1766 
1767  ESI->CmpIdx = -1;
1768  ESI->NumberOfEvents = 0;
1769  ESI->NativeCount = 0;
1770 
1771  if ( ( ESI->state & PAPI_MULTIPLEXING ) && ESI->multiplex.mpx_evset )
1772  papi_free( ESI->multiplex.mpx_evset );
1773 
1774  if ( ( ESI->state & PAPI_CPU_ATTACH ) && ESI->CpuInfo )
1776 
1777  if ( ESI->ctl_state )
1778  papi_free( ESI->ctl_state );
1779 
1780  if ( ESI->sw_stop )
1781  papi_free( ESI->sw_stop );
1782 
1783  if ( ESI->hw_start )
1784  papi_free( ESI->hw_start );
1785 
1786  if ( ESI->EventInfoArray )
1787  papi_free( ESI->EventInfoArray );
1788 
1789  if ( ESI->NativeInfoArray )
1790  papi_free( ESI->NativeInfoArray );
1791 
1792  if ( ESI->NativeBits )
1793  papi_free( ESI->NativeBits );
1794 
1795  if ( ESI->overflow.deadline )
1796  papi_free( ESI->overflow.deadline );
1797 
1798  if ( ESI->profile.prof )
1799  papi_free( ESI->profile.prof );
1800 
1801  ESI->ctl_state = NULL;
1802  ESI->sw_stop = NULL;
1803  ESI->hw_start = NULL;
1804  ESI->EventInfoArray = NULL;
1805  ESI->NativeInfoArray = NULL;
1806  ESI->NativeBits = NULL;
1807 
1808  memset( &ESI->domain, 0x0, sizeof(EventSetDomainInfo_t) );
1809  memset( &ESI->granularity, 0x0, sizeof(EventSetGranularityInfo_t) );
1810  memset( &ESI->overflow, 0x0, sizeof(EventSetOverflowInfo_t) );
1811  memset( &ESI->multiplex, 0x0, sizeof(EventSetMultiplexInfo_t) );
1812  memset( &ESI->attach, 0x0, sizeof(EventSetAttachInfo_t) );
1813  memset( &ESI->cpu, 0x0, sizeof(EventSetCpuInfo_t) );
1814  memset( &ESI->profile, 0x0, sizeof(EventSetProfileInfo_t) );
1815  memset( &ESI->inherit, 0x0, sizeof(EventSetInheritInfo_t) );
1816 
1817  ESI->CpuInfo = NULL;
1818 
1819  return PAPI_OK;
1820 }
int _papi_hwi_is_sw_multiplex(EventSetInfo_t *ESI)
memset(eventId, 0, size)
#define PAPI_CPU_ATTACH
Definition: papi.h:455
#define PAPI_EVENTS_IN_DERIVED_EVENT
Definition: genpapifdef.c:39
#define papi_free(a)
Definition: papi_memory.h:35
#define PAPI_NULL
Definition: papi.h:290
MPX_EventSet * mpx_evset
Definition: sw_multiplex.h:32
EventSetAttachInfo_t attach
#define PAPI_MULTIPLEXING
Definition: papi.h:378
hwd_register_t * NativeBits
EventSetDomainInfo_t domain
return PAPI_OK
Definition: linux-nvml.c:458
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
papi_vector_t * _papi_hwd[]
int i
Definition: fileop.c:140
EventSetOverflowInfo_t overflow
EventSetInheritInfo_t inherit
struct _CpuInfo * CpuInfo
#define NOT_DERIVED
Definition: papi_internal.h:69
PAPI_sprofil_t ** prof
static int native
Definition: event_info.c:39
int _papi_hwi_shutdown_cpu(CpuInfo_t *cpu)
Definition: cpus.c:306
NativeInfo_t * NativeInfoArray
EventInfo_t * EventInfoArray
long long * hw_start
EventSetMultiplexInfo_t multiplex
EventSetGranularityInfo_t granularity
hwd_context_t * _papi_hwi_get_context(EventSetInfo_t *ESI, int *is_dirty)
int pos[PAPI_EVENTS_IN_DERIVED_EVENT]
long long * sw_stop
int mpx_remove_event(MPX_EventSet **mpx_events, int EventCode)
Definition: sw_multiplex.c:418
int
Definition: iozone.c:18528
int(* update_control_state)(hwd_control_state_t *, NativeInfo_t *, int, hwd_context_t *)
Definition: papi_vector.h:38
unsigned int event_code
int _papi_hwi_invalid_cmp(int cidx)
EventSetProfileInfo_t profile
hwd_control_state_t * ctl_state
long j
Definition: iozone.c:19135
ssize_t retval
Definition: libasync.c:338
EventSetCpuInfo_t cpu

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_hwi_component_index ( int  event_code)

Definition at line 514 of file papi_internal.c.

514  {
515  INTDBG("ENTER: event_code: %#x\n", event_code);
516 
517  int cidx;
518  int event_index;
519 
520  /* currently assume presets are for component 0 only */
521  if (event_code&PAPI_PRESET_MASK) {
522  INTDBG("EXIT: Event %#x is a PRESET, assigning component %d\n", event_code,0);
523  return 0;
524  }
525 
526  event_index=event_code&PAPI_NATIVE_AND_MASK;
527 
528  if ( (event_index < 0) || (event_index>=num_native_events)) {
529  INTDBG("EXIT: Event index %#x is out of range, num_native_events: %d\n", event_index, num_native_events);
530  return PAPI_ENOEVNT;
531  }
532 
533  cidx=_papi_native_events[event_index].cidx;
534 
535  if ((cidx<0) || (cidx >= papi_num_components)) {
536  INTDBG("EXIT: Component index %#x is out of range, papi_num_components: %d\n", cidx, papi_num_components);
537  return PAPI_ENOCMP;
538  }
539 
540  INTDBG("EXIT: Found cidx: %d event_index: %d, event_code: %#x\n", cidx, event_index, event_code);
541  return cidx;
542 }
#define PAPI_ENOEVNT
Definition: papi.h:258
static struct native_event_info * _papi_native_events
Definition: papi_internal.c:76
#define PAPI_PRESET_MASK
#define INTDBG(format, args...)
Definition: papi_debug.h:65
static int cidx
Definition: event_info.c:40
#define PAPI_ENOCMP
Definition: papi.h:268
int papi_num_components
#define PAPI_NATIVE_AND_MASK
static int num_native_events
Definition: papi_internal.c:77

Here is the caller graph for this function:

int _papi_hwi_convert_eventset_to_multiplex ( _papi_int_multiplex_t mpx)

Definition at line 1823 of file papi_internal.c.

1824 {
1825  int retval, i, j = 0, *mpxlist = NULL;
1826  EventSetInfo_t *ESI = mpx->ESI;
1827  int flags = mpx->flags;
1828 
1829  /* If there are any events in the EventSet,
1830  convert them to multiplex events */
1831 
1832  if ( ESI->NumberOfEvents ) {
1833 
1834  mpxlist =
1835  ( int * ) papi_malloc( sizeof ( int ) *
1836  ( size_t ) ESI->NumberOfEvents );
1837  if ( mpxlist == NULL )
1838  return ( PAPI_ENOMEM );
1839 
1840  /* Build the args to MPX_add_events(). */
1841 
1842  /* Remember the EventInfoArray can be sparse
1843  and the data can be non-contiguous */
1844 
1845  for ( i = 0; i < EventInfoArrayLength( ESI ); i++ )
1846  if ( ESI->EventInfoArray[i].event_code !=
1847  ( unsigned int ) PAPI_NULL )
1848  mpxlist[j++] = ( int ) ESI->EventInfoArray[i].event_code;
1849 
1850  /* Resize the EventInfo_t array */
1851 
1852  if ( ( _papi_hwd[ESI->CmpIdx]->cmp_info.kernel_multiplex == 0 ) ||
1853  ( ( _papi_hwd[ESI->CmpIdx]->cmp_info.kernel_multiplex ) &&
1854  ( flags & PAPI_MULTIPLEX_FORCE_SW ) ) ) {
1855  retval =
1856  MPX_add_events( &ESI->multiplex.mpx_evset, mpxlist, j,
1857  ESI->domain.domain,
1858  ESI->granularity.granularity );
1859  if ( retval != PAPI_OK ) {
1860  papi_free( mpxlist );
1861  return ( retval );
1862  }
1863  }
1864 
1865  papi_free( mpxlist );
1866  }
1867 
1868  /* Update the state before initialization! */
1869 
1870  ESI->state |= PAPI_MULTIPLEXING;
1871  if ( _papi_hwd[ESI->CmpIdx]->cmp_info.kernel_multiplex &&
1872  ( flags & PAPI_MULTIPLEX_FORCE_SW ) )
1874  ESI->multiplex.ns = ( int ) mpx->ns;
1875 
1876  return ( PAPI_OK );
1877 }
static int EventInfoArrayLength(const EventSetInfo_t *ESI)
long long flags
Definition: iozone.c:12330
#define papi_free(a)
Definition: papi_memory.h:35
#define papi_malloc(a)
Definition: papi_memory.h:34
#define PAPI_NULL
Definition: papi.h:290
MPX_EventSet * mpx_evset
Definition: sw_multiplex.h:32
#define PAPI_MULTIPLEXING
Definition: papi.h:378
#define PAPI_MULTIPLEX_FORCE_SW
Definition: papi.h:417
EventSetDomainInfo_t domain
return PAPI_OK
Definition: linux-nvml.c:458
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
papi_vector_t * _papi_hwd[]
int MPX_add_events(MPX_EventSet **mpx_events, int *event_list, int num_events, int domain, int granularity)
Definition: sw_multiplex.c:676
int i
Definition: fileop.c:140
unsigned int kernel_multiplex
Definition: papi.h:653
EventInfo_t * EventInfoArray
#define PAPI_ENOMEM
Definition: papi.h:252
EventSetMultiplexInfo_t multiplex
EventSetGranularityInfo_t granularity
int
Definition: iozone.c:18528
unsigned int event_code
EventSetInfo_t * ESI
return
Definition: iozone.c:22170
long j
Definition: iozone.c:19135
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_hwi_create_eventset ( int EventSet,
ThreadInfo_t handle 
)

Definition at line 910 of file papi_internal.c.

911 {
912  EventSetInfo_t *ESI;
913  int retval;
914 
915  /* Is the EventSet already in existence? */
916 
917  if ( ( EventSet == NULL ) || ( handle == NULL ) )
918  return PAPI_EINVAL;
919 
920  if ( *EventSet != PAPI_NULL )
921  return PAPI_EINVAL;
922 
923  /* Well, then allocate a new one. Use n to keep track of a NEW EventSet */
924 
925  retval = create_EventSet( &ESI );
926  if ( retval != PAPI_OK )
927  return retval;
928 
929  ESI->CmpIdx = -1; /* when eventset is created, it is not decided yet which component it belongs to, until first event is added */
930  ESI->state = PAPI_STOPPED;
931 
932  /* Add it to the global table */
933 
934  retval = add_EventSet( ESI, handle );
935  if ( retval < PAPI_OK ) {
937  return retval ;
938  }
939 
940  *EventSet = ESI->EventSetIndex;
941 
942  INTDBG( "(%p,%p): new EventSet in slot %d\n",
943  ( void * ) EventSet, handle, *EventSet );
944 
945  return retval;
946 }
#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
#define INTDBG(format, args...)
Definition: papi_debug.h:65
#define PAPI_STOPPED
Definition: papi.h:372
void _papi_hwi_free_EventSet(EventSetInfo_t *ESI)
ssize_t retval
Definition: libasync.c:338
static int create_EventSet(EventSetInfo_t **here)
static int add_EventSet(EventSetInfo_t *ESI, ThreadInfo_t *master)

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_hwi_derived_type ( char *  tmp,
int code 
)

Definition at line 2179 of file papi_internal.c.

2180 {
2181  int i = 0;
2182  while ( _papi_hwi_derived[i].name != NULL ) {
2183  if ( strcasecmp( tmp, _papi_hwi_derived[i].name ) == 0 ) {
2184  *code = _papi_hwi_derived[i].value;
2185  return PAPI_OK;
2186  }
2187  i++;
2188  }
2189  INTDBG( "Invalid derived string %s\n", tmp );
2190  return PAPI_EINVAL;
2191 }
return PAPI_OK
Definition: linux-nvml.c:458
return PAPI_EINVAL
Definition: linux-nvml.c:408
#define INTDBG(format, args...)
Definition: papi_debug.h:65
int i
Definition: fileop.c:140
static const hwi_describe_t _papi_hwi_derived[]
char * name
Definition: iozone.c:23648
long long tmp
Definition: iozone.c:12031

Here is the caller graph for this function:

void _papi_hwi_dummy_handler ( int  EventSet,
void address,
long long  overflow_vector,
void context 
)

Definition at line 1977 of file papi_internal.c.

1979 {
1980  /* This function is not used and shouldn't be called. */
1981  ( void ) EventSet; /*unused */
1982  ( void ) address; /*unused */
1983  ( void ) overflow_vector; /*unused */
1984  ( void ) context; /*unused */
1985  return;
1986 }
int EventSet
Definition: data_range.c:25
void
Definition: iozone.c:18627

Here is the caller graph for this function:

int _papi_hwi_eventcode_to_native ( int  event_code)

Definition at line 569 of file papi_internal.c.

569  {
570  INTDBG("ENTER: event_code: %#x\n", event_code);
571 
572  int result;
573  int event_index;
574 
575  event_index=event_code&PAPI_NATIVE_AND_MASK;
576  if (event_index>=num_native_events) {
577  INTDBG("EXIT: PAPI_ENOEVNT\n");
578  return PAPI_ENOEVNT;
579  }
580 
581  result=_papi_native_events[event_index].component_event;
582 
583  INTDBG("EXIT: result: %#x\n", result);
584  return result;
585 
586 }
#define PAPI_ENOEVNT
Definition: papi.h:258
static struct native_event_info * _papi_native_events
Definition: papi_internal.c:76
#define INTDBG(format, args...)
Definition: papi_debug.h:65
#define PAPI_NATIVE_AND_MASK
static int num_native_events
Definition: papi_internal.c:77

Here is the caller graph for this function:

void _papi_hwi_free_EventSet ( EventSetInfo_t ESI)

Definition at line 865 of file papi_internal.c.

866 {
868 
869 #ifdef DEBUG
870  memset( ESI, 0x00, sizeof ( EventSetInfo_t ) );
871 #endif
872  papi_free( ESI );
873 
874 }
memset(eventId, 0, size)
#define papi_free(a)
Definition: papi_memory.h:35
int _papi_hwi_cleanup_eventset(EventSetInfo_t *ESI)

Here is the call graph for this function:

Here is the caller graph for this function:

void _papi_hwi_free_papi_event_string ( )

Definition at line 106 of file papi_internal.c.

106  {
107  if (papi_event_string != NULL) {
109  papi_event_string = NULL;
110  }
111  return;
112 }
char * papi_event_string
Definition: papi_internal.c:87
free(dummyfile[xx])

Here is the call graph for this function:

Here is the caller graph for this function:

hwd_context_t* _papi_hwi_get_context ( EventSetInfo_t ESI,
int is_dirty 
)

Definition at line 2540 of file papi_internal.c.

2541 {
2542  INTDBG("Entry: ESI: %p, is_dirty: %p\n", ESI, is_dirty);
2543  int dirty_ctx;
2544  hwd_context_t *ctx=NULL;
2545 
2546  /* assume for now the control state is clean (last updated by this ESI) */
2547  dirty_ctx = 0;
2548 
2549  /* get a context pointer based on if we are counting for a thread or for a cpu */
2550  if (ESI->state & PAPI_CPU_ATTACHED) {
2551  /* use cpu context */
2552  ctx = ESI->CpuInfo->context[ESI->CmpIdx];
2553 
2554  /* if the user wants to know if the control state was last set by the same event set, tell him */
2555  if (is_dirty != NULL) {
2556  if (ESI->CpuInfo->from_esi != ESI) {
2557  dirty_ctx = 1;
2558  }
2559  *is_dirty = dirty_ctx;
2560  }
2561  ESI->CpuInfo->from_esi = ESI;
2562 
2563  } else {
2564 
2565  /* use thread context */
2566  ctx = ESI->master->context[ESI->CmpIdx];
2567 
2568  /* if the user wants to know if the control state was last set by the same event set, tell him */
2569  if (is_dirty != NULL) {
2570  if (ESI->master->from_esi != ESI) {
2571  dirty_ctx = 1;
2572  }
2573  *is_dirty = dirty_ctx;
2574  }
2575  ESI->master->from_esi = ESI;
2576 
2577  }
2578  return( ctx );
2579 }
#define PAPI_CPU_ATTACHED
Definition: papi.h:380
#define INTDBG(format, args...)
Definition: papi_debug.h:65
struct _CpuInfo * CpuInfo
struct _ThreadInfo * master

Here is the caller graph for this function:

int _papi_hwi_get_native_event_info ( unsigned int  EventCode,
PAPI_event_info_t info 
)

Definition at line 2423 of file papi_internal.c.

2425 {
2426  INTDBG("ENTER: EventCode: %#x, info: %p\n", EventCode, info);
2427  int retval;
2428  int cidx;
2429  int nevt_code;
2430 
2431  cidx = _papi_hwi_component_index( EventCode );
2432  if (cidx<0) return PAPI_ENOCMP;
2433 
2434  if (_papi_hwd[cidx]->cmp_info.disabled) return PAPI_ENOCMP;
2435 
2436  if ( EventCode & PAPI_NATIVE_MASK ) {
2437  // save event code so components can get it with call to: _papi_hwi_get_papi_event_code()
2438  _papi_hwi_set_papi_event_code(EventCode, 0);
2439 
2440  /* clear the event info */
2441  memset( info, 0, sizeof ( PAPI_event_info_t ) );
2442  info->event_code = ( unsigned int ) EventCode;
2443 
2444  retval = _papi_hwd[cidx]->ntv_code_to_info(
2445  _papi_hwi_eventcode_to_native(EventCode), info);
2446 
2447  /* If component error, it's missing the ntv_code_to_info vector */
2448  /* so we'll have to fake it. */
2449  if ( retval == PAPI_ECMP ) {
2450 
2451 
2452  INTDBG("missing NTV_CODE_TO_INFO, faking\n");
2453  /* Fill in the info structure */
2454 
2455  if ((nevt_code = _papi_hwi_eventcode_to_native(EventCode)) < 0) {
2456  INTDBG("EXIT: nevt_code: %d\n", nevt_code);
2457  return nevt_code;
2458  }
2459  if ( (retval = _papi_hwd[cidx]->ntv_code_to_name(
2460  (unsigned int)nevt_code,
2461  info->symbol,
2462  sizeof(info->symbol)) ) == PAPI_OK ) {
2463 
2464  } else {
2465  INTDBG("EXIT: retval: %d\n", retval);
2466  return retval;
2467  }
2468 
2469  if ((nevt_code = _papi_hwi_eventcode_to_native(EventCode)) <0) {
2470  INTDBG("EXIT: nevt_code: %d\n", nevt_code);
2471  return nevt_code;
2472  }
2473  retval = _papi_hwd[cidx]->ntv_code_to_descr(
2474  (unsigned int)nevt_code,
2475  info->long_descr,
2476  sizeof ( info->long_descr));
2477  if (retval!=PAPI_OK) {
2478  INTDBG("Failed ntv_code_to_descr()\n");
2479  }
2480 
2481  }
2483  _papi_hwd[cidx]->cmp_info.short_name,
2484  info->symbol,
2485  info->symbol,
2486  sizeof(info->symbol) );
2487 
2488  INTDBG("EXIT: retval: %d\n", retval);
2489  return retval;
2490  }
2491 
2492  INTDBG("EXIT: PAPI_ENOEVNT\n");
2493  return PAPI_ENOEVNT;
2494 }
#define PAPI_ENOEVNT
Definition: papi.h:258
memset(eventId, 0, size)
#define PAPI_NATIVE_MASK
char long_descr[PAPI_HUGE_STR_LEN]
Definition: papi.h:966
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:963
return PAPI_OK
Definition: linux-nvml.c:458
papi_vector_t * _papi_hwd[]
#define INTDBG(format, args...)
Definition: papi_debug.h:65
static int cidx
Definition: event_info.c:40
int(* ntv_code_to_info)(unsigned int, PAPI_event_info_t *)
Definition: papi_vector.h:48
#define PAPI_ECMP
Definition: papi.h:254
again struct sockaddr sizeof(struct sockaddr_in))
#define PAPI_ENOCMP
Definition: papi.h:268
void _papi_hwi_set_papi_event_code(unsigned int event_code, int update_flag)
int
Definition: iozone.c:18528
int _papi_hwi_component_index(int event_code)
int(* ntv_code_to_descr)(unsigned int, char *, int)
Definition: papi_vector.h:46
int _papi_hwi_prefix_component_name(char *component_name, char *event_name, char *out, int out_len)
int _papi_hwi_eventcode_to_native(int event_code)
unsigned int event_code
Definition: papi.h:961
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_hwi_get_ntv_idx ( unsigned int  papi_evt_code)

Definition at line 141 of file papi_internal.c.

141  {
142  INTDBG("ENTER: papi_evt_code: %#x\n", papi_evt_code);
143 
144  int result;
145  int event_index;
146 
147  if (papi_evt_code == 0) {
148  INTDBG("EXIT: PAPI_ENOEVNT, invalid papi event code\n");
149  return PAPI_ENOEVNT;
150  }
151 
152  event_index=papi_evt_code&PAPI_NATIVE_AND_MASK;
153  if ((event_index<0) || (event_index>=num_native_events)) {
154  INTDBG("EXIT: PAPI_ENOEVNT, invalid index into native event array\n");
155  return PAPI_ENOEVNT;
156  }
157 
158  result=_papi_native_events[event_index].ntv_idx;
159 
160  INTDBG("EXIT: result: %d\n", result);
161  return result;
162 }
#define PAPI_ENOEVNT
Definition: papi.h:258
static struct native_event_info * _papi_native_events
Definition: papi_internal.c:76
#define INTDBG(format, args...)
Definition: papi_debug.h:65
#define PAPI_NATIVE_AND_MASK
static int num_native_events
Definition: papi_internal.c:77

Here is the caller graph for this function:

PAPI_os_info_t* _papi_hwi_get_os_info ( void  )
unsigned int _papi_hwi_get_papi_event_code ( void  )

Definition at line 135 of file papi_internal.c.

135  {
136  INTDBG("papi_event_code: %#x\n", papi_event_code);
137  return papi_event_code;
138 }
static unsigned int papi_event_code
#define INTDBG(format, args...)
Definition: papi_debug.h:65

Here is the caller graph for this function:

char* _papi_hwi_get_papi_event_string ( void  )

Definition at line 101 of file papi_internal.c.

101  {
102  INTDBG("papi_event_string: %s\n", papi_event_string);
103  return papi_event_string;
104 }
char * papi_event_string
Definition: papi_internal.c:87
#define INTDBG(format, args...)
Definition: papi_debug.h:65

Here is the caller graph for this function:

int _papi_hwi_get_preset_event_info ( int  EventCode,
PAPI_event_info_t info 
)

Definition at line 2223 of file papi_internal.c.

2224 {
2225  INTDBG("ENTER: EventCode: %#x, info: %p\n", EventCode, info);
2226 
2227  int i = EventCode & PAPI_PRESET_AND_MASK;
2228  unsigned int j;
2229 
2230  if ( _papi_hwi_presets[i].symbol ) { /* if the event is in the preset table */
2231  // since we are setting the whole structure to zero the strncpy calls below will
2232  // be leaving NULL terminates strings as long as they copy 1 less byte than the
2233  // buffer size of the field.
2234  memset( info, 0, sizeof ( PAPI_event_info_t ) );
2235 
2236  info->event_code = ( unsigned int ) EventCode;
2237  strncpy( info->symbol, _papi_hwi_presets[i].symbol,
2238  sizeof(info->symbol)-1);
2239 
2240  if ( _papi_hwi_presets[i].short_descr != NULL )
2241  strncpy( info->short_descr, _papi_hwi_presets[i].short_descr,
2242  sizeof ( info->short_descr )-1 );
2243 
2244  if ( _papi_hwi_presets[i].long_descr != NULL )
2245  strncpy( info->long_descr, _papi_hwi_presets[i].long_descr,
2246  sizeof ( info->long_descr )-1 );
2247 
2249  info->count = _papi_hwi_presets[i].count;
2250 
2252  info->derived, sizeof ( info->derived ) );
2253 
2254  if ( _papi_hwi_presets[i].postfix != NULL )
2255  strncpy( info->postfix, _papi_hwi_presets[i].postfix,
2256  sizeof ( info->postfix )-1 );
2257 
2258  for(j=0;j < info->count; j++) {
2259  info->code[j]=_papi_hwi_presets[i].code[j];
2260  strncpy(info->name[j], _papi_hwi_presets[i].name[j],
2261  sizeof(info->name[j])-1);
2262  }
2263 
2264  if ( _papi_hwi_presets[i].note != NULL ) {
2265  strncpy( info->note, _papi_hwi_presets[i].note,
2266  sizeof ( info->note )-1 );
2267  }
2268 
2269  return PAPI_OK;
2270  } else {
2271  return PAPI_ENOEVNT;
2272  }
2273 }
#define PAPI_ENOEVNT
Definition: papi.h:258
unsigned int count
Definition: papi.h:984
memset(eventId, 0, size)
char long_descr[PAPI_HUGE_STR_LEN]
Definition: papi.h:966
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:963
static int _papi_hwi_derived_string(int type, char *derived, int len)
return PAPI_OK
Definition: linux-nvml.c:458
char note[PAPI_HUGE_STR_LEN]
Definition: papi.h:1010
#define INTDBG(format, args...)
Definition: papi_debug.h:65
unsigned int event_type
Definition: papi_preset.h:30
int i
Definition: fileop.c:140
char short_descr[PAPI_MIN_STR_LEN]
Definition: papi.h:964
hwi_presets_t _papi_hwi_presets[PAPI_MAX_PRESET_EVENTS]
unsigned int event_type
Definition: papi.h:989
char * short_descr
Definition: papi_preset.h:25
unsigned int code[PAPI_MAX_INFO_TERMS]
Definition: papi.h:1000
again struct sockaddr sizeof(struct sockaddr_in))
char * long_descr
Definition: papi_preset.h:26
int
Definition: iozone.c:18528
unsigned int code[PAPI_MAX_INFO_TERMS]
Definition: papi_preset.h:32
char * name[PAPI_MAX_INFO_TERMS]
Definition: papi_preset.h:33
#define PAPI_PRESET_AND_MASK
long j
Definition: iozone.c:19135
unsigned int event_code
Definition: papi.h:961
char * symbol
Definition: papi_preset.h:24
char derived[PAPI_MIN_STR_LEN]
Definition: papi.h:992
char postfix[PAPI_2MAX_STR_LEN]
Definition: papi.h:995
unsigned int count
Definition: papi_preset.h:29
char name[PAPI_MAX_INFO_TERMS][PAPI_2MAX_STR_LEN]
Definition: papi.h:1006
char * postfix
Definition: papi_preset.h:31

Here is the call graph for this function:

Here is the caller graph for this function:

void _papi_hwi_init_errors ( void  )

Definition at line 477 of file papi_internal.c.

477  {
478 /* we use add error to avoid the cost of lookups, we know the errors are not there yet */
479  _papi_hwi_add_error("No error");
480  _papi_hwi_add_error("Invalid argument");
481  _papi_hwi_add_error("Insufficient memory");
482  _papi_hwi_add_error("A System/C library call failed");
483  _papi_hwi_add_error("Not supported by component");
484  _papi_hwi_add_error("Access to the counters was lost or interrupted");
485  _papi_hwi_add_error("Internal error, please send mail to the developers");
486  _papi_hwi_add_error("Event does not exist");
487  _papi_hwi_add_error("Event exists, but cannot be counted due to hardware resource limits");
488  _papi_hwi_add_error("EventSet is currently not running");
489  _papi_hwi_add_error("EventSet is currently counting");
490  _papi_hwi_add_error("No such EventSet available");
491  _papi_hwi_add_error("Event in argument is not a valid preset");
492  _papi_hwi_add_error("Hardware does not support performance counters");
493  _papi_hwi_add_error("Unknown error code");
494  _papi_hwi_add_error("Permission level does not permit operation");
495  _papi_hwi_add_error("PAPI hasn't been initialized yet");
496  _papi_hwi_add_error("Component Index isn't set");
497  _papi_hwi_add_error("Not supported");
498  _papi_hwi_add_error("Not implemented");
499  _papi_hwi_add_error("Buffer size exceeded");
500  _papi_hwi_add_error("EventSet domain is not supported for the operation");
501  _papi_hwi_add_error("Invalid or missing event attributes");
502  _papi_hwi_add_error("Too many events or attributes");
503  _papi_hwi_add_error("Bad combination of features");
504 }
static int _papi_hwi_add_error(char *error)

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_hwi_init_global ( void  )

Definition at line 1889 of file papi_internal.c.

1890 {
1891  int retval, i = 0;
1892 
1894  if ( retval != PAPI_OK ) {
1895  return retval;
1896  }
1897 
1898  while ( _papi_hwd[i] ) {
1899 
1900  retval = _papi_hwi_innoculate_vector( _papi_hwd[i] );
1901  if ( retval != PAPI_OK ) {
1902  return retval;
1903  }
1904 
1905  /* We can be disabled by user before init */
1906  if (!_papi_hwd[i]->cmp_info.disabled) {
1907  retval = _papi_hwd[i]->init_component( i );
1909 
1910  /* Do some sanity checking */
1911  if (retval==PAPI_OK) {
1912  if (_papi_hwd[i]->cmp_info.num_cntrs >
1914  fprintf(stderr,"Warning! num_cntrs is more than num_mpx_cntrs\n");
1915  }
1916 
1917  }
1918  }
1919 
1920  i++;
1921  }
1922  return PAPI_OK;
1923 }
int _papi_hwi_innoculate_os_vector(papi_os_vector_t *v)
Definition: papi_vector.c:200
return PAPI_OK
Definition: linux-nvml.c:458
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
papi_vector_t * _papi_hwd[]
papi_os_vector_t _papi_os_vector
Definition: aix.c:1288
int i
Definition: fileop.c:140
int _papi_hwi_innoculate_vector(papi_vector_t *v)
Definition: papi_vector.c:109
ssize_t retval
Definition: libasync.c:338
int(* init_component)(int)
Definition: papi_vector.h:35

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_hwi_init_global_internal ( void  )

Definition at line 1929 of file papi_internal.c.

1930 {
1931 
1932  int retval;
1933 
1935 
1937 
1938  /* Global struct to maintain EventSet mapping */
1940  if ( retval != PAPI_OK ) {
1941  return retval;
1942  }
1943 
1944  _papi_hwi_system_info.pid = 0; /* Process identifier */
1945 
1946  /* PAPI_hw_info_t struct */
1948 
1949  return PAPI_OK;
1950 }
memset(eventId, 0, size)
int _papi_hwi_using_signal[PAPI_NSIG]
Definition: extras.c:363
Hardware info structure.
Definition: papi.h:777
return PAPI_OK
Definition: linux-nvml.c:458
DynamicArray_t global_eventset_map
static int allocate_eventset_map(DynamicArray_t *map)
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:57
PAPI_hw_info_t hw_info
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_hwi_init_os ( void  )

Definition at line 1213 of file aix.c.

1213  {
1214 
1215  struct utsname uname_buffer;
1216 
1217  uname(&uname_buffer);
1218 
1219  strncpy(_papi_os_info.name,uname_buffer.sysname,PAPI_MAX_STR_LEN);
1220 
1221  strncpy(_papi_os_info.version,uname_buffer.release,PAPI_MAX_STR_LEN);
1222 
1227 
1228  return PAPI_OK;
1229 
1230 }
#define PAPI_INT_MPX_DEF_US
Definition: papi_internal.h:65
return PAPI_OK
Definition: linux-nvml.c:458
char name[PAPI_MAX_STR_LEN]
PAPI_os_info_t _papi_os_info
Definition: aix.c:1210
#define PAPI_INT_ITIMER
Definition: papi_internal.h:54
char version[PAPI_MAX_STR_LEN]
#define PAPI_INT_MPX_SIGNAL
Definition: papi_internal.h:52
#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_hwi_invalid_cmp ( int  cidx)

Definition at line 507 of file papi_internal.c.

508 {
509  return ( cidx < 0 || cidx >= papi_num_components );
510 }
int papi_num_components

Here is the caller graph for this function:

int _papi_hwi_is_sw_multiplex ( EventSetInfo_t ESI)

Definition at line 2516 of file papi_internal.c.

2517 {
2518  /* Are we multiplexing at all */
2519  if ( ( ESI->state & PAPI_MULTIPLEXING ) == 0 ) {
2520  return 0;
2521  }
2522 
2523  /* Does the component support kernel multiplexing */
2524  if ( _papi_hwd[ESI->CmpIdx]->cmp_info.kernel_multiplex ) {
2525  /* Have we forced software multiplexing */
2526  if ( ESI->multiplex.flags == PAPI_MULTIPLEX_FORCE_SW ) {
2527  return 1;
2528  }
2529  /* Nope, using hardware multiplexing */
2530  return 0;
2531  }
2532 
2533  /* We are multiplexing but the component does not support hardware */
2534 
2535  return 1;
2536 
2537 }
#define PAPI_MULTIPLEXING
Definition: papi.h:378
#define PAPI_MULTIPLEX_FORCE_SW
Definition: papi.h:417
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
papi_vector_t * _papi_hwd[]
unsigned int kernel_multiplex
Definition: papi.h:653
EventSetMultiplexInfo_t multiplex

Here is the caller graph for this function:

int _papi_hwi_lookup_EventCodeIndex ( const EventSetInfo_t ESI,
unsigned int  EventCode 
)

Definition at line 978 of file papi_internal.c.

980 {
981  int i;
982  int limit = EventInfoArrayLength( ESI );
983 
984  for ( i = 0; i < limit; i++ ) {
985  if ( ESI->EventInfoArray[i].event_code == EventCode ) {
986  return i;
987  }
988  }
989 
990  return PAPI_EINVAL;
991 }
static int EventInfoArrayLength(const EventSetInfo_t *ESI)
return PAPI_EINVAL
Definition: linux-nvml.c:408
int i
Definition: fileop.c:140
EventInfo_t * EventInfoArray
unsigned int event_code

Here is the call graph for this function:

Here is the caller graph for this function:

EventSetInfo_t* _papi_hwi_lookup_EventSet ( int  eventset)

Definition at line 2497 of file papi_internal.c.

2498 {
2500  EventSetInfo_t *set;
2501 
2502  if ( ( eventset < 0 ) || ( eventset > map->totalSlots ) )
2503  return ( NULL );
2504 
2505  set = map->dataSlotArray[eventset];
2506 #ifdef DEBUG
2507  if ( ( ISLEVEL( DEBUG_THREADS ) ) && ( _papi_hwi_thread_id_fn ) &&
2508  ( set->master->tid != _papi_hwi_thread_id_fn( ) ) )
2509  return ( NULL );
2510 #endif
2511 
2512  return ( set );
2513 }
DynamicArray_t global_eventset_map
struct _ThreadInfo * master
unsigned long int(* _papi_hwi_thread_id_fn)(void)
Definition: threads.c:42
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:57
EventSetInfo_t ** dataSlotArray
#define ISLEVEL(a)
Definition: papi_debug.h:54
#define DEBUG_THREADS
Definition: papi_debug.h:30

Here is the caller graph for this function:

void _papi_hwi_map_events_to_native ( EventSetInfo_t ESI)

Definition at line 1058 of file papi_internal.c.

1059 {
1060  INTDBG("ENTER: ESI: %p, ESI->EventInfoArray: %p, ESI->NativeInfoArray: %p, ESI->NumberOfEvents: %d, ESI->NativeCount: %d\n", ESI, ESI->EventInfoArray, ESI->NativeInfoArray, ESI->NumberOfEvents, ESI->NativeCount);
1061 
1062  int i, event, k, n, preset_index = 0, nevt;
1063  int total_events = ESI->NumberOfEvents;
1064 
1065  event = 0;
1066  for( i = 0; i < total_events; i++ ) {
1067 
1068  /* find the first event that isn't PAPI_NULL */
1069  /* Is this really necessary? --vmw */
1070  while ( ESI->EventInfoArray[event].event_code == ( unsigned int ) PAPI_NULL ) {
1071  event++;
1072  }
1073 
1074  /* If it's a preset */
1075  if ( IS_PRESET(ESI->EventInfoArray[event].event_code) ) {
1076  preset_index = ( int ) ESI->EventInfoArray[event].event_code & PAPI_PRESET_AND_MASK;
1077 
1078  /* walk all sub-events in the preset */
1079  for( k = 0; k < PAPI_EVENTS_IN_DERIVED_EVENT; k++ ) {
1080  nevt = _papi_hwi_presets[preset_index].code[k];
1081  if ( nevt == PAPI_NULL ) {
1082  break;
1083  }
1084 
1085  INTDBG("Looking for subevent %#x\n",nevt);
1086 
1087  /* Match each sub-event to something in the Native List */
1088  for( n = 0; n < ESI->NativeCount; n++ ) {
1089  if ( nevt == ESI->NativeInfoArray[n].ni_papi_code ) {
1090  INTDBG("Found papi event: %#x, &ESI->NativeInfoArray[%d]: %p, ni_event: %#x, ni_position %d\n",
1091  nevt, n, &(ESI->NativeInfoArray[n]), ESI->NativeInfoArray[n].ni_event, ESI->NativeInfoArray[n].ni_position);
1093  break;
1094  }
1095  }
1096  }
1097  }
1098  /* It's a native event */
1099  else if( IS_NATIVE(ESI->EventInfoArray[event].event_code) ) {
1100  nevt = ( int ) ESI->EventInfoArray[event].event_code;
1101 
1102  // get index into native info array for this event
1103  int nidx = event_already_in_eventset( ESI, nevt );
1104  // if not found, then we need to return an error
1105  if (nidx == PAPI_ENOEVNT) {
1106  INTDBG("EXIT: needed event not found\n");
1107  return;
1108  }
1109  ESI->EventInfoArray[event].pos[0] = ESI->NativeInfoArray[nidx].ni_position;
1110  INTDBG("nidx: %d, ni_position: %d\n", nidx, ESI->NativeInfoArray[nidx].ni_position);
1111 
1112  /* It's a user-defined event */
1113  } else if ( IS_USER_DEFINED(ESI->EventInfoArray[event].event_code) ) {
1114  for ( k = 0; k < PAPI_EVENTS_IN_DERIVED_EVENT; k++ ) {
1115  nevt = _papi_user_events[preset_index].events[k];
1116  if ( nevt == PAPI_NULL ) break;
1117 
1118  /* Match each sub-event to something in the Native List */
1119  for ( n = 0; n < ESI->NativeCount; n++ ) {
1120  if ( _papi_hwi_eventcode_to_native(nevt) == ESI->NativeInfoArray[n].ni_event ) {
1122  }
1123  }
1124  }
1125  }
1126  event++;
1127  }
1128 }
#define PAPI_ENOEVNT
Definition: papi.h:258
#define IS_PRESET(EventCode)
Definition: papi.h:227
#define PAPI_EVENTS_IN_DERIVED_EVENT
Definition: genpapifdef.c:39
#define IS_USER_DEFINED(EventCode)
Definition: papi.h:228
#define PAPI_NULL
Definition: papi.h:290
device[deviceId] domain[domainId] event
Definition: linux-cuda.c:306
int events[PAPI_EVENTS_IN_DERIVED_EVENT]
#define INTDBG(format, args...)
Definition: papi_debug.h:65
int i
Definition: fileop.c:140
static int event_already_in_eventset(EventSetInfo_t *ESI, int papi_event)
#define IS_NATIVE(EventCode)
Definition: papi.h:226
int k
Definition: iozone.c:19136
hwi_presets_t _papi_hwi_presets[PAPI_MAX_PRESET_EVENTS]
NativeInfo_t * NativeInfoArray
EventInfo_t * EventInfoArray
int pos[PAPI_EVENTS_IN_DERIVED_EVENT]
int
Definition: iozone.c:18528
unsigned int code[PAPI_MAX_INFO_TERMS]
Definition: papi_preset.h:32
unsigned int event_code
#define PAPI_PRESET_AND_MASK
user_defined_event_t * _papi_user_events
int _papi_hwi_eventcode_to_native(int event_code)
int n
Definition: mendes-alt.c:164

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_hwi_native_code_to_name ( unsigned int  EventCode,
char *  hwi_name,
int  len 
)

Definition at line 2385 of file papi_internal.c.

2387 {
2388  INTDBG("ENTER: EventCode: %#x, hwi_name: %p, len: %d\n", EventCode, hwi_name, len);
2389  int cidx;
2390  int retval;
2391  int nevt_code;
2392 
2393  cidx = _papi_hwi_component_index( EventCode );
2394  if (cidx<0) return PAPI_ENOEVNT;
2395 
2396  if ( EventCode & PAPI_NATIVE_MASK ) {
2397  // save event code so components can get it with call to: _papi_hwi_get_papi_event_code()
2398  _papi_hwi_set_papi_event_code(EventCode, 0);
2399 
2400  if ((nevt_code = _papi_hwi_eventcode_to_native(EventCode)) < 0) {
2401  INTDBG("EXIT: nevt_code: %d\n", nevt_code);
2402  return nevt_code;
2403  }
2404  if ( (retval = _papi_hwd[cidx]->ntv_code_to_name(
2405  (unsigned int)nevt_code,
2406  hwi_name, len) ) == PAPI_OK ) {
2407  retval = _papi_hwi_prefix_component_name( _papi_hwd[cidx]->cmp_info.short_name,
2408  hwi_name, hwi_name, len);
2409  INTDBG("EXIT: retval: %d\n", retval);
2410  return retval;
2411  }
2412  INTDBG("EXIT: retval: %d\n", retval);
2413  return (retval);
2414  }
2415  INTDBG("EXIT: PAPI_ENOEVNT\n");
2416  return PAPI_ENOEVNT;
2417 }
#define PAPI_ENOEVNT
Definition: papi.h:258
#define PAPI_NATIVE_MASK
return PAPI_OK
Definition: linux-nvml.c:458
papi_vector_t * _papi_hwd[]
#define INTDBG(format, args...)
Definition: papi_debug.h:65
static int cidx
Definition: event_info.c:40
void _papi_hwi_set_papi_event_code(unsigned int event_code, int update_flag)
int _papi_hwi_component_index(int event_code)
int _papi_hwi_prefix_component_name(char *component_name, char *event_name, char *out, int out_len)
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_hwi_native_name_to_code ( char *  in,
int out 
)

Definition at line 2310 of file papi_internal.c.

2311 {
2312  INTDBG("ENTER: in: %s, out: %p\n", in, out);
2313 
2314  int retval = PAPI_ENOEVNT;
2315  char name[PAPI_HUGE_STR_LEN]; /* make sure it's big enough */
2316  unsigned int i;
2317  int cidx;
2318  char *full_event_name = strdup(in);
2319 
2321 
2322 
2323  for(cidx=0; cidx < papi_num_components; cidx++) {
2324 
2325  if (_papi_hwd[cidx]->cmp_info.disabled) continue;
2326 
2327  // if this component does not support the pmu which defines this event, no need to call it
2328  if (is_supported_by_component(cidx, full_event_name) == 0) continue;
2329 
2330  INTDBG("cidx: %d, name: %s, event: %s\n", cidx, _papi_hwd[cidx]->cmp_info.name, in);
2331 
2332  // show that we do not have an event code yet (the component may create one and update this info)
2333  // this also clears any values left over from a previous call
2335 
2336  /* first check the component for name_to_code */
2337  retval = _papi_hwd[cidx]->ntv_name_to_code( in, ( unsigned * ) out );
2338  if (retval==PAPI_OK) {
2339  *out = _papi_hwi_native_to_eventcode(cidx, *out, -1, in);
2340  free (full_event_name);
2341  INTDBG("EXIT: PAPI_OK event: %s code: %#x\n", in, *out);
2342  return PAPI_OK;
2343  }
2344 
2345  /* If not implemented, work around */
2346  if ( retval==PAPI_ECMP) {
2347  i = 0;
2349 
2350 // _papi_hwi_lock( INTERNAL_LOCK );
2351 
2352  do {
2353  // save event code so components can get it with call to: _papi_hwi_get_papi_event_code()
2355  retval = _papi_hwd[cidx]->ntv_code_to_name(
2356  i,
2357  name, sizeof(name));
2358  /* printf("%#x\nname =|%s|\ninput=|%s|\n", i, name, in); */
2359  if ( retval == PAPI_OK && in != NULL) {
2360  if ( strcasecmp( name, in ) == 0 ) {
2361  *out = _papi_hwi_native_to_eventcode(cidx, i, -1, name);
2362  INTDBG("EXIT: PAPI_OK, event: %s, code: %#x\n", in, *out);
2363  return PAPI_OK;
2364  }
2365  retval = PAPI_ENOEVNT;
2366  } else {
2367  *out = 0;
2368  retval = PAPI_ENOEVNT;
2369  break;
2370  }
2371  } while ( ( _papi_hwd[cidx]->ntv_enum_events( &i, PAPI_ENUM_EVENTS ) == PAPI_OK ) );
2372 
2373 // _papi_hwi_unlock( INTERNAL_LOCK );
2374  }
2375  }
2376 
2377  free (full_event_name);
2378  INTDBG("EXIT: retval: %d\n", retval);
2379  return retval;
2380 }
#define PAPI_ENOEVNT
Definition: papi.h:258
static int is_supported_by_component(int cidx, char *event_name)
int(* ntv_code_to_name)(unsigned int, char *, int)
Definition: papi_vector.h:45
return PAPI_OK
Definition: linux-nvml.c:458
papi_vector_t * _papi_hwd[]
#define PAPI_HUGE_STR_LEN
Definition: papi.h:465
#define INTDBG(format, args...)
Definition: papi_debug.h:65
char * _papi_hwi_strip_component_prefix(char *event_name)
int i
Definition: fileop.c:140
int _papi_hwi_native_to_eventcode(int cidx, int event_code, int ntv_idx, const char *event_name)
free(dummyfile[xx])
static int cidx
Definition: event_info.c:40
#define PAPI_ECMP
Definition: papi.h:254
goto out
Definition: pscanf.h:20
void _papi_hwi_set_papi_event_code(unsigned int event_code, int update_flag)
int papi_num_components
int(* ntv_enum_events)(unsigned int *, int)
Definition: papi_vector.h:43
char * name
Definition: iozone.c:23648
int(* ntv_name_to_code)(char *, unsigned int *)
Definition: papi_vector.h:44
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_hwi_native_to_eventcode ( int  cidx,
int  event_code,
int  ntv_idx,
const char *  event_name 
)

Definition at line 546 of file papi_internal.c.

546  {
547  INTDBG("Entry: cidx: %d, event: %#x, ntv_idx: %d, event_name: %s\n", cidx, event_code, ntv_idx, event_name);
548 
549  int result;
550 
551  if (papi_event_code_changed > 0) {
553  INTDBG("EXIT: papi_event_code: %#x set by the component\n", result);
554  return result;
555  }
556 
557  result=_papi_hwi_find_native_event(cidx, event_code, event_name);
558  if (result==PAPI_ENOEVNT) {
559  // Need to create one
560  result=_papi_hwi_add_native_event(cidx, event_code, ntv_idx, event_name);
561  }
562 
563  INTDBG("EXIT: result: %#x\n", result);
564  return result;
565 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:23
#define PAPI_ENOEVNT
Definition: papi.h:258
unsigned int _papi_hwi_get_papi_event_code()
static int _papi_hwi_find_native_event(int cidx, int event, const char *event_name)
#define INTDBG(format, args...)
Definition: papi_debug.h:65
static int cidx
Definition: event_info.c:40
static int _papi_hwi_add_native_event(int cidx, int ntv_event, int ntv_idx, const char *event_name)
static int papi_event_code_changed

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_hwi_query_native_event ( unsigned int  EventCode)

Definition at line 2279 of file papi_internal.c.

2280 {
2281  INTDBG("ENTER: EventCode: %#x\n", EventCode);
2282  char name[PAPI_HUGE_STR_LEN]; /* probably overkill, */
2283  /* but should always be big enough */
2284  int cidx;
2285  int nevt_code;
2286 
2287  cidx = _papi_hwi_component_index( EventCode );
2288  if (cidx<0) {
2289  INTDBG("EXIT: PAPI_ENOCMP\n");
2290  return PAPI_ENOCMP;
2291  }
2292 
2293  // save event code so components can get it with call to: _papi_hwi_get_papi_event_code()
2294  _papi_hwi_set_papi_event_code(EventCode, 0);
2295 
2296  if ((nevt_code = _papi_hwi_eventcode_to_native(EventCode)) < 0) {
2297  INTDBG("EXIT: nevt_code: %d\n", nevt_code);
2298  return nevt_code;
2299  }
2300  int ret = _papi_hwd[cidx]->ntv_code_to_name( (unsigned int)nevt_code, name, sizeof(name));
2301 
2302  INTDBG("EXIT: ret: %d\n", ret);
2303  return (ret);
2304 }
int(* ntv_code_to_name)(unsigned int, char *, int)
Definition: papi_vector.h:45
papi_vector_t * _papi_hwd[]
#define PAPI_HUGE_STR_LEN
Definition: papi.h:465
#define INTDBG(format, args...)
Definition: papi_debug.h:65
long long ret
Definition: iozone.c:1346
static int cidx
Definition: event_info.c:40
#define PAPI_ENOCMP
Definition: papi.h:268
void _papi_hwi_set_papi_event_code(unsigned int event_code, int update_flag)
char * name
Definition: iozone.c:23648
int _papi_hwi_component_index(int event_code)
int _papi_hwi_eventcode_to_native(int event_code)

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_hwi_read ( hwd_context_t context,
EventSetInfo_t ESI,
long long values 
)

Definition at line 1661 of file papi_internal.c.

1663 {
1664  int retval;
1665  long long *dp = NULL;
1666  int i, index;
1667 
1668  retval = _papi_hwd[ESI->CmpIdx]->read( context, ESI->ctl_state,
1669  &dp, ESI->state );
1670  if ( retval != PAPI_OK ) {
1671  return retval;
1672  }
1673 
1674  /* This routine distributes hardware counters to software counters in the
1675  order that they were added. Note that the higher level
1676  EventInfoArray[i] entries may not be contiguous because the user
1677  has the right to remove an event.
1678  But if we do compaction after remove event, this function can be
1679  changed.
1680  */
1681 
1682  for ( i = 0; i != ESI->NumberOfEvents; i++ ) {
1683 
1684  index = ESI->EventInfoArray[i].pos[0];
1685 
1686  if ( index == -1 )
1687  continue;
1688 
1689  INTDBG( "ESI->EventInfoArray: %p, pos[%d]: %d, dp[%d]: %lld\n", ESI->EventInfoArray, i, index, index, dp[index] );
1690 
1691  /* If this is not a derived event */
1692 
1693  if ( ESI->EventInfoArray[i].derived == NOT_DERIVED ) {
1694  values[i] = dp[index];
1695  INTDBG( "value: %#llx\n", values[i] );
1696  } else { /* If this is a derived event */
1697  values[i] = handle_derived( &ESI->EventInfoArray[i], dp );
1698 #ifdef DEBUG
1699  if ( values[i] < ( long long ) 0 ) {
1700  INTDBG( "Derived Event is negative!!: %lld\n", values[i] );
1701  }
1702  INTDBG( "derived value: %#llx \n", values[i] );
1703 #endif
1704  }
1705  }
1706 
1707  return PAPI_OK;
1708 }
int(* read)(hwd_context_t *, hwd_control_state_t *, long long **, int)
Definition: papi_vector.h:30
return PAPI_OK
Definition: linux-nvml.c:458
papi_vector_t * _papi_hwd[]
#define INTDBG(format, args...)
Definition: papi_debug.h:65
int i
Definition: fileop.c:140
#define NOT_DERIVED
Definition: papi_internal.h:69
EventInfo_t * EventInfoArray
int pos[PAPI_EVENTS_IN_DERIVED_EVENT]
static long long handle_derived(EventInfo_t *evi, long long *from)
hwd_control_state_t * ctl_state
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_hwi_remove_event ( EventSetInfo_t ESI,
int  EventCode 
)

Definition at line 1576 of file papi_internal.c.

1577 {
1578  int j = 0, retval, thisindex;
1579  EventInfo_t *array;
1580 
1581  thisindex =
1582  _papi_hwi_lookup_EventCodeIndex( ESI, ( unsigned int ) EventCode );
1583  if ( thisindex < PAPI_OK )
1584  return ( thisindex );
1585 
1586  /* If it is a MPX EventSet, remove it from the multiplex data structure and
1587  this threads multiplex list */
1588 
1589  if ( _papi_hwi_is_sw_multiplex( ESI ) ) {
1590  retval = mpx_remove_event( &ESI->multiplex.mpx_evset, EventCode );
1591  if ( retval < PAPI_OK )
1592  return ( retval );
1593  } else
1594  /* Remove the events hardware dependent stuff from the EventSet */
1595  {
1596  if ( IS_PRESET(EventCode) ) {
1597  int preset_index = EventCode & PAPI_PRESET_AND_MASK;
1598 
1599  /* Check if it's within the valid range */
1600  if ( ( preset_index < 0 ) ||
1601  ( preset_index >= PAPI_MAX_PRESET_EVENTS ) )
1602  return PAPI_EINVAL;
1603 
1604  /* Check if event exists */
1605  if ( !_papi_hwi_presets[preset_index].count )
1606  return PAPI_ENOEVNT;
1607 
1608  /* Remove the preset event. */
1609  for ( j = 0; _papi_hwi_presets[preset_index].code[j] != (unsigned int)PAPI_NULL;
1610  j++ );
1612  (int *)_papi_hwi_presets[preset_index].code, j );
1613  if ( retval != PAPI_OK )
1614  return ( retval );
1615  } else if ( IS_NATIVE(EventCode) ) {
1616  /* Check if native event exists */
1617  if ( _papi_hwi_query_native_event( ( unsigned int ) EventCode ) !=
1618  PAPI_OK )
1619  return PAPI_ENOEVNT;
1620 
1621  /* Remove the native event. */
1622  retval = remove_native_events( ESI, &EventCode, 1 );
1623  if ( retval != PAPI_OK )
1624  return ( retval );
1625  } else if ( IS_USER_DEFINED( EventCode ) ) {
1626  int index = EventCode & PAPI_UE_AND_MASK;
1627 
1628  if ( (index < 0) || (index >= (int)_papi_user_events_count) )
1629  return ( PAPI_EINVAL );
1630 
1631  for( j = 0; j < PAPI_EVENTS_IN_DERIVED_EVENT &&
1632  _papi_user_events[index].events[j] != 0; j++ ) {
1634  _papi_user_events[index].events, j);
1635 
1636  if ( retval != PAPI_OK )
1637  return ( retval );
1638  }
1639  } else
1640  return ( PAPI_ENOEVNT );
1641  }
1642  array = ESI->EventInfoArray;
1643 
1644  /* Compact the Event Info Array list if it's not the last event */
1645  /* clear the newly empty slot in the array */
1646  for ( ; thisindex < ESI->NumberOfEvents - 1; thisindex++ )
1647  array[thisindex] = array[thisindex + 1];
1648 
1649 
1650  array[thisindex].event_code = ( unsigned int ) PAPI_NULL;
1651  for ( j = 0; j < PAPI_EVENTS_IN_DERIVED_EVENT; j++ )
1652  array[thisindex].pos[j] = PAPI_NULL;
1653  array[thisindex].ops = NULL;
1654  array[thisindex].derived = NOT_DERIVED;
1655  ESI->NumberOfEvents--;
1656 
1657  return ( PAPI_OK );
1658 }
int _papi_hwi_is_sw_multiplex(EventSetInfo_t *ESI)
#define PAPI_ENOEVNT
Definition: papi.h:258
#define IS_PRESET(EventCode)
Definition: papi.h:227
#define PAPI_EVENTS_IN_DERIVED_EVENT
Definition: genpapifdef.c:39
#define IS_USER_DEFINED(EventCode)
Definition: papi.h:228
int _papi_hwi_query_native_event(unsigned int EventCode)
#define PAPI_NULL
Definition: papi.h:290
MPX_EventSet * mpx_evset
Definition: sw_multiplex.h:32
#define PAPI_MAX_PRESET_EVENTS
int events[PAPI_EVENTS_IN_DERIVED_EVENT]
return PAPI_OK
Definition: linux-nvml.c:458
int count
Definition: iozone.c:22422
return PAPI_EINVAL
Definition: linux-nvml.c:408
char events[MAX_EVENTS][BUFSIZ]
#define IS_NATIVE(EventCode)
Definition: papi.h:226
#define NOT_DERIVED
Definition: papi_internal.h:69
hwi_presets_t _papi_hwi_presets[PAPI_MAX_PRESET_EVENTS]
int _papi_hwi_lookup_EventCodeIndex(const EventSetInfo_t *ESI, unsigned int EventCode)
EventInfo_t * EventInfoArray
static int remove_native_events(EventSetInfo_t *ESI, int *nevt, int size)
EventSetMultiplexInfo_t multiplex
int mpx_remove_event(MPX_EventSet **mpx_events, int EventCode)
Definition: sw_multiplex.c:418
int
Definition: iozone.c:18528
unsigned int code[PAPI_MAX_INFO_TERMS]
Definition: papi_preset.h:32
unsigned int event_code
#define PAPI_UE_AND_MASK
#define PAPI_PRESET_AND_MASK
user_defined_event_t * _papi_user_events
long j
Definition: iozone.c:19135
ssize_t retval
Definition: libasync.c:338
unsigned int _papi_user_events_count

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_hwi_remove_EventSet ( EventSetInfo_t ESI)

Definition at line 996 of file papi_internal.c.

997 {
999  int i;
1000 
1001  i = ESI->EventSetIndex;
1002 
1004 
1005  _papi_hwi_free_EventSet( ESI );
1006 
1007  /* do bookkeeping for PAPI_EVENTSET_MAP */
1008 
1009  map->dataSlotArray[i] = NULL;
1010  map->availSlots++;
1011  map->fullSlots--;
1012 
1014 
1015  return PAPI_OK;
1016 }
return PAPI_OK
Definition: linux-nvml.c:458
int i
Definition: fileop.c:140
inline_static int _papi_hwi_lock(int lck)
Definition: threads.h:64
DynamicArray_t global_eventset_map
inline_static int _papi_hwi_unlock(int lck)
Definition: threads.h:78
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:57
EventSetInfo_t ** dataSlotArray
#define INTERNAL_LOCK
Definition: papi_internal.h:85
void _papi_hwi_free_EventSet(EventSetInfo_t *ESI)

Here is the call graph for this function:

Here is the caller graph for this function:

void _papi_hwi_set_papi_event_code ( unsigned int  event_code,
int  update_flag 
)

Definition at line 118 of file papi_internal.c.

118  {
119  INTDBG("new event_code: %#x, update_flag: %d, previous event_code: %#x\n", event_code, update_flag, papi_event_code);
120 
121  // if call is just to reset and start over, set both flags to show nothing saved yet
122  if (update_flag < 0) {
124  papi_event_code = -1;
125  return;
126  }
127 
128  // if 0, it is being set prior to calling a component, if >0 it is being changed by the component
129  papi_event_code_changed = update_flag;
130  // save the event code passed in
131  papi_event_code = event_code;
132  return;
133 }
static unsigned int papi_event_code
#define INTDBG(format, args...)
Definition: papi_debug.h:65
static int papi_event_code_changed

Here is the caller graph for this function:

void _papi_hwi_set_papi_event_string ( const char *  event_string)

Definition at line 89 of file papi_internal.c.

89  {
90  INTDBG("event_string: %s\n", event_string);
91  if (papi_event_string != NULL) {
93  papi_event_string = NULL;
94  }
95  if (event_string != NULL) {
96  papi_event_string = strdup(event_string);
97  }
98  return;
99 }
char * papi_event_string
Definition: papi_internal.c:87
#define INTDBG(format, args...)
Definition: papi_debug.h:65
free(dummyfile[xx])

Here is the call graph for this function:

Here is the caller graph for this function:

void _papi_hwi_shutdown_global_internal ( void  )

Definition at line 1953 of file papi_internal.c.

1954 {
1956 
1958 
1960 
1963  0x00, sizeof ( DynamicArray_t ) );
1964 
1966 
1969  }
1970  memset( &_papi_hwi_system_info, 0x0, sizeof ( _papi_hwi_system_info ) );
1971 
1972 }
memset(eventId, 0, size)
#define papi_free(a)
Definition: papi_memory.h:35
PAPI_shlib_info_t shlib_info
static void _papi_hwi_cleanup_errors()
inline_static int _papi_hwi_lock(int lck)
Definition: threads.h:64
DynamicArray_t global_eventset_map
inline_static int _papi_hwi_unlock(int lck)
Definition: threads.h:78
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:57
again struct sockaddr sizeof(struct sockaddr_in))
EventSetInfo_t ** dataSlotArray
#define INTERNAL_LOCK
Definition: papi_internal.h:85
PAPI_address_map_t * map
Definition: papi.h:711
int _papi_hwi_cleanup_all_presets(void)
Definition: papi_preset.c:107

Here is the call graph for this function:

Here is the caller graph for this function:

void PAPIERROR ( char *  format,
  ... 
)

Definition at line 594 of file papi_internal.c.

595 {
596  va_list args;
597  if ( ( _papi_hwi_error_level != PAPI_QUIET ) ||
598  ( getenv( "PAPI_VERBOSE" ) ) ) {
599  va_start( args, format );
600  fprintf( stderr, "\nPAPI Error: " );
601  vfprintf( stderr, format, args );
602  fprintf( stderr, ".\n" );
603  va_end( args );
604  }
605 }
char * getenv()
va_start(arg_list, fmt)
int _papi_hwi_error_level
Definition: papi_internal.c:55
va_end(arg_list)
#define PAPI_QUIET
Definition: papi.h:386

Here is the call graph for this function:

Variable Documentation

char** _papi_errlist

Definition at line 80 of file papi_internal.c.

PAPI_debug_handler_t _papi_hwi_debug_handler

Definition at line 56 of file papi_internal.c.

int _papi_hwi_errno

Definition at line 58 of file papi_internal.c.

int _papi_hwi_error_level

Definition at line 450 of file papi_internal.h.

int _papi_hwi_num_errors

Definition at line 59 of file papi_internal.c.

papi_mdi_t _papi_hwi_system_info

Definition at line 57 of file papi_internal.c.

int _papi_hwi_using_signal[PAPI_NSIG]

Definition at line 363 of file extras.c.

int _papi_num_compiled_components
PAPI_os_info_t _papi_os_info

Definition at line 1210 of file aix.c.

int init_level

Definition at line 54 of file papi_internal.c.

int papi_num_components

Definition at line 1881 of file papi_internal.c.