PAPI 7.1.0.0
Loading...
Searching...
No Matches
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
 
struct  _papi_hwi_sysdetect_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
 

Enumerations

enum  { PAPI_SYSDETECT_QUERY__DEV_TYPE_ENUM , PAPI_SYSDETECT_QUERY__DEV_TYPE_ATTR , PAPI_SYSDETECT_QUERY__DEV_ATTR }
 

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 (int PE_OR_PEU)
 
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)
 
int _papi_hwi_enum_dev_type (int enum_modifier, void **handle)
 
int _papi_hwi_get_dev_type_attr (void *handle, PAPI_dev_type_attr_e attr, void *val)
 
int _papi_hwi_get_dev_attr (void *handle, int id, PAPI_dev_attr_e attr, void *val)
 

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
 
THREAD_LOCAL_STORAGE_KEYWORD int _papi_rate_events_running
 
THREAD_LOCAL_STORAGE_KEYWORD int _papi_hl_events_running
 
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 90 of file papi_internal.h.

◆ CPUS_LOCK

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

Definition at line 92 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 69 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 71 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 72 of file papi_internal.h.

◆ DERIVED_INFIX

#define DERIVED_INFIX   0x40

Process counters based on specified infix string

Definition at line 75 of file papi_internal.h.

◆ DERIVED_POSTFIX

#define DERIVED_POSTFIX   0x20

Process counters based on specified postfix string

Definition at line 74 of file papi_internal.h.

◆ DERIVED_PS

#define DERIVED_PS   0x2

Divide by the cycle counter and convert to seconds

Definition at line 70 of file papi_internal.h.

◆ DERIVED_SUB

#define DERIVED_SUB   0x10

Sub all counters from counter with operand_index

Definition at line 73 of file papi_internal.h.

◆ DONT_NEED_CONTEXT

#define DONT_NEED_CONTEXT   0

Definition at line 98 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 91 of file papi_internal.h.

◆ HIGHLEVEL_LOCK

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

Definition at line 88 of file papi_internal.h.

◆ hwd_context_t

#define hwd_context_t   void

Definition at line 106 of file papi_internal.h.

◆ hwd_control_state_t

#define hwd_control_state_t   void

Definition at line 107 of file papi_internal.h.

◆ hwd_reg_alloc_t

#define hwd_reg_alloc_t   void

Definition at line 108 of file papi_internal.h.

◆ hwd_register_t

#define hwd_register_t   void

Definition at line 109 of file papi_internal.h.

◆ hwd_siginfo_t

#define hwd_siginfo_t   void

Definition at line 110 of file papi_internal.h.

◆ hwd_ucontext_t

typedef struct sigcontext hwd_ucontext_t   void

Definition at line 111 of file papi_internal.h.

◆ inline_static

#define inline_static   inline static

Definition at line 123 of file papi_internal.h.

◆ INTERNAL_LOCK

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

Definition at line 85 of file papi_internal.h.

◆ LOWLEVEL_TLS

#define LOWLEVEL_TLS   PAPI_NUM_TLS+0

Definition at line 79 of file papi_internal.h.

◆ MEMORY_LOCK

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

Definition at line 89 of file papi_internal.h.

◆ MULTIPLEX_LOCK

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

Definition at line 86 of file papi_internal.h.

◆ NAMELIB_LOCK

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

Definition at line 93 of file papi_internal.h.

◆ NEED_CONTEXT

#define NEED_CONTEXT   1

Definition at line 97 of file papi_internal.h.

◆ NOT_DERIVED

#define NOT_DERIVED   0x0

Do nothing

Definition at line 68 of file papi_internal.h.

◆ NUM_INNER_TLS

#define NUM_INNER_TLS   1

Definition at line 80 of file papi_internal.h.

◆ PAPI_ERROR_CODE_str

#define PAPI_ERROR_CODE_str   "Error Code"

Definition at line 40 of file papi_internal.h.

◆ PAPI_EVENTS_IN_DERIVED_EVENT

#define PAPI_EVENTS_IN_DERIVED_EVENT   8

Definition at line 100 of file papi_internal.h.

◆ PAPI_INT_ITIMER

#define PAPI_INT_ITIMER   ITIMER_PROF

Definition at line 53 of file papi_internal.h.

◆ PAPI_INT_ITIMER_MS

#define PAPI_INT_ITIMER_MS   1

Definition at line 55 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 64 of file papi_internal.h.

◆ PAPI_INT_MPX_SIGNAL

#define PAPI_INT_MPX_SIGNAL   SIGPROF

Definition at line 51 of file papi_internal.h.

◆ PAPI_INT_SIGNAL

#define PAPI_INT_SIGNAL   SIGPROF

Definition at line 52 of file papi_internal.h.

◆ PAPI_MAX_TLS

#define PAPI_MAX_TLS   (NUM_INNER_TLS+PAPI_NUM_TLS)

Definition at line 81 of file papi_internal.h.

◆ PAPI_NSIG

#define PAPI_NSIG   128

Definition at line 59 of file papi_internal.h.

◆ PAPI_SHUTDOWN_str

#define PAPI_SHUTDOWN_str   "PAPI_shutdown: PAPI is not initialized"

Definition at line 41 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 42 of file papi_internal.h.

◆ THREADS_LOCK

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

Definition at line 87 of file papi_internal.h.

Typedef Documentation

◆ _papi_int_itimer_t

Definition at line 363 of file papi_internal.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
PAPI_SYSDETECT_QUERY__DEV_TYPE_ENUM 
PAPI_SYSDETECT_QUERY__DEV_TYPE_ATTR 
PAPI_SYSDETECT_QUERY__DEV_ATTR 

Definition at line 495 of file papi_internal.h.

495 {
499};
@ PAPI_SYSDETECT_QUERY__DEV_TYPE_ENUM
@ PAPI_SYSDETECT_QUERY__DEV_ATTR
@ PAPI_SYSDETECT_QUERY__DEV_TYPE_ATTR

Function Documentation

◆ _papi_hwi_add_event()

int _papi_hwi_add_event ( EventSetInfo_t ESI,
int  EventCode 
)

Definition at line 1337 of file papi_internal.c.

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

◆ _papi_hwi_assign_eventset()

int _papi_hwi_assign_eventset ( EventSetInfo_t ESI,
int  cidx 
)

Definition at line 762 of file papi_internal.c.

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

◆ _papi_hwi_cleanup_eventset()

int _papi_hwi_cleanup_eventset ( EventSetInfo_t ESI)

Definition at line 1758 of file papi_internal.c.

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

◆ _papi_hwi_component_index()

int _papi_hwi_component_index ( int  event_code)

Definition at line 522 of file papi_internal.c.

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

◆ _papi_hwi_convert_eventset_to_multiplex()

int _papi_hwi_convert_eventset_to_multiplex ( _papi_int_multiplex_t mpx)

Definition at line 1870 of file papi_internal.c.

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

◆ _papi_hwi_create_eventset()

int _papi_hwi_create_eventset ( int EventSet,
ThreadInfo_t handle 
)

Definition at line 939 of file papi_internal.c.

940{
941 EventSetInfo_t *ESI;
942 int retval;
943
944 /* Is the EventSet already in existence? */
945
946 if ( ( EventSet == NULL ) || ( handle == NULL ) )
947 return PAPI_EINVAL;
948
949 if ( *EventSet != PAPI_NULL )
950 return PAPI_EINVAL;
951
952 /* Well, then allocate a new one. Use n to keep track of a NEW EventSet */
953
954 retval = create_EventSet( &ESI );
955 if ( retval != PAPI_OK )
956 return retval;
957
958 ESI->CmpIdx = -1; /* when eventset is created, it is not decided yet which component it belongs to, until first event is added */
959 ESI->state = PAPI_STOPPED;
960
961 /* Add it to the global table */
962
963 retval = add_EventSet( ESI, handle );
964 if ( retval < PAPI_OK ) {
966 return retval ;
967 }
968
969 *EventSet = ESI->EventSetIndex;
970
971 INTDBG( "(%p,%p): new EventSet in slot %d\n",
972 ( void * ) EventSet, handle, *EventSet );
973
974 return retval;
975}
static papi_handle_t handle
Definition: Gamum.c:21
static int EventSet
Definition: init_fini.c:8
void _papi_hwi_free_EventSet(EventSetInfo_t *ESI)
static int add_EventSet(EventSetInfo_t *ESI, ThreadInfo_t *master)
static int create_EventSet(EventSetInfo_t **here)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _papi_hwi_derived_type()

int _papi_hwi_derived_type ( char *  tmp,
int code 
)

Definition at line 2247 of file papi_internal.c.

2248{
2249 int i = 0;
2250 while ( _papi_hwi_derived[i].name != NULL ) {
2251 if ( strcasecmp( tmp, _papi_hwi_derived[i].name ) == 0 ) {
2252 *code = _papi_hwi_derived[i].value;
2253 return PAPI_OK;
2254 }
2255 i++;
2256 }
2257 INTDBG( "Invalid derived string %s\n", tmp );
2258 return PAPI_EINVAL;
2259}
double tmp
static const hwi_describe_t _papi_hwi_derived[]
const char * name
Definition: rocs.c:225
Here is the caller graph for this function:

◆ _papi_hwi_dummy_handler()

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

Definition at line 2041 of file papi_internal.c.

2043{
2044 /* This function is not used and shouldn't be called. */
2045 ( void ) EventSet; /*unused */
2046 ( void ) address; /*unused */
2047 ( void ) overflow_vector; /*unused */
2048 ( void ) context; /*unused */
2049 return;
2050}
Here is the caller graph for this function:

◆ _papi_hwi_enum_dev_type()

int _papi_hwi_enum_dev_type ( int  enum_modifier,
void **  handle 
)

Definition at line 2758 of file papi_internal.c.

2759{
2762 args.query.enumerate.modifier = enum_modifier;
2763
2764 int cidx = get_component_index("sysdetect");
2765 assert(cidx < papi_num_components);
2766
2767 return _papi_hwd[cidx]->user(0, &args, handle);
2768}
static int get_component_index(const char *name)
union _papi_hwi_sysdetect_t::@183 query
struct _papi_hwi_sysdetect_t::@183::@184 enumerate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _papi_hwi_eventcode_to_native()

int _papi_hwi_eventcode_to_native ( int  event_code)

Definition at line 583 of file papi_internal.c.

583 {
584 INTDBG("ENTER: event_code: %#x\n", event_code);
585
586 int result;
587 int event_index;
588
589 event_index=event_code&PAPI_NATIVE_AND_MASK;
590 if ((event_index < 0) || (event_index>=num_native_events)) {
591 INTDBG("EXIT: PAPI_ENOEVNT\n");
592 return PAPI_ENOEVNT;
593 }
594
596
597 INTDBG("EXIT: result: %#x\n", result);
598 return result;
599
600}
volatile int result
Here is the caller graph for this function:

◆ _papi_hwi_free_EventSet()

void _papi_hwi_free_EventSet ( EventSetInfo_t ESI)

Definition at line 894 of file papi_internal.c.

895{
897
898#ifdef DEBUG
899 memset( ESI, 0x00, sizeof ( EventSetInfo_t ) );
900#endif
901 papi_free( ESI );
902
903}
int _papi_hwi_cleanup_eventset(EventSetInfo_t *ESI)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _papi_hwi_free_papi_event_string()

void _papi_hwi_free_papi_event_string ( )

Definition at line 110 of file papi_internal.c.

110 {
111 if (papi_event_string != NULL) {
112 free(papi_event_string);
113 papi_event_string = NULL;
114 }
115 return;
116}
char * papi_event_string
Definition: papi_internal.c:91
Here is the caller graph for this function:

◆ _papi_hwi_get_context()

hwd_context_t * _papi_hwi_get_context ( EventSetInfo_t ESI,
int is_dirty 
)

Definition at line 2702 of file papi_internal.c.

2703{
2704 INTDBG("Entry: ESI: %p, is_dirty: %p\n", ESI, is_dirty);
2705 int dirty_ctx;
2706 hwd_context_t *ctx=NULL;
2707
2708 /* assume for now the control state is clean (last updated by this ESI) */
2709 dirty_ctx = 0;
2710
2711 /* get a context pointer based on if we are counting for a thread or for a cpu */
2712 if (ESI->state & PAPI_CPU_ATTACHED) {
2713 /* use cpu context */
2714 ctx = ESI->CpuInfo->context[ESI->CmpIdx];
2715
2716 /* if the user wants to know if the control state was last set by the same event set, tell him */
2717 if (is_dirty != NULL) {
2718 if (ESI->CpuInfo->from_esi != ESI) {
2719 dirty_ctx = 1;
2720 }
2721 *is_dirty = dirty_ctx;
2722 }
2723 ESI->CpuInfo->from_esi = ESI;
2724
2725 } else {
2726
2727 /* use thread context */
2728 ctx = ESI->master->context[ESI->CmpIdx];
2729
2730 /* if the user wants to know if the control state was last set by the same event set, tell him */
2731 if (is_dirty != NULL) {
2732 if (ESI->master->from_esi != ESI) {
2733 dirty_ctx = 1;
2734 }
2735 *is_dirty = dirty_ctx;
2736 }
2737 ESI->master->from_esi = ESI;
2738
2739 }
2740 return( ctx );
2741}
#define PAPI_CPU_ATTACHED
Definition: f90papi.h:96
struct _ThreadInfo * master
Here is the caller graph for this function:

◆ _papi_hwi_get_dev_attr()

int _papi_hwi_get_dev_attr ( void *  handle,
int  id,
PAPI_dev_attr_e  attr,
void *  val 
)

Definition at line 2785 of file papi_internal.c.

2786{
2789 args.query.dev.handle = handle;
2790 args.query.dev.id = id;
2791 args.query.dev.attr = attr;
2792
2793 int cidx = get_component_index("sysdetect");
2794 assert(cidx < papi_num_components);
2795
2796 return _papi_hwd[cidx]->user(0, &args, value);
2797}
PAPI_dev_type_attr_e attr
struct _papi_hwi_sysdetect_t::@183::@186 dev
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _papi_hwi_get_dev_type_attr()

int _papi_hwi_get_dev_type_attr ( void *  handle,
PAPI_dev_type_attr_e  attr,
void *  val 
)

Definition at line 2771 of file papi_internal.c.

2772{
2775 args.query.dev_type.handle = handle;
2776 args.query.dev_type.attr = attr;
2777
2778 int cidx = get_component_index("sysdetect");
2779 assert(cidx < papi_num_components);
2780
2781 return _papi_hwd[cidx]->user(0, &args, value);
2782}
struct _papi_hwi_sysdetect_t::@183::@185 dev_type
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _papi_hwi_get_native_event_info()

int _papi_hwi_get_native_event_info ( unsigned int  EventCode,
PAPI_event_info_t info 
)

Definition at line 2583 of file papi_internal.c.

2585{
2586 INTDBG("ENTER: EventCode: %#x, info: %p\n", EventCode, info);
2587 int retval;
2588 int cidx;
2589 int nevt_code;
2590
2591 cidx = _papi_hwi_component_index( EventCode );
2592 if (cidx<0) return PAPI_ENOCMP;
2593
2594 if (_papi_hwd[cidx]->cmp_info.disabled &&
2595 _papi_hwd[cidx]->cmp_info.disabled != PAPI_EDELAY_INIT)
2596 return PAPI_ENOCMP;
2597
2598 if ( EventCode & PAPI_NATIVE_MASK ) {
2599 // save event code so components can get it with call to: _papi_hwi_get_papi_event_code()
2600 _papi_hwi_set_papi_event_code(EventCode, 0);
2601
2602 /* clear the event info */
2603 memset( info, 0, sizeof ( PAPI_event_info_t ) );
2604 info->event_code = ( unsigned int ) EventCode;
2605 info->component_index = (unsigned int) cidx;
2606 retval = _papi_hwd[cidx]->ntv_code_to_info(
2607 _papi_hwi_eventcode_to_native(EventCode), info);
2608
2609 /* If component error, it's missing the ntv_code_to_info vector */
2610 /* so we'll have to fake it. */
2611 if ( retval == PAPI_ECMP ) {
2612
2613
2614 INTDBG("missing NTV_CODE_TO_INFO, faking\n");
2615 /* Fill in the info structure */
2616
2617 if ((nevt_code = _papi_hwi_eventcode_to_native(EventCode)) < 0) {
2618 INTDBG("EXIT: nevt_code: %d\n", nevt_code);
2619 return nevt_code;
2620 }
2621 if ( (retval = _papi_hwd[cidx]->ntv_code_to_name(
2622 (unsigned int)nevt_code,
2623 info->symbol,
2624 sizeof(info->symbol)) ) == PAPI_OK ) {
2625
2626 } else {
2627 INTDBG("EXIT: retval: %d\n", retval);
2628 return retval;
2629 }
2630
2631 if ((nevt_code = _papi_hwi_eventcode_to_native(EventCode)) <0) {
2632 INTDBG("EXIT: nevt_code: %d\n", nevt_code);
2633 return nevt_code;
2634 }
2635 retval = _papi_hwd[cidx]->ntv_code_to_descr(
2636 (unsigned int)nevt_code,
2637 info->long_descr,
2638 sizeof ( info->long_descr));
2639 if (retval!=PAPI_OK) {
2640 INTDBG("Failed ntv_code_to_descr()\n");
2641 }
2642
2643 }
2645 _papi_hwd[cidx]->cmp_info.short_name,
2646 info->symbol,
2647 info->symbol,
2648 sizeof(info->symbol) );
2649
2650 INTDBG("EXIT: retval: %d\n", retval);
2651 return retval;
2652 }
2653
2654 INTDBG("EXIT: PAPI_ENOEVNT\n");
2655 return PAPI_ENOEVNT;
2656}
Prefixes a component's name to each of its events.
#define PAPI_NATIVE_MASK
int _papi_hwi_eventcode_to_native(int event_code)
void _papi_hwi_set_papi_event_code(unsigned int event_code, int update_flag)
int component_index
Definition: papi.h:968
unsigned int event_code
Definition: papi.h:958
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:960
char long_descr[PAPI_HUGE_STR_LEN]
Definition: papi.h:963
Here is the call graph for this function:
Here is the caller 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
160
161 INTDBG("EXIT: result: %d\n", result);
162 return result;
163}
Here is the caller graph for this function:

◆ _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_hwi_my_thread->tls_papi_event_code);
139}
unsigned int tls_papi_event_code
Definition: threads.h:36
THREAD_LOCAL_STORAGE_KEYWORD ThreadInfo_t * _papi_hwi_my_thread
Definition: threads.c:37
Here is the caller graph for this function:

◆ _papi_hwi_get_papi_event_string()

char * _papi_hwi_get_papi_event_string ( void  )

Definition at line 105 of file papi_internal.c.

105 {
106 INTDBG("papi_event_string: %s\n", papi_event_string);
107 return papi_event_string;
108}
Here is the caller graph for this function:

◆ _papi_hwi_get_preset_event_info()

int _papi_hwi_get_preset_event_info ( int  EventCode,
PAPI_event_info_t info 
)

Definition at line 2291 of file papi_internal.c.

2292{
2293 INTDBG("ENTER: EventCode: %#x, info: %p\n", EventCode, info);
2294
2295 int i = EventCode & PAPI_PRESET_AND_MASK;
2296 unsigned int j;
2297
2298 if ( _papi_hwi_presets[i].symbol ) { /* if the event is in the preset table */
2299 // since we are setting the whole structure to zero the strncpy calls below will
2300 // be leaving NULL terminates strings as long as they copy 1 less byte than the
2301 // buffer size of the field.
2302 memset( info, 0, sizeof ( PAPI_event_info_t ) );
2303
2304 info->event_code = ( unsigned int ) EventCode;
2305 strncpy( info->symbol, _papi_hwi_presets[i].symbol,
2306 sizeof(info->symbol)-1);
2307
2308 if ( _papi_hwi_presets[i].short_descr != NULL )
2309 strncpy( info->short_descr, _papi_hwi_presets[i].short_descr,
2310 sizeof ( info->short_descr )-1 );
2311
2312 if ( _papi_hwi_presets[i].long_descr != NULL )
2313 strncpy( info->long_descr, _papi_hwi_presets[i].long_descr,
2314 sizeof ( info->long_descr )-1 );
2315
2317 info->count = _papi_hwi_presets[i].count;
2318
2320 info->derived, sizeof ( info->derived )-1 );
2321
2322 if ( _papi_hwi_presets[i].postfix != NULL )
2323 strncpy( info->postfix, _papi_hwi_presets[i].postfix,
2324 sizeof ( info->postfix )-1 );
2325
2326 for(j=0;j < info->count; j++) {
2327 info->code[j]=_papi_hwi_presets[i].code[j];
2328 strncpy(info->name[j], _papi_hwi_presets[i].name[j],
2329 sizeof(info->name[j])-1);
2330 }
2331
2332 if ( _papi_hwi_presets[i].note != NULL ) {
2333 strncpy( info->note, _papi_hwi_presets[i].note,
2334 sizeof ( info->note )-1 );
2335 }
2336
2337 return PAPI_OK;
2338 } else {
2339 return PAPI_ENOEVNT;
2340 }
2341}
static int _papi_hwi_derived_string(int type, char *derived, int len)
char name[PAPI_MAX_INFO_TERMS][PAPI_2MAX_STR_LEN]
Definition: papi.h:1003
unsigned int event_type
Definition: papi.h:986
unsigned int count
Definition: papi.h:981
char postfix[PAPI_2MAX_STR_LEN]
Definition: papi.h:992
char note[PAPI_HUGE_STR_LEN]
Definition: papi.h:1007
char short_descr[PAPI_MIN_STR_LEN]
Definition: papi.h:961
char derived[PAPI_MIN_STR_LEN]
Definition: papi.h:989
unsigned int code[PAPI_MAX_INFO_TERMS]
Definition: papi.h:997
char * symbol
Definition: papi_preset.h:24
unsigned int count
Definition: papi_preset.h:29
unsigned int event_type
Definition: papi_preset.h:30
char * short_descr
Definition: papi_preset.h:25
char * name[PAPI_MAX_INFO_TERMS]
Definition: papi_preset.h:33
char * long_descr
Definition: papi_preset.h:26
Here is the call graph for this function:
Here is the caller 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 2351 of file papi_internal.c.

2352{
2353 INTDBG("ENTER: EventCode: %#x, info: %p\n", EventCode, info);
2354
2355 unsigned int i = EventCode & PAPI_UE_AND_MASK;
2356 unsigned int j;
2357
2358 // if event code not in valid range, return error
2359 if (i >= PAPI_MAX_USER_EVENTS) {
2360 INTDBG("EXIT: Invalid event index: %d, max value is: %d\n", i, PAPI_MAX_USER_EVENTS - 1);
2361 return( PAPI_ENOEVNT );
2362 }
2363
2364 if ( user_defined_events[i].symbol == NULL) { /* if the event is in the preset table */
2365 INTDBG("EXIT: Event symbol for this event is NULL\n");
2366 return PAPI_ENOEVNT;
2367 }
2368
2369 /* set whole structure to 0 */
2370 memset( info, 0, sizeof ( PAPI_event_info_t ) );
2371
2372 info->event_code = ( unsigned int ) EventCode;
2373 strncpy( info->symbol, user_defined_events[i].symbol,
2374 sizeof(info->symbol)-1);
2375
2376 if ( user_defined_events[i].short_descr != NULL )
2378 sizeof(info->short_descr)-1);
2379
2380 if ( user_defined_events[i].long_descr != NULL )
2381 strncpy( info->long_descr, user_defined_events[i].long_descr,
2382 sizeof(info->long_descr)-1);
2383
2384// info->event_type = user_defined_events[i].event_type;
2386
2388 info->derived, sizeof(info->derived)-1);
2389
2390 if ( user_defined_events[i].postfix != NULL )
2391 strncpy( info->postfix, user_defined_events[i].postfix,
2392 sizeof(info->postfix)-1);
2393
2394 for(j=0;j < info->count; j++) {
2395 info->code[j]=user_defined_events[i].code[j];
2396 INTDBG("info->code[%d]: %#x\n", j, info->code[j]);
2397 strncpy(info->name[j], user_defined_events[i].name[j], sizeof(info->name[j])-1);
2398 }
2399
2400 if ( user_defined_events[i].note != NULL ) {
2401 strncpy( info->note, user_defined_events[i].note, sizeof(info->note)-1);
2402 }
2403
2404 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);
2405 return PAPI_OK;
2406}
#define PAPI_MAX_USER_EVENTS
Here is the call graph for this function:
Here is the caller 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 /* 26 PAPI_EDELAY_INIT */ _papi_hwi_add_error("Delayed initialization component");
511 /* 27 PAPI_EMULPASS */ _papi_hwi_add_error("Event exists, but cannot be counted due to multiple passes required by hardware");
512}
Here is the caller graph for this function:

◆ _papi_hwi_init_global()

int _papi_hwi_init_global ( int  PE_OR_PEU)

Definition at line 1938 of file papi_internal.c.

1939{
1940 int retval, is_pe_peu, i = 0;
1941
1943 if ( retval != PAPI_OK ) {
1944 return retval;
1945 }
1946
1947 while ( _papi_hwd[i] ) {
1948 is_pe_peu = 0;
1949 if (strcmp(_papi_hwd[i]->cmp_info.name, "perf_event") == 0) is_pe_peu=1;
1950 if (strcmp(_papi_hwd[i]->cmp_info.name, "perf_event_uncore") == 0) is_pe_peu=1;
1952 if ( retval != PAPI_OK ) {
1953 return retval;
1954 }
1955
1956 /* We can be disabled by user before init */
1957 if (!_papi_hwd[i]->cmp_info.disabled && (PE_OR_PEU == is_pe_peu)) {
1958 retval = _papi_hwd[i]->init_component( i );
1959
1960 /* Do some sanity checking */
1961 if (retval==PAPI_OK) {
1962 if (_papi_hwd[i]->cmp_info.num_cntrs >
1963 _papi_hwd[i]->cmp_info.num_mpx_cntrs) {
1964 fprintf(stderr,"Warning! num_cntrs %d is more than num_mpx_cntrs %d for component %s\n",
1965 _papi_hwd[i]->cmp_info.num_cntrs,
1966 _papi_hwd[i]->cmp_info.num_mpx_cntrs,
1967 _papi_hwd[i]->cmp_info.name);
1968 }
1969
1970 }
1971 }
1972
1973 i++;
1974 }
1975 return PAPI_OK;
1976}
papi_os_vector_t _papi_os_vector
Definition: aix.c:1288
FILE * stderr
int _papi_hwi_innoculate_vector(papi_vector_t *v)
Definition: papi_vector.c:109
int _papi_hwi_innoculate_os_vector(papi_os_vector_t *v)
Definition: papi_vector.c:200
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _papi_hwi_init_global_internal()

int _papi_hwi_init_global_internal ( void  )

Definition at line 1982 of file papi_internal.c.

1983{
1984
1985 int retval;
1986
1987 memset(&_papi_hwi_system_info,0x0,sizeof( _papi_hwi_system_info ));
1988
1989 memset( _papi_hwi_using_signal,0x0,sizeof( _papi_hwi_using_signal ));
1990
1991 /* Global struct to maintain EventSet mapping */
1993 if ( retval != PAPI_OK ) {
1994 return retval;
1995 }
1996
1997 _papi_hwi_system_info.pid = 0; /* Process identifier */
1998
1999 /* PAPI_hw_info_t struct */
2000 memset(&(_papi_hwi_system_info.hw_info),0x0,sizeof(PAPI_hw_info_t));
2001 return PAPI_OK;
2002}
int _papi_hwi_using_signal[PAPI_NSIG]
Definition: extras.c:365
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:56
static int allocate_eventset_map(DynamicArray_t *map)
Hardware info structure.
Definition: papi.h:774
DynamicArray_t global_eventset_map
PAPI_hw_info_t hw_info
Here is the call graph for this function:
Here is the caller 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}
PAPI_os_info_t _papi_os_info
Definition: aix.c:1210
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
#define PAPI_INT_MPX_SIGNAL
Definition: papi_internal.h:51
#define PAPI_INT_MPX_DEF_US
Definition: papi_internal.h:64
#define PAPI_INT_ITIMER
Definition: papi_internal.h:53
char version[PAPI_MAX_STR_LEN]
char name[PAPI_MAX_STR_LEN]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _papi_hwi_invalid_cmp()

int _papi_hwi_invalid_cmp ( int  cidx)

Definition at line 515 of file papi_internal.c.

516{
517 return ( cidx < 0 || cidx >= papi_num_components );
518}
Here is the caller graph for this function:

◆ _papi_hwi_is_sw_multiplex()

int _papi_hwi_is_sw_multiplex ( EventSetInfo_t ESI)

Definition at line 2678 of file papi_internal.c.

2679{
2680 /* Are we multiplexing at all */
2681 if ( ( ESI->state & PAPI_MULTIPLEXING ) == 0 ) {
2682 return 0;
2683 }
2684
2685 /* Does the component support kernel multiplexing */
2686 if ( _papi_hwd[ESI->CmpIdx]->cmp_info.kernel_multiplex ) {
2687 /* Have we forced software multiplexing */
2688 if ( ESI->multiplex.flags == PAPI_MULTIPLEX_FORCE_SW ) {
2689 return 1;
2690 }
2691 /* Nope, using hardware multiplexing */
2692 return 0;
2693 }
2694
2695 /* We are multiplexing but the component does not support hardware */
2696
2697 return 1;
2698
2699}
Here is the caller graph for this function:

◆ _papi_hwi_lookup_EventCodeIndex()

int _papi_hwi_lookup_EventCodeIndex ( const EventSetInfo_t ESI,
unsigned int  EventCode 
)

Definition at line 1007 of file papi_internal.c.

1009{
1010 int i;
1011 int limit = EventInfoArrayLength( ESI );
1012
1013 for ( i = 0; i < limit; i++ ) {
1014 if ( ESI->EventInfoArray[i].event_code == EventCode ) {
1015 return i;
1016 }
1017 }
1018
1019 return PAPI_EINVAL;
1020}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _papi_hwi_lookup_EventSet()

EventSetInfo_t * _papi_hwi_lookup_EventSet ( int  eventset)

Definition at line 2659 of file papi_internal.c.

2660{
2662 EventSetInfo_t *set;
2663
2664 if ( ( eventset < 0 ) || ( eventset > map->totalSlots ) )
2665 return ( NULL );
2666
2667 set = map->dataSlotArray[eventset];
2668#ifdef DEBUG
2669 if ( ( ISLEVEL( DEBUG_THREADS ) ) && ( _papi_hwi_thread_id_fn ) &&
2670 ( set->master->tid != _papi_hwi_thread_id_fn( ) ) )
2671 return ( NULL );
2672#endif
2673
2674 return ( set );
2675}
unsigned long int(* _papi_hwi_thread_id_fn)(void)
Definition: threads.c:42
#define ISLEVEL(a)
Definition: papi_debug.h:55
#define DEBUG_THREADS
Definition: papi_debug.h:30
EventSetInfo_t ** dataSlotArray
Here is the caller graph for this function:

◆ _papi_hwi_map_events_to_native()

void _papi_hwi_map_events_to_native ( EventSetInfo_t ESI)

Definition at line 1087 of file papi_internal.c.

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

2547{
2548 INTDBG("ENTER: EventCode: %#x, hwi_name: %p, len: %d\n", EventCode, hwi_name, len);
2549 int cidx;
2550 int retval;
2551 int nevt_code;
2552
2553 cidx = _papi_hwi_component_index( EventCode );
2554 if (cidx<0) return PAPI_ENOEVNT;
2555
2556 if ( EventCode & PAPI_NATIVE_MASK ) {
2557 // save event code so components can get it with call to: _papi_hwi_get_papi_event_code()
2558 _papi_hwi_set_papi_event_code(EventCode, 0);
2559
2560 if ((nevt_code = _papi_hwi_eventcode_to_native(EventCode)) < 0) {
2561 INTDBG("EXIT: nevt_code: %d\n", nevt_code);
2562 return nevt_code;
2563 }
2564 if ( (retval = _papi_hwd[cidx]->ntv_code_to_name(
2565 (unsigned int)nevt_code,
2566 hwi_name, len) ) == PAPI_OK ) {
2567 retval = _papi_hwi_prefix_component_name( _papi_hwd[cidx]->cmp_info.short_name,
2568 hwi_name, hwi_name, len);
2569 INTDBG("EXIT: retval: %d\n", retval);
2570 return retval;
2571 }
2572 INTDBG("EXIT: retval: %d\n", retval);
2573 return (retval);
2574 }
2575 INTDBG("EXIT: PAPI_ENOEVNT\n");
2576 return PAPI_ENOEVNT;
2577}
Here is the call graph for this function:
Here is the caller 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 2443 of file papi_internal.c.

2444{
2445 INTDBG("ENTER: in: %s, out: %p\n", in, out);
2446
2447 int retval = PAPI_ENOEVNT;
2448 char name[PAPI_HUGE_STR_LEN]; /* make sure it's big enough */
2449
2450 unsigned int i;
2451 int cidx;
2452 char *full_event_name;
2453
2454 if (in == NULL) {
2455 INTDBG("EXIT: PAPI_EINVAL\n");
2456 return PAPI_EINVAL;
2457 }
2458
2459 full_event_name = strdup(in);
2460
2462
2463 // look in each component
2464 for(cidx=0; cidx < papi_num_components; cidx++) {
2465
2466 if (_papi_hwd[cidx]->cmp_info.disabled &&
2467 _papi_hwd[cidx]->cmp_info.disabled != PAPI_EDELAY_INIT)
2468 continue;
2469
2470 // if this component does not support the pmu
2471 // which defines this event, no need to call it
2472 if (is_supported_by_component(cidx, full_event_name) == 0) {
2473 continue;
2474 }
2475
2476 INTDBG("cidx: %d, name: %s, event: %s\n",
2477 cidx, _papi_hwd[cidx]->cmp_info.name, in);
2478
2479 // show that we do not have an event code yet
2480 // (the component may create one and update this info)
2481 // this also clears any values left over from a previous call
2483
2484
2485 // if component has a ntv_name_to_code function, use it to get event code
2486 if (_papi_hwd[cidx]->ntv_name_to_code != NULL) {
2487 // try and get this events event code
2488 retval = _papi_hwd[cidx]->ntv_name_to_code( in, ( unsigned * ) out );
2489 if (retval==PAPI_OK) {
2490 *out = _papi_hwi_native_to_eventcode(cidx, *out, -1, in);
2491 free (full_event_name);
2492 INTDBG("EXIT: PAPI_OK event: %s code: %#x\n", in, *out);
2493 return PAPI_OK;
2494 }
2495 } else {
2496 // force the code through the work around
2497 retval = PAPI_ECMP;
2498 }
2499
2500 /* If not implemented, work around */
2501 if ( retval==PAPI_ECMP) {
2502 i = 0;
2503 retval = _papi_hwd[cidx]->ntv_enum_events( &i, PAPI_ENUM_FIRST );
2504 if (retval != PAPI_OK) {
2505 free (full_event_name);
2506 INTDBG("EXIT: retval: %d\n", retval);
2507 return retval;
2508 }
2509
2510// _papi_hwi_lock( INTERNAL_LOCK );
2511
2512 do {
2513 // save event code so components can get it with call to: _papi_hwi_get_papi_event_code()
2515 retval = _papi_hwd[cidx]->ntv_code_to_name(i, name, sizeof(name));
2516 /* printf("%#x\nname =|%s|\ninput=|%s|\n", i, name, in); */
2517 if ( retval == PAPI_OK && in != NULL) {
2518 if ( strcasecmp( name, in ) == 0 ) {
2520 free (full_event_name);
2521 INTDBG("EXIT: PAPI_OK, event: %s, code: %#x\n", in, *out);
2522 return PAPI_OK;
2523 }
2525 } else {
2526 *out = 0;
2528 break;
2529 }
2530 } while ( ( _papi_hwd[cidx]->ntv_enum_events( &i, PAPI_ENUM_EVENTS ) == PAPI_OK ) );
2531
2532// _papi_hwi_unlock( INTERNAL_LOCK );
2533 }
2534 }
2535
2536 free (full_event_name);
2537 INTDBG("EXIT: retval: %d\n", retval);
2538
2539 return retval;
2540}
Strip off cmp_name::: from an event name.
#define PAPI_ENUM_EVENTS
Definition: f90papi.h:224
#define PAPI_ENUM_FIRST
Definition: f90papi.h:85
#define PAPI_HUGE_STR_LEN
Definition: f90papi.h:120
int _papi_hwi_native_to_eventcode(int cidx, int event_code, int ntv_idx, const char *event_name)
static int is_supported_by_component(int cidx, char *event_name)
Here is the call graph for this function:
Here is the caller 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 560 of file papi_internal.c.

560 {
561 INTDBG("Entry: cidx: %d, event: %#x, ntv_idx: %d, event_name: %s\n", cidx, event_code, ntv_idx, event_name);
562
563 int result;
564
567 INTDBG("EXIT: papi_event_code: %#x set by the component\n", result);
568 return result;
569 }
570
572 if (result==PAPI_ENOEVNT) {
573 // Need to create one
574 result=_papi_hwi_add_native_event(cidx, event_code, ntv_idx, event_name);
575 }
576
577 INTDBG("EXIT: result: %#x\n", result);
578 return result;
579}
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
static int _papi_hwi_find_native_event(int cidx, int event, const char *event_name)
unsigned int _papi_hwi_get_papi_event_code()
static int _papi_hwi_add_native_event(int cidx, int ntv_event, int ntv_idx, const char *event_name)
int tls_papi_event_code_changed
Definition: threads.h:37
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _papi_hwi_query_native_event()

int _papi_hwi_query_native_event ( unsigned int  EventCode)

Definition at line 2412 of file papi_internal.c.

2413{
2414 INTDBG("ENTER: EventCode: %#x\n", EventCode);
2415 char name[PAPI_HUGE_STR_LEN]; /* probably overkill, */
2416 /* but should always be big enough */
2417 int cidx;
2418 int nevt_code;
2419
2420 cidx = _papi_hwi_component_index( EventCode );
2421 if (cidx<0) {
2422 INTDBG("EXIT: PAPI_ENOCMP\n");
2423 return PAPI_ENOCMP;
2424 }
2425
2426 // save event code so components can get it with call to: _papi_hwi_get_papi_event_code()
2427 _papi_hwi_set_papi_event_code(EventCode, 0);
2428
2429 if ((nevt_code = _papi_hwi_eventcode_to_native(EventCode)) < 0) {
2430 INTDBG("EXIT: nevt_code: %d\n", nevt_code);
2431 return nevt_code;
2432 }
2433 int ret = _papi_hwd[cidx]->ntv_code_to_name( (unsigned int)nevt_code, name, sizeof(name));
2434
2435 INTDBG("EXIT: ret: %d\n", ret);
2436 return (ret);
2437}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _papi_hwi_read()

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

Definition at line 1705 of file papi_internal.c.

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

◆ _papi_hwi_remove_event()

int _papi_hwi_remove_event ( EventSetInfo_t ESI,
int  EventCode 
)

Definition at line 1622 of file papi_internal.c.

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

◆ _papi_hwi_remove_EventSet()

int _papi_hwi_remove_EventSet ( EventSetInfo_t ESI)

Definition at line 1025 of file papi_internal.c.

1026{
1028 int i;
1029
1030 i = ESI->EventSetIndex;
1031
1033
1035
1036 /* do bookkeeping for PAPI_EVENTSET_MAP */
1037
1038 map->dataSlotArray[i] = NULL;
1039 map->availSlots++;
1040 map->fullSlots--;
1041
1043
1044 return PAPI_OK;
1045}
#define INTERNAL_LOCK
Definition: papi_internal.h:85
inline_static int _papi_hwi_lock(int lck)
Definition: threads.h:69
inline_static int _papi_hwi_unlock(int lck)
Definition: threads.h:83
Here is the call graph for this function:
Here is the caller 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_hwi_my_thread->tls_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) {
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
131 // save the event code passed in
133 return;
134}
Here is the caller graph for this function:

◆ _papi_hwi_set_papi_event_string()

void _papi_hwi_set_papi_event_string ( const char *  event_string)

Definition at line 93 of file papi_internal.c.

93 {
94 INTDBG("event_string: %s\n", event_string);
95 if (papi_event_string != NULL) {
96 free (papi_event_string);
97 papi_event_string = NULL;
98 }
99 if (event_string != NULL) {
100 papi_event_string = strdup(event_string);
101 }
102 return;
103}
Here is the caller graph for this function:

◆ _papi_hwi_shutdown_global_internal()

void _papi_hwi_shutdown_global_internal ( void  )

Definition at line 2005 of file papi_internal.c.

2006{
2007 int i = 0;
2009
2011
2013
2014 for( i = 0; i < num_native_events; i++){
2016 }
2017
2018 free(_papi_native_events);
2019 _papi_native_events = NULL; // In case a new library init is done.
2020 num_native_events=0; // ..
2021 num_native_chunks=0; // ..
2022
2024
2027 0x00, sizeof ( DynamicArray_t ) );
2028
2030
2033 }
2034 memset( &_papi_hwi_system_info, 0x0, sizeof ( _papi_hwi_system_info ) );
2035
2036}
char * evt_name(evstock *stock, int index)
Definition: eventstock.c:193
static void _papi_hwi_cleanup_errors()
static int num_native_chunks
Definition: papi_internal.c:82
void _papi_hwi_free_papi_event_string()
int _papi_hwi_cleanup_all_presets(void)
Definition: papi_preset.c:114
PAPI_address_map_t * map
Definition: papi.h:703
PAPI_shlib_info_t shlib_info
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PAPIERROR()

void PAPIERROR ( char *  format,
  ... 
)

Definition at line 608 of file papi_internal.c.

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

◆ PAPIWARN()

void PAPIWARN ( char *  format,
  ... 
)

Definition at line 622 of file papi_internal.c.

623{
624 va_list args;
625 if ( ( _papi_hwi_error_level != PAPI_QUIET ) ||
626 ( getenv( "PAPI_VERBOSE" ) ) ) {
627 va_start( args, format );
628 fprintf( stderr, "PAPI Warning: " );
629 vfprintf( stderr, format, args );
630 fprintf( stderr, "\n" );
631 va_end( args );
632 }
633}
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ _papi_errlist

char** _papi_errlist
extern

Definition at line 84 of file papi_internal.c.

◆ _papi_hl_events_running

THREAD_LOCAL_STORAGE_KEYWORD int _papi_hl_events_running
extern

Definition at line 63 of file papi_internal.c.

◆ _papi_hwi_debug_handler

PAPI_debug_handler_t _papi_hwi_debug_handler
extern

Definition at line 55 of file papi_internal.c.

◆ _papi_hwi_errno

int _papi_hwi_errno
extern

Definition at line 57 of file papi_internal.c.

◆ _papi_hwi_error_level

int _papi_hwi_error_level
extern

Definition at line 453 of file papi_internal.h.

◆ _papi_hwi_num_errors

int _papi_hwi_num_errors
extern

Definition at line 58 of file papi_internal.c.

◆ _papi_hwi_system_info

papi_mdi_t _papi_hwi_system_info
extern

Definition at line 56 of file papi_internal.c.

◆ _papi_hwi_using_signal

int _papi_hwi_using_signal[PAPI_NSIG]
extern

Definition at line 365 of file extras.c.

◆ _papi_num_compiled_components

int _papi_num_compiled_components
extern

◆ _papi_os_info

PAPI_os_info_t _papi_os_info
extern

Definition at line 1210 of file aix.c.

◆ _papi_rate_events_running

THREAD_LOCAL_STORAGE_KEYWORD int _papi_rate_events_running
extern

Definition at line 62 of file papi_internal.c.

◆ init_level

int init_level
extern

Definition at line 53 of file papi_internal.c.

◆ papi_num_components

int papi_num_components
extern

Definition at line 1928 of file papi_internal.c.