PAPI  5.7.0.0
papi_internal.h File Reference
Include dependency graph for papi_internal.h:

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 DERIVED_INFIX   0x40
 
#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,...)
 
void PAPIWARN (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_get_user_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 (const 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

◆ COMPONENT_LOCK

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

Definition at line 91 of file papi_internal.h.

◆ CPUS_LOCK

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

Definition at line 93 of file papi_internal.h.

◆ DEADBEEF

#define DEADBEEF   0xdedbeef

Definition at line 26 of file papi_internal.h.

◆ DERIVED_ADD

#define DERIVED_ADD   0x1

Add counters

Definition at line 70 of file papi_internal.h.

◆ DERIVED_ADD_PS

#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.

◆ DERIVED_CMPD

#define DERIVED_CMPD   0x8

Event lives in operand index but takes 2 or more codes

Definition at line 73 of file papi_internal.h.

◆ DERIVED_INFIX

#define DERIVED_INFIX   0x40

Process counters based on specified infix string

Definition at line 76 of file papi_internal.h.

◆ DERIVED_POSTFIX

#define DERIVED_POSTFIX   0x20

Process counters based on specified postfix string

Definition at line 75 of file papi_internal.h.

◆ DERIVED_PS

#define DERIVED_PS   0x2

Divide by the cycle counter and convert to seconds

Definition at line 71 of file papi_internal.h.

◆ DERIVED_SUB

#define DERIVED_SUB   0x10

Sub all counters from counter with operand_index

Definition at line 74 of file papi_internal.h.

◆ DONT_NEED_CONTEXT

#define DONT_NEED_CONTEXT   0

Definition at line 99 of file papi_internal.h.

◆ GLOBAL_LOCK

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

Definition at line 92 of file papi_internal.h.

◆ HIGHLEVEL_LOCK

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

Definition at line 89 of file papi_internal.h.

◆ hwd_context_t

#define hwd_context_t   void

Definition at line 107 of file papi_internal.h.

◆ hwd_control_state_t

#define hwd_control_state_t   void

Definition at line 108 of file papi_internal.h.

◆ hwd_reg_alloc_t

#define hwd_reg_alloc_t   void

Definition at line 109 of file papi_internal.h.

◆ hwd_register_t

#define hwd_register_t   void

Definition at line 110 of file papi_internal.h.

◆ hwd_siginfo_t

#define hwd_siginfo_t   void

Definition at line 111 of file papi_internal.h.

◆ hwd_ucontext_t

typedef struct sigcontext hwd_ucontext_t   void

Definition at line 112 of file papi_internal.h.

◆ inline_static

#define inline_static   inline static

Definition at line 124 of file papi_internal.h.

◆ INTERNAL_LOCK

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

Definition at line 86 of file papi_internal.h.

◆ LOWLEVEL_TLS

#define LOWLEVEL_TLS   PAPI_NUM_TLS+0

Definition at line 80 of file papi_internal.h.

◆ MEMORY_LOCK

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

Definition at line 90 of file papi_internal.h.

◆ MULTIPLEX_LOCK

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

Definition at line 87 of file papi_internal.h.

◆ NAMELIB_LOCK

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

Definition at line 94 of file papi_internal.h.

◆ NEED_CONTEXT

#define NEED_CONTEXT   1

Definition at line 98 of file papi_internal.h.

◆ NOT_DERIVED

#define NOT_DERIVED   0x0

Do nothing

Definition at line 69 of file papi_internal.h.

◆ NUM_INNER_TLS

#define NUM_INNER_TLS   1

Definition at line 81 of file papi_internal.h.

◆ PAPI_ERROR_CODE_str

#define PAPI_ERROR_CODE_str   "Error Code"

Definition at line 41 of file papi_internal.h.

◆ PAPI_EVENTS_IN_DERIVED_EVENT

#define PAPI_EVENTS_IN_DERIVED_EVENT   8

Definition at line 101 of file papi_internal.h.

◆ PAPI_INT_ITIMER

#define PAPI_INT_ITIMER   ITIMER_PROF

Definition at line 54 of file papi_internal.h.

◆ PAPI_INT_ITIMER_MS

#define PAPI_INT_ITIMER_MS   1

Definition at line 56 of file papi_internal.h.

◆ PAPI_INT_MPX_DEF_US

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

Definition at line 65 of file papi_internal.h.

◆ PAPI_INT_MPX_SIGNAL

#define PAPI_INT_MPX_SIGNAL   SIGPROF

Definition at line 52 of file papi_internal.h.

◆ PAPI_INT_SIGNAL

#define PAPI_INT_SIGNAL   SIGPROF

Definition at line 53 of file papi_internal.h.

◆ PAPI_MAX_TLS

#define PAPI_MAX_TLS   (NUM_INNER_TLS+PAPI_NUM_TLS)

Definition at line 82 of file papi_internal.h.

◆ PAPI_NSIG

#define PAPI_NSIG   128

Definition at line 60 of file papi_internal.h.

◆ PAPI_SHUTDOWN_str

#define PAPI_SHUTDOWN_str   "PAPI_shutdown: PAPI is not initialized"

Definition at line 42 of file papi_internal.h.

◆ PAPI_SHUTDOWN_SYNC_str

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

Definition at line 43 of file papi_internal.h.

◆ THREADS_LOCK

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

Definition at line 88 of file papi_internal.h.

Typedef Documentation

◆ _papi_int_itimer_t

Definition at line 364 of file papi_internal.h.

Function Documentation

◆ _papi_hwi_add_event()

int _papi_hwi_add_event ( EventSetInfo_t ESI,
int  EventCode 
)

Definition at line 1335 of file papi_internal.c.

1336 {
1337  INTDBG("ENTER: ESI: %p (%d), EventCode: %#x\n", ESI, ESI->EventSetIndex, EventCode);
1338 
1339  int i, j, thisindex, remap, retval = PAPI_OK;
1340  int cidx;
1341 
1342  /* Sanity check the component */
1343  cidx=_papi_hwi_component_index( EventCode );
1344  if (cidx<0) {
1345  return PAPI_ENOCMP;
1346  }
1347  if (_papi_hwd[cidx]->cmp_info.disabled) {
1348  return PAPI_ECMP_DISABLED;
1349  }
1350 
1351  /* Sanity check that the new EventCode is from the same component */
1352  /* as previous events. */
1353 
1354  if ( ESI->CmpIdx < 0 ) {
1355  if ( ( retval = _papi_hwi_assign_eventset( ESI, cidx)) != PAPI_OK ) {
1356  INTDBG("EXIT: Error assigning eventset to component index %d\n", cidx);
1357  return retval;
1358  }
1359  } else {
1360  if ( ESI->CmpIdx != cidx ) {
1361  INTDBG("EXIT: Event is not valid for component index %d\n", cidx);
1362  return PAPI_EINVAL;
1363  }
1364  }
1365 
1366  /* Make sure the event is not present and get the next free slot. */
1367  thisindex = get_free_EventCodeIndex( ESI, ( unsigned int ) EventCode );
1368  if ( thisindex < PAPI_OK ) {
1369  return thisindex;
1370  }
1371 
1372  INTDBG("Adding event to slot %d of EventSet %d\n",thisindex,ESI->EventSetIndex);
1373 
1374  /* If it is a software MPX EventSet, add it to the multiplex data structure */
1375  /* and this thread's multiplex list */
1376 
1377  if ( !_papi_hwi_is_sw_multiplex( ESI ) ) {
1378 
1379  /* Handle preset case */
1380  if ( IS_PRESET(EventCode) ) {
1381  int count;
1382  int preset_index = EventCode & ( int ) PAPI_PRESET_AND_MASK;
1383 
1384  /* Check if it's within the valid range */
1385  if ( ( preset_index < 0 ) || ( preset_index >= PAPI_MAX_PRESET_EVENTS ) ) {
1386  return PAPI_EINVAL;
1387  }
1388 
1389  /* count the number of native events in this preset */
1390  count = ( int ) _papi_hwi_presets[preset_index].count;
1391 
1392  /* Check if event exists */
1393  if ( !count ) {
1394  return PAPI_ENOEVNT;
1395  }
1396 
1397  /* check if the native events have been used as overflow events */
1398  /* this is not allowed */
1399  if ( ESI->state & PAPI_OVERFLOWING ) {
1400  for( i = 0; i < count; i++ ) {
1401  for( j = 0; j < ESI->overflow.event_counter; j++ ) {
1402  if ( ESI->overflow.EventCode[j] ==(int)
1403  ( _papi_hwi_presets[preset_index].code[i] ) ) {
1404  return PAPI_ECNFLCT;
1405  }
1406  }
1407  }
1408  }
1409 
1410  /* Try to add the preset. */
1411 
1412  remap = add_native_events( ESI,
1413  _papi_hwi_presets[preset_index].code,
1414  count, &ESI->EventInfoArray[thisindex] );
1415  if ( remap < 0 ) {
1416  return remap;
1417  }
1418  else {
1419  /* Fill in the EventCode (machine independent) information */
1420  ESI->EventInfoArray[thisindex].event_code =
1421  ( unsigned int ) EventCode;
1422  ESI->EventInfoArray[thisindex].derived =
1423  _papi_hwi_presets[preset_index].derived_int;
1424  ESI->EventInfoArray[thisindex].ops =
1425  _papi_hwi_presets[preset_index].postfix;
1426  ESI->NumberOfEvents++;
1428 
1429  }
1430  }
1431  /* Handle adding Native events */
1432  else if ( IS_NATIVE(EventCode) ) {
1433 
1434  /* Check if native event exists */
1435  if ( _papi_hwi_query_native_event( ( unsigned int ) EventCode ) != PAPI_OK ) {
1436  return PAPI_ENOEVNT;
1437  }
1438 
1439  /* check if the native events have been used as overflow events */
1440  /* This is not allowed */
1441  if ( ESI->state & PAPI_OVERFLOWING ) {
1442  for( j = 0; j < ESI->overflow.event_counter; j++ ) {
1443  if ( EventCode == ESI->overflow.EventCode[j] ) {
1444  return PAPI_ECNFLCT;
1445  }
1446  }
1447  }
1448 
1449  /* Try to add the native event. */
1450 
1451  remap = add_native_events( ESI, (unsigned int *)&EventCode, 1,
1452  &ESI->EventInfoArray[thisindex] );
1453 
1454  if ( remap < 0 ) {
1455  return remap;
1456  } else {
1457 
1458  /* Fill in the EventCode (machine independent) information */
1459  ESI->EventInfoArray[thisindex].event_code =
1460  ( unsigned int ) EventCode;
1461  ESI->NumberOfEvents++;
1463 
1464  }
1465  } else if ( IS_USER_DEFINED( EventCode ) ) {
1466  int count;
1467  int index = EventCode & PAPI_UE_AND_MASK;
1468 
1469  if ( index < 0 || index >= user_defined_events_count )
1470  return ( PAPI_EINVAL );
1471 
1472  count = ( int ) user_defined_events[index].count;
1473 
1474  for ( i = 0; i < count; i++ ) {
1475  for ( j = 0; j < ESI->overflow.event_counter; j++ ) {
1476  if ( ESI->overflow.EventCode[j] ==
1477  (int)(user_defined_events[index].code[i]) ) {
1478  return ( PAPI_EBUG );
1479  }
1480  }
1481  }
1482 
1483  remap = add_native_events( ESI,
1484  user_defined_events[index].code,
1485  count, &ESI->EventInfoArray[thisindex] );
1486 
1487  if ( remap < 0 ) {
1488  return remap;
1489  } else {
1490  ESI->EventInfoArray[thisindex].event_code = (unsigned int) EventCode;
1491  ESI->EventInfoArray[thisindex].derived = user_defined_events[index].derived_int;
1492  ESI->EventInfoArray[thisindex].ops = user_defined_events[index].postfix;
1493  ESI->NumberOfEvents++;
1495  }
1496  } else {
1497 
1498  /* not Native, Preset, or User events */
1499 
1500  return PAPI_EBUG;
1501  }
1502  }
1503  else {
1504 
1505  /* Multiplexing is special. See multiplex.c */
1506 
1507  retval = mpx_add_event( &ESI->multiplex.mpx_evset, EventCode,
1508  ESI->domain.domain,
1509  ESI->granularity.granularity );
1510 
1511 
1512  if ( retval < PAPI_OK ) {
1513  return retval;
1514  }
1515 
1516  /* Relevant (???) */
1517  ESI->EventInfoArray[thisindex].event_code = ( unsigned int ) EventCode;
1518  ESI->EventInfoArray[thisindex].derived = NOT_DERIVED;
1519 
1520  ESI->NumberOfEvents++;
1521 
1522  /* event is in the EventInfoArray but not mapped to the NativeEvents */
1523  /* this causes issues if you try to set overflow on the event. */
1524  /* in theory this wouldn't matter anyway. */
1525  }
1526 
1527  /* reinstate the overflows if any */
1528  retval=update_overflow( ESI );
1529 
1530  return retval;
1531 }
int _papi_hwi_is_sw_multiplex(EventSetInfo_t *ESI)
#define PAPI_OK
Definition: fpapi.h:105
#define IS_PRESET(EventCode)
Definition: papi.h:229
#define PAPI_EINVAL
Definition: fpapi.h:106
#define IS_USER_DEFINED(EventCode)
Definition: papi.h:230
#define PAPI_UE_AND_MASK
int _papi_hwi_query_native_event(unsigned int EventCode)
MPX_EventSet * mpx_evset
Definition: sw_multiplex.h:32
EventSetDomainInfo_t domain
#define PAPI_EBUG
Definition: fpapi.h:111
#define PAPI_ECMP_DISABLED
Definition: fpapi.h:130
int retval
Definition: zero_fork.c:53
#define INTDBG(format, args...)
Definition: papi_debug.h:65
#define PAPI_ENOCMP
Definition: fpapi.h:122
static int cidx
#define PAPI_MAX_PRESET_EVENTS
Definition: fpapi.h:16
EventSetOverflowInfo_t overflow
#define IS_NATIVE(EventCode)
Definition: papi.h:228
#define NOT_DERIVED
Definition: papi_internal.h:69
hwi_presets_t _papi_hwi_presets[PAPI_MAX_PRESET_EVENTS]
static int update_overflow(EventSetInfo_t *ESI)
int mpx_add_event(MPX_EventSet **mpx_events, int EventCode, int domain, int granularity)
Definition: sw_multiplex.c:305
EventInfo_t * EventInfoArray
EventSetMultiplexInfo_t multiplex
EventSetGranularityInfo_t granularity
int user_defined_events_count
Definition: papi_internal.c:60
int _papi_hwi_assign_eventset(EventSetInfo_t *ESI, int cidx)
hwi_presets_t user_defined_events[PAPI_MAX_USER_EVENTS]
Definition: papi_internal.c:59
#define PAPI_ENOEVNT
Definition: fpapi.h:112
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_PRESET_AND_MASK
struct papi_vectors * _papi_hwd[]
#define PAPI_ECNFLCT
Definition: fpapi.h:113
#define PAPI_OVERFLOWING
Definition: fpapi.h:33
static int add_native_events(EventSetInfo_t *ESI, unsigned int *nevt, int size, EventInfo_t *out)
static int get_free_EventCodeIndex(const EventSetInfo_t *ESI, unsigned int EventCode)
void _papi_hwi_map_events_to_native(EventSetInfo_t *ESI)
static long count
int i
Definition: fileop.c:140
char * postfix
Definition: papi_preset.h:31
Here is the call graph for this function:

◆ _papi_hwi_assign_eventset()

int _papi_hwi_assign_eventset ( EventSetInfo_t ESI,
int  cidx 
)

Definition at line 760 of file papi_internal.c.

761 {
762  INTDBG("ENTER: ESI: %p (%d), cidx: %d\n", ESI, ESI->EventSetIndex, cidx);
763  int retval;
764  size_t max_counters;
765  char *ptr;
766  unsigned int i, j;
767 
768  /* If component doesn't exist... */
769  if (_papi_hwi_invalid_cmp(cidx)) return PAPI_ECMP;
770 
771  /* Assigned at create time */
772  ESI->domain.domain = _papi_hwd[cidx]->cmp_info.default_domain;
773  ESI->granularity.granularity =
774  _papi_hwd[cidx]->cmp_info.default_granularity;
775  ESI->CmpIdx = cidx;
776 
777  /* ??? */
778  max_counters = ( size_t ) _papi_hwd[cidx]->cmp_info.num_mpx_cntrs;
779 
780  ESI->ctl_state = (hwd_control_state_t *) papi_calloc( 1, (size_t)
781  _papi_hwd[cidx]->size.control_state );
782  ESI->sw_stop = (long long *) papi_calloc( ( size_t ) max_counters,
783  sizeof ( long long ) );
784  ESI->hw_start = ( long long * ) papi_calloc( ( size_t ) max_counters,
785  sizeof ( long long ) );
786  ESI->EventInfoArray = ( EventInfo_t * ) papi_calloc( (size_t) max_counters,
787  sizeof ( EventInfo_t ) );
788 
789  /* allocate room for the native events and for the component-private */
790  /* register structures */
791  /* ugh is there a cleaner way to allocate this? vmw */
792  ESI->NativeInfoArray = ( NativeInfo_t * )
793  papi_calloc( ( size_t ) max_counters, sizeof ( NativeInfo_t ));
794 
795  ESI->NativeBits = papi_calloc(( size_t ) max_counters,
796  ( size_t ) _papi_hwd[cidx]->size.reg_value );
797 
798  /* NOTE: the next two malloc allocate blocks of memory that are later */
799  /* parcelled into overflow and profile arrays */
800  ESI->overflow.deadline = ( long long * )
801  papi_malloc( ( sizeof ( long long ) +
802  sizeof ( int ) * 3 ) * ( size_t ) max_counters );
803 
804  ESI->profile.prof = ( PAPI_sprofil_t ** )
805  papi_malloc( ( sizeof ( PAPI_sprofil_t * ) * ( size_t ) max_counters +
806  ( size_t ) max_counters * sizeof ( int ) * 4 ) );
807 
808  /* If any of these allocations failed, free things up and fail */
809 
810  if ( ( ESI->ctl_state == NULL ) ||
811  ( ESI->sw_stop == NULL ) ||
812  ( ESI->hw_start == NULL ) ||
813  ( ESI->NativeInfoArray == NULL ) ||
814  ( ESI->NativeBits == NULL ) ||
815  ( ESI->EventInfoArray == NULL ) ||
816  ( ESI->profile.prof == NULL ) ||
817  ( ESI->overflow.deadline == NULL ) ) {
818 
819  if ( ESI->sw_stop ) papi_free( ESI->sw_stop );
820  if ( ESI->hw_start ) papi_free( ESI->hw_start );
821  if ( ESI->EventInfoArray ) papi_free( ESI->EventInfoArray );
822  if ( ESI->NativeInfoArray ) papi_free( ESI->NativeInfoArray );
823  if ( ESI->NativeBits ) papi_free( ESI->NativeBits );
824  if ( ESI->ctl_state ) papi_free( ESI->ctl_state );
825  if ( ESI->overflow.deadline ) papi_free( ESI->overflow.deadline );
826  if ( ESI->profile.prof ) papi_free( ESI->profile.prof );
827  papi_free( ESI );
828  return PAPI_ENOMEM;
829  }
830 
831 
832  /* Carve up the overflow block into separate arrays */
833  ptr = ( char * ) ESI->overflow.deadline;
834  ptr += sizeof ( long long ) * max_counters;
835  ESI->overflow.threshold = ( int * ) ptr;
836  ptr += sizeof ( int ) * max_counters;
837  ESI->overflow.EventIndex = ( int * ) ptr;
838  ptr += sizeof ( int ) * max_counters;
839  ESI->overflow.EventCode = ( int * ) ptr;
840 
841  /* Carve up the profile block into separate arrays */
842  ptr = ( char * ) ESI->profile.prof +
843  ( sizeof ( PAPI_sprofil_t * ) * max_counters );
844  ESI->profile.count = ( int * ) ptr;
845  ptr += sizeof ( int ) * max_counters;
846  ESI->profile.threshold = ( int * ) ptr;
847  ptr += sizeof ( int ) * max_counters;
848  ESI->profile.EventIndex = ( int * ) ptr;
849  ptr += sizeof ( int ) * max_counters;
850  ESI->profile.EventCode = ( int * ) ptr;
851 
852  /* initialize_EventInfoArray */
853 
854  for ( i = 0; i < max_counters; i++ ) {
855  ESI->EventInfoArray[i].event_code=( unsigned int ) PAPI_NULL;
856  ESI->EventInfoArray[i].ops = NULL;
858  for ( j = 0; j < PAPI_EVENTS_IN_DERIVED_EVENT; j++ ) {
859  ESI->EventInfoArray[i].pos[j] = PAPI_NULL;
860  }
861  }
862 
863  /* initialize_NativeInfoArray */
864  for( i = 0; i < max_counters; i++ ) {
865  ESI->NativeInfoArray[i].ni_event = -1;
866  ESI->NativeInfoArray[i].ni_position = -1;
867  ESI->NativeInfoArray[i].ni_papi_code = -1;
868  ESI->NativeInfoArray[i].ni_owners = 0;
869  ESI->NativeInfoArray[i].ni_bits = ((unsigned char*)ESI->NativeBits) +
870  (i*_papi_hwd[cidx]->size.reg_value);
871  }
872 
873  ESI->NativeCount = 0;
874 
875  ESI->state = PAPI_STOPPED;
876 
877  /* these used to be init_config */
878  retval = _papi_hwd[cidx]->init_control_state( ESI->ctl_state );
879  retval |= _papi_hwd[cidx]->set_domain( ESI->ctl_state, ESI->domain.domain);
880 
881  return retval;
882 }
#define PAPI_ENOMEM
Definition: fpapi.h:107
#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
hwd_register_t * NativeBits
long unsigned int size_t
EventSetDomainInfo_t domain
int retval
Definition: zero_fork.c:53
#define INTDBG(format, args...)
Definition: papi_debug.h:65
#define PAPI_ECMP
Definition: fpapi.h:109
static int cidx
EventSetOverflowInfo_t overflow
#define NOT_DERIVED
Definition: papi_internal.h:69
PAPI_sprofil_t ** prof
#define PAPI_NULL
Definition: fpapi.h:13
NativeInfo_t * NativeInfoArray
EventInfo_t * EventInfoArray
#define PAPI_STOPPED
Definition: fpapi.h:29
long long * hw_start
EventSetGranularityInfo_t granularity
int pos[PAPI_EVENTS_IN_DERIVED_EVENT]
long long * sw_stop
unsigned int event_code
struct papi_vectors * _papi_hwd[]
int _papi_hwi_invalid_cmp(int cidx)
EventSetProfileInfo_t profile
hwd_control_state_t * ctl_state
#define papi_calloc(a, b)
Definition: papi_memory.h:37
int i
Definition: fileop.c:140
Here is the call graph for this function:

◆ _papi_hwi_cleanup_eventset()

int _papi_hwi_cleanup_eventset ( EventSetInfo_t ESI)

Definition at line 1755 of file papi_internal.c.

1756 {
1757  int i, j, num_cntrs, retval;
1758  hwd_context_t *context;
1759  int EventCode;
1761  if ( !_papi_hwi_invalid_cmp( ESI->CmpIdx ) ) {
1762  num_cntrs = _papi_hwd[ESI->CmpIdx]->cmp_info.num_mpx_cntrs;
1763 
1764  for(i=0;i<num_cntrs;i++) {
1765 
1766  EventCode=ESI->EventInfoArray[i].event_code;
1767 
1768  /* skip if event not there */
1769  if ( EventCode == PAPI_NULL ) continue;
1770 
1771  /* If it is a MPX EventSet, remove it from the multiplex */
1772  /* data structure and this thread's multiplex list */
1773 
1774  if ( _papi_hwi_is_sw_multiplex( ESI ) ) {
1775  retval = mpx_remove_event( &ESI->multiplex.mpx_evset, EventCode );
1776  if ( retval < PAPI_OK )
1777  return retval;
1778  } else {
1779 
1780  native = ESI->NativeInfoArray;
1781 
1782  /* clear out ESI->NativeInfoArray */
1783  /* do we really need to do this, seeing as we free() it later? */
1784 
1785  for( j = 0; j < ESI->NativeCount; j++ ) {
1786  native[j].ni_event = -1;
1787  native[j].ni_position = -1;
1788  native[j].ni_owners = 0;
1789  /* native[j].ni_bits?? */
1790  }
1791  }
1792 
1793  /* do we really need to do this, seeing as we free() it later? */
1794  ESI->EventInfoArray[i].event_code= ( unsigned int ) PAPI_NULL;
1795  for( j = 0; j < PAPI_EVENTS_IN_DERIVED_EVENT; j++ ) {
1796  ESI->EventInfoArray[i].pos[j] = PAPI_NULL;
1797  }
1798  ESI->EventInfoArray[i].ops = NULL;
1800  }
1801 
1802  context = _papi_hwi_get_context( ESI, NULL );
1803  /* calling with count of 0 equals a close? */
1804  retval = _papi_hwd[ESI->CmpIdx]->update_control_state( ESI->ctl_state,
1805  NULL, 0, context);
1806  if (retval!=PAPI_OK) {
1807  return retval;
1808  }
1809  }
1810 
1811  ESI->CmpIdx = -1;
1812  ESI->NumberOfEvents = 0;
1813  ESI->NativeCount = 0;
1814 
1815  if ( ( ESI->state & PAPI_MULTIPLEXING ) && ESI->multiplex.mpx_evset )
1816  papi_free( ESI->multiplex.mpx_evset );
1817 
1818  if ( ( ESI->state & PAPI_CPU_ATTACH ) && ESI->CpuInfo )
1820 
1821  if ( ESI->ctl_state )
1822  papi_free( ESI->ctl_state );
1823 
1824  if ( ESI->sw_stop )
1825  papi_free( ESI->sw_stop );
1826 
1827  if ( ESI->hw_start )
1828  papi_free( ESI->hw_start );
1829 
1830  if ( ESI->EventInfoArray )
1831  papi_free( ESI->EventInfoArray );
1832 
1833  if ( ESI->NativeInfoArray )
1834  papi_free( ESI->NativeInfoArray );
1835 
1836  if ( ESI->NativeBits )
1837  papi_free( ESI->NativeBits );
1838 
1839  if ( ESI->overflow.deadline )
1840  papi_free( ESI->overflow.deadline );
1841 
1842  if ( ESI->profile.prof )
1843  papi_free( ESI->profile.prof );
1844 
1845  ESI->ctl_state = NULL;
1846  ESI->sw_stop = NULL;
1847  ESI->hw_start = NULL;
1848  ESI->EventInfoArray = NULL;
1849  ESI->NativeInfoArray = NULL;
1850  ESI->NativeBits = NULL;
1851 
1852  memset( &ESI->domain, 0x0, sizeof(EventSetDomainInfo_t) );
1853  memset( &ESI->granularity, 0x0, sizeof(EventSetGranularityInfo_t) );
1854  memset( &ESI->overflow, 0x0, sizeof(EventSetOverflowInfo_t) );
1855  memset( &ESI->multiplex, 0x0, sizeof(EventSetMultiplexInfo_t) );
1856  memset( &ESI->attach, 0x0, sizeof(EventSetAttachInfo_t) );
1857  memset( &ESI->cpu, 0x0, sizeof(EventSetCpuInfo_t) );
1858  memset( &ESI->profile, 0x0, sizeof(EventSetProfileInfo_t) );
1859  memset( &ESI->inherit, 0x0, sizeof(EventSetInheritInfo_t) );
1860 
1861  ESI->CpuInfo = NULL;
1862 
1863  return PAPI_OK;
1864 }
int _papi_hwi_is_sw_multiplex(EventSetInfo_t *ESI)
#define PAPI_OK
Definition: fpapi.h:105
#define PAPI_CPU_ATTACH
Definition: papi.h:458
#define PAPI_EVENTS_IN_DERIVED_EVENT
Definition: genpapifdef.c:39
#define papi_free(a)
Definition: papi_memory.h:35
MPX_EventSet * mpx_evset
Definition: sw_multiplex.h:32
EventSetAttachInfo_t attach
hwd_register_t * NativeBits
EventSetDomainInfo_t domain
int retval
Definition: zero_fork.c:53
EventSetOverflowInfo_t overflow
EventSetInheritInfo_t inherit
struct _CpuInfo * CpuInfo
#define NOT_DERIVED
Definition: papi_internal.h:69
PAPI_sprofil_t ** prof
static int native
#define PAPI_MULTIPLEXING
Definition: fpapi.h:35
#define PAPI_NULL
Definition: fpapi.h:13
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
unsigned int event_code
struct papi_vectors * _papi_hwd[]
int _papi_hwi_invalid_cmp(int cidx)
EventSetProfileInfo_t profile
hwd_control_state_t * ctl_state
int i
Definition: fileop.c:140
EventSetCpuInfo_t cpu
Here is the call graph for this function:

◆ _papi_hwi_component_index()

int _papi_hwi_component_index ( int  event_code)

Definition at line 520 of file papi_internal.c.

520  {
521  INTDBG("ENTER: event_code: %#x\n", event_code);
522 
523  int cidx;
524  int event_index;
525 
526  /* currently assume presets are for component 0 only */
527  if (IS_PRESET(event_code)) {
528  INTDBG("EXIT: Event %#x is a PRESET, assigning component %d\n", event_code,0);
529  return 0;
530  }
531 
532  /* user defined events are treated like preset events (component 0 only) */
533  if (IS_USER_DEFINED(event_code)) {
534  INTDBG("EXIT: Event %#x is USER DEFINED, assigning component %d\n", event_code,0);
535  return 0;
536  }
537 
538  event_index=event_code&PAPI_NATIVE_AND_MASK;
539 
540  if ( (event_index < 0) || (event_index>=num_native_events)) {
541  INTDBG("EXIT: Event index %#x is out of range, num_native_events: %d\n", event_index, num_native_events);
542  return PAPI_ENOEVNT;
543  }
544 
545  cidx=_papi_native_events[event_index].cidx;
546 
547  if ((cidx<0) || (cidx >= papi_num_components)) {
548  INTDBG("EXIT: Component index %#x is out of range, papi_num_components: %d\n", cidx, papi_num_components);
549  return PAPI_ENOCMP;
550  }
551 
552  INTDBG("EXIT: Found cidx: %d event_index: %d, event_code: %#x\n", cidx, event_index, event_code);
553  return cidx;
554 }
#define IS_PRESET(EventCode)
Definition: papi.h:229
static struct native_event_info * _papi_native_events
Definition: papi_internal.c:77
#define IS_USER_DEFINED(EventCode)
Definition: papi.h:230
#define INTDBG(format, args...)
Definition: papi_debug.h:65
#define PAPI_ENOCMP
Definition: fpapi.h:122
static int cidx
int papi_num_components
#define PAPI_ENOEVNT
Definition: fpapi.h:112
#define PAPI_NATIVE_AND_MASK
static int num_native_events
Definition: papi_internal.c:78

◆ _papi_hwi_convert_eventset_to_multiplex()

int _papi_hwi_convert_eventset_to_multiplex ( _papi_int_multiplex_t mpx)

Definition at line 1867 of file papi_internal.c.

1868 {
1869  int retval, i, j = 0, *mpxlist = NULL;
1870  EventSetInfo_t *ESI = mpx->ESI;
1871  int flags = mpx->flags;
1872 
1873  /* If there are any events in the EventSet,
1874  convert them to multiplex events */
1875 
1876  if ( ESI->NumberOfEvents ) {
1877 
1878  mpxlist =
1879  ( int * ) papi_malloc( sizeof ( int ) *
1880  ( size_t ) ESI->NumberOfEvents );
1881  if ( mpxlist == NULL )
1882  return ( PAPI_ENOMEM );
1883 
1884  /* Build the args to MPX_add_events(). */
1885 
1886  /* Remember the EventInfoArray can be sparse
1887  and the data can be non-contiguous */
1888 
1889  for ( i = 0; i < EventInfoArrayLength( ESI ); i++ )
1890  if ( ESI->EventInfoArray[i].event_code !=
1891  ( unsigned int ) PAPI_NULL )
1892  mpxlist[j++] = ( int ) ESI->EventInfoArray[i].event_code;
1893 
1894  /* Resize the EventInfo_t array */
1895 
1896  if ( ( _papi_hwd[ESI->CmpIdx]->cmp_info.kernel_multiplex == 0 ) ||
1897  ( ( _papi_hwd[ESI->CmpIdx]->cmp_info.kernel_multiplex ) &&
1898  ( flags & PAPI_MULTIPLEX_FORCE_SW ) ) ) {
1899  retval =
1900  MPX_add_events( &ESI->multiplex.mpx_evset, mpxlist, j,
1901  ESI->domain.domain,
1902  ESI->granularity.granularity );
1903  if ( retval != PAPI_OK ) {
1904  papi_free( mpxlist );
1905  return ( retval );
1906  }
1907  }
1908 
1909  papi_free( mpxlist );
1910  }
1911 
1912  /* Update the state before initialization! */
1913 
1914  ESI->state |= PAPI_MULTIPLEXING;
1915  if ( _papi_hwd[ESI->CmpIdx]->cmp_info.kernel_multiplex &&
1916  ( flags & PAPI_MULTIPLEX_FORCE_SW ) )
1918  ESI->multiplex.ns = ( int ) mpx->ns;
1919 
1920  return ( PAPI_OK );
1921 }
#define PAPI_OK
Definition: fpapi.h:105
#define PAPI_ENOMEM
Definition: fpapi.h:107
static int EventInfoArrayLength(const EventSetInfo_t *ESI)
#define papi_free(a)
Definition: papi_memory.h:35
#define papi_malloc(a)
Definition: papi_memory.h:34
MPX_EventSet * mpx_evset
Definition: sw_multiplex.h:32
#define PAPI_MULTIPLEX_FORCE_SW
Definition: fpapi.h:46
long unsigned int size_t
EventSetDomainInfo_t domain
int retval
Definition: zero_fork.c:53
int MPX_add_events(MPX_EventSet **mpx_events, int *event_list, int num_events, int domain, int granularity)
Definition: sw_multiplex.c:676
#define PAPI_MULTIPLEXING
Definition: fpapi.h:35
#define PAPI_NULL
Definition: fpapi.h:13
EventInfo_t * EventInfoArray
EventSetMultiplexInfo_t multiplex
EventSetGranularityInfo_t granularity
unsigned int event_code
struct papi_vectors * _papi_hwd[]
EventSetInfo_t * ESI
int i
Definition: fileop.c:140
Here is the call graph for this function:

◆ _papi_hwi_create_eventset()

int _papi_hwi_create_eventset ( int *  EventSet,
ThreadInfo_t handle 
)

Definition at line 937 of file papi_internal.c.

938 {
939  EventSetInfo_t *ESI;
940  int retval;
941 
942  /* Is the EventSet already in existence? */
943 
944  if ( ( EventSet == NULL ) || ( handle == NULL ) )
945  return PAPI_EINVAL;
946 
947  if ( *EventSet != PAPI_NULL )
948  return PAPI_EINVAL;
949 
950  /* Well, then allocate a new one. Use n to keep track of a NEW EventSet */
951 
952  retval = create_EventSet( &ESI );
953  if ( retval != PAPI_OK )
954  return retval;
955 
956  ESI->CmpIdx = -1; /* when eventset is created, it is not decided yet which component it belongs to, until first event is added */
957  ESI->state = PAPI_STOPPED;
958 
959  /* Add it to the global table */
960 
961  retval = add_EventSet( ESI, handle );
962  if ( retval < PAPI_OK ) {
964  return retval ;
965  }
966 
967  *EventSet = ESI->EventSetIndex;
968 
969  INTDBG( "(%p,%p): new EventSet in slot %d\n",
970  ( void * ) EventSet, handle, *EventSet );
971 
972  return retval;
973 }
#define PAPI_OK
Definition: fpapi.h:105
#define PAPI_EINVAL
Definition: fpapi.h:106
int EventSet
int retval
Definition: zero_fork.c:53
#define INTDBG(format, args...)
Definition: papi_debug.h:65
#define PAPI_NULL
Definition: fpapi.h:13
#define PAPI_STOPPED
Definition: fpapi.h:29
void _papi_hwi_free_EventSet(EventSetInfo_t *ESI)
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:

◆ _papi_hwi_derived_type()

int _papi_hwi_derived_type ( char *  tmp,
int *  code 
)

Definition at line 2242 of file papi_internal.c.

2243 {
2244  int i = 0;
2245  while ( _papi_hwi_derived[i].name != NULL ) {
2246  if ( strcasecmp( tmp, _papi_hwi_derived[i].name ) == 0 ) {
2247  *code = _papi_hwi_derived[i].value;
2248  return PAPI_OK;
2249  }
2250  i++;
2251  }
2252  INTDBG( "Invalid derived string %s\n", tmp );
2253  return PAPI_EINVAL;
2254 }
#define PAPI_OK
Definition: fpapi.h:105
static const char * name
Definition: fork_overflow.c:31
#define PAPI_EINVAL
Definition: fpapi.h:106
double tmp
#define INTDBG(format, args...)
Definition: papi_debug.h:65
static const hwi_describe_t _papi_hwi_derived[]
int i
Definition: fileop.c:140

◆ _papi_hwi_dummy_handler()

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

Definition at line 2036 of file papi_internal.c.

2038 {
2039  /* This function is not used and shouldn't be called. */
2040  ( void ) EventSet; /*unused */
2041  ( void ) address; /*unused */
2042  ( void ) overflow_vector; /*unused */
2043  ( void ) context; /*unused */
2044  return;
2045 }
int EventSet

◆ _papi_hwi_eventcode_to_native()

int _papi_hwi_eventcode_to_native ( int  event_code)

Definition at line 581 of file papi_internal.c.

581  {
582  INTDBG("ENTER: event_code: %#x\n", event_code);
583 
584  int result;
585  int event_index;
586 
587  event_index=event_code&PAPI_NATIVE_AND_MASK;
588  if ((event_index < 0) || (event_index>=num_native_events)) {
589  INTDBG("EXIT: PAPI_ENOEVNT\n");
590  return PAPI_ENOEVNT;
591  }
592 
593  result=_papi_native_events[event_index].component_event;
594 
595  INTDBG("EXIT: result: %#x\n", result);
596  return result;
597 
598 }
static struct native_event_info * _papi_native_events
Definition: papi_internal.c:77
#define INTDBG(format, args...)
Definition: papi_debug.h:65
#define PAPI_ENOEVNT
Definition: fpapi.h:112
#define PAPI_NATIVE_AND_MASK
static int num_native_events
Definition: papi_internal.c:78

◆ _papi_hwi_free_EventSet()

void _papi_hwi_free_EventSet ( EventSetInfo_t ESI)

Definition at line 892 of file papi_internal.c.

893 {
895 
896 #ifdef DEBUG
897  memset( ESI, 0x00, sizeof ( EventSetInfo_t ) );
898 #endif
899  papi_free( ESI );
900 
901 }
#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:

◆ _papi_hwi_free_papi_event_string()

void _papi_hwi_free_papi_event_string ( )

Definition at line 107 of file papi_internal.c.

107  {
108  if (papi_event_string != NULL) {
109  free(papi_event_string);
110  papi_event_string = NULL;
111  }
112  return;
113 }
char * papi_event_string
Definition: papi_internal.c:88

◆ _papi_hwi_get_context()

hwd_context_t* _papi_hwi_get_context ( EventSetInfo_t ESI,
int *  is_dirty 
)

Definition at line 2693 of file papi_internal.c.

2694 {
2695  INTDBG("Entry: ESI: %p, is_dirty: %p\n", ESI, is_dirty);
2696  int dirty_ctx;
2697  hwd_context_t *ctx=NULL;
2698 
2699  /* assume for now the control state is clean (last updated by this ESI) */
2700  dirty_ctx = 0;
2701 
2702  /* get a context pointer based on if we are counting for a thread or for a cpu */
2703  if (ESI->state & PAPI_CPU_ATTACHED) {
2704  /* use cpu context */
2705  ctx = ESI->CpuInfo->context[ESI->CmpIdx];
2706 
2707  /* if the user wants to know if the control state was last set by the same event set, tell him */
2708  if (is_dirty != NULL) {
2709  if (ESI->CpuInfo->from_esi != ESI) {
2710  dirty_ctx = 1;
2711  }
2712  *is_dirty = dirty_ctx;
2713  }
2714  ESI->CpuInfo->from_esi = ESI;
2715 
2716  } else {
2717 
2718  /* use thread context */
2719  ctx = ESI->master->context[ESI->CmpIdx];
2720 
2721  /* if the user wants to know if the control state was last set by the same event set, tell him */
2722  if (is_dirty != NULL) {
2723  if (ESI->master->from_esi != ESI) {
2724  dirty_ctx = 1;
2725  }
2726  *is_dirty = dirty_ctx;
2727  }
2728  ESI->master->from_esi = ESI;
2729 
2730  }
2731  return( ctx );
2732 }
#define PAPI_CPU_ATTACHED
Definition: fpapi.h:37
#define INTDBG(format, args...)
Definition: papi_debug.h:65
struct _CpuInfo * CpuInfo
struct _ThreadInfo * master

◆ _papi_hwi_get_native_event_info()

int _papi_hwi_get_native_event_info ( unsigned int  EventCode,
PAPI_event_info_t info 
)

Definition at line 2576 of file papi_internal.c.

2578 {
2579  INTDBG("ENTER: EventCode: %#x, info: %p\n", EventCode, info);
2580  int retval;
2581  int cidx;
2582  int nevt_code;
2583 
2584  cidx = _papi_hwi_component_index( EventCode );
2585  if (cidx<0) return PAPI_ENOCMP;
2586 
2587  if (_papi_hwd[cidx]->cmp_info.disabled) return PAPI_ENOCMP;
2588 
2589  if ( EventCode & PAPI_NATIVE_MASK ) {
2590  // save event code so components can get it with call to: _papi_hwi_get_papi_event_code()
2591  _papi_hwi_set_papi_event_code(EventCode, 0);
2592 
2593  /* clear the event info */
2594  memset( info, 0, sizeof ( PAPI_event_info_t ) );
2595  info->event_code = ( unsigned int ) EventCode;
2596  info->component_index = (unsigned int) cidx;
2597  retval = _papi_hwd[cidx]->ntv_code_to_info(
2598  _papi_hwi_eventcode_to_native(EventCode), info);
2599 
2600  /* If component error, it's missing the ntv_code_to_info vector */
2601  /* so we'll have to fake it. */
2602  if ( retval == PAPI_ECMP ) {
2603 
2604 
2605  INTDBG("missing NTV_CODE_TO_INFO, faking\n");
2606  /* Fill in the info structure */
2607 
2608  if ((nevt_code = _papi_hwi_eventcode_to_native(EventCode)) < 0) {
2609  INTDBG("EXIT: nevt_code: %d\n", nevt_code);
2610  return nevt_code;
2611  }
2612  if ( (retval = _papi_hwd[cidx]->ntv_code_to_name(
2613  (unsigned int)nevt_code,
2614  info->symbol,
2615  sizeof(info->symbol)) ) == PAPI_OK ) {
2616 
2617  } else {
2618  INTDBG("EXIT: retval: %d\n", retval);
2619  return retval;
2620  }
2621 
2622  if ((nevt_code = _papi_hwi_eventcode_to_native(EventCode)) <0) {
2623  INTDBG("EXIT: nevt_code: %d\n", nevt_code);
2624  return nevt_code;
2625  }
2626  retval = _papi_hwd[cidx]->ntv_code_to_descr(
2627  (unsigned int)nevt_code,
2628  info->long_descr,
2629  sizeof ( info->long_descr));
2630  if (retval!=PAPI_OK) {
2631  INTDBG("Failed ntv_code_to_descr()\n");
2632  }
2633 
2634  }
2636  _papi_hwd[cidx]->cmp_info.short_name,
2637  info->symbol,
2638  info->symbol,
2639  sizeof(info->symbol) );
2640 
2641  INTDBG("EXIT: retval: %d\n", retval);
2642  return retval;
2643  }
2644 
2645  INTDBG("EXIT: PAPI_ENOEVNT\n");
2646  return PAPI_ENOEVNT;
2647 }
#define PAPI_OK
Definition: fpapi.h:105
#define PAPI_NATIVE_MASK
char long_descr[PAPI_HUGE_STR_LEN]
Definition: papi.h:970
int retval
Definition: zero_fork.c:53
#define INTDBG(format, args...)
Definition: papi_debug.h:65
#define PAPI_ECMP
Definition: fpapi.h:109
#define PAPI_ENOCMP
Definition: fpapi.h:122
static int cidx
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:967
void _papi_hwi_set_papi_event_code(unsigned int event_code, int update_flag)
int component_index
Definition: papi.h:975
#define PAPI_ENOEVNT
Definition: fpapi.h:112
int _papi_hwi_component_index(int event_code)
struct papi_vectors * _papi_hwd[]
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:965
Here is the call graph for this function:

◆ _papi_hwi_get_ntv_idx()

int _papi_hwi_get_ntv_idx ( unsigned int  papi_evt_code)

Definition at line 142 of file papi_internal.c.

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

◆ _papi_hwi_get_os_info()

PAPI_os_info_t* _papi_hwi_get_os_info ( void  )

◆ _papi_hwi_get_papi_event_code()

unsigned int _papi_hwi_get_papi_event_code ( void  )

Definition at line 136 of file papi_internal.c.

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

◆ _papi_hwi_get_papi_event_string()

char* _papi_hwi_get_papi_event_string ( void  )

Definition at line 102 of file papi_internal.c.

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

◆ _papi_hwi_get_preset_event_info()

int _papi_hwi_get_preset_event_info ( int  EventCode,
PAPI_event_info_t info 
)

Definition at line 2286 of file papi_internal.c.

2287 {
2288  INTDBG("ENTER: EventCode: %#x, info: %p\n", EventCode, info);
2289 
2290  int i = EventCode & PAPI_PRESET_AND_MASK;
2291  unsigned int j;
2292 
2293  if ( _papi_hwi_presets[i].symbol ) { /* if the event is in the preset table */
2294  // since we are setting the whole structure to zero the strncpy calls below will
2295  // be leaving NULL terminates strings as long as they copy 1 less byte than the
2296  // buffer size of the field.
2297  memset( info, 0, sizeof ( PAPI_event_info_t ) );
2298 
2299  info->event_code = ( unsigned int ) EventCode;
2300  strncpy( info->symbol, _papi_hwi_presets[i].symbol,
2301  sizeof(info->symbol)-1);
2302 
2303  if ( _papi_hwi_presets[i].short_descr != NULL )
2304  strncpy( info->short_descr, _papi_hwi_presets[i].short_descr,
2305  sizeof ( info->short_descr )-1 );
2306 
2307  if ( _papi_hwi_presets[i].long_descr != NULL )
2308  strncpy( info->long_descr, _papi_hwi_presets[i].long_descr,
2309  sizeof ( info->long_descr )-1 );
2310 
2312  info->count = _papi_hwi_presets[i].count;
2313 
2315  info->derived, sizeof ( info->derived ) );
2316 
2317  if ( _papi_hwi_presets[i].postfix != NULL )
2318  strncpy( info->postfix, _papi_hwi_presets[i].postfix,
2319  sizeof ( info->postfix )-1 );
2320 
2321  for(j=0;j < info->count; j++) {
2322  info->code[j]=_papi_hwi_presets[i].code[j];
2323  strncpy(info->name[j], _papi_hwi_presets[i].name[j],
2324  sizeof(info->name[j])-1);
2325  }
2326 
2327  if ( _papi_hwi_presets[i].note != NULL ) {
2328  strncpy( info->note, _papi_hwi_presets[i].note,
2329  sizeof ( info->note )-1 );
2330  }
2331 
2332  return PAPI_OK;
2333  } else {
2334  return PAPI_ENOEVNT;
2335  }
2336 }
#define PAPI_OK
Definition: fpapi.h:105
unsigned int count
Definition: papi.h:988
static int _papi_hwi_derived_string(int type, char *derived, int len)
char long_descr[PAPI_HUGE_STR_LEN]
Definition: papi.h:970
unsigned int code[PAPI_MAX_INFO_TERMS]
Definition: papi.h:1004
char derived[PAPI_MIN_STR_LEN]
Definition: papi.h:996
#define INTDBG(format, args...)
Definition: papi_debug.h:65
unsigned int event_type
Definition: papi_preset.h:30
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:967
hwi_presets_t _papi_hwi_presets[PAPI_MAX_PRESET_EVENTS]
unsigned int event_type
Definition: papi.h:993
char short_descr[PAPI_MIN_STR_LEN]
Definition: papi.h:968
char * short_descr
Definition: papi_preset.h:25
char name[PAPI_MAX_INFO_TERMS][PAPI_2MAX_STR_LEN]
Definition: papi.h:1010
char * long_descr
Definition: papi_preset.h:26
#define PAPI_ENOEVNT
Definition: fpapi.h:112
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
char postfix[PAPI_2MAX_STR_LEN]
Definition: papi.h:999
unsigned int event_code
Definition: papi.h:965
char * symbol
Definition: papi_preset.h:24
char note[PAPI_HUGE_STR_LEN]
Definition: papi.h:1014
unsigned int count
Definition: papi_preset.h:29
int i
Definition: fileop.c:140
char * postfix
Definition: papi_preset.h:31
Here is the call graph for this function:

◆ _papi_hwi_get_user_event_info()

int _papi_hwi_get_user_event_info ( int  EventCode,
PAPI_event_info_t info 
)

Definition at line 2346 of file papi_internal.c.

2347 {
2348  INTDBG("ENTER: EventCode: %#x, info: %p\n", EventCode, info);
2349 
2350  unsigned int i = EventCode & PAPI_UE_AND_MASK;
2351  unsigned int j;
2352 
2353  // if event code not in valid range, return error
2354  if (i >= PAPI_MAX_USER_EVENTS) {
2355  INTDBG("EXIT: Invalid event index: %d, max value is: %d\n", i, PAPI_MAX_USER_EVENTS - 1);
2356  return( PAPI_ENOEVNT );
2357  }
2358 
2359  if ( user_defined_events[i].symbol == NULL) { /* if the event is in the preset table */
2360  INTDBG("EXIT: Event symbol for this event is NULL\n");
2361  return PAPI_ENOEVNT;
2362  }
2363 
2364  /* set whole structure to 0 */
2365  memset( info, 0, sizeof ( PAPI_event_info_t ) );
2366 
2367  info->event_code = ( unsigned int ) EventCode;
2368  strncpy( info->symbol, user_defined_events[i].symbol,
2369  sizeof(info->symbol)-1);
2370 
2371  if ( user_defined_events[i].short_descr != NULL )
2372  strncpy( info->short_descr, user_defined_events[i].short_descr,
2373  sizeof(info->short_descr)-1);
2374 
2375  if ( user_defined_events[i].long_descr != NULL )
2376  strncpy( info->long_descr, user_defined_events[i].long_descr,
2377  sizeof(info->long_descr)-1);
2378 
2379 // info->event_type = user_defined_events[i].event_type;
2380  info->count = user_defined_events[i].count;
2381 
2383  info->derived, sizeof(info->derived)-1);
2384 
2385  if ( user_defined_events[i].postfix != NULL )
2386  strncpy( info->postfix, user_defined_events[i].postfix,
2387  sizeof(info->postfix)-1);
2388 
2389  for(j=0;j < info->count; j++) {
2390  info->code[j]=user_defined_events[i].code[j];
2391  INTDBG("info->code[%d]: %#x\n", j, info->code[j]);
2392  strncpy(info->name[j], user_defined_events[i].name[j], sizeof(info->name[j])-1);
2393  }
2394 
2395  if ( user_defined_events[i].note != NULL ) {
2396  strncpy( info->note, user_defined_events[i].note, sizeof(info->note)-1);
2397  }
2398 
2399  INTDBG("EXIT: PAPI_OK: event_code: %#x, symbol: %s, short_desc: %s, long_desc: %s\n", info->event_code, info->symbol, info->short_descr, info->long_descr);
2400  return PAPI_OK;
2401 }
#define PAPI_OK
Definition: fpapi.h:105
unsigned int count
Definition: papi.h:988
#define PAPI_UE_AND_MASK
static int _papi_hwi_derived_string(int type, char *derived, int len)
char long_descr[PAPI_HUGE_STR_LEN]
Definition: papi.h:970
unsigned int code[PAPI_MAX_INFO_TERMS]
Definition: papi.h:1004
char derived[PAPI_MIN_STR_LEN]
Definition: papi.h:996
#define INTDBG(format, args...)
Definition: papi_debug.h:65
#define PAPI_MAX_USER_EVENTS
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:967
char short_descr[PAPI_MIN_STR_LEN]
Definition: papi.h:968
char * short_descr
Definition: papi_preset.h:25
char name[PAPI_MAX_INFO_TERMS][PAPI_2MAX_STR_LEN]
Definition: papi.h:1010
hwi_presets_t user_defined_events[PAPI_MAX_USER_EVENTS]
Definition: papi_internal.c:59
char * long_descr
Definition: papi_preset.h:26
#define PAPI_ENOEVNT
Definition: fpapi.h:112
unsigned int code[PAPI_MAX_INFO_TERMS]
Definition: papi_preset.h:32
char * name[PAPI_MAX_INFO_TERMS]
Definition: papi_preset.h:33
char postfix[PAPI_2MAX_STR_LEN]
Definition: papi.h:999
unsigned int event_code
Definition: papi.h:965
char * symbol
Definition: papi_preset.h:24
char note[PAPI_HUGE_STR_LEN]
Definition: papi.h:1014
unsigned int count
Definition: papi_preset.h:29
int i
Definition: fileop.c:140
char * postfix
Definition: papi_preset.h:31
Here is the call graph for this function:

◆ _papi_hwi_init_errors()

void _papi_hwi_init_errors ( void  )

Definition at line 482 of file papi_internal.c.

482  {
483 /* we use add error to avoid the cost of lookups, we know the errors are not there yet */
484  /* 0 PAPI_OK */ _papi_hwi_add_error("No error");
485  /* 1 PAPI_EINVAL */ _papi_hwi_add_error("Invalid argument");
486  /* 2 PAPI_ENOMEM */ _papi_hwi_add_error("Insufficient memory");
487  /* 3 PAPI_ESYS */ _papi_hwi_add_error("A System/C library call failed");
488  /* 4 PAPI_ECMP */ _papi_hwi_add_error("Not supported by component");
489  /* 5 PAPI_ECLOST */ _papi_hwi_add_error("Access to the counters was lost or interrupted");
490  /* 6 PAPI_EBUG */ _papi_hwi_add_error("Internal error, please send mail to the developers");
491  /* 7 PAPI_ENOEVNT */ _papi_hwi_add_error("Event does not exist");
492  /* 8 PAPI_ECNFLCT */ _papi_hwi_add_error("Event exists, but cannot be counted due to hardware resource limits");
493  /* 9 PAPI_ENOTRUN */ _papi_hwi_add_error("EventSet is currently not running");
494  /* 10 PAPI_EISRUN */ _papi_hwi_add_error("EventSet is currently counting");
495  /* 11 PAPI_ENOEVST */ _papi_hwi_add_error("No such EventSet available");
496  /* 12 PAPI_ENOTPRESET */_papi_hwi_add_error("Event in argument is not a valid preset");
497  /* 13 PAPI_ENOCNTR */ _papi_hwi_add_error("Hardware does not support performance counters");
498  /* 14 PAPI_EMISC */ _papi_hwi_add_error("Unknown error code");
499  /* 15 PAPI_EPERM */ _papi_hwi_add_error("Permission level does not permit operation");
500  /* 16 PAPI_ENOINIT */ _papi_hwi_add_error("PAPI hasn't been initialized yet");
501  /* 17 PAPI_ENOCMP */ _papi_hwi_add_error("Component Index isn't set");
502  /* 18 PAPI_ENOSUPP */ _papi_hwi_add_error("Not supported");
503  /* 19 PAPI_ENOIMPL */ _papi_hwi_add_error("Not implemented");
504  /* 20 PAPI_EBUF */ _papi_hwi_add_error("Buffer size exceeded");
505  /* 21 PAPI_EINVAL_DOM */_papi_hwi_add_error("EventSet domain is not supported for the operation");
506  /* 22 PAPI_EATTR */ _papi_hwi_add_error("Invalid or missing event attributes");
507  /* 23 PAPI_ECOUNT */ _papi_hwi_add_error("Too many events or attributes");
508  /* 24 PAPI_ECOMBO */ _papi_hwi_add_error("Bad combination of features");
509  /* 25 PAPI_ECMP_DISABLED */_papi_hwi_add_error("Component containing event is disabled");
510 }
static int _papi_hwi_add_error(char *error)
Here is the call graph for this function:

◆ _papi_hwi_init_global()

int _papi_hwi_init_global ( void  )

Definition at line 1933 of file papi_internal.c.

1934 {
1935  int retval, i = 0;
1936 
1938  if ( retval != PAPI_OK ) {
1939  return retval;
1940  }
1941 
1942  while ( _papi_hwd[i] ) {
1943 
1945  if ( retval != PAPI_OK ) {
1946  return retval;
1947  }
1948 
1949  /* We can be disabled by user before init */
1950  if (!_papi_hwd[i]->cmp_info.disabled) {
1951  retval = _papi_hwd[i]->init_component( i );
1952  _papi_hwd[i]->cmp_info.disabled=retval;
1953 
1954  /* Do some sanity checking */
1955  if (retval==PAPI_OK) {
1956  if (_papi_hwd[i]->cmp_info.num_cntrs >
1957  _papi_hwd[i]->cmp_info.num_mpx_cntrs) {
1958  fprintf(stderr,"Warning! num_cntrs %d is more than num_mpx_cntrs %d for component %s\n",
1959  _papi_hwd[i]->cmp_info.num_cntrs,
1960  _papi_hwd[i]->cmp_info.num_mpx_cntrs,
1961  _papi_hwd[i]->cmp_info.name);
1962  }
1963 
1964  }
1965  }
1966 
1967  i++;
1968  }
1969  return PAPI_OK;
1970 }
#define PAPI_OK
Definition: fpapi.h:105
int _papi_hwi_innoculate_os_vector(papi_os_vector_t *v)
Definition: papi_vector.c:200
int retval
Definition: zero_fork.c:53
papi_os_vector_t _papi_os_vector
Definition: aix.c:1288
int _papi_hwi_innoculate_vector(papi_vector_t *v)
Definition: papi_vector.c:109
struct papi_vectors * _papi_hwd[]
int i
Definition: fileop.c:140
Here is the call graph for this function:

◆ _papi_hwi_init_global_internal()

int _papi_hwi_init_global_internal ( void  )

Definition at line 1976 of file papi_internal.c.

1977 {
1978 
1979  int retval;
1980 
1981  memset(&_papi_hwi_system_info,0x0,sizeof( _papi_hwi_system_info ));
1982 
1983  memset( _papi_hwi_using_signal,0x0,sizeof( _papi_hwi_using_signal ));
1984 
1985  /* Global struct to maintain EventSet mapping */
1987  if ( retval != PAPI_OK ) {
1988  return retval;
1989  }
1990 
1991  _papi_hwi_system_info.pid = 0; /* Process identifier */
1992 
1993  /* PAPI_hw_info_t struct */
1994  memset(&(_papi_hwi_system_info.hw_info),0x0,sizeof(PAPI_hw_info_t));
1995 
1996  return PAPI_OK;
1997 }
#define PAPI_OK
Definition: fpapi.h:105
int _papi_hwi_using_signal[PAPI_NSIG]
Definition: extras.c:365
Hardware info structure.
Definition: papi.h:781
int retval
Definition: zero_fork.c:53
DynamicArray_t global_eventset_map
static int allocate_eventset_map(DynamicArray_t *map)
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:56
PAPI_hw_info_t hw_info
Here is the call graph for this function:

◆ _papi_hwi_init_os()

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_OK
Definition: fpapi.h:105
#define PAPI_INT_MPX_DEF_US
Definition: papi_internal.h:65
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: fpapi.h:43
Here is the call graph for this function:

◆ _papi_hwi_invalid_cmp()

int _papi_hwi_invalid_cmp ( int  cidx)

Definition at line 513 of file papi_internal.c.

514 {
515  return ( cidx < 0 || cidx >= papi_num_components );
516 }
int papi_num_components

◆ _papi_hwi_is_sw_multiplex()

int _papi_hwi_is_sw_multiplex ( EventSetInfo_t ESI)

Definition at line 2669 of file papi_internal.c.

2670 {
2671  /* Are we multiplexing at all */
2672  if ( ( ESI->state & PAPI_MULTIPLEXING ) == 0 ) {
2673  return 0;
2674  }
2675 
2676  /* Does the component support kernel multiplexing */
2677  if ( _papi_hwd[ESI->CmpIdx]->cmp_info.kernel_multiplex ) {
2678  /* Have we forced software multiplexing */
2679  if ( ESI->multiplex.flags == PAPI_MULTIPLEX_FORCE_SW ) {
2680  return 1;
2681  }
2682  /* Nope, using hardware multiplexing */
2683  return 0;
2684  }
2685 
2686  /* We are multiplexing but the component does not support hardware */
2687 
2688  return 1;
2689 
2690 }
#define PAPI_MULTIPLEX_FORCE_SW
Definition: fpapi.h:46
#define PAPI_MULTIPLEXING
Definition: fpapi.h:35
EventSetMultiplexInfo_t multiplex
struct papi_vectors * _papi_hwd[]

◆ _papi_hwi_lookup_EventCodeIndex()

int _papi_hwi_lookup_EventCodeIndex ( const EventSetInfo_t ESI,
unsigned int  EventCode 
)

Definition at line 1005 of file papi_internal.c.

1007 {
1008  int i;
1009  int limit = EventInfoArrayLength( ESI );
1010 
1011  for ( i = 0; i < limit; i++ ) {
1012  if ( ESI->EventInfoArray[i].event_code == EventCode ) {
1013  return i;
1014  }
1015  }
1016 
1017  return PAPI_EINVAL;
1018 }
#define PAPI_EINVAL
Definition: fpapi.h:106
static int EventInfoArrayLength(const EventSetInfo_t *ESI)
EventInfo_t * EventInfoArray
unsigned int event_code
int i
Definition: fileop.c:140
Here is the call graph for this function:

◆ _papi_hwi_lookup_EventSet()

EventSetInfo_t* _papi_hwi_lookup_EventSet ( int  eventset)

Definition at line 2650 of file papi_internal.c.

2651 {
2653  EventSetInfo_t *set;
2654 
2655  if ( ( eventset < 0 ) || ( eventset > map->totalSlots ) )
2656  return ( NULL );
2657 
2658  set = map->dataSlotArray[eventset];
2659 #ifdef DEBUG
2660  if ( ( ISLEVEL( DEBUG_THREADS ) ) && ( _papi_hwi_thread_id_fn ) &&
2661  ( set->master->tid != _papi_hwi_thread_id_fn( ) ) )
2662  return ( NULL );
2663 #endif
2664 
2665  return ( set );
2666 }
unsigned long int(* _papi_hwi_thread_id_fn)(void)
Definition: threads.c:42
DynamicArray_t global_eventset_map
struct _ThreadInfo * master
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:56
EventSetInfo_t ** dataSlotArray
#define ISLEVEL(a)
Definition: papi_debug.h:54
#define DEBUG_THREADS
Definition: papi_debug.h:30

◆ _papi_hwi_map_events_to_native()

void _papi_hwi_map_events_to_native ( EventSetInfo_t ESI)

Definition at line 1085 of file papi_internal.c.

1086 {
1087  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);
1088 
1089  int i, event, k, n, preset_index = 0, nevt;
1090  int total_events = ESI->NumberOfEvents;
1091 
1092  event = 0;
1093  for( i = 0; i < total_events; i++ ) {
1094 
1095  /* find the first event that isn't PAPI_NULL */
1096  /* Is this really necessary? --vmw */
1097  while ( ESI->EventInfoArray[event].event_code == ( unsigned int ) PAPI_NULL ) {
1098  event++;
1099  }
1100 
1101  /* If it's a preset */
1102  if ( IS_PRESET(ESI->EventInfoArray[event].event_code) ) {
1103  preset_index = ( int ) ESI->EventInfoArray[event].event_code & PAPI_PRESET_AND_MASK;
1104 
1105  /* walk all sub-events in the preset */
1106  for( k = 0; k < PAPI_EVENTS_IN_DERIVED_EVENT; k++ ) {
1107  nevt = _papi_hwi_presets[preset_index].code[k];
1108  if ( nevt == PAPI_NULL ) {
1109  break;
1110  }
1111 
1112  INTDBG("Looking for subevent %#x\n",nevt);
1113 
1114  /* Match each sub-event to something in the Native List */
1115  for( n = 0; n < ESI->NativeCount; n++ ) {
1116  if ( nevt == ESI->NativeInfoArray[n].ni_papi_code ) {
1117  INTDBG("Found papi event: %#x, &ESI->NativeInfoArray[%d]: %p, ni_event: %#x, ni_position %d\n",
1118  nevt, n, &(ESI->NativeInfoArray[n]), ESI->NativeInfoArray[n].ni_event, ESI->NativeInfoArray[n].ni_position);
1119  ESI->EventInfoArray[event].pos[k] = ESI->NativeInfoArray[n].ni_position;
1120  break;
1121  }
1122  }
1123  }
1124  }
1125  /* If it's a native event */
1126  else if( IS_NATIVE(ESI->EventInfoArray[event].event_code) ) {
1127  nevt = ( int ) ESI->EventInfoArray[event].event_code;
1128 
1129  // get index into native info array for this event
1130  int nidx = event_already_in_eventset( ESI, nevt );
1131  // if not found, then we need to return an error
1132  if (nidx == PAPI_ENOEVNT) {
1133  INTDBG("EXIT: needed event not found\n");
1134  return;
1135  }
1136  ESI->EventInfoArray[event].pos[0] = ESI->NativeInfoArray[nidx].ni_position;
1137  INTDBG("nidx: %d, ni_position: %d\n", nidx, ESI->NativeInfoArray[nidx].ni_position);
1138 
1139  }
1140  /* If it's a user-defined event */
1141  else if ( IS_USER_DEFINED(ESI->EventInfoArray[event].event_code) ) {
1142  preset_index = ( int ) ESI->EventInfoArray[event].event_code & PAPI_UE_AND_MASK;
1143  for ( k = 0; k < PAPI_EVENTS_IN_DERIVED_EVENT; k++ ) {
1144  nevt = user_defined_events[preset_index].code[k];
1145  INTDBG("nevt: %#x, user_defined_events[%d].code[%d]: %#x, code[%d]: %#x\n",
1146  nevt, preset_index, k, user_defined_events[preset_index].code[k], k+1, user_defined_events[preset_index].code[k+1]);
1147 
1148  if ( nevt == PAPI_NULL ) break;
1149 
1150  /* Match each sub-event to something in the Native List */
1151  for ( n = 0; n < ESI->NativeCount; n++ ) {
1152  // if this is the event we are looking for, set its position and exit inner loop to look for next sub-event
1153  if ( _papi_hwi_eventcode_to_native(nevt) == ESI->NativeInfoArray[n].ni_event ) {
1154  ESI->EventInfoArray[event].pos[k] = ESI->NativeInfoArray[n].ni_position;
1155  break;
1156  }
1157  }
1158  }
1159  }
1160  event++;
1161  }
1162  INTDBG("EXIT: \n");
1163  return;
1164 }
#define IS_PRESET(EventCode)
Definition: papi.h:229
#define PAPI_EVENTS_IN_DERIVED_EVENT
Definition: genpapifdef.c:39
#define IS_USER_DEFINED(EventCode)
Definition: papi.h:230
#define PAPI_UE_AND_MASK
#define INTDBG(format, args...)
Definition: papi_debug.h:65
static int event_already_in_eventset(EventSetInfo_t *ESI, int papi_event)
#define IS_NATIVE(EventCode)
Definition: papi.h:228
hwi_presets_t _papi_hwi_presets[PAPI_MAX_PRESET_EVENTS]
#define PAPI_NULL
Definition: fpapi.h:13
NativeInfo_t * NativeInfoArray
EventInfo_t * EventInfoArray
int pos[PAPI_EVENTS_IN_DERIVED_EVENT]
hwi_presets_t user_defined_events[PAPI_MAX_USER_EVENTS]
Definition: papi_internal.c:59
#define PAPI_ENOEVNT
Definition: fpapi.h:112
unsigned int code[PAPI_MAX_INFO_TERMS]
Definition: papi_preset.h:32
unsigned int event_code
#define PAPI_PRESET_AND_MASK
int _papi_hwi_eventcode_to_native(int event_code)
int i
Definition: fileop.c:140
Here is the call graph for this function:

◆ _papi_hwi_native_code_to_name()

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

Definition at line 2538 of file papi_internal.c.

2540 {
2541  INTDBG("ENTER: EventCode: %#x, hwi_name: %p, len: %d\n", EventCode, hwi_name, len);
2542  int cidx;
2543  int retval;
2544  int nevt_code;
2545 
2546  cidx = _papi_hwi_component_index( EventCode );
2547  if (cidx<0) return PAPI_ENOEVNT;
2548 
2549  if ( EventCode & PAPI_NATIVE_MASK ) {
2550  // save event code so components can get it with call to: _papi_hwi_get_papi_event_code()
2551  _papi_hwi_set_papi_event_code(EventCode, 0);
2552 
2553  if ((nevt_code = _papi_hwi_eventcode_to_native(EventCode)) < 0) {
2554  INTDBG("EXIT: nevt_code: %d\n", nevt_code);
2555  return nevt_code;
2556  }
2557  if ( (retval = _papi_hwd[cidx]->ntv_code_to_name(
2558  (unsigned int)nevt_code,
2559  hwi_name, len) ) == PAPI_OK ) {
2560  retval = _papi_hwi_prefix_component_name( _papi_hwd[cidx]->cmp_info.short_name,
2561  hwi_name, hwi_name, len);
2562  INTDBG("EXIT: retval: %d\n", retval);
2563  return retval;
2564  }
2565  INTDBG("EXIT: retval: %d\n", retval);
2566  return (retval);
2567  }
2568  INTDBG("EXIT: PAPI_ENOEVNT\n");
2569  return PAPI_ENOEVNT;
2570 }
#define PAPI_OK
Definition: fpapi.h:105
#define PAPI_NATIVE_MASK
int retval
Definition: zero_fork.c:53
#define INTDBG(format, args...)
Definition: papi_debug.h:65
static int cidx
void _papi_hwi_set_papi_event_code(unsigned int event_code, int update_flag)
#define PAPI_ENOEVNT
Definition: fpapi.h:112
int _papi_hwi_component_index(int event_code)
struct papi_vectors * _papi_hwd[]
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)
Here is the call graph for this function:

◆ _papi_hwi_native_name_to_code()

int _papi_hwi_native_name_to_code ( const char *  in,
int *  out 
)

Definition at line 2438 of file papi_internal.c.

2439 {
2440  INTDBG("ENTER: in: %s, out: %p\n", in, out);
2441 
2442  int retval = PAPI_ENOEVNT;
2443  char name[PAPI_HUGE_STR_LEN]; /* make sure it's big enough */
2444 
2445  unsigned int i;
2446  int cidx;
2447  char *full_event_name;
2448 
2449  if (in == NULL) {
2450  INTDBG("EXIT: PAPI_EINVAL\n");
2451  return PAPI_EINVAL;
2452  }
2453 
2454  full_event_name = strdup(in);
2455 
2457 
2458  // look in each component
2459  for(cidx=0; cidx < papi_num_components; cidx++) {
2460 
2461  if (_papi_hwd[cidx]->cmp_info.disabled) continue;
2462 
2463  // if this component does not support the pmu
2464  // which defines this event, no need to call it
2465  if (is_supported_by_component(cidx, full_event_name) == 0) {
2466  continue;
2467  }
2468 
2469  INTDBG("cidx: %d, name: %s, event: %s\n",
2470  cidx, _papi_hwd[cidx]->cmp_info.name, in);
2471 
2472  // show that we do not have an event code yet
2473  // (the component may create one and update this info)
2474  // this also clears any values left over from a previous call
2476 
2477 
2478  // if component has a ntv_name_to_code function, use it to get event code
2479  if (_papi_hwd[cidx]->ntv_name_to_code != NULL) {
2480  // try and get this events event code
2481  retval = _papi_hwd[cidx]->ntv_name_to_code( in, ( unsigned * ) out );
2482  if (retval==PAPI_OK) {
2483  *out = _papi_hwi_native_to_eventcode(cidx, *out, -1, in);
2484  free (full_event_name);
2485  INTDBG("EXIT: PAPI_OK event: %s code: %#x\n", in, *out);
2486  return PAPI_OK;
2487  }
2488  } else {
2489  // force the code through the work around
2490  retval = PAPI_ECMP;
2491  }
2492 
2493  /* If not implemented, work around */
2494  if ( retval==PAPI_ECMP) {
2495  i = 0;
2496  retval = _papi_hwd[cidx]->ntv_enum_events( &i, PAPI_ENUM_FIRST );
2497  if (retval != PAPI_OK) {
2498  free (full_event_name);
2499  INTDBG("EXIT: retval: %d\n", retval);
2500  return retval;
2501  }
2502 
2503 // _papi_hwi_lock( INTERNAL_LOCK );
2504 
2505  do {
2506  // save event code so components can get it with call to: _papi_hwi_get_papi_event_code()
2508  retval = _papi_hwd[cidx]->ntv_code_to_name(i, name, sizeof(name));
2509  /* printf("%#x\nname =|%s|\ninput=|%s|\n", i, name, in); */
2510  if ( retval == PAPI_OK && in != NULL) {
2511  if ( strcasecmp( name, in ) == 0 ) {
2512  *out = _papi_hwi_native_to_eventcode(cidx, i, -1, name);
2513  free (full_event_name);
2514  INTDBG("EXIT: PAPI_OK, event: %s, code: %#x\n", in, *out);
2515  return PAPI_OK;
2516  }
2517  retval = PAPI_ENOEVNT;
2518  } else {
2519  *out = 0;
2520  retval = PAPI_ENOEVNT;
2521  break;
2522  }
2523  } while ( ( _papi_hwd[cidx]->ntv_enum_events( &i, PAPI_ENUM_EVENTS ) == PAPI_OK ) );
2524 
2525 // _papi_hwi_unlock( INTERNAL_LOCK );
2526  }
2527  }
2528 
2529  free (full_event_name);
2530  INTDBG("EXIT: retval: %d\n", retval);
2531 
2532  return retval;
2533 }
#define PAPI_OK
Definition: fpapi.h:105
static const char * name
Definition: fork_overflow.c:31
#define PAPI_EINVAL
Definition: fpapi.h:106
static int is_supported_by_component(int cidx, char *event_name)
int retval
Definition: zero_fork.c:53
#define INTDBG(format, args...)
Definition: papi_debug.h:65
#define PAPI_ECMP
Definition: fpapi.h:109
static int cidx
int _papi_hwi_native_to_eventcode(int cidx, int event_code, int ntv_idx, const char *event_name)
#define PAPI_HUGE_STR_LEN
Definition: fpapi.h:42
void _papi_hwi_set_papi_event_code(unsigned int event_code, int update_flag)
int papi_num_components
#define PAPI_ENOEVNT
Definition: fpapi.h:112
struct papi_vectors * _papi_hwd[]
const char * _papi_hwi_strip_component_prefix(const char *event_name)
int i
Definition: fileop.c:140
Here is the call graph for this function:

◆ _papi_hwi_native_to_eventcode()

int _papi_hwi_native_to_eventcode ( int  cidx,
int  event_code,
int  ntv_idx,
const char *  event_name 
)

Definition at line 558 of file papi_internal.c.

558  {
559  INTDBG("Entry: cidx: %d, event: %#x, ntv_idx: %d, event_name: %s\n", cidx, event_code, ntv_idx, event_name);
560 
561  int result;
562 
563  if (papi_event_code_changed > 0) {
565  INTDBG("EXIT: papi_event_code: %#x set by the component\n", result);
566  return result;
567  }
568 
569  result=_papi_hwi_find_native_event(cidx, event_code, event_name);
570  if (result==PAPI_ENOEVNT) {
571  // Need to create one
572  result=_papi_hwi_add_native_event(cidx, event_code, ntv_idx, event_name);
573  }
574 
575  INTDBG("EXIT: result: %#x\n", result);
576  return result;
577 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
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
#define PAPI_ENOEVNT
Definition: fpapi.h:112
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:

◆ _papi_hwi_query_native_event()

int _papi_hwi_query_native_event ( unsigned int  EventCode)

Definition at line 2407 of file papi_internal.c.

2408 {
2409  INTDBG("ENTER: EventCode: %#x\n", EventCode);
2410  char name[PAPI_HUGE_STR_LEN]; /* probably overkill, */
2411  /* but should always be big enough */
2412  int cidx;
2413  int nevt_code;
2414 
2415  cidx = _papi_hwi_component_index( EventCode );
2416  if (cidx<0) {
2417  INTDBG("EXIT: PAPI_ENOCMP\n");
2418  return PAPI_ENOCMP;
2419  }
2420 
2421  // save event code so components can get it with call to: _papi_hwi_get_papi_event_code()
2422  _papi_hwi_set_papi_event_code(EventCode, 0);
2423 
2424  if ((nevt_code = _papi_hwi_eventcode_to_native(EventCode)) < 0) {
2425  INTDBG("EXIT: nevt_code: %d\n", nevt_code);
2426  return nevt_code;
2427  }
2428  int ret = _papi_hwd[cidx]->ntv_code_to_name( (unsigned int)nevt_code, name, sizeof(name));
2429 
2430  INTDBG("EXIT: ret: %d\n", ret);
2431  return (ret);
2432 }
static const char * name
Definition: fork_overflow.c:31
#define INTDBG(format, args...)
Definition: papi_debug.h:65
#define PAPI_ENOCMP
Definition: fpapi.h:122
static int cidx
#define PAPI_HUGE_STR_LEN
Definition: fpapi.h:42
long long ret
Definition: iozone.c:1346
void _papi_hwi_set_papi_event_code(unsigned int event_code, int update_flag)
int _papi_hwi_component_index(int event_code)
struct papi_vectors * _papi_hwd[]
int _papi_hwi_eventcode_to_native(int event_code)
Here is the call graph for this function:

◆ _papi_hwi_read()

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

Definition at line 1702 of file papi_internal.c.

1704 {
1705  INTDBG("ENTER: context: %p, ESI: %p, values: %p\n", context, ESI, values);
1706  int retval;
1707  long long *dp = NULL;
1708  int i, index;
1709 
1710  retval = _papi_hwd[ESI->CmpIdx]->read( context, ESI->ctl_state,
1711  &dp, ESI->state );
1712  if ( retval != PAPI_OK ) {
1713  INTDBG("EXIT: retval: %d\n", retval);
1714  return retval;
1715  }
1716 
1717  /* This routine distributes hardware counters to software counters in the
1718  order that they were added. Note that the higher level
1719  EventInfoArray[i] entries may not be contiguous because the user
1720  has the right to remove an event.
1721  But if we do compaction after remove event, this function can be
1722  changed.
1723  */
1724 
1725  for ( i = 0; i != ESI->NumberOfEvents; i++ ) {
1726 
1727  index = ESI->EventInfoArray[i].pos[0];
1728 
1729  if ( index == -1 )
1730  continue;
1731 
1732  INTDBG( "ESI->EventInfoArray: %p, pos[%d]: %d, dp[%d]: %lld, derived[%d]: %#x\n", ESI->EventInfoArray, i, index, index, dp[index], i, ESI->EventInfoArray[i].derived );
1733 
1734  /* If this is not a derived event */
1735 
1736  if ( ESI->EventInfoArray[i].derived == NOT_DERIVED ) {
1737  values[i] = dp[index];
1738  INTDBG( "value: %#llx\n", values[i] );
1739  } else { /* If this is a derived event */
1740  values[i] = handle_derived( &ESI->EventInfoArray[i], dp );
1741 #ifdef DEBUG
1742  if ( values[i] < ( long long ) 0 ) {
1743  INTDBG( "Derived Event is negative!!: %lld\n", values[i] );
1744  }
1745  INTDBG( "derived value: %#llx \n", values[i] );
1746 #endif
1747  }
1748  }
1749 
1750  INTDBG("EXIT: PAPI_OK\n");
1751  return PAPI_OK;
1752 }
#define PAPI_OK
Definition: fpapi.h:105
int retval
Definition: zero_fork.c:53
#define INTDBG(format, args...)
Definition: papi_debug.h:65
#define NOT_DERIVED
Definition: papi_internal.h:69
EventInfo_t * EventInfoArray
int pos[PAPI_EVENTS_IN_DERIVED_EVENT]
struct papi_vectors * _papi_hwd[]
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
int i
Definition: fileop.c:140
Here is the call graph for this function:

◆ _papi_hwi_remove_event()

int _papi_hwi_remove_event ( EventSetInfo_t ESI,
int  EventCode 
)

Definition at line 1619 of file papi_internal.c.

1620 {
1621  int j = 0, retval, thisindex;
1622  EventInfo_t *array;
1623 
1624  thisindex =
1625  _papi_hwi_lookup_EventCodeIndex( ESI, ( unsigned int ) EventCode );
1626  if ( thisindex < PAPI_OK )
1627  return ( thisindex );
1628 
1629  /* If it is a MPX EventSet, remove it from the multiplex data structure and
1630  this threads multiplex list */
1631 
1632  if ( _papi_hwi_is_sw_multiplex( ESI ) ) {
1633  retval = mpx_remove_event( &ESI->multiplex.mpx_evset, EventCode );
1634  if ( retval < PAPI_OK )
1635  return ( retval );
1636  } else
1637  /* Remove the events hardware dependent stuff from the EventSet */
1638  {
1639  if ( IS_PRESET(EventCode) ) {
1640  int preset_index = EventCode & PAPI_PRESET_AND_MASK;
1641 
1642  /* Check if it's within the valid range */
1643  if ( ( preset_index < 0 ) ||
1644  ( preset_index >= PAPI_MAX_PRESET_EVENTS ) )
1645  return PAPI_EINVAL;
1646 
1647  /* Check if event exists */
1648  if ( !_papi_hwi_presets[preset_index].count )
1649  return PAPI_ENOEVNT;
1650 
1651  /* Remove the preset event. */
1652  for ( j = 0; _papi_hwi_presets[preset_index].code[j] != (unsigned int)PAPI_NULL;
1653  j++ );
1654  retval = remove_native_events( ESI, ( int * )_papi_hwi_presets[preset_index].code, j );
1655  if ( retval != PAPI_OK )
1656  return ( retval );
1657  } else if ( IS_NATIVE(EventCode) ) {
1658  /* Check if native event exists */
1659  if ( _papi_hwi_query_native_event( ( unsigned int ) EventCode ) !=
1660  PAPI_OK )
1661  return PAPI_ENOEVNT;
1662 
1663  /* Remove the native event. */
1664  retval = remove_native_events( ESI, &EventCode, 1 );
1665  if ( retval != PAPI_OK )
1666  return ( retval );
1667  } else if ( IS_USER_DEFINED( EventCode ) ) {
1668  int index = EventCode & PAPI_UE_AND_MASK;
1669 
1670  if ( (index < 0) || (index >= user_defined_events_count) )
1671  return ( PAPI_EINVAL );
1672 
1673  for( j = 0; j < PAPI_EVENTS_IN_DERIVED_EVENT &&
1674  user_defined_events[index].code[j] != 0; j++ ) {
1675  retval = remove_native_events( ESI, ( int * )user_defined_events[index].code, j);
1676 
1677  if ( retval != PAPI_OK )
1678  return ( retval );
1679  }
1680  } else
1681  return ( PAPI_ENOEVNT );
1682  }
1683  array = ESI->EventInfoArray;
1684 
1685  /* Compact the Event Info Array list if it's not the last event */
1686  /* clear the newly empty slot in the array */
1687  for ( ; thisindex < ESI->NumberOfEvents - 1; thisindex++ )
1688  array[thisindex] = array[thisindex + 1];
1689 
1690 
1691  array[thisindex].event_code = ( unsigned int ) PAPI_NULL;
1692  for ( j = 0; j < PAPI_EVENTS_IN_DERIVED_EVENT; j++ )
1693  array[thisindex].pos[j] = PAPI_NULL;
1694  array[thisindex].ops = NULL;
1695  array[thisindex].derived = NOT_DERIVED;
1696  ESI->NumberOfEvents--;
1697 
1698  return ( PAPI_OK );
1699 }
int _papi_hwi_is_sw_multiplex(EventSetInfo_t *ESI)
#define PAPI_OK
Definition: fpapi.h:105
#define IS_PRESET(EventCode)
Definition: papi.h:229
#define PAPI_EVENTS_IN_DERIVED_EVENT
Definition: genpapifdef.c:39
#define PAPI_EINVAL
Definition: fpapi.h:106
#define IS_USER_DEFINED(EventCode)
Definition: papi.h:230
#define PAPI_UE_AND_MASK
int _papi_hwi_query_native_event(unsigned int EventCode)
MPX_EventSet * mpx_evset
Definition: sw_multiplex.h:32
static double array[ARRAYSIZE]
Definition: papi_l1_dca.c:23
int retval
Definition: zero_fork.c:53
#define PAPI_MAX_PRESET_EVENTS
Definition: fpapi.h:16
#define IS_NATIVE(EventCode)
Definition: papi.h:228
#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)
#define PAPI_NULL
Definition: fpapi.h:13
EventInfo_t * EventInfoArray
static int remove_native_events(EventSetInfo_t *ESI, int *nevt, int size)
EventSetMultiplexInfo_t multiplex
int user_defined_events_count
Definition: papi_internal.c:60
hwi_presets_t user_defined_events[PAPI_MAX_USER_EVENTS]
Definition: papi_internal.c:59
int mpx_remove_event(MPX_EventSet **mpx_events, int EventCode)
Definition: sw_multiplex.c:418
#define PAPI_ENOEVNT
Definition: fpapi.h:112
unsigned int code[PAPI_MAX_INFO_TERMS]
Definition: papi_preset.h:32
#define PAPI_PRESET_AND_MASK
static long count
Here is the call graph for this function:

◆ _papi_hwi_remove_EventSet()

int _papi_hwi_remove_EventSet ( EventSetInfo_t ESI)

Definition at line 1023 of file papi_internal.c.

1024 {
1026  int i;
1027 
1028  i = ESI->EventSetIndex;
1029 
1031 
1032  _papi_hwi_free_EventSet( ESI );
1033 
1034  /* do bookkeeping for PAPI_EVENTSET_MAP */
1035 
1036  map->dataSlotArray[i] = NULL;
1037  map->availSlots++;
1038  map->fullSlots--;
1039 
1041 
1042  return PAPI_OK;
1043 }
#define PAPI_OK
Definition: fpapi.h:105
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:56
EventSetInfo_t ** dataSlotArray
#define INTERNAL_LOCK
Definition: papi_internal.h:86
void _papi_hwi_free_EventSet(EventSetInfo_t *ESI)
int i
Definition: fileop.c:140
Here is the call graph for this function:

◆ _papi_hwi_set_papi_event_code()

void _papi_hwi_set_papi_event_code ( unsigned int  event_code,
int  update_flag 
)

Definition at line 119 of file papi_internal.c.

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

◆ _papi_hwi_set_papi_event_string()

void _papi_hwi_set_papi_event_string ( const char *  event_string)

Definition at line 90 of file papi_internal.c.

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

◆ _papi_hwi_shutdown_global_internal()

void _papi_hwi_shutdown_global_internal ( void  )

Definition at line 2000 of file papi_internal.c.

2001 {
2002  int i = 0;
2004 
2006 
2008 
2009  for( i = 0; i < num_native_events; i++){
2010  free(_papi_native_events[i].evt_name);
2011  }
2012 
2013  free(_papi_native_events);
2014  _papi_native_events = NULL; // In case a new library init is done.
2015  num_native_events=0; // ..
2016  num_native_chunks=0; // ..
2017 
2019 
2022  0x00, sizeof ( DynamicArray_t ) );
2023 
2025 
2028  }
2029  memset( &_papi_hwi_system_info, 0x0, sizeof ( _papi_hwi_system_info ) );
2030 
2031 }
static struct native_event_info * _papi_native_events
Definition: papi_internal.c:77
#define papi_free(a)
Definition: papi_memory.h:35
void _papi_hwi_free_papi_event_string()
PAPI_address_map_t * map
Definition: papi.h:715
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
static int num_native_chunks
Definition: papi_internal.c:79
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:56
EventSetInfo_t ** dataSlotArray
#define INTERNAL_LOCK
Definition: papi_internal.h:86
int _papi_hwi_cleanup_all_presets(void)
Definition: papi_preset.c:114
int i
Definition: fileop.c:140
static int num_native_events
Definition: papi_internal.c:78
Here is the call graph for this function:

◆ PAPIERROR()

void PAPIERROR ( char *  format,
  ... 
)

Definition at line 606 of file papi_internal.c.

607 {
608  va_list args;
609  if ( ( _papi_hwi_error_level != PAPI_QUIET ) ||
610  ( getenv( "PAPI_VERBOSE" ) ) ) {
611  va_start( args, format );
612  fprintf( stderr, "PAPI Error: " );
613  vfprintf( stderr, format, args );
614  fprintf( stderr, "\n" );
615  va_end( args );
616  }
617 }
char * getenv()
va_start(arg_list, fmt)
int _papi_hwi_error_level
Definition: papi_internal.c:54
va_end(arg_list)
#define PAPI_QUIET
Definition: fpapi.h:38
Here is the call graph for this function:

◆ PAPIWARN()

void PAPIWARN ( char *  format,
  ... 
)

Definition at line 620 of file papi_internal.c.

621 {
622  va_list args;
623  if ( ( _papi_hwi_error_level != PAPI_QUIET ) ||
624  ( getenv( "PAPI_VERBOSE" ) ) ) {
625  va_start( args, format );
626  fprintf( stderr, "PAPI Warning: " );
627  vfprintf( stderr, format, args );
628  fprintf( stderr, "\n" );
629  va_end( args );
630  }
631 }
char * getenv()
va_start(arg_list, fmt)
int _papi_hwi_error_level
Definition: papi_internal.c:54
va_end(arg_list)
#define PAPI_QUIET
Definition: fpapi.h:38
Here is the call graph for this function:

Variable Documentation

◆ _papi_errlist

char** _papi_errlist

Definition at line 81 of file papi_internal.c.

◆ _papi_hwi_debug_handler

PAPI_debug_handler_t _papi_hwi_debug_handler

Definition at line 55 of file papi_internal.c.

◆ _papi_hwi_errno

int _papi_hwi_errno

Definition at line 57 of file papi_internal.c.

◆ _papi_hwi_error_level

int _papi_hwi_error_level

Definition at line 451 of file papi_internal.h.

◆ _papi_hwi_num_errors

int _papi_hwi_num_errors

Definition at line 58 of file papi_internal.c.

◆ _papi_hwi_system_info

papi_mdi_t _papi_hwi_system_info

Definition at line 56 of file papi_internal.c.

◆ _papi_hwi_using_signal

int _papi_hwi_using_signal[PAPI_NSIG]

Definition at line 365 of file extras.c.

◆ _papi_num_compiled_components

int _papi_num_compiled_components

◆ _papi_os_info

PAPI_os_info_t _papi_os_info

Definition at line 1210 of file aix.c.

◆ init_level

int init_level

Definition at line 53 of file papi_internal.c.

◆ papi_num_components

int papi_num_components

Definition at line 1925 of file papi_internal.c.