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 65 of file papi_internal.c.


Function Documentation

static int _papi_hwi_add_error ( char *  error  )  [static]

Definition at line 392 of file papi_internal.c.

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

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 1315 of file papi_internal.c.

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

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 347 of file papi_internal.c.

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

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 740 of file papi_internal.c.

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

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 419 of file papi_internal.c.

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

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 1729 of file papi_internal.c.

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

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_hwi_component_index ( int  event_code  ) 

Definition at line 514 of file papi_internal.c.

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

Here is the caller graph for this function:

int _papi_hwi_convert_eventset_to_multiplex ( _papi_int_multiplex_t mpx  ) 

Definition at line 1841 of file papi_internal.c.

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

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 917 of file papi_internal.c.

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

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 2228 of file papi_internal.c.

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

Here is the caller graph for this function:

int _papi_hwi_derived_type ( char *  tmp,
int *  code 
)

Definition at line 2207 of file papi_internal.c.

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

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 1998 of file papi_internal.c.

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

Here is the caller graph for this function:

int _papi_hwi_eventcode_to_native ( int  event_code  ) 

Definition at line 575 of file papi_internal.c.

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

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 313 of file papi_internal.c.

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

Here is the caller graph for this function:

void _papi_hwi_free_EventSet ( EventSetInfo_t ESI  ) 

Definition at line 872 of file papi_internal.c.

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

Here is the call graph for this function:

Here is the caller graph for this function:

void _papi_hwi_free_papi_event_string (  ) 

Definition at line 106 of file papi_internal.c.

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

Here is the caller graph for this function:

hwd_context_t* _papi_hwi_get_context ( EventSetInfo_t ESI,
int *  is_dirty 
)

Definition at line 2651 of file papi_internal.c.

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

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 2534 of file papi_internal.c.

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

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_hwi_get_ntv_idx ( unsigned int  papi_evt_code  ) 

Definition at line 141 of file papi_internal.c.

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

Here is the caller graph for this function:

unsigned int _papi_hwi_get_papi_event_code ( void   ) 

Definition at line 135 of file papi_internal.c.

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

Here is the caller graph for this function:

char* _papi_hwi_get_papi_event_string ( void   ) 

Definition at line 101 of file papi_internal.c.

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

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 2251 of file papi_internal.c.

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

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 2311 of file papi_internal.c.

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

Here is the call graph for this function:

Here is the caller graph for this function:

void _papi_hwi_init_errors ( void   ) 

Definition at line 477 of file papi_internal.c.

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

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 1907 of file papi_internal.c.

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

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 1950 of file papi_internal.c.

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

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_hwi_invalid_cmp ( int  cidx  ) 

Definition at line 507 of file papi_internal.c.

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

Here is the caller graph for this function:

int _papi_hwi_is_sw_multiplex ( EventSetInfo_t ESI  ) 

Definition at line 2627 of file papi_internal.c.

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

Here is the caller graph for this function:

static int _papi_hwi_lookup_error ( char *  error  )  [static]

Definition at line 443 of file papi_internal.c.

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

Here is the caller graph for this function:

int _papi_hwi_lookup_EventCodeIndex ( const EventSetInfo_t ESI,
unsigned int  EventCode 
)

Definition at line 985 of file papi_internal.c.

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

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 2608 of file papi_internal.c.

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

Here is the caller graph for this function:

void _papi_hwi_map_events_to_native ( EventSetInfo_t ESI  ) 

Definition at line 1065 of file papi_internal.c.

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

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 2496 of file papi_internal.c.

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

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 2403 of file papi_internal.c.

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

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 552 of file papi_internal.c.

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

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 2072 of file papi_internal.c.

02073 {
02074     INTDBG("ENTER: evi: %p, evi->ops: %p (%s), evi->pos[0]: %d, evi->pos[1]: %d, hw_counter: %p (%lld %lld)\n", evi, evi->ops, evi->ops, evi->pos[0], evi->pos[1], hw_counter, hw_counter[0], hw_counter[1]);
02075     char *point = evi->ops, operand[16];
02076     double stack[PAPI_EVENTS_IN_DERIVED_EVENT];
02077     int i, top = 0;
02078 
02079     memset(&stack,0,PAPI_EVENTS_IN_DERIVED_EVENT*sizeof(double));
02080 
02081     while ( *point != '\0' ) {
02082         if ( *point == '|' ) {  /* ignore leading and consecutive '|' characters */
02083             point++;
02084         } else if ( *point == 'N' ) {   /* to get count for each native event */
02085             i = 0;
02086             point++;
02087             do {
02088                 operand[i] = *point;
02089                 point++;
02090                 i++;
02091             } while ( *point != '|' );
02092             operand[i] = '\0';
02093             stack[top] = ( double ) hw_counter[evi->pos[atoi( operand )]];
02094             top++;
02095             point++;
02096         } else if ( *point == '#' ) {   /* to get mhz, ignore the rest char's */
02097             stack[top] = _papi_hwi_system_info.hw_info.cpu_max_mhz * 1000000.0;
02098             top++;
02099             do {
02100                 point++;
02101             } while ( *point != '|' );
02102             point++;
02103         } else if ( isdigit( *point ) ) {   /* to get integer, I suppose only integer will be used, 
02104                                                no error check here, please only use integer */
02105             i = 0;
02106             do {
02107                 operand[i] = *point;
02108                 point++;
02109                 i++;
02110             } while ( *point != '|' );
02111             operand[i] = '\0';
02112             stack[top] = atoi( operand );
02113             top++;
02114             point++;
02115         } else if ( *point == '+' ) {   /* + calculation */
02116             stack[top - 2] += stack[top - 1];
02117             top--;
02118             do {
02119                 point++;
02120             } while ( *point != '|' );
02121             point++;
02122         } else if ( *point == '-' ) {   /* - calculation */
02123             stack[top - 2] -= stack[top - 1];
02124             top--;
02125             do {
02126                 point++;
02127             } while ( *point != '|' );
02128             point++;
02129         } else if ( *point == '*' ) {   /* * calculation */
02130             stack[top - 2] *= stack[top - 1];
02131             top--;
02132             do {
02133                 point++;
02134             } while ( *point != '|' );
02135             point++;
02136         } else if ( *point == '/' ) {   /* / calculation */
02137             stack[top - 2] /= stack[top - 1];
02138             top--;
02139             do {
02140                 point++;
02141             } while ( *point != '|' );
02142             point++;
02143         } else {             /* do nothing */
02144             do {
02145                 point++;
02146             } while ( *point != '|' );
02147             point++;
02148         }
02149     }
02150     INTDBG("EXIT: stack[0]: %lld\n", (long long)stack[0]);
02151     return ( long long ) stack[0];
02152 }

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 243 of file papi_internal.c.

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

Here is the caller graph for this function:

int _papi_hwi_publish_error ( char *  error  ) 

Definition at line 466 of file papi_internal.c.

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

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 2372 of file papi_internal.c.

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

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 1676 of file papi_internal.c.

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

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 1593 of file papi_internal.c.

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

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 1003 of file papi_internal.c.

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

Here is the call graph for this function:

Here is the caller graph for this function:

void _papi_hwi_set_papi_event_code ( unsigned int  event_code,
int  update_flag 
)

Definition at line 118 of file papi_internal.c.

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

Here is the caller graph for this function:

void _papi_hwi_set_papi_event_string ( const char *  event_string  ) 

Definition at line 89 of file papi_internal.c.

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

Here is the caller graph for this function:

void _papi_hwi_shutdown_global_internal ( void   ) 

Definition at line 1974 of file papi_internal.c.

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

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 294 of file papi_internal.c.

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

Here is the caller graph for this function:

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

Definition at line 884 of file papi_internal.c.

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

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 1212 of file papi_internal.c.

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

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 1148 of file papi_internal.c.

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

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 653 of file papi_internal.c.

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

Here is the caller graph for this function:

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

Definition at line 725 of file papi_internal.c.

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

Here is the caller graph for this function:

static int default_debug_handler ( int  errorCode  )  [static]

Definition at line 614 of file papi_internal.c.

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

Here is the call graph for this function:

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

Definition at line 1031 of file papi_internal.c.

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

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 706 of file papi_internal.c.

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

Here is the caller graph for this function:

static int expand_dynamic_array ( DynamicArray_t DA  )  [static]

Definition at line 678 of file papi_internal.c.

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

Here is the caller graph for this function:

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

Definition at line 960 of file papi_internal.c.

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

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 2155 of file papi_internal.c.

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

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 2010 of file papi_internal.c.

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

Here is the caller graph for this function:

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

Definition at line 2057 of file papi_internal.c.

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

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 2052 of file papi_internal.c.

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

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 2027 of file papi_internal.c.

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

Here is the caller graph for this function:

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

Definition at line 172 of file papi_internal.c.

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

Here is the caller graph for this function:

void PAPIERROR ( char *  format,
  ... 
)

Definition at line 600 of file papi_internal.c.

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

Here is the call graph for this function:

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

Definition at line 1508 of file papi_internal.c.

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

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 2045 of file papi_internal.c.

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

Here is the caller graph for this function:

static int update_overflow ( EventSetInfo_t ESI  )  [static]

Definition at line 1184 of file papi_internal.c.

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

Here is the caller graph for this function:


Variable Documentation

char** _papi_errlist = NULL

Definition at line 80 of file papi_internal.c.

Definition at line 54 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 2185 of file papi_internal.c.

int _papi_hwi_errno = PAPI_OK

Definition at line 56 of file papi_internal.c.

int _papi_hwi_error_level = PAPI_QUIET

Definition at line 53 of file papi_internal.c.

Definition at line 57 of file papi_internal.c.

Definition at line 55 of file papi_internal.c.

struct native_event_info* _papi_native_events = NULL [static]

Definition at line 76 of file papi_internal.c.

int init_level = PAPI_NOT_INITED

Definition at line 52 of file papi_internal.c.

int num_error_chunks = 0 [static]

Definition at line 81 of file papi_internal.c.

int num_native_chunks = 0 [static]

Definition at line 78 of file papi_internal.c.

int num_native_events = 0 [static]

Definition at line 77 of file papi_internal.c.

unsigned int papi_event_code = -1 [static]

Definition at line 115 of file papi_internal.c.

int papi_event_code_changed = -1 [static]

Definition at line 116 of file papi_internal.c.

char* papi_event_string = NULL

Definition at line 87 of file papi_internal.c.

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

Definition at line 1899 of file papi_internal.c.

hwi_presets_t user_defined_events[PAPI_MAX_USER_EVENTS]

Definition at line 58 of file papi_internal.c.

Definition at line 59 of file papi_internal.c.


Generated on 26 Jan 2016 for PAPI by  doxygen 1.6.1