papi_internal.c File Reference

Include dependency graph for papi_internal.c:

Go to the source code of this file.

Data Structures

struct  native_event_info

Defines

#define NATIVE_EVENT_CHUNKSIZE   1024

Functions

static int default_debug_handler (int errorCode)
static long long handle_derived (EventInfo_t *evi, long long *from)
void _papi_hwi_set_papi_event_string (const char *event_string)
char * _papi_hwi_get_papi_event_string ()
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 ()
int _papi_hwi_get_ntv_idx (unsigned int papi_evt_code)
static int is_supported_by_component (int cidx, char *event_name)
int _papi_hwi_prefix_component_name (char *component_name, char *event_name, char *out, int out_len)
char * _papi_hwi_strip_component_prefix (char *event_name)
static int _papi_hwi_find_native_event (int cidx, int event, const char *event_name)
static int _papi_hwi_add_native_event (int cidx, int ntv_event, int ntv_idx, const char *event_name)
static int _papi_hwi_add_error (char *error)
static void _papi_hwi_cleanup_errors ()
static int _papi_hwi_lookup_error (char *error)
int _papi_hwi_publish_error (char *error)
void _papi_hwi_init_errors (void)
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)
void PAPIERROR (char *format,...)
static int allocate_eventset_map (DynamicArray_t *map)
static int expand_dynamic_array (DynamicArray_t *DA)
static int EventInfoArrayLength (const EventSetInfo_t *ESI)
static int create_EventSet (EventSetInfo_t **here)
int _papi_hwi_assign_eventset (EventSetInfo_t *ESI, int cidx)
void _papi_hwi_free_EventSet (EventSetInfo_t *ESI)
static int add_EventSet (EventSetInfo_t *ESI, ThreadInfo_t *master)
int _papi_hwi_create_eventset (int *EventSet, ThreadInfo_t *handle)
static int get_free_EventCodeIndex (const EventSetInfo_t *ESI, unsigned int EventCode)
int _papi_hwi_lookup_EventCodeIndex (const EventSetInfo_t *ESI, unsigned int EventCode)
int _papi_hwi_remove_EventSet (EventSetInfo_t *ESI)
static int event_already_in_eventset (EventSetInfo_t *ESI, int papi_event)
void _papi_hwi_map_events_to_native (EventSetInfo_t *ESI)
static int add_native_fail_clean (EventSetInfo_t *ESI, int nevt)
static int update_overflow (EventSetInfo_t *ESI)
static int add_native_events (EventSetInfo_t *ESI, unsigned int *nevt, int size, EventInfo_t *out)
int _papi_hwi_add_event (EventSetInfo_t *ESI, int EventCode)
static int remove_native_events (EventSetInfo_t *ESI, int *nevt, int size)
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)
void _papi_hwi_shutdown_global_internal (void)
void _papi_hwi_dummy_handler (int EventSet, void *address, long long overflow_vector, void *context)
static long long handle_derived_add (int *position, long long *from)
static long long handle_derived_subtract (int *position, long long *from)
static long long units_per_second (long long units, long long cycles)
static long long handle_derived_ps (int *position, long long *from)
static long long handle_derived_add_ps (int *position, long long *from)
static long long _papi_hwi_postfix_calc (EventInfo_t *evi, long long *hw_counter)
int _papi_hwi_derived_type (char *tmp, int *code)
static int _papi_hwi_derived_string (int type, char *derived, int len)
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_query_native_event (unsigned int EventCode)
int _papi_hwi_native_name_to_code (char *in, int *out)
int _papi_hwi_native_code_to_name (unsigned int EventCode, char *hwi_name, int len)
int _papi_hwi_get_native_event_info (unsigned int EventCode, PAPI_event_info_t *info)
EventSetInfo_t_papi_hwi_lookup_EventSet (int eventset)
int _papi_hwi_is_sw_multiplex (EventSetInfo_t *ESI)
hwd_context_t_papi_hwi_get_context (EventSetInfo_t *ESI, int *is_dirty)

Variables

int init_level = PAPI_NOT_INITED
int _papi_hwi_error_level = PAPI_QUIET
PAPI_debug_handler_t _papi_hwi_debug_handler = default_debug_handler
papi_mdi_t _papi_hwi_system_info
int _papi_hwi_errno = PAPI_OK
int _papi_hwi_num_errors = 0
hwi_presets_t user_defined_events [PAPI_MAX_USER_EVENTS]
int user_defined_events_count = 0
static struct native_event_info_papi_native_events = NULL
static int num_native_events = 0
static int num_native_chunks = 0
char ** _papi_errlist = NULL
static int num_error_chunks = 0
char * papi_event_string = NULL
static unsigned int papi_event_code = -1
static int papi_event_code_changed = -1
int papi_num_components = ( sizeof ( _papi_hwd ) / sizeof ( *_papi_hwd ) ) - 1
static const hwi_describe_t _papi_hwi_derived []

Define Documentation

#define NATIVE_EVENT_CHUNKSIZE   1024

Definition at line 66 of file papi_internal.c.


Function Documentation

static int _papi_hwi_add_error ( char *  error  )  [static]

Definition at line 393 of file papi_internal.c.

00394 {
00395     INTDBG("Adding a new Error message |%s|\n", error);
00396     _papi_hwi_lock(INTERNAL_LOCK);
00397 
00398     if (_papi_hwi_num_errors >= num_error_chunks*NATIVE_EVENT_CHUNKSIZE) {
00399         num_error_chunks++;
00400         _papi_errlist=realloc(_papi_errlist, 
00401                         num_error_chunks*NATIVE_EVENT_CHUNKSIZE*sizeof(char *));
00402         if (_papi_errlist==NULL) {
00403             _papi_hwi_num_errors = -2;
00404             goto bail;
00405         }
00406 
00407     }
00408 
00409     _papi_errlist[_papi_hwi_num_errors] = strdup( error );
00410     if ( _papi_errlist[_papi_hwi_num_errors] == NULL )
00411         _papi_hwi_num_errors = -2;
00412 
00413 bail:
00414     _papi_hwi_unlock(INTERNAL_LOCK);
00415 
00416     return _papi_hwi_num_errors++;
00417 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_hwi_add_event ( EventSetInfo_t ESI,
int  EventCode 
)

Definition at line 1316 of file papi_internal.c.

01317 {
01318     INTDBG("ENTER: ESI: %p (%d), EventCode: %#x\n", ESI, ESI->EventSetIndex, EventCode);
01319 
01320     int i, j, thisindex, remap, retval = PAPI_OK;
01321     int cidx;
01322 
01323     cidx=_papi_hwi_component_index( EventCode );
01324     if (cidx<0) return PAPI_ENOCMP;
01325 
01326     /* Sanity check that the new EventCode is from the same component */
01327     /* as previous events.                                            */
01328     
01329     if ( ESI->CmpIdx < 0 ) {
01330        if ( ( retval = _papi_hwi_assign_eventset( ESI, cidx)) != PAPI_OK ) {
01331           INTDBG("EXIT: Error assigning eventset to component index %d\n", cidx);
01332           return retval;
01333        }
01334     } else {
01335        if ( ESI->CmpIdx != cidx ) {
01336             INTDBG("EXIT: Event is not valid for component index %d\n", cidx);
01337             return PAPI_EINVAL;
01338        }
01339     }
01340 
01341     /* Make sure the event is not present and get the next free slot. */
01342     thisindex = get_free_EventCodeIndex( ESI, ( unsigned int ) EventCode );
01343     if ( thisindex < PAPI_OK ) {
01344        return thisindex;
01345     }
01346 
01347     INTDBG("Adding event to slot %d of EventSet %d\n",thisindex,ESI->EventSetIndex);
01348 
01349     /* If it is a software MPX EventSet, add it to the multiplex data structure */
01350     /* and this thread's multiplex list                                         */
01351 
01352     if ( !_papi_hwi_is_sw_multiplex( ESI ) ) {
01353 
01354        /* Handle preset case */
01355        if ( IS_PRESET(EventCode) ) {
01356       int count;
01357       int preset_index = EventCode & ( int ) PAPI_PRESET_AND_MASK;
01358 
01359       /* Check if it's within the valid range */
01360       if ( ( preset_index < 0 ) || ( preset_index >= PAPI_MAX_PRESET_EVENTS ) ) {
01361          return PAPI_EINVAL;
01362       }
01363 
01364       /* count the number of native events in this preset */
01365       count = ( int ) _papi_hwi_presets[preset_index].count;
01366 
01367       /* Check if event exists */
01368       if ( !count ) {
01369          return PAPI_ENOEVNT;
01370       }
01371             
01372       /* check if the native events have been used as overflow events */
01373       /* this is not allowed                                          */
01374       if ( ESI->state & PAPI_OVERFLOWING ) {
01375          for( i = 0; i < count; i++ ) {
01376         for( j = 0; j < ESI->overflow.event_counter; j++ ) {
01377           if ( ESI->overflow.EventCode[j] ==(int)
01378             ( _papi_hwi_presets[preset_index].code[i] ) ) {
01379               return PAPI_ECNFLCT;
01380            }
01381         }
01382          }
01383       }
01384 
01385       /* Try to add the preset. */
01386 
01387       remap = add_native_events( ESI,
01388                      _papi_hwi_presets[preset_index].code,
01389                      count, &ESI->EventInfoArray[thisindex] );
01390       if ( remap < 0 ) {
01391          return remap;
01392       }
01393           else {
01394          /* Fill in the EventCode (machine independent) information */
01395          ESI->EventInfoArray[thisindex].event_code = 
01396                                   ( unsigned int ) EventCode;
01397          ESI->EventInfoArray[thisindex].derived =
01398                   _papi_hwi_presets[preset_index].derived_int;
01399          ESI->EventInfoArray[thisindex].ops =
01400                   _papi_hwi_presets[preset_index].postfix;
01401              ESI->NumberOfEvents++;
01402          _papi_hwi_map_events_to_native( ESI );
01403          
01404       }
01405        }
01406        /* Handle adding Native events */
01407        else if ( IS_NATIVE(EventCode) ) {
01408 
01409       /* Check if native event exists */
01410       if ( _papi_hwi_query_native_event( ( unsigned int ) EventCode ) != PAPI_OK ) {
01411          return PAPI_ENOEVNT;
01412       }
01413             
01414       /* check if the native events have been used as overflow events */
01415       /* This is not allowed                                          */
01416       if ( ESI->state & PAPI_OVERFLOWING ) {
01417          for( j = 0; j < ESI->overflow.event_counter; j++ ) {
01418             if ( EventCode == ESI->overflow.EventCode[j] ) {
01419            return PAPI_ECNFLCT;
01420         }
01421          }
01422       }
01423 
01424       /* Try to add the native event. */
01425 
01426       remap = add_native_events( ESI, (unsigned int *)&EventCode, 1,
01427                      &ESI->EventInfoArray[thisindex] );
01428 
01429       if ( remap < 0 ) {
01430          return remap;
01431       } else {
01432 
01433          /* Fill in the EventCode (machine independent) information */
01434          ESI->EventInfoArray[thisindex].event_code = 
01435                                        ( unsigned int ) EventCode;
01436              ESI->NumberOfEvents++;
01437          _papi_hwi_map_events_to_native( ESI );
01438          
01439       }
01440        } else if ( IS_USER_DEFINED( EventCode ) ) {
01441          int count;
01442          int index = EventCode & PAPI_UE_AND_MASK;
01443 
01444          if ( index < 0 || index >= user_defined_events_count )
01445            return ( PAPI_EINVAL );
01446 
01447          count = ( int ) user_defined_events[index].count;
01448 
01449          for ( i = 0; i < count; i++ ) {
01450            for ( j = 0; j < ESI->overflow.event_counter; j++ ) {
01451              if ( ESI->overflow.EventCode[j] ==
01452                  (int)(user_defined_events[index].code[i]) ) {
01453                return ( PAPI_EBUG );
01454              }
01455            }
01456          }
01457 
01458          remap = add_native_events( ESI,
01459              user_defined_events[index].code,
01460              count, &ESI->EventInfoArray[thisindex] );
01461 
01462          if ( remap < 0 ) {
01463            return remap;
01464          } else {
01465            ESI->EventInfoArray[thisindex].event_code = (unsigned int) EventCode;
01466            ESI->EventInfoArray[thisindex].derived = user_defined_events[index].derived_int;
01467            ESI->EventInfoArray[thisindex].ops = user_defined_events[index].postfix;
01468            ESI->NumberOfEvents++;
01469            _papi_hwi_map_events_to_native( ESI );
01470          }
01471        } else {
01472 
01473       /* not Native, Preset, or User events */
01474 
01475       return PAPI_EBUG;
01476        }
01477     }
01478     else {
01479         
01480        /* Multiplexing is special. See multiplex.c */
01481 
01482        retval = mpx_add_event( &ESI->multiplex.mpx_evset, EventCode,
01483                    ESI->domain.domain, 
01484                    ESI->granularity.granularity );
01485 
01486 
01487        if ( retval < PAPI_OK ) {
01488       return retval;
01489        }
01490 
01491        /* Relevant (???) */
01492        ESI->EventInfoArray[thisindex].event_code = ( unsigned int ) EventCode;  
01493        ESI->EventInfoArray[thisindex].derived = NOT_DERIVED;
01494 
01495        ESI->NumberOfEvents++;
01496 
01497        /* event is in the EventInfoArray but not mapped to the NativeEvents */
01498        /* this causes issues if you try to set overflow on the event.       */
01499        /* in theory this wouldn't matter anyway.                            */
01500     }
01501 
01502     /* reinstate the overflows if any */
01503     retval=update_overflow( ESI );
01504 
01505     return retval;
01506 }

Here is the call graph for this function:

Here is the caller graph for this function:

static int _papi_hwi_add_native_event ( int  cidx,
int  ntv_event,
int  ntv_idx,
const char *  event_name 
) [static]

Definition at line 348 of file papi_internal.c.

00348                                                                                          {
00349     INTDBG("ENTER: cidx: %d, ntv_event: %#x, ntv_idx: %d, event_name: %s\n", cidx, ntv_event, ntv_idx, event_name);
00350 
00351   int new_native_event;
00352   
00353   _papi_hwi_lock( INTERNAL_LOCK );
00354 
00355   if (num_native_events>=num_native_chunks*NATIVE_EVENT_CHUNKSIZE) {
00356      num_native_chunks++;
00357      _papi_native_events=realloc(_papi_native_events,
00358                  num_native_chunks*NATIVE_EVENT_CHUNKSIZE*
00359                  sizeof(struct native_event_info));
00360      if (_papi_native_events==NULL) {
00361         new_native_event=PAPI_ENOMEM;
00362     goto native_alloc_early_out;
00363      }
00364   }
00365 
00366   _papi_native_events[num_native_events].cidx=cidx;
00367   _papi_native_events[num_native_events].component_event=ntv_event;
00368   _papi_native_events[num_native_events].ntv_idx=ntv_idx;
00369   if (event_name != NULL) {
00370       _papi_native_events[num_native_events].evt_name=strdup(event_name);
00371   } else {
00372       _papi_native_events[num_native_events].evt_name=NULL;
00373   }
00374   new_native_event=num_native_events|PAPI_NATIVE_MASK;
00375 
00376   num_native_events++;
00377 
00378 native_alloc_early_out:
00379 
00380   _papi_hwi_unlock( INTERNAL_LOCK );
00381 
00382   INTDBG("EXIT: new_native_event: %#x, num_native_events: %d\n", new_native_event, num_native_events);
00383   return new_native_event;
00384 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_hwi_assign_eventset ( EventSetInfo_t ESI,
int  cidx 
)

Definition at line 741 of file papi_internal.c.

00742 {
00743    INTDBG("ENTER: ESI: %p (%d), cidx: %d\n", ESI, ESI->EventSetIndex, cidx);
00744    int retval;
00745    size_t max_counters;
00746    char *ptr;
00747    unsigned int i, j;
00748 
00749    /* If component doesn't exist... */
00750    if (_papi_hwi_invalid_cmp(cidx)) return PAPI_ECMP;
00751 
00752    /* Assigned at create time */
00753    ESI->domain.domain = _papi_hwd[cidx]->cmp_info.default_domain;
00754    ESI->granularity.granularity =
00755                              _papi_hwd[cidx]->cmp_info.default_granularity;
00756    ESI->CmpIdx = cidx;
00757 
00758    /* ??? */
00759    max_counters = ( size_t ) _papi_hwd[cidx]->cmp_info.num_mpx_cntrs;
00760 
00761    ESI->ctl_state = (hwd_control_state_t *) papi_calloc( 1, (size_t) 
00762                    _papi_hwd[cidx]->size.control_state );
00763    ESI->sw_stop = (long long *) papi_calloc( ( size_t ) max_counters,
00764                               sizeof ( long long ) );
00765    ESI->hw_start = ( long long * ) papi_calloc( ( size_t ) max_counters,
00766                                                       sizeof ( long long ) );
00767    ESI->EventInfoArray = ( EventInfo_t * ) papi_calloc( (size_t) max_counters,
00768                                                       sizeof ( EventInfo_t ) );
00769 
00770    /* allocate room for the native events and for the component-private */
00771    /* register structures */
00772    /* ugh is there a cleaner way to allocate this?  vmw */
00773    ESI->NativeInfoArray = ( NativeInfo_t * ) 
00774      papi_calloc( ( size_t ) max_counters, sizeof ( NativeInfo_t ));
00775 
00776    ESI->NativeBits = papi_calloc(( size_t ) max_counters,
00777                                  ( size_t ) _papi_hwd[cidx]->size.reg_value );
00778 
00779    /* NOTE: the next two malloc allocate blocks of memory that are later */
00780    /* parcelled into overflow and profile arrays                         */
00781    ESI->overflow.deadline = ( long long * )
00782         papi_malloc( ( sizeof ( long long ) +
00783                        sizeof ( int ) * 3 ) * ( size_t ) max_counters );
00784 
00785    ESI->profile.prof = ( PAPI_sprofil_t ** )
00786         papi_malloc( ( sizeof ( PAPI_sprofil_t * ) * ( size_t ) max_counters +
00787                        ( size_t ) max_counters * sizeof ( int ) * 4 ) );
00788 
00789    /* If any of these allocations failed, free things up and fail */
00790 
00791    if ( ( ESI->ctl_state == NULL ) ||
00792     ( ESI->sw_stop == NULL )   || 
00793         ( ESI->hw_start == NULL )  ||
00794     ( ESI->NativeInfoArray == NULL ) || 
00795     ( ESI->NativeBits == NULL ) || 
00796         ( ESI->EventInfoArray == NULL )  ||
00797     ( ESI->profile.prof == NULL ) || 
00798         ( ESI->overflow.deadline == NULL ) ) {
00799 
00800       if ( ESI->sw_stop ) papi_free( ESI->sw_stop );
00801       if ( ESI->hw_start ) papi_free( ESI->hw_start );
00802       if ( ESI->EventInfoArray ) papi_free( ESI->EventInfoArray );
00803       if ( ESI->NativeInfoArray ) papi_free( ESI->NativeInfoArray );
00804       if ( ESI->NativeBits ) papi_free( ESI->NativeBits );
00805       if ( ESI->ctl_state ) papi_free( ESI->ctl_state );
00806       if ( ESI->overflow.deadline ) papi_free( ESI->overflow.deadline );
00807       if ( ESI->profile.prof ) papi_free( ESI->profile.prof );
00808       papi_free( ESI );
00809       return PAPI_ENOMEM;
00810    }
00811 
00812 
00813    /* Carve up the overflow block into separate arrays */
00814    ptr = ( char * ) ESI->overflow.deadline;
00815    ptr += sizeof ( long long ) * max_counters;
00816    ESI->overflow.threshold = ( int * ) ptr;
00817    ptr += sizeof ( int ) * max_counters;
00818    ESI->overflow.EventIndex = ( int * ) ptr;
00819    ptr += sizeof ( int ) * max_counters;
00820    ESI->overflow.EventCode = ( int * ) ptr;
00821 
00822    /* Carve up the profile block into separate arrays */
00823    ptr = ( char * ) ESI->profile.prof +
00824         ( sizeof ( PAPI_sprofil_t * ) * max_counters );
00825    ESI->profile.count = ( int * ) ptr;
00826    ptr += sizeof ( int ) * max_counters;
00827    ESI->profile.threshold = ( int * ) ptr;
00828    ptr += sizeof ( int ) * max_counters;
00829    ESI->profile.EventIndex = ( int * ) ptr;
00830    ptr += sizeof ( int ) * max_counters;
00831    ESI->profile.EventCode = ( int * ) ptr;
00832 
00833    /* initialize_EventInfoArray */
00834 
00835    for ( i = 0; i < max_counters; i++ ) {
00836        ESI->EventInfoArray[i].event_code=( unsigned int ) PAPI_NULL;
00837        ESI->EventInfoArray[i].ops = NULL;
00838        ESI->EventInfoArray[i].derived=NOT_DERIVED;
00839        for ( j = 0; j < PAPI_EVENTS_IN_DERIVED_EVENT; j++ ) {
00840        ESI->EventInfoArray[i].pos[j] = PAPI_NULL;
00841        }
00842    }
00843 
00844    /* initialize_NativeInfoArray */
00845    for( i = 0; i < max_counters; i++ ) {
00846       ESI->NativeInfoArray[i].ni_event = -1;
00847       ESI->NativeInfoArray[i].ni_position = -1;
00848       ESI->NativeInfoArray[i].ni_papi_code = -1;
00849       ESI->NativeInfoArray[i].ni_owners = 0;
00850       ESI->NativeInfoArray[i].ni_bits = ((unsigned char*)ESI->NativeBits) + 
00851                                           (i*_papi_hwd[cidx]->size.reg_value);
00852    }
00853 
00854    ESI->NativeCount = 0;
00855 
00856    ESI->state = PAPI_STOPPED;
00857 
00858    /* these used to be init_config */
00859    retval = _papi_hwd[cidx]->init_control_state( ESI->ctl_state );  
00860    retval |= _papi_hwd[cidx]->set_domain( ESI->ctl_state, ESI->domain.domain);
00861 
00862    return retval;
00863 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void _papi_hwi_cleanup_errors (  )  [static]

Definition at line 420 of file papi_internal.c.

00421 {
00422     int i; 
00423     
00424     if ( _papi_errlist == NULL || 
00425             _papi_hwi_num_errors == 0 )
00426         return; 
00427 
00428 
00429     _papi_hwi_lock( INTERNAL_LOCK );
00430     for (i=0; i < _papi_hwi_num_errors; i++ ) {
00431         free( _papi_errlist[i]);
00432         _papi_errlist[i] = NULL;
00433     } 
00434 
00435     free( _papi_errlist );
00436     _papi_errlist = NULL;
00437     _papi_hwi_num_errors = 0;
00438     num_error_chunks=0;
00439 
00440     _papi_hwi_unlock( INTERNAL_LOCK );
00441 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_hwi_cleanup_eventset ( EventSetInfo_t ESI  ) 

Definition at line 1730 of file papi_internal.c.

01731 {
01732    int i, j, num_cntrs, retval;
01733    hwd_context_t *context;
01734    int EventCode;
01735    NativeInfo_t *native;
01736    if ( !_papi_hwi_invalid_cmp( ESI->CmpIdx ) ) {
01737    num_cntrs = _papi_hwd[ESI->CmpIdx]->cmp_info.num_mpx_cntrs;
01738 
01739    for(i=0;i<num_cntrs;i++) {
01740 
01741       EventCode=ESI->EventInfoArray[i].event_code;     
01742 
01743       /* skip if event not there */
01744       if ( EventCode == PAPI_NULL ) continue;
01745 
01746       /* If it is a MPX EventSet, remove it from the multiplex */
01747       /* data structure and this thread's multiplex list */
01748 
01749       if ( _papi_hwi_is_sw_multiplex( ESI ) ) {
01750      retval = mpx_remove_event( &ESI->multiplex.mpx_evset, EventCode );
01751      if ( retval < PAPI_OK )
01752         return retval;
01753       } else {
01754 
01755       native = ESI->NativeInfoArray;
01756 
01757       /* clear out ESI->NativeInfoArray */
01758       /* do we really need to do this, seeing as we free() it later? */
01759 
01760       for( j = 0; j < ESI->NativeCount; j++ ) {
01761          native[j].ni_event = -1;
01762          native[j].ni_position = -1;
01763          native[j].ni_owners = 0;
01764          /* native[j].ni_bits?? */
01765       }
01766       }
01767 
01768       /* do we really need to do this, seeing as we free() it later? */
01769       ESI->EventInfoArray[i].event_code= ( unsigned int ) PAPI_NULL;
01770       for( j = 0; j < PAPI_EVENTS_IN_DERIVED_EVENT; j++ ) {
01771       ESI->EventInfoArray[i].pos[j] = PAPI_NULL;
01772       }
01773       ESI->EventInfoArray[i].ops = NULL;
01774       ESI->EventInfoArray[i].derived = NOT_DERIVED;
01775    }
01776 
01777    context = _papi_hwi_get_context( ESI, NULL );
01778    /* calling with count of 0 equals a close? */
01779    retval = _papi_hwd[ESI->CmpIdx]->update_control_state( ESI->ctl_state,
01780                    NULL, 0, context);
01781    if (retval!=PAPI_OK) {
01782      return retval;
01783    }
01784    }
01785 
01786    ESI->CmpIdx = -1;
01787    ESI->NumberOfEvents = 0;
01788    ESI->NativeCount = 0;
01789 
01790    if ( ( ESI->state & PAPI_MULTIPLEXING ) && ESI->multiplex.mpx_evset )
01791            papi_free( ESI->multiplex.mpx_evset );
01792 
01793    if ( ( ESI->state & PAPI_CPU_ATTACH ) && ESI->CpuInfo )
01794            _papi_hwi_shutdown_cpu( ESI->CpuInfo );
01795 
01796    if ( ESI->ctl_state )
01797       papi_free( ESI->ctl_state );
01798 
01799    if ( ESI->sw_stop )
01800       papi_free( ESI->sw_stop );
01801 
01802    if ( ESI->hw_start )
01803       papi_free( ESI->hw_start );
01804     
01805    if ( ESI->EventInfoArray )
01806       papi_free( ESI->EventInfoArray );
01807     
01808    if ( ESI->NativeInfoArray ) 
01809       papi_free( ESI->NativeInfoArray );
01810 
01811    if ( ESI->NativeBits ) 
01812       papi_free( ESI->NativeBits );
01813     
01814    if ( ESI->overflow.deadline )
01815       papi_free( ESI->overflow.deadline );
01816     
01817    if ( ESI->profile.prof )
01818       papi_free( ESI->profile.prof );
01819 
01820    ESI->ctl_state = NULL;
01821    ESI->sw_stop = NULL;
01822    ESI->hw_start = NULL;
01823    ESI->EventInfoArray = NULL;
01824    ESI->NativeInfoArray = NULL;
01825    ESI->NativeBits = NULL;
01826 
01827    memset( &ESI->domain, 0x0, sizeof(EventSetDomainInfo_t) );
01828    memset( &ESI->granularity, 0x0, sizeof(EventSetGranularityInfo_t) );
01829    memset( &ESI->overflow, 0x0, sizeof(EventSetOverflowInfo_t) );
01830    memset( &ESI->multiplex, 0x0, sizeof(EventSetMultiplexInfo_t) );
01831    memset( &ESI->attach, 0x0, sizeof(EventSetAttachInfo_t) );
01832    memset( &ESI->cpu, 0x0, sizeof(EventSetCpuInfo_t) );
01833    memset( &ESI->profile, 0x0, sizeof(EventSetProfileInfo_t) );
01834    memset( &ESI->inherit, 0x0, sizeof(EventSetInheritInfo_t) );
01835 
01836    ESI->CpuInfo = NULL;
01837 
01838    return PAPI_OK;
01839 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_hwi_component_index ( int  event_code  ) 

Definition at line 515 of file papi_internal.c.

00515                                             {
00516     INTDBG("ENTER: event_code: %#x\n", event_code);
00517 
00518   int cidx;
00519   int event_index;
00520 
00521   /* currently assume presets are for component 0 only */
00522   if (IS_PRESET(event_code)) {
00523      INTDBG("EXIT: Event %#x is a PRESET, assigning component %d\n", event_code,0);
00524      return 0;
00525   }
00526 
00527   /* user defined events are treated like preset events (component 0 only) */
00528   if (IS_USER_DEFINED(event_code)) {
00529      INTDBG("EXIT: Event %#x is USER DEFINED, assigning component %d\n", event_code,0);
00530      return 0;
00531   }
00532 
00533   event_index=event_code&PAPI_NATIVE_AND_MASK;
00534 
00535   if ( (event_index < 0) || (event_index>=num_native_events)) {
00536      INTDBG("EXIT: Event index %#x is out of range, num_native_events: %d\n", event_index, num_native_events);
00537      return PAPI_ENOEVNT;
00538   }
00539 
00540   cidx=_papi_native_events[event_index].cidx;
00541 
00542   if ((cidx<0) || (cidx >= papi_num_components)) {
00543       INTDBG("EXIT: Component index %#x is out of range, papi_num_components: %d\n", cidx, papi_num_components);
00544       return PAPI_ENOCMP;
00545   }
00546 
00547   INTDBG("EXIT: Found cidx: %d event_index: %d, event_code: %#x\n", cidx, event_index, event_code);
00548   return cidx;
00549 }

Here is the caller graph for this function:

int _papi_hwi_convert_eventset_to_multiplex ( _papi_int_multiplex_t mpx  ) 

Definition at line 1842 of file papi_internal.c.

01843 {
01844     int retval, i, j = 0, *mpxlist = NULL;
01845     EventSetInfo_t *ESI = mpx->ESI;
01846     int flags = mpx->flags;
01847 
01848     /* If there are any events in the EventSet, 
01849        convert them to multiplex events */
01850 
01851     if ( ESI->NumberOfEvents ) {
01852 
01853         mpxlist =
01854             ( int * ) papi_malloc( sizeof ( int ) *
01855                                    ( size_t ) ESI->NumberOfEvents );
01856         if ( mpxlist == NULL )
01857             return ( PAPI_ENOMEM );
01858 
01859         /* Build the args to MPX_add_events(). */
01860 
01861         /* Remember the EventInfoArray can be sparse
01862            and the data can be non-contiguous */
01863 
01864         for ( i = 0; i < EventInfoArrayLength( ESI ); i++ )
01865             if ( ESI->EventInfoArray[i].event_code !=
01866                  ( unsigned int ) PAPI_NULL )
01867                 mpxlist[j++] = ( int ) ESI->EventInfoArray[i].event_code;
01868 
01869         /* Resize the EventInfo_t array */
01870 
01871         if ( ( _papi_hwd[ESI->CmpIdx]->cmp_info.kernel_multiplex == 0 ) ||
01872              ( ( _papi_hwd[ESI->CmpIdx]->cmp_info.kernel_multiplex ) &&
01873                ( flags & PAPI_MULTIPLEX_FORCE_SW ) ) ) {
01874             retval =
01875                 MPX_add_events( &ESI->multiplex.mpx_evset, mpxlist, j,
01876                                 ESI->domain.domain,
01877                                 ESI->granularity.granularity );
01878             if ( retval != PAPI_OK ) {
01879                 papi_free( mpxlist );
01880                 return ( retval );
01881             }
01882         }
01883 
01884         papi_free( mpxlist );
01885     }
01886 
01887     /* Update the state before initialization! */
01888 
01889     ESI->state |= PAPI_MULTIPLEXING;
01890     if ( _papi_hwd[ESI->CmpIdx]->cmp_info.kernel_multiplex &&
01891          ( flags & PAPI_MULTIPLEX_FORCE_SW ) )
01892         ESI->multiplex.flags = PAPI_MULTIPLEX_FORCE_SW;
01893     ESI->multiplex.ns = ( int ) mpx->ns;
01894 
01895     return ( PAPI_OK );
01896 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_hwi_create_eventset ( int *  EventSet,
ThreadInfo_t handle 
)

Definition at line 918 of file papi_internal.c.

00919 {
00920     EventSetInfo_t *ESI;
00921     int retval;
00922 
00923     /* Is the EventSet already in existence? */
00924 
00925     if ( ( EventSet == NULL ) || ( handle == NULL ) )
00926         return PAPI_EINVAL;
00927 
00928     if ( *EventSet != PAPI_NULL )
00929         return PAPI_EINVAL;
00930 
00931     /* Well, then allocate a new one. Use n to keep track of a NEW EventSet */
00932 
00933     retval = create_EventSet( &ESI );
00934     if ( retval != PAPI_OK )
00935         return retval;
00936 
00937     ESI->CmpIdx = -1;        /* when eventset is created, it is not decided yet which component it belongs to, until first event is added */
00938     ESI->state = PAPI_STOPPED;
00939 
00940     /* Add it to the global table */
00941 
00942     retval = add_EventSet( ESI, handle );
00943     if ( retval < PAPI_OK ) {
00944         _papi_hwi_free_EventSet( ESI );
00945         return retval ;
00946     }
00947 
00948     *EventSet = ESI->EventSetIndex;
00949 
00950     INTDBG( "(%p,%p): new EventSet in slot %d\n",
00951             ( void * ) EventSet, handle, *EventSet );
00952 
00953     return retval;
00954 }

Here is the call graph for this function:

Here is the caller graph for this function:

static int _papi_hwi_derived_string ( int  type,
char *  derived,
int  len 
) [static]

Definition at line 2226 of file papi_internal.c.

02227 {
02228   int j;
02229 
02230   for ( j = 0; _papi_hwi_derived[j].value != -1; j++ ) {
02231     if ( _papi_hwi_derived[j].value == type ) {
02232       strncpy( derived, _papi_hwi_derived[j].name, ( size_t )\
02233            len );
02234       return PAPI_OK;
02235     }
02236   }
02237   INTDBG( "Invalid derived type %d\n", type );
02238   return PAPI_EINVAL;
02239 }

Here is the caller graph for this function:

int _papi_hwi_derived_type ( char *  tmp,
int *  code 
)

Definition at line 2205 of file papi_internal.c.

02206 {
02207   int i = 0;
02208   while ( _papi_hwi_derived[i].name != NULL ) {
02209     if ( strcasecmp( tmp, _papi_hwi_derived[i].name ) == 0 ) {
02210       *code = _papi_hwi_derived[i].value;
02211       return PAPI_OK;
02212     }
02213     i++;
02214   }
02215   INTDBG( "Invalid derived string %s\n", tmp );
02216   return PAPI_EINVAL;
02217 }

Here is the caller graph for this function:

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

Definition at line 1999 of file papi_internal.c.

02001 {
02002     /* This function is not used and shouldn't be called. */
02003     ( void ) EventSet;       /*unused */
02004     ( void ) address;        /*unused */
02005     ( void ) overflow_vector;   /*unused */
02006     ( void ) context;        /*unused */
02007     return;
02008 }

Here is the caller graph for this function:

int _papi_hwi_eventcode_to_native ( int  event_code  ) 

Definition at line 576 of file papi_internal.c.

00576                                               {
00577     INTDBG("ENTER: event_code: %#x\n", event_code);
00578 
00579   int result;
00580   int event_index;
00581 
00582   event_index=event_code&PAPI_NATIVE_AND_MASK;
00583  if ((event_index < 0)  ||  (event_index>=num_native_events)) {
00584     INTDBG("EXIT: PAPI_ENOEVNT\n");
00585     return PAPI_ENOEVNT;
00586   }
00587 
00588   result=_papi_native_events[event_index].component_event;
00589   
00590   INTDBG("EXIT: result: %#x\n", result);
00591   return result;
00592 
00593 }

Here is the caller graph for this function:

static int _papi_hwi_find_native_event ( int  cidx,
int  event,
const char *  event_name 
) [static]

Definition at line 314 of file papi_internal.c.

00314                                                                          {
00315   INTDBG("ENTER: cidx: %x, event: %#x, event_name: %s\n", cidx, event, event_name);
00316 
00317   int i;
00318 
00319   // if no event name passed in, it can not be found
00320   if (event_name == NULL) {
00321         INTDBG("EXIT: PAPI_ENOEVNT\n");
00322         return PAPI_ENOEVNT;
00323   }
00324 
00325   for(i=0;i<num_native_events;i++) {
00326     // if we have have not set up this event name yet, look at next
00327     if (_papi_native_events[i].evt_name == NULL) {
00328         continue;
00329     }
00330 
00331     // is this entry for the correct component and event code
00332     if ((_papi_native_events[i].cidx==cidx) &&
00333     (_papi_native_events[i].component_event==event)) {
00334         // if this event name matches what we want, return its papi event code
00335         if (strcmp(event_name, _papi_native_events[i].evt_name) == 0) {
00336             INTDBG("EXIT: event: %#x, component_event: %#x, ntv_idx: %d, event_name: %s\n",
00337                 i|PAPI_NATIVE_MASK, _papi_native_events[i].component_event, _papi_native_events[i].ntv_idx, _papi_native_events[i].evt_name);
00338             return i|PAPI_NATIVE_MASK;
00339         }
00340     }
00341   }
00342 
00343     INTDBG("EXIT: PAPI_ENOEVNT\n");
00344     return PAPI_ENOEVNT;
00345 }

Here is the caller graph for this function:

void _papi_hwi_free_EventSet ( EventSetInfo_t ESI  ) 

Definition at line 873 of file papi_internal.c.

00874 {
00875     _papi_hwi_cleanup_eventset( ESI );
00876 
00877 #ifdef DEBUG
00878     memset( ESI, 0x00, sizeof ( EventSetInfo_t ) );
00879 #endif
00880     papi_free( ESI );
00881 
00882 }

Here is the call graph for this function:

Here is the caller graph for this function:

void _papi_hwi_free_papi_event_string (  ) 

Definition at line 107 of file papi_internal.c.

00107                                    {
00108     if (papi_event_string != NULL) {
00109         free(papi_event_string);
00110         papi_event_string = NULL;
00111     }
00112     return;
00113 }

Here is the caller graph for this function:

hwd_context_t* _papi_hwi_get_context ( EventSetInfo_t ESI,
int *  is_dirty 
)

Definition at line 2649 of file papi_internal.c.

02650 {
02651     INTDBG("Entry: ESI: %p, is_dirty: %p\n", ESI, is_dirty);
02652     int dirty_ctx;
02653     hwd_context_t *ctx=NULL;
02654 
02655     /* assume for now the control state is clean (last updated by this ESI) */
02656     dirty_ctx = 0;
02657     
02658     /* get a context pointer based on if we are counting for a thread or for a cpu */
02659     if (ESI->state & PAPI_CPU_ATTACHED) {
02660         /* use cpu context */
02661         ctx = ESI->CpuInfo->context[ESI->CmpIdx];
02662 
02663         /* if the user wants to know if the control state was last set by the same event set, tell him */
02664         if (is_dirty != NULL) {
02665             if (ESI->CpuInfo->from_esi != ESI) {
02666                 dirty_ctx = 1;
02667             }
02668             *is_dirty = dirty_ctx;
02669         }
02670         ESI->CpuInfo->from_esi = ESI;
02671        
02672     } else {
02673 
02674         /* use thread context */
02675         ctx = ESI->master->context[ESI->CmpIdx];
02676 
02677         /* if the user wants to know if the control state was last set by the same event set, tell him */
02678         if (is_dirty != NULL) {
02679             if (ESI->master->from_esi != ESI) {
02680                 dirty_ctx = 1;
02681             }
02682             *is_dirty = dirty_ctx;
02683         }
02684         ESI->master->from_esi = ESI;
02685 
02686     }
02687     return( ctx );
02688 }

Here is the caller graph for this function:

int _papi_hwi_get_native_event_info ( unsigned int  EventCode,
PAPI_event_info_t info 
)

Definition at line 2532 of file papi_internal.c.

02534 {
02535       INTDBG("ENTER: EventCode: %#x, info: %p\n", EventCode, info);
02536     int retval;
02537     int cidx;
02538     int nevt_code;
02539 
02540     cidx = _papi_hwi_component_index( EventCode );
02541     if (cidx<0) return PAPI_ENOCMP;
02542 
02543     if (_papi_hwd[cidx]->cmp_info.disabled) return PAPI_ENOCMP;
02544 
02545     if ( EventCode & PAPI_NATIVE_MASK ) {
02546         // save event code so components can get it with call to: _papi_hwi_get_papi_event_code()
02547         _papi_hwi_set_papi_event_code(EventCode, 0);
02548 
02549        /* clear the event info */
02550        memset( info, 0, sizeof ( PAPI_event_info_t ) );
02551        info->event_code = ( unsigned int ) EventCode;
02552        info->component_index = (unsigned int) cidx;
02553        retval = _papi_hwd[cidx]->ntv_code_to_info( 
02554                   _papi_hwi_eventcode_to_native(EventCode), info);
02555 
02556        /* If component error, it's missing the ntv_code_to_info vector */
02557        /* so we'll have to fake it.                                    */
02558        if ( retval == PAPI_ECMP ) {
02559 
02560 
02561       INTDBG("missing NTV_CODE_TO_INFO, faking\n");
02562       /* Fill in the info structure */
02563 
02564         if ((nevt_code = _papi_hwi_eventcode_to_native(EventCode)) < 0) {
02565             INTDBG("EXIT: nevt_code: %d\n", nevt_code);
02566             return nevt_code;
02567         }
02568       if ( (retval = _papi_hwd[cidx]->ntv_code_to_name( 
02569                     (unsigned int)nevt_code,
02570                     info->symbol,
02571                     sizeof(info->symbol)) ) == PAPI_OK ) {
02572 
02573       } else {
02574          INTDBG("EXIT: retval: %d\n", retval);
02575          return retval;
02576       }
02577 
02578         if ((nevt_code = _papi_hwi_eventcode_to_native(EventCode)) <0) {
02579             INTDBG("EXIT: nevt_code: %d\n", nevt_code);
02580             return nevt_code;
02581         }
02582       retval = _papi_hwd[cidx]->ntv_code_to_descr( 
02583                      (unsigned int)nevt_code,
02584                      info->long_descr,
02585                      sizeof ( info->long_descr));
02586       if (retval!=PAPI_OK) {
02587          INTDBG("Failed ntv_code_to_descr()\n");
02588       }
02589 
02590        }
02591        retval = _papi_hwi_prefix_component_name( 
02592                         _papi_hwd[cidx]->cmp_info.short_name, 
02593                         info->symbol,
02594                         info->symbol, 
02595                         sizeof(info->symbol) );
02596 
02597        INTDBG("EXIT: retval: %d\n", retval);
02598        return retval;
02599     }
02600 
02601     INTDBG("EXIT: PAPI_ENOEVNT\n");
02602     return PAPI_ENOEVNT;
02603 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_hwi_get_ntv_idx ( unsigned int  papi_evt_code  ) 

Definition at line 142 of file papi_internal.c.

00142                                                    {
00143     INTDBG("ENTER: papi_evt_code: %#x\n", papi_evt_code);
00144 
00145     int result;
00146     int event_index;
00147 
00148     if (papi_evt_code == 0) {
00149         INTDBG("EXIT: PAPI_ENOEVNT, invalid papi event code\n");
00150         return PAPI_ENOEVNT;
00151     }
00152 
00153     event_index=papi_evt_code&PAPI_NATIVE_AND_MASK;
00154     if ((event_index<0) || (event_index>=num_native_events)) {
00155         INTDBG("EXIT: PAPI_ENOEVNT, invalid index into native event array\n");
00156         return PAPI_ENOEVNT;
00157     }
00158 
00159     result=_papi_native_events[event_index].ntv_idx;
00160 
00161     INTDBG("EXIT: result: %d\n", result);
00162     return result;
00163 }

Here is the caller graph for this function:

unsigned int _papi_hwi_get_papi_event_code ( void   ) 

Definition at line 136 of file papi_internal.c.

00136                                  {
00137     INTDBG("papi_event_code: %#x\n", papi_event_code);
00138     return papi_event_code;
00139 }

Here is the caller graph for this function:

char* _papi_hwi_get_papi_event_string ( void   ) 

Definition at line 102 of file papi_internal.c.

00102                                    {
00103     INTDBG("papi_event_string: %s\n", papi_event_string);
00104     return papi_event_string;
00105 }

Here is the caller graph for this function:

int _papi_hwi_get_preset_event_info ( int  EventCode,
PAPI_event_info_t info 
)

Definition at line 2249 of file papi_internal.c.

02250 {
02251     INTDBG("ENTER: EventCode: %#x, info: %p\n", EventCode, info);
02252 
02253     int i = EventCode & PAPI_PRESET_AND_MASK;
02254     unsigned int j;
02255 
02256     if ( _papi_hwi_presets[i].symbol ) {    /* if the event is in the preset table */
02257       // since we are setting the whole structure to zero the strncpy calls below will 
02258       // be leaving NULL terminates strings as long as they copy 1 less byte than the 
02259       // buffer size of the field.
02260        memset( info, 0, sizeof ( PAPI_event_info_t ) );
02261 
02262        info->event_code = ( unsigned int ) EventCode;
02263        strncpy( info->symbol, _papi_hwi_presets[i].symbol,
02264         sizeof(info->symbol)-1);
02265 
02266        if ( _papi_hwi_presets[i].short_descr != NULL )
02267           strncpy( info->short_descr, _papi_hwi_presets[i].short_descr,
02268                   sizeof ( info->short_descr )-1 );
02269 
02270        if ( _papi_hwi_presets[i].long_descr != NULL )
02271           strncpy( info->long_descr,  _papi_hwi_presets[i].long_descr,
02272                   sizeof ( info->long_descr )-1 );
02273 
02274        info->event_type = _papi_hwi_presets[i].event_type;
02275        info->count = _papi_hwi_presets[i].count;
02276 
02277        _papi_hwi_derived_string( _papi_hwi_presets[i].derived_int,
02278                      info->derived,  sizeof ( info->derived ) );
02279 
02280        if ( _papi_hwi_presets[i].postfix != NULL )
02281           strncpy( info->postfix, _papi_hwi_presets[i].postfix,
02282                   sizeof ( info->postfix )-1 );
02283 
02284        for(j=0;j < info->count; j++) {
02285           info->code[j]=_papi_hwi_presets[i].code[j];
02286           strncpy(info->name[j], _papi_hwi_presets[i].name[j],
02287           sizeof(info->name[j])-1);
02288        }
02289 
02290        if ( _papi_hwi_presets[i].note != NULL ) {
02291           strncpy( info->note, _papi_hwi_presets[i].note,
02292                   sizeof ( info->note )-1 );
02293        }
02294 
02295        return PAPI_OK;
02296     } else {
02297        return PAPI_ENOEVNT;
02298     }
02299 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_hwi_get_user_event_info ( int  EventCode,
PAPI_event_info_t info 
)

Definition at line 2309 of file papi_internal.c.

02310 {
02311     INTDBG("ENTER: EventCode: %#x, info: %p\n", EventCode, info);
02312 
02313     unsigned int i = EventCode & PAPI_UE_AND_MASK;
02314     unsigned int j;
02315 
02316     // if event code not in valid range, return error
02317     if (i >= PAPI_MAX_USER_EVENTS) {
02318         INTDBG("EXIT: Invalid event index: %d, max value is: %d\n", i, PAPI_MAX_USER_EVENTS - 1);
02319         return( PAPI_ENOEVNT );
02320     }
02321 
02322     if ( user_defined_events[i].symbol == NULL) {   /* if the event is in the preset table */
02323         INTDBG("EXIT: Event symbol for this event is NULL\n");
02324         return PAPI_ENOEVNT;
02325     }
02326 
02327     /* set whole structure to 0 */
02328     memset( info, 0, sizeof ( PAPI_event_info_t ) );
02329 
02330     info->event_code = ( unsigned int ) EventCode;
02331     strncpy( info->symbol, user_defined_events[i].symbol,
02332         sizeof(info->symbol)-1);
02333 
02334     if ( user_defined_events[i].short_descr != NULL )
02335         strncpy( info->short_descr, user_defined_events[i].short_descr,
02336             sizeof(info->short_descr)-1);
02337 
02338     if ( user_defined_events[i].long_descr != NULL )
02339         strncpy( info->long_descr,  user_defined_events[i].long_descr,
02340             sizeof(info->long_descr)-1);
02341 
02342 //  info->event_type = user_defined_events[i].event_type;
02343     info->count = user_defined_events[i].count;
02344 
02345     _papi_hwi_derived_string( user_defined_events[i].derived_int,
02346             info->derived,  sizeof(info->derived)-1);
02347 
02348     if ( user_defined_events[i].postfix != NULL )
02349         strncpy( info->postfix, user_defined_events[i].postfix,
02350             sizeof(info->postfix)-1);
02351 
02352     for(j=0;j < info->count; j++) {
02353         info->code[j]=user_defined_events[i].code[j];
02354         INTDBG("info->code[%d]: %#x\n", j, info->code[j]);
02355         strncpy(info->name[j], user_defined_events[i].name[j], sizeof(info->name[j])-1);
02356     }
02357 
02358     if ( user_defined_events[i].note != NULL ) {
02359         strncpy( info->note, user_defined_events[i].note, sizeof(info->note)-1);
02360     }
02361 
02362     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);
02363     return PAPI_OK;
02364 }

Here is the call graph for this function:

Here is the caller graph for this function:

void _papi_hwi_init_errors ( void   ) 

Definition at line 478 of file papi_internal.c.

00478                             {
00479 /* we use add error to avoid the cost of lookups, we know the errors are not there yet */
00480     _papi_hwi_add_error("No error");
00481     _papi_hwi_add_error("Invalid argument");
00482     _papi_hwi_add_error("Insufficient memory");
00483     _papi_hwi_add_error("A System/C library call failed");
00484     _papi_hwi_add_error("Not supported by component");
00485     _papi_hwi_add_error("Access to the counters was lost or interrupted");
00486     _papi_hwi_add_error("Internal error, please send mail to the developers");
00487     _papi_hwi_add_error("Event does not exist");
00488     _papi_hwi_add_error("Event exists, but cannot be counted due to hardware resource limits");
00489     _papi_hwi_add_error("EventSet is currently not running");
00490     _papi_hwi_add_error("EventSet is currently counting");
00491     _papi_hwi_add_error("No such EventSet available");
00492     _papi_hwi_add_error("Event in argument is not a valid preset");
00493     _papi_hwi_add_error("Hardware does not support performance counters");
00494     _papi_hwi_add_error("Unknown error code");
00495     _papi_hwi_add_error("Permission level does not permit operation");
00496     _papi_hwi_add_error("PAPI hasn't been initialized yet");
00497     _papi_hwi_add_error("Component Index isn't set");
00498     _papi_hwi_add_error("Not supported");
00499     _papi_hwi_add_error("Not implemented");
00500     _papi_hwi_add_error("Buffer size exceeded");
00501     _papi_hwi_add_error("EventSet domain is not supported for the operation");
00502     _papi_hwi_add_error("Invalid or missing event attributes");
00503     _papi_hwi_add_error("Too many events or attributes");
00504     _papi_hwi_add_error("Bad combination of features");
00505 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_hwi_init_global ( void   ) 

Definition at line 1908 of file papi_internal.c.

01909 {
01910         int retval, i = 0;
01911 
01912     retval = _papi_hwi_innoculate_os_vector( &_papi_os_vector );
01913     if ( retval != PAPI_OK ) {
01914        return retval;
01915     }
01916 
01917     while ( _papi_hwd[i] ) {
01918 
01919        retval = _papi_hwi_innoculate_vector( _papi_hwd[i] );
01920        if ( retval != PAPI_OK ) {
01921           return retval;
01922        }
01923 
01924        /* We can be disabled by user before init */
01925        if (!_papi_hwd[i]->cmp_info.disabled) {
01926           retval = _papi_hwd[i]->init_component( i );
01927           _papi_hwd[i]->cmp_info.disabled=retval;
01928 
01929           /* Do some sanity checking */
01930           if (retval==PAPI_OK) {
01931         if (_papi_hwd[i]->cmp_info.num_cntrs >
01932             _papi_hwd[i]->cmp_info.num_mpx_cntrs) {
01933           fprintf(stderr,"Warning!  num_cntrs %d is more than num_mpx_cntrs %d for component %s\n",
01934                         _papi_hwd[i]->cmp_info.num_cntrs,
01935                         _papi_hwd[i]->cmp_info.num_mpx_cntrs,
01936                         _papi_hwd[i]->cmp_info.name);
01937         }
01938 
01939           }
01940        }
01941 
01942        i++;
01943     }
01944     return PAPI_OK;
01945 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_hwi_init_global_internal ( void   ) 

Definition at line 1951 of file papi_internal.c.

01952 {
01953 
01954     int retval;
01955 
01956     memset(&_papi_hwi_system_info,0x0,sizeof( _papi_hwi_system_info ));
01957 
01958     memset( _papi_hwi_using_signal,0x0,sizeof( _papi_hwi_using_signal ));
01959 
01960     /* Global struct to maintain EventSet mapping */
01961     retval = allocate_eventset_map( &_papi_hwi_system_info.global_eventset_map );
01962     if ( retval != PAPI_OK ) {
01963         return retval;
01964     }
01965 
01966     _papi_hwi_system_info.pid = 0;  /* Process identifier */
01967 
01968     /* PAPI_hw_info_t struct */
01969     memset(&(_papi_hwi_system_info.hw_info),0x0,sizeof(PAPI_hw_info_t));
01970 
01971     return PAPI_OK;
01972 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_hwi_invalid_cmp ( int  cidx  ) 

Definition at line 508 of file papi_internal.c.

00509 {
00510   return ( cidx < 0 || cidx >= papi_num_components );
00511 }

Here is the caller graph for this function:

int _papi_hwi_is_sw_multiplex ( EventSetInfo_t ESI  ) 

Definition at line 2625 of file papi_internal.c.

02626 {
02627    /* Are we multiplexing at all */
02628    if ( ( ESI->state & PAPI_MULTIPLEXING ) == 0 ) {
02629       return 0;
02630    }
02631 
02632    /* Does the component support kernel multiplexing */
02633    if ( _papi_hwd[ESI->CmpIdx]->cmp_info.kernel_multiplex ) {
02634       /* Have we forced software multiplexing */
02635       if ( ESI->multiplex.flags == PAPI_MULTIPLEX_FORCE_SW ) {
02636      return 1;
02637       }
02638       /* Nope, using hardware multiplexing */
02639       return 0;
02640    } 
02641 
02642    /* We are multiplexing but the component does not support hardware */
02643 
02644    return 1;
02645 
02646 }

Here is the caller graph for this function:

static int _papi_hwi_lookup_error ( char *  error  )  [static]

Definition at line 444 of file papi_internal.c.

00445 {
00446     int i;
00447 
00448     for (i=0; i<_papi_hwi_num_errors; i++) {
00449         if ( !strncasecmp( _papi_errlist[i], error, strlen( error ) ) )
00450             return i; 
00451         
00452     } 
00453 
00454     return (-1);
00455 }

Here is the caller graph for this function:

int _papi_hwi_lookup_EventCodeIndex ( const EventSetInfo_t ESI,
unsigned int  EventCode 
)

Definition at line 986 of file papi_internal.c.

00988 {
00989     int i;
00990     int limit = EventInfoArrayLength( ESI );
00991 
00992     for ( i = 0; i < limit; i++ ) {
00993        if ( ESI->EventInfoArray[i].event_code == EventCode ) {
00994           return i;
00995        }
00996     }
00997 
00998     return PAPI_EINVAL;
00999 }

Here is the call graph for this function:

Here is the caller graph for this function:

EventSetInfo_t* _papi_hwi_lookup_EventSet ( int  eventset  ) 

Definition at line 2606 of file papi_internal.c.

02607 {
02608     const DynamicArray_t *map = &_papi_hwi_system_info.global_eventset_map;
02609     EventSetInfo_t *set;
02610 
02611     if ( ( eventset < 0 ) || ( eventset > map->totalSlots ) )
02612         return ( NULL );
02613 
02614     set = map->dataSlotArray[eventset];
02615 #ifdef DEBUG
02616     if ( ( ISLEVEL( DEBUG_THREADS ) ) && ( _papi_hwi_thread_id_fn ) &&
02617          ( set->master->tid != _papi_hwi_thread_id_fn(  ) ) )
02618         return ( NULL );
02619 #endif
02620 
02621     return ( set );
02622 }

Here is the caller graph for this function:

void _papi_hwi_map_events_to_native ( EventSetInfo_t ESI  ) 

Definition at line 1066 of file papi_internal.c.

01067 {
01068     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);
01069 
01070     int i, event, k, n, preset_index = 0, nevt;
01071     int total_events = ESI->NumberOfEvents;
01072 
01073     event = 0;
01074     for( i = 0; i < total_events; i++ ) {
01075 
01076         /* find the first event that isn't PAPI_NULL */
01077         /* Is this really necessary? --vmw           */
01078         while ( ESI->EventInfoArray[event].event_code == ( unsigned int ) PAPI_NULL ) {
01079             event++;
01080         }
01081 
01082         /* If it's a preset */
01083         if ( IS_PRESET(ESI->EventInfoArray[event].event_code) ) {
01084             preset_index = ( int ) ESI->EventInfoArray[event].event_code & PAPI_PRESET_AND_MASK;
01085 
01086             /* walk all sub-events in the preset */
01087             for( k = 0; k < PAPI_EVENTS_IN_DERIVED_EVENT; k++ ) {
01088                 nevt = _papi_hwi_presets[preset_index].code[k];
01089                 if ( nevt == PAPI_NULL ) {
01090                     break;
01091                 }
01092 
01093                 INTDBG("Looking for subevent %#x\n",nevt);
01094 
01095                 /* Match each sub-event to something in the Native List */
01096                 for( n = 0; n < ESI->NativeCount; n++ ) {
01097                     if ( nevt == ESI->NativeInfoArray[n].ni_papi_code ) {
01098                         INTDBG("Found papi event: %#x, &ESI->NativeInfoArray[%d]: %p, ni_event: %#x, ni_position %d\n",
01099                                 nevt, n, &(ESI->NativeInfoArray[n]), ESI->NativeInfoArray[n].ni_event, ESI->NativeInfoArray[n].ni_position);
01100                         ESI->EventInfoArray[event].pos[k] = ESI->NativeInfoArray[n].ni_position;
01101                         break;
01102                     }
01103                 }
01104             }
01105         }
01106         /* If it's a native event */
01107         else if( IS_NATIVE(ESI->EventInfoArray[event].event_code) ) {
01108             nevt = ( int ) ESI->EventInfoArray[event].event_code;
01109 
01110             // get index into native info array for this event
01111             int nidx = event_already_in_eventset( ESI, nevt );
01112             // if not found, then we need to return an error
01113             if (nidx == PAPI_ENOEVNT) {
01114                 INTDBG("EXIT: needed event not found\n");
01115                 return;
01116             }
01117             ESI->EventInfoArray[event].pos[0] = ESI->NativeInfoArray[nidx].ni_position;
01118             INTDBG("nidx: %d, ni_position: %d\n", nidx, ESI->NativeInfoArray[nidx].ni_position);
01119 
01120         }
01121         /* If it's a user-defined event */
01122         else if ( IS_USER_DEFINED(ESI->EventInfoArray[event].event_code) ) {
01123             preset_index = ( int ) ESI->EventInfoArray[event].event_code & PAPI_UE_AND_MASK;
01124             for ( k = 0; k < PAPI_EVENTS_IN_DERIVED_EVENT; k++ ) {
01125                 nevt = user_defined_events[preset_index].code[k];
01126                 INTDBG("nevt: %#x, user_defined_events[%d].code[%d]: %#x, code[%d]: %#x\n",
01127                         nevt, preset_index, k, user_defined_events[preset_index].code[k], k+1, user_defined_events[preset_index].code[k+1]);
01128 
01129                 if ( nevt == PAPI_NULL ) break;
01130 
01131                 /* Match each sub-event to something in the Native List */
01132                 for ( n = 0; n < ESI->NativeCount; n++ ) {
01133                     // if this is the event we are looking for, set its position and exit inner loop to look for next sub-event
01134                     if ( _papi_hwi_eventcode_to_native(nevt) == ESI->NativeInfoArray[n].ni_event ) {
01135                         ESI->EventInfoArray[event].pos[k] = ESI->NativeInfoArray[n].ni_position;
01136                         break;
01137                     }
01138                 }
01139             }
01140         }
01141         event++;
01142     }
01143     INTDBG("EXIT: \n");
01144     return;
01145 }

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 2494 of file papi_internal.c.

02496 {
02497     INTDBG("ENTER: EventCode: %#x, hwi_name: %p, len: %d\n", EventCode, hwi_name, len);
02498   int cidx;
02499   int retval; 
02500   int nevt_code;
02501 
02502   cidx = _papi_hwi_component_index( EventCode );
02503   if (cidx<0) return PAPI_ENOEVNT;
02504 
02505   if ( EventCode & PAPI_NATIVE_MASK ) {
02506       // save event code so components can get it with call to: _papi_hwi_get_papi_event_code()
02507       _papi_hwi_set_papi_event_code(EventCode, 0);
02508 
02509     if ((nevt_code = _papi_hwi_eventcode_to_native(EventCode)) < 0) {
02510         INTDBG("EXIT: nevt_code: %d\n", nevt_code);
02511         return nevt_code;
02512     }
02513     if ( (retval = _papi_hwd[cidx]->ntv_code_to_name( 
02514                         (unsigned int)nevt_code,
02515                         hwi_name, len) ) == PAPI_OK ) {
02516             retval = _papi_hwi_prefix_component_name( _papi_hwd[cidx]->cmp_info.short_name, 
02517                                              hwi_name, hwi_name, len);
02518             INTDBG("EXIT: retval: %d\n", retval);
02519             return retval;
02520     }
02521     INTDBG("EXIT: retval: %d\n", retval);
02522     return (retval);
02523   }
02524   INTDBG("EXIT: PAPI_ENOEVNT\n");
02525   return PAPI_ENOEVNT;
02526 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_hwi_native_name_to_code ( char *  in,
int *  out 
)

Definition at line 2401 of file papi_internal.c.

02402 {
02403     INTDBG("ENTER: in: %s, out: %p\n", in, out);
02404 
02405     int retval = PAPI_ENOEVNT;
02406     char name[PAPI_HUGE_STR_LEN];      /* make sure it's big enough */
02407     unsigned int i;
02408     int cidx;
02409     char *full_event_name;
02410 
02411     if (in == NULL) {
02412         INTDBG("EXIT: PAPI_EINVAL\n");
02413         return PAPI_EINVAL;
02414     }
02415 
02416     full_event_name = strdup(in);
02417 
02418     in = _papi_hwi_strip_component_prefix(in);
02419 
02420     // look in each component
02421     for(cidx=0; cidx < papi_num_components; cidx++) {
02422 
02423        if (_papi_hwd[cidx]->cmp_info.disabled) continue;
02424 
02425        // if this component does not support the pmu which defines this event, no need to call it
02426        if (is_supported_by_component(cidx, full_event_name) == 0) continue;
02427 
02428        INTDBG("cidx: %d, name: %s, event: %s\n", cidx, _papi_hwd[cidx]->cmp_info.name, in);
02429 
02430        // show that we do not have an event code yet (the component may create one and update this info)
02431        // this also clears any values left over from a previous call
02432        _papi_hwi_set_papi_event_code(-1, -1);
02433 
02434 
02435         // if component has a ntv_name_to_code function, use it to get event code
02436         if (_papi_hwd[cidx]->ntv_name_to_code != NULL) {
02437             // try and get this events event code
02438             retval = _papi_hwd[cidx]->ntv_name_to_code( in, ( unsigned * ) out );
02439             if (retval==PAPI_OK) {
02440                 *out = _papi_hwi_native_to_eventcode(cidx, *out, -1, in);
02441                 free (full_event_name);
02442                 INTDBG("EXIT: PAPI_OK  event: %s code: %#x\n", in, *out);
02443                 return PAPI_OK;
02444             }
02445         } else {
02446             // force the code through the work around
02447             retval = PAPI_ECMP;
02448         }
02449 
02450         /* If not implemented, work around */
02451         if ( retval==PAPI_ECMP) {
02452             i = 0;
02453             retval = _papi_hwd[cidx]->ntv_enum_events( &i, PAPI_ENUM_FIRST );
02454             if (retval != PAPI_OK) {
02455                 free (full_event_name);
02456                 INTDBG("EXIT: retval: %d\n", retval);
02457                 return retval;
02458             }
02459 
02460 //          _papi_hwi_lock( INTERNAL_LOCK );
02461 
02462             do {
02463                 // save event code so components can get it with call to: _papi_hwi_get_papi_event_code()
02464                 _papi_hwi_set_papi_event_code(i, 0);
02465                 retval = _papi_hwd[cidx]->ntv_code_to_name(i, name, sizeof(name));
02466                 /* printf("%#x\nname =|%s|\ninput=|%s|\n", i, name, in); */
02467                 if ( retval == PAPI_OK && in != NULL) {
02468                     if ( strcasecmp( name, in ) == 0 ) {
02469                         *out = _papi_hwi_native_to_eventcode(cidx, i, -1, name);
02470                         free (full_event_name);
02471                         INTDBG("EXIT: PAPI_OK, event: %s, code: %#x\n", in, *out);
02472                         return PAPI_OK;
02473                     }
02474                     retval = PAPI_ENOEVNT;
02475                 } else {
02476                     *out = 0;
02477                     retval = PAPI_ENOEVNT;
02478                     break;
02479                 }
02480             } while ( ( _papi_hwd[cidx]->ntv_enum_events( &i, PAPI_ENUM_EVENTS ) == PAPI_OK ) );
02481 
02482 //          _papi_hwi_unlock( INTERNAL_LOCK );
02483         }
02484     }
02485 
02486     free (full_event_name);
02487     INTDBG("EXIT: retval: %d\n", retval);
02488     return retval;
02489 }

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 553 of file papi_internal.c.

00553                                                                                              {
00554   INTDBG("Entry: cidx: %d, event: %#x, ntv_idx: %d, event_name: %s\n", cidx, event_code, ntv_idx, event_name);
00555 
00556   int result;
00557 
00558   if (papi_event_code_changed > 0) {
00559       result = _papi_hwi_get_papi_event_code();
00560       INTDBG("EXIT: papi_event_code: %#x set by the component\n", result);
00561       return result;
00562   }
00563 
00564   result=_papi_hwi_find_native_event(cidx, event_code, event_name);
00565   if (result==PAPI_ENOEVNT) {
00566      // Need to create one
00567      result=_papi_hwi_add_native_event(cidx, event_code, ntv_idx, event_name);
00568   }
00569 
00570   INTDBG("EXIT: result: %#x\n", result);
00571   return result;
00572 }

Here is the call graph for this function:

Here is the caller graph for this function:

static long long _papi_hwi_postfix_calc ( EventInfo_t evi,
long long *  hw_counter 
) [static]

Definition at line 2073 of file papi_internal.c.

02074  {
02075         char *point = evi->ops, operand[16];
02076         double stack[PAPI_EVENTS_IN_DERIVED_EVENT];
02077        int i, val, top = 0;
02078 
02079        INTDBG("ENTER: evi: %p, evi->ops: %p (%s), evi->pos[0]: %d, evi->pos[1]: %d, hw_counter: %p (%lld %lld)\n",
02080               evi, evi->ops, evi->ops, evi->pos[0], evi->pos[1], hw_counter, hw_counter[0], hw_counter[1]);
02081 
02082         memset(&stack,0,PAPI_EVENTS_IN_DERIVED_EVENT*sizeof(double));
02083 
02084         while ( *point != '\0' ) {
02085                if ( *point == '|' ) {  /* consume '|' characters */
02086                         point++;
02087                 } else if ( *point == 'N' ) {   /* to get count for each native event */
02088                         point++;
02089                        i = 0;
02090                        while ( isdigit(*point) ) {
02091                                assert(i<16);
02092                                 operand[i] = *point;
02093                                 point++;
02094                                 i++;
02095                        }
02096                        assert(0<i && i<16);
02097                         operand[i] = '\0';
02098                        val = atoi( operand );
02099                        assert( top < PAPI_EVENTS_IN_DERIVED_EVENT );
02100                        assert( 0 <= val && val < PAPI_EVENTS_IN_DERIVED_EVENT );
02101                        stack[top] = ( double ) hw_counter[evi->pos[val]];
02102                         top++;
02103                } else if ( *point == '#' ) {   /* to get mhz */
02104                         point++;
02105                        assert( top < PAPI_EVENTS_IN_DERIVED_EVENT );
02106                         stack[top] = _papi_hwi_system_info.hw_info.cpu_max_mhz * 1000000.0;
02107                         top++;
02108                } else if ( isdigit( *point ) ) {
02109                         i = 0;
02110                        while ( isdigit(*point) ) {
02111                                assert(i<16);
02112                                 operand[i] = *point;
02113                                 point++;
02114                                 i++;
02115                        }
02116                        assert(0<i && i<16);
02117                         operand[i] = '\0';
02118                        assert( top < PAPI_EVENTS_IN_DERIVED_EVENT );
02119                         stack[top] = atoi( operand );
02120                         top++;
02121                 } else if ( *point == '+' ) {   /* + calculation */
02122                        point++;
02123                        assert(top >= 2);
02124                         stack[top - 2] += stack[top - 1];
02125                         top--;
02126                 } else if ( *point == '-' ) {   /* - calculation */
02127                        point++;
02128                        assert(top >= 2);
02129                         stack[top - 2] -= stack[top - 1];
02130                         top--;
02131                 } else if ( *point == '*' ) {   /* * calculation */
02132                        point++;
02133                        assert(top >= 2);
02134                         stack[top - 2] *= stack[top - 1];
02135                         top--;
02136                 } else if ( *point == '/' ) {   /* / calculation */
02137                        point++;
02138                        assert(top >= 2);
02139                        /* FIXME should handle runtime divide by zero */
02140                         stack[top - 2] /= stack[top - 1];
02141                         top--;
02142                } else { /* flag an error parsing the preset */
02143                        PAPIERROR( "BUG! Unable to parse \"%s\"", evi->ops );
02144                        return ( long long ) stack[0];
02145                 }
02146         }
02147         assert(top == 1);
02148         INTDBG("EXIT: stack[0]: %lld\n", (long long)stack[0]);
02149         return ( long long ) stack[0];
02150  }

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_hwi_prefix_component_name ( char *  component_name,
char *  event_name,
char *  out,
int  out_len 
)

Definition at line 244 of file papi_internal.c.

00245 {
00246     int size1, size2;
00247     char temp[out_len];
00248 
00249     size1 = strlen(event_name);
00250     size2 = strlen(component_name);
00251 
00252 /* sanity checks */
00253     if ( size1 == 0 ) {
00254         return (PAPI_EBUG); /* hopefully event_name always has length?! */
00255     }   
00256 
00257     if ( size1 >= out_len )
00258         return (PAPI_ENOMEM);
00259 
00260 /* Guard against event_name == out */
00261     memcpy( temp, event_name, out_len );
00262 
00263 /* no component name to prefix */
00264     if ( size2 == 0 ) {
00265         sprintf(out, "%s%c", temp, '\0' );
00266         return (PAPI_OK);
00267     }
00268     
00269 /* Don't prefix 'cpu' component names for now */
00270     if ( strstr(component_name, "pe") ||
00271          strstr(component_name, "bgq") ||
00272          strstr(component_name, "bgp") ) {
00273         sprintf( out, "%s%c", temp, '\0'); 
00274         return (PAPI_OK);
00275     }
00276 
00277 /* strlen(component_name) + ::: + strlen(event_name) + NULL */
00278     if ( size1+size2+3+1 > out_len )
00279         return (PAPI_ENOMEM);
00280 
00281     sprintf( out, "%s:::%s%c" , component_name, temp, '\0');
00282     return (PAPI_OK);
00283 }

Here is the caller graph for this function:

int _papi_hwi_publish_error ( char *  error  ) 

Definition at line 467 of file papi_internal.c.

00468 {
00469     int error_code = -1;
00470 
00471     if ( (error_code = _papi_hwi_lookup_error( error )) < 0 )
00472         error_code = _papi_hwi_add_error(error);
00473 
00474     return (-error_code); /* internally error_code is an index, externally, it should be <= 0 */
00475 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_hwi_query_native_event ( unsigned int  EventCode  ) 

Definition at line 2370 of file papi_internal.c.

02371 {
02372     INTDBG("ENTER: EventCode: %#x\n", EventCode);
02373    char name[PAPI_HUGE_STR_LEN];      /* probably overkill, */
02374                                       /* but should always be big enough */
02375    int cidx;
02376    int nevt_code;
02377 
02378    cidx = _papi_hwi_component_index( EventCode );
02379    if (cidx<0) {
02380        INTDBG("EXIT: PAPI_ENOCMP\n");
02381        return PAPI_ENOCMP;
02382    }
02383 
02384    // save event code so components can get it with call to: _papi_hwi_get_papi_event_code()
02385    _papi_hwi_set_papi_event_code(EventCode, 0);
02386 
02387     if ((nevt_code = _papi_hwi_eventcode_to_native(EventCode)) < 0) {
02388         INTDBG("EXIT: nevt_code: %d\n", nevt_code);
02389         return nevt_code;
02390     }
02391    int ret = _papi_hwd[cidx]->ntv_code_to_name( (unsigned int)nevt_code, name, sizeof(name));
02392 
02393    INTDBG("EXIT: ret: %d\n", ret);
02394    return (ret);
02395 }

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1677 of file papi_internal.c.

01679 {
01680     INTDBG("ENTER: context: %p, ESI: %p, values: %p\n", context, ESI, values);
01681     int retval;
01682     long long *dp = NULL;
01683     int i, index;
01684 
01685     retval = _papi_hwd[ESI->CmpIdx]->read( context, ESI->ctl_state, 
01686                            &dp, ESI->state );
01687     if ( retval != PAPI_OK ) {
01688         INTDBG("EXIT: retval: %d\n", retval);
01689        return retval;
01690     }
01691 
01692     /* This routine distributes hardware counters to software counters in the
01693        order that they were added. Note that the higher level
01694        EventInfoArray[i] entries may not be contiguous because the user
01695        has the right to remove an event.
01696        But if we do compaction after remove event, this function can be 
01697        changed.  
01698      */
01699 
01700     for ( i = 0; i != ESI->NumberOfEvents; i++ ) {
01701 
01702         index = ESI->EventInfoArray[i].pos[0];
01703 
01704         if ( index == -1 )
01705             continue;
01706 
01707         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 );
01708 
01709         /* If this is not a derived event */
01710 
01711         if ( ESI->EventInfoArray[i].derived == NOT_DERIVED ) {
01712             values[i] = dp[index];
01713             INTDBG( "value: %#llx\n", values[i] );
01714         } else {             /* If this is a derived event */
01715             values[i] = handle_derived( &ESI->EventInfoArray[i], dp );
01716 #ifdef DEBUG
01717             if ( values[i] < ( long long ) 0 ) {
01718                 INTDBG( "Derived Event is negative!!: %lld\n", values[i] );
01719             }
01720             INTDBG( "derived value: %#llx \n", values[i] );
01721 #endif
01722         }
01723     }
01724 
01725     INTDBG("EXIT: PAPI_OK\n");
01726     return PAPI_OK;
01727 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_hwi_remove_event ( EventSetInfo_t ESI,
int  EventCode 
)

Definition at line 1594 of file papi_internal.c.

01595 {
01596     int j = 0, retval, thisindex;
01597     EventInfo_t *array;
01598 
01599     thisindex =
01600         _papi_hwi_lookup_EventCodeIndex( ESI, ( unsigned int ) EventCode );
01601     if ( thisindex < PAPI_OK )
01602         return ( thisindex );
01603 
01604     /* If it is a MPX EventSet, remove it from the multiplex data structure and
01605        this threads multiplex list */
01606 
01607     if ( _papi_hwi_is_sw_multiplex( ESI ) ) {
01608         retval = mpx_remove_event( &ESI->multiplex.mpx_evset, EventCode );
01609         if ( retval < PAPI_OK )
01610             return ( retval );
01611     } else
01612         /* Remove the events hardware dependent stuff from the EventSet */
01613     {
01614         if ( IS_PRESET(EventCode) ) {
01615             int preset_index = EventCode & PAPI_PRESET_AND_MASK;
01616 
01617             /* Check if it's within the valid range */
01618             if ( ( preset_index < 0 ) ||
01619                  ( preset_index >= PAPI_MAX_PRESET_EVENTS ) )
01620                 return PAPI_EINVAL;
01621 
01622             /* Check if event exists */
01623             if ( !_papi_hwi_presets[preset_index].count )
01624                 return PAPI_ENOEVNT;
01625 
01626             /* Remove the preset event. */
01627             for ( j = 0; _papi_hwi_presets[preset_index].code[j] != (unsigned int)PAPI_NULL;
01628                   j++ );
01629             retval = remove_native_events( ESI, ( int * )_papi_hwi_presets[preset_index].code, j );
01630             if ( retval != PAPI_OK )
01631                 return ( retval );
01632         } else if ( IS_NATIVE(EventCode) ) {
01633             /* Check if native event exists */
01634             if ( _papi_hwi_query_native_event( ( unsigned int ) EventCode ) !=
01635                  PAPI_OK )
01636                 return PAPI_ENOEVNT;
01637 
01638             /* Remove the native event. */
01639             retval = remove_native_events( ESI, &EventCode, 1 );
01640             if ( retval != PAPI_OK )
01641                 return ( retval );
01642         } else if ( IS_USER_DEFINED( EventCode ) ) {
01643           int index = EventCode & PAPI_UE_AND_MASK;
01644 
01645           if ( (index < 0) || (index >= user_defined_events_count) )
01646             return ( PAPI_EINVAL );
01647 
01648           for( j = 0; j < PAPI_EVENTS_IN_DERIVED_EVENT &&
01649               user_defined_events[index].code[j] != 0; j++ ) {
01650             retval = remove_native_events( ESI, ( int * )user_defined_events[index].code, j);
01651 
01652             if ( retval != PAPI_OK )
01653               return ( retval );
01654           }
01655         } else
01656             return ( PAPI_ENOEVNT );
01657     }
01658     array = ESI->EventInfoArray;
01659 
01660     /* Compact the Event Info Array list if it's not the last event */
01661     /* clear the newly empty slot in the array */
01662     for ( ; thisindex < ESI->NumberOfEvents - 1; thisindex++ )
01663         array[thisindex] = array[thisindex + 1];
01664 
01665 
01666     array[thisindex].event_code = ( unsigned int ) PAPI_NULL;
01667     for ( j = 0; j < PAPI_EVENTS_IN_DERIVED_EVENT; j++ )
01668         array[thisindex].pos[j] = PAPI_NULL;
01669     array[thisindex].ops = NULL;
01670     array[thisindex].derived = NOT_DERIVED;
01671     ESI->NumberOfEvents--;
01672 
01673     return ( PAPI_OK );
01674 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_hwi_remove_EventSet ( EventSetInfo_t ESI  ) 

Definition at line 1004 of file papi_internal.c.

01005 {
01006     DynamicArray_t *map = &_papi_hwi_system_info.global_eventset_map;
01007     int i;
01008 
01009     i = ESI->EventSetIndex;
01010 
01011     _papi_hwi_lock( INTERNAL_LOCK );
01012 
01013     _papi_hwi_free_EventSet( ESI );
01014 
01015     /* do bookkeeping for PAPI_EVENTSET_MAP */
01016 
01017     map->dataSlotArray[i] = NULL;
01018     map->availSlots++;
01019     map->fullSlots--;
01020 
01021     _papi_hwi_unlock( INTERNAL_LOCK );
01022 
01023     return PAPI_OK;
01024 }

Here is the call graph for this function:

Here is the caller graph for this function:

void _papi_hwi_set_papi_event_code ( unsigned int  event_code,
int  update_flag 
)

Definition at line 119 of file papi_internal.c.

00119                                                                          {
00120     INTDBG("new event_code: %#x, update_flag: %d, previous event_code: %#x\n", event_code, update_flag, papi_event_code);
00121 
00122     // if call is just to reset and start over, set both flags to show nothing saved yet
00123     if (update_flag < 0) {
00124         papi_event_code_changed = -1;
00125         papi_event_code = -1;
00126         return;
00127     }
00128 
00129     // if 0, it is being set prior to calling a component, if >0 it is being changed by the component
00130     papi_event_code_changed = update_flag;
00131     // save the event code passed in
00132     papi_event_code = event_code;
00133     return;
00134 }

Here is the caller graph for this function:

void _papi_hwi_set_papi_event_string ( const char *  event_string  ) 

Definition at line 90 of file papi_internal.c.

00090                                                            {
00091     INTDBG("event_string: %s\n", event_string);
00092     if (papi_event_string != NULL) {
00093         free (papi_event_string);
00094         papi_event_string = NULL;
00095     }
00096     if (event_string != NULL) {
00097         papi_event_string = strdup(event_string);
00098     }
00099     return;
00100 }

Here is the caller graph for this function:

void _papi_hwi_shutdown_global_internal ( void   ) 

Definition at line 1975 of file papi_internal.c.

01976 {
01977     _papi_hwi_cleanup_all_presets(  );
01978 
01979     _papi_hwi_cleanup_errors( );
01980 
01981     _papi_hwi_lock( INTERNAL_LOCK );
01982 
01983     papi_free(  _papi_hwi_system_info.global_eventset_map.dataSlotArray );
01984     memset(  &_papi_hwi_system_info.global_eventset_map, 
01985          0x00, sizeof ( DynamicArray_t ) );
01986 
01987     _papi_hwi_unlock( INTERNAL_LOCK );
01988 
01989     if ( _papi_hwi_system_info.shlib_info.map ) {
01990         papi_free( _papi_hwi_system_info.shlib_info.map );
01991     }
01992     memset( &_papi_hwi_system_info, 0x0, sizeof ( _papi_hwi_system_info ) );
01993 
01994 }

Here is the call graph for this function:

Here is the caller graph for this function:

char* _papi_hwi_strip_component_prefix ( char *  event_name  ) 

Definition at line 295 of file papi_internal.c.

00296 {
00297     char *start = NULL;
00298 /* We assume ::: is the seperator 
00299  * eg: 
00300  *      papi_component:::event_name 
00301  */
00302 
00303     start = strstr( event_name, ":::" );
00304     if ( start != NULL )
00305         start+= 3; /* return the actual start of event_name */
00306     else
00307         start = event_name;
00308 
00309     return (start);
00310 }

Here is the caller graph for this function:

static int add_EventSet ( EventSetInfo_t ESI,
ThreadInfo_t master 
) [static]

Definition at line 885 of file papi_internal.c.

00886 {
00887     DynamicArray_t *map = &_papi_hwi_system_info.global_eventset_map;
00888     int i, errorCode;
00889 
00890     _papi_hwi_lock( INTERNAL_LOCK );
00891 
00892     if ( map->availSlots == 0 ) {
00893         errorCode = expand_dynamic_array( map );
00894         if ( errorCode < PAPI_OK ) {
00895             _papi_hwi_unlock( INTERNAL_LOCK );
00896             return ( errorCode );
00897         }
00898     }
00899 
00900     i = 0;
00901     for ( i = 0; i < map->totalSlots; i++ ) {
00902         if ( map->dataSlotArray[i] == NULL ) {
00903             ESI->master = master;
00904             ESI->EventSetIndex = i;
00905             map->fullSlots++;
00906             map->availSlots--;
00907             map->dataSlotArray[i] = ESI;
00908             _papi_hwi_unlock( INTERNAL_LOCK );
00909             return ( PAPI_OK );
00910         }
00911     }
00912 
00913     _papi_hwi_unlock( INTERNAL_LOCK );
00914     return ( PAPI_EBUG );
00915 }

Here is the call graph for this function:

Here is the caller graph for this function:

static int add_native_events ( EventSetInfo_t ESI,
unsigned int *  nevt,
int  size,
EventInfo_t out 
) [static]

Definition at line 1213 of file papi_internal.c.

01215 {
01216     INTDBG ("ENTER: ESI: %p, nevt: %p, size: %d, out: %p\n", ESI, nevt, size, out);
01217    int nidx, i, j, added_events = 0;
01218    int retval, retval2;
01219    int max_counters;
01220    hwd_context_t *context;
01221 
01222    max_counters = _papi_hwd[ESI->CmpIdx]->cmp_info.num_mpx_cntrs;
01223 
01224    /* Walk through the list of native events, adding them */
01225    for( i = 0; i < size; i++ ) {
01226 
01227       /* Check to see if event is already in EventSet */
01228       nidx = event_already_in_eventset( ESI, nevt[i] );
01229 
01230       if ( nidx >= 0 ) {
01231      /* Event is already there.  Set position */
01232      out->pos[i] = ESI->NativeInfoArray[nidx].ni_position;
01233      ESI->NativeInfoArray[nidx].ni_owners++;
01234      continue;
01235       }
01236 
01237      /* Event wasn't already there */
01238 
01239      if ( ESI->NativeCount == max_counters ) {
01240 
01241         /* No more room in counters! */
01242         for( j = 0; j < i; j++ ) {
01243            if ( ( nidx = add_native_fail_clean( ESI, nevt[j] ) ) >= 0 ) {
01244           out->pos[j] = -1;
01245           continue;
01246            }
01247            INTDBG( "should not happen!\n" );
01248         }
01249         INTDBG( "EXIT: counters are full!\n" );
01250         return PAPI_ECOUNT;
01251      }
01252             
01253         /* there is an empty slot for the native event; */
01254         /* initialize the native index for the new added event */
01255         INTDBG( "Adding nevt[%d]: %#x, ESI->NativeInfoArray[%d]: %p, Component: %d\n",
01256             i, nevt[i], ESI->NativeCount, &ESI->NativeInfoArray[ESI->NativeCount], ESI->CmpIdx );
01257         ESI->NativeInfoArray[ESI->NativeCount].ni_event = 
01258               _papi_hwi_eventcode_to_native(nevt[i]);
01259         ESI->NativeInfoArray[ESI->NativeCount].ni_papi_code = nevt[i];
01260 
01261         ESI->NativeInfoArray[ESI->NativeCount].ni_owners = 1;
01262         ESI->NativeCount++;
01263         added_events++;
01264    }
01265 
01266    INTDBG("added_events: %d\n", added_events);
01267 
01268    /* if we added events we need to tell the component so it */
01269    /* can add them too.                                      */
01270    if ( added_events ) {
01271       /* get the context we should use for this event set */
01272       context = _papi_hwi_get_context( ESI, NULL );
01273        
01274       if ( _papi_hwd[ESI->CmpIdx]->allocate_registers( ESI ) == PAPI_OK ) {
01275 
01276      retval = _papi_hwd[ESI->CmpIdx]->update_control_state( ESI->ctl_state,
01277           ESI->NativeInfoArray,
01278           ESI->NativeCount,
01279           context);
01280      if ( retval != PAPI_OK ) {
01281 clean:
01282         for( i = 0; i < size; i++ ) {
01283            if ( ( nidx = add_native_fail_clean( ESI, nevt[i] ) ) >= 0 ) {
01284           out->pos[i] = -1;
01285           continue;
01286            }
01287            INTDBG( "should not happen!\n" );
01288         }
01289         /* re-establish the control state after the previous error */
01290         retval2 = _papi_hwd[ESI->CmpIdx]->update_control_state( 
01291                        ESI->ctl_state,
01292                ESI->NativeInfoArray,
01293                ESI->NativeCount,
01294                context);
01295         if ( retval2 != PAPI_OK ) {
01296            PAPIERROR("update_control_state failed to re-establish working events!" );
01297            INTDBG( "EXIT: update_control_state returned: %d\n", retval2);
01298            return retval2;
01299         }
01300         INTDBG( "EXIT: update_control_state returned: %d\n", retval);
01301         return retval;
01302      }
01303      INTDBG( "EXIT: update_control_state returned: %d, we return: 1 (need remap)\n", retval);
01304      return 1; /* need remap */
01305       } else {
01306      retval = PAPI_EMISC;
01307      goto clean;
01308       }
01309    }
01310    INTDBG( "EXIT: PAPI_OK\n");
01311    return PAPI_OK;
01312 }

Here is the call graph for this function:

Here is the caller graph for this function:

static int add_native_fail_clean ( EventSetInfo_t ESI,
int  nevt 
) [static]

Definition at line 1149 of file papi_internal.c.

01150 {
01151     INTDBG("ENTER: ESI: %p, nevt: %#x\n", ESI, nevt);
01152 
01153    int i, max_counters;
01154    int cidx;
01155 
01156    cidx = _papi_hwi_component_index( nevt );
01157    if (cidx<0) return PAPI_ENOCMP;
01158 
01159    max_counters = _papi_hwd[cidx]->cmp_info.num_mpx_cntrs;
01160 
01161    /* to find the native event from the native events list */
01162    for( i = 0; i < max_counters; i++ ) {
01163 //     INTDBG("ESI->NativeInfoArray[%d]: %p, ni_event: %#x, ni_papi_event_code: %#x, ni_position: %d, ni_owners: %d\n",
01164 //             i, &(ESI->NativeInfoArray[i]), ESI->NativeInfoArray[i].ni_event, ESI->NativeInfoArray[i].ni_papi_code, ESI->NativeInfoArray[i].ni_position, ESI->NativeInfoArray[i].ni_owners);
01165      if ( nevt == ESI->NativeInfoArray[i].ni_papi_code ) {
01166      ESI->NativeInfoArray[i].ni_owners--;
01167      /* to clean the entry in the nativeInfo array */
01168      if ( ESI->NativeInfoArray[i].ni_owners == 0 ) {
01169         ESI->NativeInfoArray[i].ni_event = -1;
01170         ESI->NativeInfoArray[i].ni_position = -1;
01171         ESI->NativeInfoArray[i].ni_papi_code = -1;
01172         ESI->NativeCount--;
01173      }
01174      INTDBG( "EXIT: nevt: %#x, returned: %d\n", nevt, i);
01175      return i;
01176       }
01177    }
01178     INTDBG( "EXIT: returned: -1\n");
01179    return -1;
01180 }

Here is the call graph for this function:

Here is the caller graph for this function:

static int allocate_eventset_map ( DynamicArray_t map  )  [static]

Definition at line 654 of file papi_internal.c.

00655 {
00656     /* Allocate and clear the Dynamic Array structure */
00657     if ( map->dataSlotArray != NULL )
00658         papi_free( map->dataSlotArray );
00659     memset( map, 0x00, sizeof ( DynamicArray_t ) );
00660 
00661     /* Allocate space for the EventSetInfo_t pointers */
00662 
00663     map->dataSlotArray =
00664         ( EventSetInfo_t ** ) papi_malloc( PAPI_INIT_SLOTS *
00665                                            sizeof ( EventSetInfo_t * ) );
00666     if ( map->dataSlotArray == NULL ) {
00667         return ( PAPI_ENOMEM );
00668     }
00669     memset( map->dataSlotArray, 0x00,
00670             PAPI_INIT_SLOTS * sizeof ( EventSetInfo_t * ) );
00671     map->totalSlots = PAPI_INIT_SLOTS;
00672     map->availSlots = PAPI_INIT_SLOTS;
00673     map->fullSlots = 0;
00674 
00675     return ( PAPI_OK );
00676 }

Here is the caller graph for this function:

static int create_EventSet ( EventSetInfo_t **  here  )  [static]

Definition at line 726 of file papi_internal.c.

00727 {
00728    EventSetInfo_t *ESI;
00729 
00730    ESI = ( EventSetInfo_t * ) papi_calloc( 1, sizeof ( EventSetInfo_t ) );
00731    if ( ESI == NULL ) {
00732       return PAPI_ENOMEM;
00733    }
00734 
00735    *here = ESI;
00736 
00737    return PAPI_OK;
00738 }

Here is the caller graph for this function:

static int default_debug_handler ( int  errorCode  )  [static]

Definition at line 615 of file papi_internal.c.

00616 {
00617     char str[PAPI_HUGE_STR_LEN];
00618 
00619     if ( errorCode == PAPI_OK )
00620         return ( errorCode );
00621     if ( ( errorCode > 0 ) || ( -errorCode > _papi_hwi_num_errors ) ) {
00622         PAPIERROR( "%s %d,%s,Bug! Unknown error code", PAPI_ERROR_CODE_str,
00623                    errorCode, "" );
00624         return ( PAPI_EBUG );
00625     }
00626 
00627     switch ( _papi_hwi_error_level ) {
00628     case PAPI_VERB_ECONT:
00629     case PAPI_VERB_ESTOP:
00630         /* gcc 2.96 bug fix, do not change */
00631         /* fprintf(stderr,"%s %d: %s: %s\n",PAPI_ERROR_CODE_str,errorCode,_papi_hwi_err[-errorCode].name,_papi_hwi_err[-errorCode].descr); */
00632 
00633         sprintf( str, "%s %d,%s", PAPI_ERROR_CODE_str, errorCode,
00634                  _papi_errlist[-errorCode] );
00635         if ( errorCode == PAPI_ESYS )
00636             sprintf( str + strlen( str ), ": %s", strerror( errno ) );
00637 
00638         PAPIERROR( str );
00639 
00640         if ( _papi_hwi_error_level == PAPI_VERB_ESTOP )
00641             abort(  );       /* patch provided by will cohen of redhat */
00642         else
00643             return errorCode;
00644         break;
00645 
00646     case PAPI_QUIET:
00647     default:
00648         return errorCode;
00649     }
00650     return ( PAPI_EBUG );    /* Never get here */
00651 }

Here is the call graph for this function:

static int event_already_in_eventset ( EventSetInfo_t ESI,
int  papi_event 
) [static]

Definition at line 1032 of file papi_internal.c.

01033 {
01034    INTDBG( "ENTER: ESI: %p, papi_event: %#x\n", ESI, papi_event);
01035    int i;
01036 
01037    int nevt = _papi_hwi_eventcode_to_native(papi_event);
01038 
01039    /* to find the native event from the native events list */
01040    for( i = 0; i < ESI->NativeCount; i++ ) {
01041       if ( nevt == ESI->NativeInfoArray[i].ni_event ) {
01042          // Also need to check papi event code if set because the same event with different masks
01043          // will generate the same libpfm4 event code (what was checked above).  But there will be
01044          // different papi events created for it and they need to be handled separately.
01045          if (papi_event == ESI->NativeInfoArray[i].ni_papi_code) {
01046             INTDBG( "EXIT: event: %#x already mapped at index: %d\n", papi_event, i);
01047             return i;
01048          }
01049       }
01050    }
01051    INTDBG( "EXIT: PAPI_ENOEVNT\n");
01052    return PAPI_ENOEVNT;
01053 }

Here is the call graph for this function:

Here is the caller graph for this function:

static int EventInfoArrayLength ( const EventSetInfo_t ESI  )  [static]

Definition at line 707 of file papi_internal.c.

00708 {
00709    return ( _papi_hwd[ESI->CmpIdx]->cmp_info.num_mpx_cntrs );
00710 }

Here is the caller graph for this function:

static int expand_dynamic_array ( DynamicArray_t DA  )  [static]

Definition at line 679 of file papi_internal.c.

00680 {
00681     int number;
00682     EventSetInfo_t **n;
00683 
00684     /*realloc existing PAPI_EVENTSET_MAP.dataSlotArray */
00685 
00686     number = DA->totalSlots * 2;
00687     n = ( EventSetInfo_t ** ) papi_realloc( DA->dataSlotArray,
00688                                             ( size_t ) number *
00689                                             sizeof ( EventSetInfo_t * ) );
00690     if ( n == NULL )
00691         return ( PAPI_ENOMEM );
00692 
00693     /* Need to assign this value, what if realloc moved it? */
00694 
00695     DA->dataSlotArray = n;
00696 
00697     memset( DA->dataSlotArray + DA->totalSlots, 0x00,
00698             ( size_t ) DA->totalSlots * sizeof ( EventSetInfo_t * ) );
00699 
00700     DA->totalSlots = number;
00701     DA->availSlots = number - DA->fullSlots;
00702 
00703     return ( PAPI_OK );
00704 }

Here is the caller graph for this function:

static int get_free_EventCodeIndex ( const EventSetInfo_t ESI,
unsigned int  EventCode 
) [static]

Definition at line 961 of file papi_internal.c.

00962 {
00963     int k;
00964     int lowslot = PAPI_ECNFLCT;
00965     int limit = EventInfoArrayLength( ESI );
00966 
00967     /* Check for duplicate events and get the lowest empty slot */
00968 
00969     for ( k = 0; k < limit; k++ ) {
00970         if ( ESI->EventInfoArray[k].event_code == EventCode )
00971             return ( PAPI_ECNFLCT );
00972         /*if ((ESI->EventInfoArray[k].event_code == PAPI_NULL) && (lowslot == PAPI_ECNFLCT)) */
00973         if ( ESI->EventInfoArray[k].event_code == ( unsigned int ) PAPI_NULL ) {
00974             lowslot = k;
00975             break;
00976         }
00977     }
00978     return ( lowslot );
00979 }

Here is the call graph for this function:

Here is the caller graph for this function:

static long long handle_derived ( EventInfo_t evi,
long long *  from 
) [static]

Definition at line 2153 of file papi_internal.c.

02154 {
02155     INTDBG("ENTER: evi: %p, evi->derived: %d, from: %p\n", evi, evi->derived, from);
02156     switch ( evi->derived ) {
02157     case DERIVED_ADD:
02158         return ( handle_derived_add( evi->pos, from ) );
02159     case DERIVED_ADD_PS:
02160         return ( handle_derived_add_ps( evi->pos, from ) );
02161     case DERIVED_SUB:
02162         return ( handle_derived_subtract( evi->pos, from ) );
02163     case DERIVED_PS:
02164         return ( handle_derived_ps( evi->pos, from ) );
02165     case DERIVED_POSTFIX:
02166         return ( _papi_hwi_postfix_calc( evi, from ) );
02167     case DERIVED_CMPD:       /* This type has existed for a long time, but was never implemented.
02168                                 Probably because its a no-op. However, if it's in a header, it
02169                                 should be supported. As I found out when I implemented it in 
02170                                 Pentium 4 for testing...dkt */
02171         return ( from[evi->pos[0]] );
02172     default:
02173         PAPIERROR( "BUG! Unknown derived command %d, returning 0", evi->derived );
02174         INTDBG("EXIT: Unknown derived command %d\n", evi->derived);
02175         return ( ( long long ) 0 );
02176     }
02177 }

Here is the call graph for this function:

Here is the caller graph for this function:

static long long handle_derived_add ( int *  position,
long long *  from 
) [static]

Definition at line 2011 of file papi_internal.c.

02012 {
02013     int pos, i;
02014     long long retval = 0;
02015 
02016     i = 0;
02017     while ( i < PAPI_EVENTS_IN_DERIVED_EVENT ) {
02018         pos = position[i++];
02019         if ( pos == PAPI_NULL )
02020             break;
02021         INTDBG( "Compound event, adding %lld to %lld\n", from[pos], retval );
02022         retval += from[pos];
02023     }
02024     return ( retval );
02025 }

Here is the caller graph for this function:

static long long handle_derived_add_ps ( int *  position,
long long *  from 
) [static]

Definition at line 2058 of file papi_internal.c.

02059 {
02060     long long tmp = handle_derived_add( position + 1, from );
02061     return ( units_per_second( tmp, from[position[0]] ) );
02062 }

Here is the call graph for this function:

Here is the caller graph for this function:

static long long handle_derived_ps ( int *  position,
long long *  from 
) [static]

Definition at line 2053 of file papi_internal.c.

02054 {
02055     return ( units_per_second( from[position[1]], from[position[0]] ) );
02056 }

Here is the call graph for this function:

Here is the caller graph for this function:

static long long handle_derived_subtract ( int *  position,
long long *  from 
) [static]

Definition at line 2028 of file papi_internal.c.

02029 {
02030     int pos, i;
02031     long long retval = from[position[0]];
02032 
02033     i = 1;
02034     while ( i < PAPI_EVENTS_IN_DERIVED_EVENT ) {
02035         pos = position[i++];
02036         if ( pos == PAPI_NULL )
02037             break;
02038         INTDBG( "Compound event, subtracting pos=%d  %lld from %lld\n", pos,
02039                 from[pos], retval );
02040         retval -= from[pos];
02041     }
02042     return ( retval );
02043 }

Here is the caller graph for this function:

static int is_supported_by_component ( int  cidx,
char *  event_name 
) [static]

Definition at line 173 of file papi_internal.c.

00173                                                       {
00174     INTDBG("ENTER: cidx: %d, event_name: %s\n", cidx, event_name);
00175     int i;
00176     int component_name = 0;
00177     int pmu_name = 0;
00178     char *wptr = NULL;
00179 
00180     // if event does not have a component name or pmu name, return to show it could be supported by this component
00181     // when component and pmu names are not provided, we just have to call the components to see if they recognize the event
00182     //
00183 
00184     // look for component names first
00185     if ((wptr = strstr(event_name, ":::")) != NULL) {
00186         component_name = 1;
00187     } else if ((wptr = strstr(event_name, "::")) != NULL) {
00188         pmu_name = 1;
00189     } else {
00190         INTDBG("EXIT: No Component or PMU name in event string, try this component\n");
00191         // need to force all components to be called to find owner of this event
00192         // ????  can we assume the default pmu when no component or pmu name is provided ????
00193         return 1;
00194     }
00195 
00196     // get a temporary copy of the component or pmu name
00197     int name_len = wptr - event_name;
00198     wptr = strdup(event_name);
00199     wptr[name_len] = '\0';
00200 
00201     // if a component name was found, compare it to the component name in the component info structure
00202     if (component_name) {
00203 //      INTDBG("component_name: %s\n", _papi_hwd[cidx]->cmp_info.name);
00204         if (strcmp (wptr, _papi_hwd[cidx]->cmp_info.name) == 0) {
00205             free (wptr);
00206             INTDBG("EXIT: Component %s supports this event\n", _papi_hwd[cidx]->cmp_info.name);
00207             return 1;
00208         }
00209     }
00210 
00211     // if a pmu name was found, compare it to the pmu name list if the component info structure (if there is one)
00212     if (pmu_name) {
00213         for ( i=0 ; i<PAPI_PMU_MAX ; i++) {
00214             if (_papi_hwd[cidx]->cmp_info.pmu_names[i] == NULL) {
00215                 continue;
00216             }
00217 //          INTDBG("pmu_name[%d]: %p (%s)\n", i, _papi_hwd[cidx]->cmp_info.pmu_names[i], _papi_hwd[cidx]->cmp_info.pmu_names[i]);
00218             if (strcmp (wptr, _papi_hwd[cidx]->cmp_info.pmu_names[i]) == 0) {
00219                 INTDBG("EXIT: Component %s supports PMU %s and this event\n", _papi_hwd[cidx]->cmp_info.name, wptr);
00220                 free (wptr);
00221                 return 1;
00222             }
00223         }
00224     }
00225 
00226     free (wptr);
00227     INTDBG("EXIT: Component does not support this event\n");
00228     return 0;
00229 }

Here is the caller graph for this function:

void PAPIERROR ( char *  format,
  ... 
)

Definition at line 601 of file papi_internal.c.

00602 {
00603     va_list args;
00604     if ( ( _papi_hwi_error_level != PAPI_QUIET ) ||
00605          ( getenv( "PAPI_VERBOSE" ) ) ) {
00606         va_start( args, format );
00607         fprintf( stderr, "\nPAPI Error: " );
00608         vfprintf( stderr, format, args );
00609         fprintf( stderr, ".\n" );
00610         va_end( args );
00611     }
00612 }

Here is the call graph for this function:

static int remove_native_events ( EventSetInfo_t ESI,
int *  nevt,
int  size 
) [static]

Definition at line 1509 of file papi_internal.c.

01510 {
01511     INTDBG( "Entry: ESI: %p, nevt: %p, size: %d\n", ESI, nevt, size);
01512    NativeInfo_t *native = ESI->NativeInfoArray;
01513    hwd_context_t *context;
01514    int i, j, zero = 0, retval;
01515 
01516    /* Remove the references to this event from the native events:
01517       for all the metrics in this event,
01518       compare to each native event in this event set,
01519       and decrement owners if they match  */
01520    for( i = 0; i < size; i++ ) {
01521     int cevt = _papi_hwi_eventcode_to_native(nevt[i]);
01522 //  INTDBG( "nevt[%d]: %#x, cevt: %#x\n", i, nevt[i], cevt);
01523       for( j = 0; j < ESI->NativeCount; j++ ) {
01524      if ((native[j].ni_event == cevt)  &&  (native[j].ni_papi_code == nevt[i]) ) {
01525 //      INTDBG( "native[%d]: %p, ni_papi_code: %#x, ni_event: %#x, ni_position: %d, ni_owners: %d\n", 
01526 //          j, &(native[j]), native[j].ni_papi_code, native[j].ni_event, native[j].ni_position, native[j].ni_owners);
01527         native[j].ni_owners--;
01528         if ( native[j].ni_owners == 0 ) {
01529            zero++;
01530         }
01531         break;
01532      }
01533       }
01534    }
01535 
01536    /* Remove any native events from the array if owners dropped to zero.
01537       The NativeInfoArray must be dense, with no empty slots, so if we
01538       remove an element, we must compact the list */
01539    for( i = 0; i < ESI->NativeCount; i++ ) {
01540 
01541       if ( native[i].ni_event == -1 ) continue;
01542 
01543       if ( native[i].ni_owners == 0 ) {
01544      int copy = 0;
01545      int sz = _papi_hwd[ESI->CmpIdx]->size.reg_value;
01546      for( j = ESI->NativeCount - 1; j > i; j-- ) {
01547         if ( native[j].ni_event == -1 || native[j].ni_owners == 0 ) continue;
01548         else {
01549            /* copy j into i */
01550            native[i].ni_event = native[j].ni_event;
01551            native[i].ni_position = native[j].ni_position;
01552            native[i].ni_owners = native[j].ni_owners;
01553            /* copy opaque [j].ni_bits to [i].ni_bits */
01554            memcpy( native[i].ni_bits, native[j].ni_bits, ( size_t ) sz );
01555            /* reset j to initialized state */
01556            native[j].ni_event = -1;
01557            native[j].ni_position = -1;
01558            native[j].ni_owners = 0;
01559            copy++;
01560            break;
01561         }
01562      }
01563 
01564      if ( copy == 0 ) {
01565         /* set this structure back to empty state */
01566         /* ni_owners is already 0 and contents of ni_bits doesn't matter */
01567         native[i].ni_event = -1;
01568         native[i].ni_position = -1;
01569      }
01570       }
01571    }
01572 
01573     INTDBG( "ESI->NativeCount: %d, zero: %d\n", ESI->NativeCount, zero);
01574 
01575    /* to reset hwd_control_state values */
01576    ESI->NativeCount -= zero;
01577 
01578    /* If we removed any elements, 
01579       clear the now empty slots, reinitialize the index, and update the count.
01580       Then send the info down to the component to update the hwd control structure. */
01581     retval = PAPI_OK;
01582     if ( zero ) {
01583       /* get the context we should use for this event set */
01584       context = _papi_hwi_get_context( ESI, NULL );
01585         retval = _papi_hwd[ESI->CmpIdx]->update_control_state( ESI->ctl_state,
01586                                                           native, ESI->NativeCount, context);
01587         if ( retval == PAPI_OK )
01588             retval = update_overflow( ESI );
01589     }
01590     return ( retval );
01591 }

Here is the call graph for this function:

Here is the caller graph for this function:

static long long units_per_second ( long long  units,
long long  cycles 
) [static]

Definition at line 2046 of file papi_internal.c.

02047 {
02048    return ( ( units * (long long) _papi_hwi_system_info.hw_info.cpu_max_mhz *
02049               (long long) 1000000 ) / cycles );
02050 }

Here is the caller graph for this function:

static int update_overflow ( EventSetInfo_t ESI  )  [static]

Definition at line 1185 of file papi_internal.c.

01186 {
01187    int i, retval = PAPI_OK;
01188 
01189    if ( ESI->overflow.flags & PAPI_OVERFLOW_HARDWARE ) {
01190       for( i = 0; i < ESI->overflow.event_counter; i++ ) {
01191      retval = _papi_hwd[ESI->CmpIdx]->set_overflow( ESI,
01192                             ESI->overflow.EventIndex[i],
01193                             ESI->overflow.threshold[i] );
01194      if ( retval != PAPI_OK ) {
01195         break;
01196      }
01197       }
01198    }
01199    return retval;
01200 }

Here is the caller graph for this function:


Variable Documentation

char** _papi_errlist = NULL

Definition at line 81 of file papi_internal.c.

Definition at line 55 of file papi_internal.c.

Initial value:
 {
  {NOT_DERIVED, "NOT_DERIVED", "Do nothing"},
  {DERIVED_ADD, "DERIVED_ADD", "Add counters"},
  {DERIVED_PS, "DERIVED_PS",
   "Divide by the cycle counter and convert to seconds"},
  {DERIVED_ADD_PS, "DERIVED_ADD_PS",
   "Add 2 counters then divide by the cycle counter and xl8 to secs."},
  {DERIVED_CMPD, "DERIVED_CMPD",
   "Event lives in first counter but takes 2 or more codes"},
  {DERIVED_SUB, "DERIVED_SUB", "Sub all counters from first counter"},
  {DERIVED_POSTFIX, "DERIVED_POSTFIX",
   "Process counters based on specified postfix string"},
  {DERIVED_INFIX, "DERIVED_INFIX",
   "Process counters based on specified infix string"},
  {-1, NULL, NULL}
}

Definition at line 2183 of file papi_internal.c.

int _papi_hwi_errno = PAPI_OK

Definition at line 57 of file papi_internal.c.

int _papi_hwi_error_level = PAPI_QUIET

Definition at line 54 of file papi_internal.c.

Definition at line 58 of file papi_internal.c.

Definition at line 56 of file papi_internal.c.

struct native_event_info* _papi_native_events = NULL [static]

Definition at line 77 of file papi_internal.c.

int init_level = PAPI_NOT_INITED

Definition at line 53 of file papi_internal.c.

int num_error_chunks = 0 [static]

Definition at line 82 of file papi_internal.c.

int num_native_chunks = 0 [static]

Definition at line 79 of file papi_internal.c.

int num_native_events = 0 [static]

Definition at line 78 of file papi_internal.c.

unsigned int papi_event_code = -1 [static]

Definition at line 116 of file papi_internal.c.

int papi_event_code_changed = -1 [static]

Definition at line 117 of file papi_internal.c.

char* papi_event_string = NULL

Definition at line 88 of file papi_internal.c.

int papi_num_components = ( sizeof ( _papi_hwd ) / sizeof ( *_papi_hwd ) ) - 1

Definition at line 1900 of file papi_internal.c.

hwi_presets_t user_defined_events[PAPI_MAX_USER_EVENTS]

Definition at line 59 of file papi_internal.c.

Definition at line 60 of file papi_internal.c.


Generated on 17 Nov 2016 for PAPI by  doxygen 1.6.1