papi_libpfm_events.h File Reference

Include dependency graph for papi_libpfm_events.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  perf_event_attr

Defines

#define PERF_TYPE_RAW   4;

Functions

int _papi_libpfm_error (int pfm_error)
int _papi_libpfm_setup_presets (char *name, int type, int cidx)
int _papi_libpfm_ntv_enum_events (unsigned int *EventCode, int modifier)
int _papi_libpfm_ntv_name_to_code (char *ntv_name, unsigned int *EventCode)
int _papi_libpfm_ntv_code_to_name (unsigned int EventCode, char *name, int len)
int _papi_libpfm_ntv_code_to_descr (unsigned int EventCode, char *name, int len)
int _papi_libpfm_ntv_code_to_bits (unsigned int EventCode, hwd_register_t *bits)
int _papi_libpfm_ntv_code_to_bits_perfctr (unsigned int EventCode, hwd_register_t *bits)
int _papi_libpfm_shutdown (void)
int _papi_libpfm_init (papi_vector_t *my_vector, int cidx)
int _pfm_decode_native_event (unsigned int EventCode, unsigned int *event, unsigned int *umask)
unsigned int _pfm_convert_umask (unsigned int event, unsigned int umask)
int prepare_umask (unsigned int foo, unsigned int *values)
int _papi_libpfm_ntv_code_to_info (unsigned int EventCode, PAPI_event_info_t *info)
int _papi_libpfm_setup_counters (struct perf_event_attr *attr, hwd_register_t *ni_bits)

Define Documentation

#define PERF_TYPE_RAW   4;

Definition at line 47 of file papi_libpfm_events.h.


Function Documentation

int _papi_libpfm_error ( int  pfm_error  ) 

Definition at line 149 of file papi_libpfm3_events.c.

00150 {
00151     switch ( pfm_error ) {
00152         case PFMLIB_SUCCESS:        return PAPI_OK;         /* success */
00153         case PFMLIB_ERR_NOTSUPP:    return PAPI_ENOSUPP;    /* function not supported */
00154         case PFMLIB_ERR_INVAL:      return PAPI_EINVAL;     /* invalid parameters */
00155         case PFMLIB_ERR_NOINIT:     return PAPI_ENOINIT;    /* library was not initialized */
00156         case PFMLIB_ERR_NOTFOUND:   return PAPI_ENOEVNT;    /* event not found */
00157         case PFMLIB_ERR_NOASSIGN:   return PAPI_ECNFLCT;    /* cannot assign events to counters */
00158         case PFMLIB_ERR_FULL:       return PAPI_EBUF;       /* buffer is full or too small */
00159         case PFMLIB_ERR_EVTMANY:    return PAPI_EMISC;      /* event used more than once */
00160         case PFMLIB_ERR_MAGIC:      return PAPI_EBUG;       /* invalid library magic number */
00161         case PFMLIB_ERR_FEATCOMB:   return PAPI_ECOMBO;     /* invalid combination of features */
00162         case PFMLIB_ERR_EVTSET:     return PAPI_ENOEVST;    /* incompatible event sets */
00163         case PFMLIB_ERR_EVTINCOMP:  return PAPI_ECNFLCT;    /* incompatible event combination */
00164         case PFMLIB_ERR_TOOMANY:    return PAPI_ECOUNT;     /* too many events or unit masks */
00165         case PFMLIB_ERR_BADHOST:    return PAPI_ESYS;       /* not supported by host CPU */
00166         case PFMLIB_ERR_UMASK:      return PAPI_EATTR;      /* invalid or missing unit mask */
00167         case PFMLIB_ERR_NOMEM:      return PAPI_ENOMEM;     /* out of memory */
00168 
00169         /* Itanium only */
00170         case PFMLIB_ERR_IRRTOOBIG:      /* code range too big */
00171         case PFMLIB_ERR_IRREMPTY:       /* empty code range */
00172         case PFMLIB_ERR_IRRINVAL:       /* invalid code range */
00173         case PFMLIB_ERR_IRRTOOMANY:     /* too many code ranges */
00174         case PFMLIB_ERR_DRRINVAL:       /* invalid data range */
00175         case PFMLIB_ERR_DRRTOOMANY:     /* too many data ranges */
00176         case PFMLIB_ERR_IRRALIGN:       /* bad alignment for code range */
00177         case PFMLIB_ERR_IRRFLAGS:       /* code range missing flags */
00178         default:
00179             return PAPI_EINVAL;
00180     }
00181 }

Here is the caller graph for this function:

int _papi_libpfm_init ( papi_vector_t my_vector,
int  cidx 
)

Definition at line 442 of file papi_libpfm3_events.c.

00442                                                       {
00443 
00444    int retval;
00445    unsigned int ncnt;
00446    unsigned int version;
00447    char pmu_name[PAPI_MIN_STR_LEN];
00448 
00449 
00450    /* The following checks the version of the PFM library
00451       against the version PAPI linked to... */
00452    SUBDBG( "pfm_initialize()\n" );
00453    if ( ( retval = pfm_initialize(  ) ) != PFMLIB_SUCCESS ) {
00454       PAPIERROR( "pfm_initialize(): %s", pfm_strerror( retval ) );
00455       return PAPI_ESYS;
00456    }
00457 
00458    /* Get the libpfm3 version */
00459    SUBDBG( "pfm_get_version(%p)\n", &version );
00460    if ( pfm_get_version( &version ) != PFMLIB_SUCCESS ) {
00461       PAPIERROR( "pfm_get_version(%p): %s", version, pfm_strerror( retval ) );
00462       return PAPI_ESYS;
00463    }
00464 
00465    /* Set the version */
00466    sprintf( my_vector->cmp_info.support_version, "%d.%d",
00467         PFM_VERSION_MAJOR( version ), PFM_VERSION_MINOR( version ) );
00468 
00469    /* Complain if the compiled-against version doesn't match current version */
00470    if ( PFM_VERSION_MAJOR( version ) != PFM_VERSION_MAJOR( PFMLIB_VERSION ) ) {
00471       PAPIERROR( "Version mismatch of libpfm: compiled %#x vs. installed %#x\n",
00472                    PFM_VERSION_MAJOR( PFMLIB_VERSION ),
00473                    PFM_VERSION_MAJOR( version ) );
00474       return PAPI_ESYS;
00475    }
00476 
00477    /* Always initialize globals dynamically to handle forks properly. */
00478 
00479    _perfmon2_pfm_pmu_type = -1;
00480 
00481    /* Opened once for all threads. */
00482    SUBDBG( "pfm_get_pmu_type(%p)\n", &_perfmon2_pfm_pmu_type );
00483    if ( pfm_get_pmu_type( &_perfmon2_pfm_pmu_type ) != PFMLIB_SUCCESS ) {
00484       PAPIERROR( "pfm_get_pmu_type(%p): %s", _perfmon2_pfm_pmu_type,
00485                    pfm_strerror( retval ) );
00486       return PAPI_ESYS;
00487    }
00488 
00489    pmu_name[0] = '\0';
00490    if ( pfm_get_pmu_name( pmu_name, PAPI_MIN_STR_LEN ) != PFMLIB_SUCCESS ) {
00491       PAPIERROR( "pfm_get_pmu_name(%p,%d): %s", pmu_name, PAPI_MIN_STR_LEN,
00492                    pfm_strerror( retval ) );
00493       return PAPI_ESYS;
00494    }
00495    SUBDBG( "PMU is a %s, type %d\n", pmu_name, _perfmon2_pfm_pmu_type );
00496 
00497    /* Setup presets */
00498    retval = _papi_load_preset_table( pmu_name, _perfmon2_pfm_pmu_type, cidx );
00499    if ( retval )
00500       return retval;
00501 
00502    /* Fill in cmp_info */
00503 
00504    SUBDBG( "pfm_get_num_events(%p)\n", &ncnt );
00505    if ( ( retval = pfm_get_num_events( &ncnt ) ) != PFMLIB_SUCCESS ) {
00506       PAPIERROR( "pfm_get_num_events(%p): %s\n", &ncnt,
00507                    pfm_strerror( retval ) );
00508       return PAPI_ESYS;
00509    }
00510    SUBDBG( "pfm_get_num_events: %d\n", ncnt );
00511    my_vector->cmp_info.num_native_events = ncnt;
00512    num_native_events = ncnt;
00513 
00514    pfm_get_num_counters( ( unsigned int * ) &my_vector->cmp_info.num_cntrs );
00515    SUBDBG( "pfm_get_num_counters: %d\n", my_vector->cmp_info.num_cntrs );
00516 
00517 
00518    if ( _papi_hwi_system_info.hw_info.vendor == PAPI_VENDOR_INTEL ) {
00519      /* Pentium4 */
00520      if ( _papi_hwi_system_info.hw_info.cpuid_family == 15 ) {
00521        PAPI_NATIVE_EVENT_AND_MASK = 0x000000ff;
00522        PAPI_NATIVE_UMASK_AND_MASK = 0x0fffff00;
00523        PAPI_NATIVE_UMASK_SHIFT = 8;
00524        /* Itanium2 */
00525      } else if ( _papi_hwi_system_info.hw_info.cpuid_family == 31 ||
00526          _papi_hwi_system_info.hw_info.cpuid_family == 32 ) {
00527        PAPI_NATIVE_EVENT_AND_MASK = 0x00000fff;
00528        PAPI_NATIVE_UMASK_AND_MASK = 0x0ffff000;
00529        PAPI_NATIVE_UMASK_SHIFT = 12;
00530      }
00531    }
00532 
00533 
00534    return PAPI_OK;
00535 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_libpfm_ntv_code_to_bits ( unsigned int  EventCode,
hwd_register_t bits 
)

Definition at line 416 of file papi_libpfm3_events.c.

00417 {
00418     unsigned int event, umask;
00419     pfmlib_event_t gete;
00420 
00421     /* For PFM & Perfmon, native info is just an index into PFM event table. */
00422     if ( _pfm_decode_native_event( EventCode, &event, &umask ) != PAPI_OK )
00423        return PAPI_ENOEVNT;
00424 
00425     memset( &gete, 0x0, sizeof ( pfmlib_event_t ) );
00426 
00427     gete.event = event;
00428     gete.num_masks = prepare_umask( umask, gete.unit_masks );
00429 
00430     memcpy( bits, &gete, sizeof ( pfmlib_event_t ) );
00431 
00432     return PAPI_OK;
00433 
00434 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_libpfm_ntv_code_to_bits_perfctr ( unsigned int  EventCode,
hwd_register_t bits 
)

Definition at line 1015 of file perfctr-x86.c.

01017 {
01018     unsigned int event, umask;
01019 
01020     X86_register_t *bits = (X86_register_t *)newbits;
01021 
01022     if ( is_pentium4() ) {
01023        pentium4_escr_value_t escr_value;
01024        pentium4_cccr_value_t cccr_value;
01025        unsigned int num_masks, replay_mask, unit_masks[12];
01026        unsigned int event_mask;
01027        unsigned int tag_value, tag_enable;
01028        unsigned int i;
01029        int j, escr, cccr, pmd;
01030 
01031        if ( _pfm_decode_native_event( EventCode, &event, &umask ) != PAPI_OK )
01032       return PAPI_ENOEVNT;
01033 
01034        /* for each allowed escr (1 or 2) find the allowed cccrs.
01035       for each allowed cccr find the pmd index
01036       convert to an intel counter number; or it into bits->counter */
01037        for ( i = 0; i < MAX_ESCRS_PER_EVENT; i++ ) {
01038       bits->counter[i] = 0;
01039       escr = pentium4_events[event].allowed_escrs[i];
01040       if ( escr < 0 ) {
01041          continue;
01042       }
01043 
01044       bits->escr[i] = escr;
01045 
01046       for ( j = 0; j < MAX_CCCRS_PER_ESCR; j++ ) {
01047          cccr = pentium4_escrs[escr].allowed_cccrs[j];
01048          if ( cccr < 0 ) {
01049         continue;
01050          }
01051 
01052          pmd = pentium4_cccrs[cccr].pmd;
01053          bits->counter[i] |= ( 1 << pfm2intel[pmd] );
01054       }
01055        }
01056 
01057        /* if there's only one valid escr, copy the values */
01058        if ( escr < 0 ) {
01059       bits->escr[1] = bits->escr[0];
01060       bits->counter[1] = bits->counter[0];
01061        }
01062 
01063        /* Calculate the event-mask value. Invalid masks
01064     * specified by the caller are ignored. */
01065        tag_value = 0;
01066        tag_enable = 0;
01067        event_mask = _pfm_convert_umask( event, umask );
01068 
01069        if ( event_mask & 0xF0000 ) {
01070       tag_enable = 1;
01071       tag_value = ( ( event_mask & 0xF0000 ) >> EVENT_MASK_BITS );
01072        }
01073 
01074        event_mask &= 0x0FFFF;   /* mask off possible tag bits */
01075 
01076        /* Set up the ESCR and CCCR register values. */
01077        escr_value.val = 0;
01078        escr_value.bits.t1_usr = 0;  /* controlled by kernel */
01079        escr_value.bits.t1_os = 0;   /* controlled by kernel */
01080 //    escr_value.bits.t0_usr       = (plm & PFM_PLM3) ? 1 : 0;
01081 //    escr_value.bits.t0_os        = (plm & PFM_PLM0) ? 1 : 0;
01082        escr_value.bits.tag_enable = tag_enable;
01083        escr_value.bits.tag_value = tag_value;
01084        escr_value.bits.event_mask = event_mask;
01085        escr_value.bits.event_select = pentium4_events[event].event_select;
01086        escr_value.bits.reserved = 0;
01087 
01088        /* initialize the proper bits in the cccr register */
01089        cccr_value.val = 0;
01090        cccr_value.bits.reserved1 = 0;
01091        cccr_value.bits.enable = 1;
01092        cccr_value.bits.escr_select = pentium4_events[event].escr_select;
01093        cccr_value.bits.active_thread = 3;   
01094        /* FIXME: This is set to count when either logical
01095     *        CPU is active. Need a way to distinguish
01096     *        between logical CPUs when HT is enabled.
01097         *        the docs say these bits should always 
01098     *        be set.                                  */
01099        cccr_value.bits.compare = 0; 
01100        /* FIXME: What do we do with "threshold" settings? */
01101        cccr_value.bits.complement = 0;  
01102        /* FIXME: What do we do with "threshold" settings? */
01103        cccr_value.bits.threshold = 0;   
01104        /* FIXME: What do we do with "threshold" settings? */
01105        cccr_value.bits.force_ovf = 0;   
01106        /* FIXME: Do we want to allow "forcing" overflow
01107         *        interrupts on all counter increments? */
01108        cccr_value.bits.ovf_pmi_t0 = 0;
01109        cccr_value.bits.ovf_pmi_t1 = 0;  
01110        /* PMI taken care of by kernel typically */
01111        cccr_value.bits.reserved2 = 0;
01112        cccr_value.bits.cascade = 0; 
01113        /* FIXME: How do we handle "cascading" counters? */
01114        cccr_value.bits.overflow = 0;
01115 
01116        /* these flags are always zero, from what I can tell... */
01117        bits->pebs_enable = 0;   /* flag for PEBS counting */
01118        bits->pebs_matrix_vert = 0;  
01119        /* flag for PEBS_MATRIX_VERT, whatever that is */
01120 
01121        /* ...unless the event is replay_event */
01122        if ( !strcmp( pentium4_events[event].name, "replay_event" ) ) {
01123       escr_value.bits.event_mask = event_mask & P4_REPLAY_REAL_MASK;
01124       num_masks = prepare_umask( umask, unit_masks );
01125       for ( i = 0; i < num_masks; i++ ) {
01126          replay_mask = unit_masks[i];
01127          if ( replay_mask > 1 && replay_mask < 11 ) {
01128             /* process each valid mask we find */
01129         bits->pebs_enable |= p4_replay_regs[replay_mask].enb;
01130         bits->pebs_matrix_vert |= p4_replay_regs[replay_mask].mat_vert;
01131          }
01132       }
01133        }
01134 
01135        /* store the escr and cccr values */
01136        bits->event = escr_value.val;
01137        bits->cccr = cccr_value.val;
01138        bits->ireset = 0;     /* I don't really know what this does */
01139        SUBDBG( "escr: 0x%lx; cccr:  0x%lx\n", escr_value.val, cccr_value.val );
01140     } else {
01141 
01142        int ret, code;
01143 
01144        if ( _pfm_decode_native_event( EventCode, &event, &umask ) != PAPI_OK )
01145       return PAPI_ENOEVNT;
01146 
01147        if ( ( ret = _pfm_get_counter_info( event, &bits->selector,
01148                           &code ) ) != PAPI_OK )
01149       return ret;
01150 
01151        bits->counter_cmd=(int) (code | ((_pfm_convert_umask(event,umask))<< 8) );
01152 
01153        SUBDBG( "selector: %#x\n", bits->selector );
01154        SUBDBG( "event: %#x; umask: %#x; code: %#x; cmd: %#x\n", event,
01155            umask, code, ( ( hwd_register_t * ) bits )->counter_cmd );
01156     }
01157 
01158     return PAPI_OK;
01159 }

Here is the call graph for this function:

int _papi_libpfm_ntv_code_to_descr ( unsigned int  EventCode,
char *  name,
int  len 
)

Definition at line 262 of file papi_libpfm3_events.c.

00263 {
00264     unsigned int event, umask;
00265     char *eventd, **maskd, *tmp;
00266     int i, ret;
00267     pfmlib_event_t gete;
00268     size_t total_len = 0;
00269 
00270     memset( &gete, 0, sizeof ( gete ) );
00271 
00272     if ( _pfm_decode_native_event( EventCode, &event, &umask ) != PAPI_OK )
00273         return ( PAPI_ENOEVNT );
00274 
00275     ret = pfm_get_event_description( event, &eventd );
00276     if ( ret != PFMLIB_SUCCESS ) {
00277         PAPIERROR( "pfm_get_event_description(%d,%p): %s",
00278                    event, &eventd, pfm_strerror( ret ) );
00279         return ( PAPI_ENOEVNT );
00280     }
00281 
00282     if ( ( gete.num_masks =
00283            ( unsigned int ) prepare_umask( umask, gete.unit_masks ) ) ) {
00284         maskd = ( char ** ) malloc( gete.num_masks * sizeof ( char * ) );
00285         if ( maskd == NULL ) {
00286             free( eventd );
00287             return ( PAPI_ENOMEM );
00288         }
00289         for ( i = 0; i < ( int ) gete.num_masks; i++ ) {
00290             ret =
00291                 pfm_get_event_mask_description( event, gete.unit_masks[i],
00292                                                 &maskd[i] );
00293             if ( ret != PFMLIB_SUCCESS ) {
00294                 PAPIERROR( "pfm_get_event_mask_description(%d,%d,%p): %s",
00295                            event, umask, &maskd, pfm_strerror( ret ) );
00296                 free( eventd );
00297                 for ( ; i >= 0; i-- )
00298                     free( maskd[i] );
00299                 free( maskd );
00300                 return ( PAPI_EINVAL );
00301             }
00302             total_len += strlen( maskd[i] );
00303         }
00304         tmp =
00305             ( char * ) malloc( strlen( eventd ) + strlen( ", masks:" ) +
00306                                total_len + gete.num_masks + 1 );
00307         if ( tmp == NULL ) {
00308             for ( i = ( int ) gete.num_masks - 1; i >= 0; i-- )
00309                 free( maskd[i] );
00310             free( maskd );
00311             free( eventd );
00312         }
00313         tmp[0] = '\0';
00314         strcat( tmp, eventd );
00315         strcat( tmp, ", masks:" );
00316         for ( i = 0; i < ( int ) gete.num_masks; i++ ) {
00317             if ( i != 0 )
00318                 strcat( tmp, "," );
00319             strcat( tmp, maskd[i] );
00320             free( maskd[i] );
00321         }
00322         free( maskd );
00323     } else {
00324         tmp = ( char * ) malloc( strlen( eventd ) + 1 );
00325         if ( tmp == NULL ) {
00326             free( eventd );
00327             return ( PAPI_ENOMEM );
00328         }
00329         tmp[0] = '\0';
00330         strcat( tmp, eventd );
00331         free( eventd );
00332     }
00333     strncpy( ntv_descr, tmp, ( size_t ) len );
00334     if ( ( int ) strlen( tmp ) > len - 1 )
00335         ret = PAPI_EBUF;
00336     else
00337         ret = PAPI_OK;
00338     free( tmp );
00339     return ( ret );
00340 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_libpfm_ntv_code_to_info ( unsigned int  EventCode,
PAPI_event_info_t info 
)

Definition at line 344 of file papi_libpfm3_events.c.

00345 {
00346 
00347   SUBDBG("ENTER %#x\n",EventCode);
00348 
00349   _papi_libpfm_ntv_code_to_name(EventCode,info->symbol,
00350                                  sizeof(info->symbol));
00351 
00352   _papi_libpfm_ntv_code_to_descr(EventCode,info->long_descr,
00353                                  sizeof(info->long_descr));
00354 
00355   return PAPI_OK;
00356 }

Here is the call graph for this function:

int _papi_libpfm_ntv_code_to_name ( unsigned int  EventCode,
char *  name,
int  len 
)

Definition at line 225 of file papi_libpfm3_events.c.

00226 {
00227     int ret;
00228     unsigned int event, umask;
00229     pfmlib_event_t gete;
00230 
00231     memset( &gete, 0, sizeof ( gete ) );
00232 
00233     if ( _pfm_decode_native_event( EventCode, &event, &umask ) != PAPI_OK )
00234         return ( PAPI_ENOEVNT );
00235 
00236     gete.event = event;
00237     gete.num_masks = ( unsigned int ) prepare_umask( umask, gete.unit_masks );
00238     if ( gete.num_masks == 0 )
00239         ret = pfm_get_event_name( gete.event, ntv_name, ( size_t ) len );
00240     else
00241         ret = pfm_get_full_event_name( &gete, ntv_name, ( size_t ) len );
00242     if ( ret != PFMLIB_SUCCESS ) {
00243         char tmp[PAPI_2MAX_STR_LEN];
00244         pfm_get_event_name( gete.event, tmp, sizeof ( tmp ) );
00245         /* Skip error message if event is not supported by host cpu;
00246          * we don't need to give this info away for papi_native_avail util */
00247         if ( ret != PFMLIB_ERR_BADHOST )
00248             PAPIERROR
00249                 ( "pfm_get_full_event_name(%p(event %d,%s,%d masks),%p,%d): %d -- %s",
00250                   &gete, gete.event, tmp, gete.num_masks, ntv_name, len, ret,
00251                   pfm_strerror( ret ) );
00252         if ( ret == PFMLIB_ERR_FULL ) {
00253             return PAPI_EBUF;
00254         }
00255 
00256         return PAPI_EMISC;
00257     }
00258     return PAPI_OK;
00259 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _papi_libpfm_ntv_enum_events ( unsigned int *  EventCode,
int  modifier 
)

Definition at line 360 of file papi_libpfm3_events.c.

00361 {
00362     unsigned int event, umask, num_masks;
00363     int ret;
00364 
00365     if ( modifier == PAPI_ENUM_FIRST ) {
00366         *EventCode = PAPI_NATIVE_MASK;  /* assumes first native event is always 0x4000000 */
00367         return ( PAPI_OK );
00368     }
00369 
00370     if ( _pfm_decode_native_event( *EventCode, &event, &umask ) != PAPI_OK )
00371         return ( PAPI_ENOEVNT );
00372 
00373     ret = pfm_get_num_event_masks( event, &num_masks );
00374     if ( ret != PFMLIB_SUCCESS ) {
00375         PAPIERROR( "pfm_get_num_event_masks(%d,%p): %s", event, &num_masks,
00376                    pfm_strerror( ret ) );
00377         return ( PAPI_ENOEVNT );
00378     }
00379     if ( num_masks > PAPI_NATIVE_UMASK_MAX )
00380         num_masks = PAPI_NATIVE_UMASK_MAX;
00381     SUBDBG( "This is umask %d of %d\n", umask, num_masks );
00382 
00383     if ( modifier == PAPI_ENUM_EVENTS ) {
00384         if ( event < ( unsigned int ) num_native_events - 1 ) {
00385             *EventCode =
00386                 ( unsigned int ) encode_native_event_raw( event + 1, 0 );
00387             return ( PAPI_OK );
00388         }
00389         return ( PAPI_ENOEVNT );
00390     } else if ( modifier == PAPI_NTV_ENUM_UMASK_COMBOS ) {
00391         if ( umask + 1 < ( unsigned int ) ( 1 << num_masks ) ) {
00392             *EventCode =
00393                 ( unsigned int ) encode_native_event_raw( event, umask + 1 );
00394             return ( PAPI_OK );
00395         }
00396         return ( PAPI_ENOEVNT );
00397     } else if ( modifier == PAPI_NTV_ENUM_UMASKS ) {
00398         int thisbit = ffs( ( int ) umask );
00399 
00400         SUBDBG( "First bit is %d in %08x\b\n", thisbit - 1, umask );
00401         thisbit = 1 << thisbit;
00402 
00403         if ( thisbit & ( ( 1 << num_masks ) - 1 ) ) {
00404             *EventCode =
00405                 ( unsigned int ) encode_native_event_raw( event,
00406                                                           ( unsigned int )
00407                                                           thisbit );
00408             return ( PAPI_OK );
00409         }
00410         return ( PAPI_ENOEVNT );
00411     } else
00412         return ( PAPI_EINVAL );
00413 }

Here is the call graph for this function:

int _papi_libpfm_ntv_name_to_code ( char *  ntv_name,
unsigned int *  EventCode 
)

Definition at line 184 of file papi_libpfm3_events.c.

00185 {
00186     pfmlib_event_t event;
00187     unsigned int i;
00188     int ret;
00189 
00190     SUBDBG( "pfm_find_full_event(%s,%p)\n", name, &event );
00191     ret = pfm_find_full_event( name, &event );
00192     if ( ret == PFMLIB_SUCCESS ) {
00193         SUBDBG( "Full event name found\n" );
00194         /* we can only capture PAPI_NATIVE_UMASK_MAX or fewer masks */
00195         if ( event.num_masks > PAPI_NATIVE_UMASK_MAX ) {
00196             SUBDBG( "num_masks (%d) > max masks (%d)\n", event.num_masks,
00197                     PAPI_NATIVE_UMASK_MAX );
00198             return PAPI_ENOEVNT;
00199         } else {
00200             /* no mask index can exceed PAPI_NATIVE_UMASK_MAX */
00201             for ( i = 0; i < event.num_masks; i++ ) {
00202                 if ( event.unit_masks[i] > PAPI_NATIVE_UMASK_MAX ) {
00203                     SUBDBG( "mask index (%d) > max masks (%d)\n",
00204                             event.unit_masks[i], PAPI_NATIVE_UMASK_MAX );
00205                     return PAPI_ENOEVNT;
00206                 }
00207             }
00208             *event_code =
00209                 encode_native_event( event.event, event.num_masks,
00210                                      event.unit_masks );
00211             return PAPI_OK;
00212         }
00213     } else if ( ret == PFMLIB_ERR_UMASK ) {
00214         SUBDBG( "UMASK error, looking for base event only\n" );
00215         ret = pfm_find_event( name, &event.event );
00216         if ( ret == PFMLIB_SUCCESS ) {
00217             *event_code = encode_native_event( event.event, 0, 0 );
00218             return PAPI_EATTR;
00219         }
00220     }
00221     return PAPI_ENOEVNT;
00222 }

Here is the call graph for this function:

int _papi_libpfm_setup_counters ( struct perf_event_attr attr,
hwd_register_t ni_bits 
)

Definition at line 770 of file papi_libpfm3_events.c.

00771                                          {
00772 
00773   int ret,pe_event;
00774   (void)ni_bits;
00775 
00776     /*
00777      * We need an event code that is common across all counters.
00778      * The implementation is required to know how to translate the supplied
00779      * code to whichever counter it ends up on.
00780      */
00781 
00782 #if defined(__powerpc__)
00783     int code;
00784     ret = pfm_get_event_code_counter( ( ( pfm_register_t * ) ni_bits )->event, 0, &code );
00785     if ( ret ) {
00786        /* Unrecognized code, but should never happen */
00787        return PAPI_EBUG;
00788     }
00789     pe_event = code;
00790     SUBDBG( "Stuffing native event index (code %#x, raw code %#x) into events array.\n",
00791                   ( ( pfm_register_t * ) ni_bits )->event, code );
00792 #else
00793 
00794    pfmlib_input_param_t inp;
00795    pfmlib_output_param_t outp;
00796 
00797    memset( &inp, 0, sizeof ( inp ) );
00798    memset( &outp, 0, sizeof ( outp ) );
00799    inp.pfp_event_count = 1;
00800    inp.pfp_dfl_plm = PAPI_DOM_USER;
00801    pfm_regmask_set( &inp.pfp_unavail_pmcs, 16 );    // mark fixed counters as unavailable
00802 
00803     inp.pfp_events[0] = *( ( pfm_register_t * ) ni_bits );
00804     ret = pfm_dispatch_events( &inp, NULL, &outp, NULL );
00805     if (ret != PFMLIB_SUCCESS) {
00806        SUBDBG( "Error: pfm_dispatch_events returned: %d\n", ret);
00807        return PAPI_ESYS;
00808     }
00809             
00810        /* Special case p4 */
00811     if (( _papi_hwi_system_info.hw_info.vendor == PAPI_VENDOR_INTEL ) && 
00812         ( _papi_hwi_system_info.hw_info.cpuid_family == 15)) {
00813 
00814     pe_event=generate_p4_event( outp.pfp_pmcs[0].reg_value, /* escr */  
00815                             outp.pfp_pmcs[1].reg_value, /* cccr */
00816                             outp.pfp_pmcs[0].reg_addr); /* escr_addr */
00817     }
00818     else {
00819         pe_event = outp.pfp_pmcs[0].reg_value;   
00820     }
00821     SUBDBG( "pe_event: %#llx\n", outp.pfp_pmcs[0].reg_value );
00822 #endif
00823 
00824     attr->config=pe_event;
00825 
00826     /* for libpfm3 we currently only handle RAW type */
00827     attr->type=PERF_TYPE_RAW;
00828 
00829     return PAPI_OK;
00830 }

Here is the call graph for this function:

int _papi_libpfm_setup_presets ( char *  name,
int  type,
int  cidx 
)
int _papi_libpfm_shutdown ( void   ) 

Definition at line 833 of file papi_libpfm3_events.c.

00833                             {
00834 
00835   SUBDBG("shutdown\n");
00836 
00837   return PAPI_OK;
00838 }

unsigned int _pfm_convert_umask ( unsigned int  event,
unsigned int  umask 
)

Definition at line 137 of file papi_libpfm3_events.c.

00138 {
00139     pfmlib_event_t gete;
00140     memset( &gete, 0, sizeof ( gete ) );
00141     gete.event = event;
00142     gete.num_masks = ( unsigned int ) prepare_umask( umask, gete.unit_masks );
00143     return ( convert_pfm_masks( &gete ) );
00144 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _pfm_decode_native_event ( unsigned int  EventCode,
unsigned int *  event,
unsigned int *  umask 
)

Definition at line 79 of file papi_libpfm3_events.c.

00081 {
00082     unsigned int tevent, major, minor;
00083 
00084     tevent = EventCode & PAPI_NATIVE_AND_MASK;
00085     major = ( tevent & PAPI_NATIVE_EVENT_AND_MASK ) >> PAPI_NATIVE_EVENT_SHIFT;
00086     if ( ( int ) major >= num_native_events )
00087         return PAPI_ENOEVNT;
00088 
00089     minor = ( tevent & PAPI_NATIVE_UMASK_AND_MASK ) >> PAPI_NATIVE_UMASK_SHIFT;
00090     *event = major;
00091     *umask = minor;
00092     SUBDBG( "EventCode %#08x is event %d, umask %#x\n", EventCode, major,
00093             minor );
00094     return PAPI_OK;
00095 }

int prepare_umask ( unsigned int  foo,
unsigned int *  values 
)

Definition at line 99 of file papi_libpfm3_events.c.

00100 {
00101     unsigned int tmp = foo, i;
00102     int j = 0;
00103 
00104     SUBDBG( "umask %#x\n", tmp );
00105     while ( ( i = ( unsigned int ) ffs( ( int ) tmp ) ) ) {
00106         tmp = tmp ^ ( 1 << ( i - 1 ) );
00107         values[j] = i - 1;
00108         SUBDBG( "umask %d is %d\n", j, values[j] );
00109         j++;
00110     }
00111     return ( j );
00112 }


Generated on 8 Sep 2016 for PAPI by  doxygen 1.6.1