pe_libpfm4_events.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int _pe_libpfm4_setup_presets (char *name, int type, int cidx)
int _pe_libpfm4_ntv_enum_events (unsigned int *EventCode, int modifier, struct native_event_table_t *event_table)
int _pe_libpfm4_ntv_name_to_code (char *ntv_name, unsigned int *EventCode, struct native_event_table_t *event_table)
int _pe_libpfm4_ntv_code_to_name (unsigned int EventCode, char *name, int len, struct native_event_table_t *event_table)
int _pe_libpfm4_ntv_code_to_descr (unsigned int EventCode, char *name, int len, struct native_event_table_t *event_table)
int _pe_libpfm4_shutdown (papi_vector_t *my_vector, struct native_event_table_t *event_table)
int _pe_libpfm4_init (papi_vector_t *my_vector, int cidx, struct native_event_table_t *event_table, int pmu_type)
int _pe_libpfm4_ntv_code_to_info (unsigned int EventCode, PAPI_event_info_t *info, struct native_event_table_t *event_table)
int _pe_libpfm4_get_cidx (void)

Function Documentation

int _pe_libpfm4_get_cidx ( void   ) 

Definition at line 78 of file perf_event.c.

00078                        {
00079     return our_cidx;
00080 }

Here is the caller graph for this function:

int _pe_libpfm4_init ( papi_vector_t my_vector,
int  cidx,
struct native_event_table_t event_table,
int  pmu_type 
)

Definition at line 1051 of file pe_libpfm4_events.c.

01053                          {
01054 
01055    int detected_pmus=0, found_default=0;
01056    int i;
01057    int j=0;
01058    pfm_err_t retval = PFM_SUCCESS;
01059    unsigned int ncnt;
01060    pfm_pmu_info_t pinfo;
01061 
01062    /* allocate the native event structure */
01063 
01064    event_table->num_native_events=0;
01065    event_table->pmu_type=pmu_type;
01066 
01067    event_table->native_events=calloc(NATIVE_EVENT_CHUNK,
01068                        sizeof(struct native_event_t));
01069    if (event_table->native_events==NULL) {
01070       return PAPI_ENOMEM;
01071    }
01072    event_table->allocated_native_events=NATIVE_EVENT_CHUNK;
01073 
01074    /* Count number of present PMUs */
01075    detected_pmus=0;
01076    ncnt=0;
01077 
01078    /* init default pmu */
01079    /* need to init pinfo or pfmlib might complain */
01080    memset(&(event_table->default_pmu), 0, sizeof(pfm_pmu_info_t));
01081    event_table->default_pmu.size = sizeof(pfm_pmu_info_t);
01082    retval=pfm_get_pmu_info(0, &(event_table->default_pmu));
01083    
01084    SUBDBG("Detected pmus:\n");
01085    for(i=0;i<PFM_PMU_MAX;i++) {
01086       memset(&pinfo,0,sizeof(pfm_pmu_info_t));
01087       pinfo.size = sizeof(pfm_pmu_info_t);
01088       retval=pfm_get_pmu_info(i, &pinfo);
01089       if ((retval!=PFM_SUCCESS) || (pinfo.name == NULL)) {
01090      continue;
01091       }
01092 
01093       if (pmu_is_present_and_right_type(&pinfo,pmu_type)) {
01094      SUBDBG("\t%d %s %s %d\n",i,pinfo.name,pinfo.desc,pinfo.type);
01095 
01096          detected_pmus++;
01097      ncnt+=pinfo.nevents;
01098 
01099      if (j < PAPI_PMU_MAX) {
01100          my_vector->cmp_info.pmu_names[j++] = strdup(pinfo.name);
01101      }
01102        
01103          if (pmu_type&PMU_TYPE_CORE) {
01104 
01105         /* Hack to have "default" PMU */
01106         if ( (pinfo.type==PFM_PMU_TYPE_CORE) &&
01107                   strcmp(pinfo.name,"ix86arch")) {
01108 
01109            SUBDBG("\t  %s is default\n",pinfo.name);
01110            memcpy(&(event_table->default_pmu),
01111               &pinfo,sizeof(pfm_pmu_info_t));
01112            found_default++;
01113         }
01114      }
01115          if (pmu_type==PMU_TYPE_UNCORE) {
01116          /* To avoid confusion, no "default" CPU for uncore */
01117            found_default=1;
01118      }
01119       }
01120    }
01121    SUBDBG("%d native events detected on %d pmus\n",ncnt,detected_pmus);
01122 
01123    if (!found_default) {
01124       SUBDBG("Could not find default PMU\n");
01125       return PAPI_ECMP;
01126    }
01127 
01128    if (found_default>1) {
01129      PAPIERROR("Found too many default PMUs!\n");
01130      return PAPI_ECMP;
01131    }
01132 
01133    my_vector->cmp_info.num_native_events = ncnt;
01134 
01135    my_vector->cmp_info.num_cntrs = event_table->default_pmu.num_cntrs+
01136                                    event_table->default_pmu.num_fixed_cntrs;
01137 
01138    SUBDBG( "num_counters: %d\n", my_vector->cmp_info.num_cntrs );
01139    
01140    /* Setup presets, only if Component 0 */
01141    if (cidx==0) {
01142       retval = _papi_load_preset_table( (char *)event_table->default_pmu.name, 
01143                      event_table->default_pmu.pmu, cidx );
01144       if ( retval ) {
01145          return retval;
01146       }
01147    }
01148 
01149    return PAPI_OK;
01150 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _pe_libpfm4_ntv_code_to_descr ( unsigned int  EventCode,
char *  name,
int  len,
struct native_event_table_t event_table 
)

Definition at line 631 of file pe_libpfm4_events.c.

00634 {
00635     SUBDBG("ENTER: EventCode: %#x, ntv_descr: %p, len: %d: event_table: %p\n", EventCode, ntv_descr, len, event_table);
00636 
00637     int eidx;
00638     int papi_event_code;
00639 
00640     // get the attribute index for this papi event
00641     papi_event_code = _papi_hwi_get_papi_event_code();
00642 
00643     // a papi event code less than 0 is invalid, return error
00644     if (papi_event_code <= 0) {
00645         SUBDBG("EXIT: PAPI_ENOEVNT\n");
00646         return PAPI_ENOEVNT;
00647     }
00648 
00649     // find our native event table for this papi event code (search list backwards because it improves chances of finding it quickly)
00650     for (eidx=event_table->num_native_events-1 ; eidx>=0 ; eidx--) {
00651         SUBDBG("native_event[%d]: papi_event_code: %#x, libpfm4_idx: %#x\n", eidx, event_table->native_events[eidx].papi_event_code, event_table->native_events[eidx].libpfm4_idx);
00652         if ((papi_event_code == event_table->native_events[eidx].papi_event_code) && (EventCode == ((unsigned)event_table->native_events[eidx].libpfm4_idx))) {
00653             break;
00654         }
00655     }
00656 
00657     // if we did not find a match, return an error
00658     if (eidx < 0) {
00659         // If we did not find a match in our native event table, then the code passed in has not been
00660         // allocated yet  It should not be possible to get to this code.  The user has to call the papi
00661         // code_to_name api with a papi event code for a native event.  But the only way to get one of
00662         // those is to call either name_to_code or enum_cmp_events first.  When one of these calls is
00663         // done we allocate the event so it should always be there.
00664 
00665         SUBDBG("EXIT: PAPI_ENOEVNT\n");
00666         return PAPI_ENOEVNT;
00667     }
00668 
00669     char *edesc = event_table->native_events[eidx].event_description;
00670 
00671     // if it will not fit, return error
00672     if (strlen (edesc) >= (unsigned)len) {
00673         SUBDBG("EXIT: event name %s will not fit in buffer provided\n", edesc);
00674         return PAPI_EBUF;
00675     }
00676     strcpy (ntv_descr, edesc);
00677 
00678     // if this event had masks, also add their descriptions
00679     char *mdesc = event_table->native_events[eidx].mask_description;
00680     if ((mdesc != NULL)  &&  (strlen(mdesc) > 0)) {
00681         if ((strlen(edesc) + 8 + strlen(mdesc)) >= (unsigned)len) {
00682             SUBDBG("EXIT: Not enough room for event and mask descriptions: need: %u, have: %u", (unsigned)(strlen(edesc) + 8 + strlen(mdesc)), (unsigned)len);
00683             return PAPI_EBUF;
00684         }
00685         strcat (ntv_descr, ", masks:");
00686         strcat (ntv_descr, mdesc);
00687     }
00688 
00689     SUBDBG("EXIT: event description: %s\n", ntv_descr);
00690     return PAPI_OK;
00691 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _pe_libpfm4_ntv_code_to_info ( unsigned int  EventCode,
PAPI_event_info_t info,
struct native_event_table_t event_table 
)

Definition at line 695 of file pe_libpfm4_events.c.

00698 {
00699     SUBDBG("ENTER: EventCode: %#x, info: %p, event_table: %p\n", EventCode, info, event_table);
00700 
00701     int ret;
00702 
00703     // get the event name first
00704     if ((ret = _pe_libpfm4_ntv_code_to_name(EventCode, info->symbol, sizeof(info->symbol), event_table)) != PAPI_OK) {
00705         SUBDBG("EXIT: _pe_libpfm4_ntv_code_to_name returned: %d\n", ret);
00706         return PAPI_ENOEVNT;
00707     }
00708 
00709     if ((ret = _pe_libpfm4_ntv_code_to_descr(EventCode, info->long_descr, sizeof(info->long_descr), event_table)) != PAPI_OK) {
00710         SUBDBG("EXIT: _pe_libpfm4_ntv_code_to_descr returned: %d\n", ret);
00711         return PAPI_ENOEVNT;
00712     }
00713 
00714     SUBDBG("EXIT: EventCode: %#x, name: %s, desc: %s\n", EventCode, info->symbol, info->long_descr);
00715     return PAPI_OK;
00716 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _pe_libpfm4_ntv_code_to_name ( unsigned int  EventCode,
char *  name,
int  len,
struct native_event_table_t event_table 
)

Definition at line 538 of file pe_libpfm4_events.c.

00541 {
00542     SUBDBG("ENTER: EventCode: %#x, ntv_name: %p, len: %d, event_table: %p\n", EventCode, ntv_name, len, event_table);
00543 
00544     int eidx;
00545     int papi_event_code;
00546 
00547     // get the attribute index for this papi event
00548     papi_event_code = _papi_hwi_get_papi_event_code();
00549 
00550     // a papi event code less than 0 is invalid, return error
00551     if (papi_event_code <= 0) {
00552         SUBDBG("EXIT: PAPI_ENOEVNT\n");
00553         return PAPI_ENOEVNT;
00554     }
00555 
00556     // find our native event table for this papi event code (search list backwards because it improves chances of finding it quickly)
00557     for (eidx=event_table->num_native_events-1 ; eidx>=0 ; eidx--) {
00558         if ((papi_event_code == event_table->native_events[eidx].papi_event_code) && (EventCode == ((unsigned)event_table->native_events[eidx].libpfm4_idx))) {
00559             SUBDBG("Found native_event[%d]: papi_event_code: %#x, libpfm4_idx: %#x\n", eidx, event_table->native_events[eidx].papi_event_code, event_table->native_events[eidx].libpfm4_idx);
00560             break;
00561         }
00562     }
00563 
00564     // if we did not find a match, return an error
00565     if (eidx < 0) {
00566         // If we did not find a match in our native event table, then the code passed in has not been
00567         // allocated yet  It should not be possible to get to this code.  The user has to call the papi
00568         // code_to_name api with a papi event code for a native event.  But the only way to get one of
00569         // those is to call either name_to_code or enum_cmp_events first.  When one of these calls is
00570         // done we allocate the event so it should always be there.
00571 
00572         SUBDBG("EXIT: PAPI_ENOEVNT\n");
00573         return PAPI_ENOEVNT;
00574     }
00575 
00576     // if this event is defined by the default pmu, then use only the event name
00577     // if it is not defined by the default pmu, then use both the pmu name and event name
00578     char *ename;
00579     if (strcmp(event_table->default_pmu.name, event_table->native_events[eidx].pmu) == 0) {
00580         ename = event_table->native_events[eidx].base_name;
00581     } else {
00582         ename = event_table->native_events[eidx].pmu_plus_name;
00583     }
00584 
00585     // if it will not fit, return error
00586     if (strlen (ename) >= (unsigned)len) {
00587         SUBDBG("EXIT: event name %s will not fit in buffer provided\n", ename);
00588         return PAPI_EBUF;
00589     }
00590     strcpy (ntv_name, ename);
00591 
00592     // if this event had masks, also add their names
00593     char *mname = event_table->native_events[eidx].mask_string;
00594     if ((mname != NULL)  &&  (strlen(mname) > 0)) {
00595         if ((strlen(ename) + 8 + strlen(mname)) >= (unsigned)len) {
00596             SUBDBG("EXIT: Not enough room for event and mask descriptions: need: %u, have: %u", (unsigned)(strlen(ename) + 8 + strlen(mname)), (unsigned)len);
00597             return PAPI_EBUF;
00598         }
00599         strcat (ntv_name, ":");
00600         strcat (ntv_name, mname);
00601     }
00602 
00603     SUBDBG("EXIT: event name: %s\n", ntv_name);
00604     return PAPI_OK;
00605 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _pe_libpfm4_ntv_enum_events ( unsigned int *  EventCode,
int  modifier,
struct native_event_table_t event_table 
)

Definition at line 736 of file pe_libpfm4_events.c.

00738                                                              {
00739 
00740     SUBDBG("ENTER: PapiEventCode: %p, *PapiEventCode: %#x, modifier: %d, event_table: %p\n", PapiEventCode, *PapiEventCode, modifier, event_table);
00741 
00742     int code,ret, pnum;
00743     int max_umasks;
00744     char event_string[BUFSIZ];
00745     pfm_pmu_info_t pinfo;
00746     pfm_event_info_t einfo;
00747     struct native_event_t *our_event;
00748 
00749     /* return first event if so specified */
00750     if ( modifier == PAPI_ENUM_FIRST ) {
00751         attr_idx = 0;   // set so if they want attribute information, it will start with the first attribute
00752         code=get_first_event_next_pmu(-1, event_table->pmu_type);
00753        if (code < 0 ) {
00754            SUBDBG("EXIT: Invalid component first event code: %d\n", code);
00755           return code;
00756        }
00757 
00758         // get the event information from libpfm4 (must zero structure)
00759         memset( &einfo, 0, sizeof( pfm_event_info_t ));
00760         einfo.size = sizeof(pfm_event_info_t);
00761         if ((ret = pfm_get_event_info(code, PFM_OS_PERF_EVENT_EXT, &einfo)) != PFM_SUCCESS) {
00762             SUBDBG("EXIT: pfm_get_event_info returned: %d\n", ret);
00763             return PAPI_ENOIMPL;
00764         }
00765 
00766         // get the pmu information from libpfm4 (must zero structure)
00767         memset( &pinfo, 0, sizeof(pfm_pmu_info_t) );
00768         pinfo.size = sizeof(pfm_pmu_info_t);
00769         ret=pfm_get_pmu_info(einfo.pmu, &pinfo);
00770         if (ret!=PFM_SUCCESS) {
00771             SUBDBG("EXIT: pfm_get_pmu_info returned: %d\n", ret);
00772             return ret;
00773         }
00774 
00775         // build full event name
00776         sprintf (event_string, "%s::%s", pinfo.name, einfo.name);
00777         SUBDBG("code: %#x, pmu: %s, event: %s, event_string: %s\n", code, pinfo.name, einfo.name, event_string);
00778 
00779         // go allocate this event, need to create tables used by the get event info call that will probably follow
00780         if ((our_event = allocate_native_event(event_string, code, event_table)) == NULL) {
00781             // allocate may have created the event table but returned NULL to tell the caller the event string was invalid (attempt to encode it failed).
00782             // if the caller wants to use this event to count something, it will report an error
00783             // but if the caller is just interested in listing the event, then we need an event table with an event name and libpfm4 index
00784             int evt_idx;
00785             if ((evt_idx = find_existing_event(event_string, event_table)) < 0) {
00786                 SUBDBG("EXIT: Allocating event: '%s' failed\n", event_string);
00787                 return PAPI_ENOEVNT;
00788             }
00789 
00790             // give back the new event code
00791             *PapiEventCode = event_table->native_events[evt_idx].libpfm4_idx;
00792             SUBDBG("EXIT: event code: %#x\n", *PapiEventCode);
00793             return PAPI_OK;
00794         }
00795 
00796         *PapiEventCode = our_event->libpfm4_idx;
00797 
00798         SUBDBG("EXIT: *PapiEventCode: %#x\n", *PapiEventCode);
00799         return PAPI_OK;
00800     }
00801 
00802     /* Handle looking for the next event */
00803     if ( modifier == PAPI_ENUM_EVENTS ) {
00804         attr_idx = 0;   // set so if they want attribute information, it will start with the first attribute
00805 
00806         // get the next event code from libpfm4, if there are no more in this pmu find first event in next pmu
00807         if ((code = pfm_get_event_next(*PapiEventCode)) < 0) {
00808 
00809             // get this events information from libpfm4, we need the pmu number of the last event we processed (table must be cleared)
00810             memset( &einfo, 0, sizeof( pfm_event_info_t ));
00811             einfo.size = sizeof(pfm_event_info_t);
00812             if ((ret = pfm_get_event_info(*PapiEventCode, PFM_OS_PERF_EVENT_EXT, &einfo)) != PFM_SUCCESS) {
00813                 SUBDBG("EXIT: pfm_get_event_info returned: %d\n", ret);
00814                 return PAPI_ENOIMPL;
00815             }
00816             SUBDBG("*PapiEventCode: %#x, event: %s\n", *PapiEventCode, einfo.name);
00817 
00818             // get the pmu number of the last event
00819             pnum = einfo.pmu;
00820 
00821             while ( pnum<PFM_PMU_MAX) {
00822                 SUBDBG("pnum: %d\n", pnum);
00823                 code=get_first_event_next_pmu(pnum, event_table->pmu_type);
00824                 if (code < 0) {
00825                     SUBDBG("EXIT: No more pmu's to list, returning: %d\n", code);
00826                     return code;
00827                 }
00828                 break;
00829             }
00830         }
00831 
00832 
00833         // get the event information from libpfm4 (must zero structure)
00834         memset( &einfo, 0, sizeof( pfm_event_info_t ));
00835         einfo.size = sizeof(pfm_event_info_t);
00836         if ((ret = pfm_get_event_info(code, PFM_OS_PERF_EVENT_EXT, &einfo)) != PFM_SUCCESS) {
00837             SUBDBG("EXIT: pfm_get_event_info returned: %d\n", ret);
00838             return PAPI_ENOIMPL;
00839         }
00840 
00841         // get the pmu information from libpfm4 (must zero structure)
00842         memset( &pinfo, 0, sizeof(pfm_pmu_info_t) );
00843         pinfo.size = sizeof(pfm_pmu_info_t);
00844         ret=pfm_get_pmu_info(einfo.pmu, &pinfo);
00845         if (ret!=PFM_SUCCESS) {
00846             SUBDBG("EXIT: pfm_get_pmu_info returned: %d\n", ret);
00847             return ret;
00848         }
00849 
00850         // build full event name
00851         sprintf (event_string, "%s::%s", pinfo.name, einfo.name);
00852         SUBDBG("code: %#x, pmu: %s, event: %s, event_string: %s\n", code, pinfo.name, einfo.name, event_string);
00853 
00854         // go allocate this event, need to create tables used by the get event info call that will follow
00855         if ((our_event = allocate_native_event(event_string, code, event_table)) == NULL) {
00856             // allocate may have created the event table but returned NULL to tell the caller the event string was invalid (attempt to encode it failed).
00857             // if the caller wants to use this event to count something, it will report an error
00858             // but if the caller is just interested in listing the event, then we need an event table with an event name and libpfm4 index
00859             int evt_idx;
00860             if ((evt_idx = find_existing_event(event_string, event_table)) < 0) {
00861                 SUBDBG("EXIT: Allocating event: '%s' failed\n", event_string);
00862                 return PAPI_ENOEVNT;
00863             }
00864 
00865             // give back the new event code
00866             *PapiEventCode = event_table->native_events[evt_idx].libpfm4_idx;
00867             SUBDBG("EXIT: event code: %#x\n", *PapiEventCode);
00868             return PAPI_OK;
00869         }
00870 
00871         // give back the new event code
00872         *PapiEventCode = our_event->libpfm4_idx;
00873 
00874         SUBDBG("EXIT: *PapiEventCode: %#x\n", *PapiEventCode);
00875         return PAPI_OK;
00876     }
00877 
00878     /* We don't handle PAPI_NTV_ENUM_UMASK_COMBOS */
00879     if ( modifier == PAPI_NTV_ENUM_UMASK_COMBOS ) {
00880         SUBDBG("EXIT: do not support umask combos yet\n");
00881         return PAPI_ENOIMPL;
00882     } 
00883 
00884     /* Enumerate PAPI_NTV_ENUM_UMASKS (umasks on an event) */
00885     if ( modifier == PAPI_NTV_ENUM_UMASKS ) {
00886         // get this events information from libpfm4, we need the number of masks this event knows about (table must be cleared)
00887         memset( &einfo, 0, sizeof( pfm_event_info_t ));
00888         einfo.size = sizeof(pfm_event_info_t);
00889         if ((ret = pfm_get_event_info(*PapiEventCode, PFM_OS_PERF_EVENT_EXT, &einfo)) != PFM_SUCCESS) {
00890             SUBDBG("EXIT: pfm_get_event_info returned: %d\n", ret);
00891             return PAPI_ENOIMPL;
00892         }
00893 //      SUBDBG("*PapiEventCode: %#x, einfo.name: %s, einfo.code: %#x, einfo.nattrs: %d\n", *PapiEventCode, einfo.name, einfo.code, einfo.nattrs);
00894 
00895         // set max number of masks
00896         max_umasks = einfo.nattrs;
00897 
00898         // if we reached last attribute, return error to show we are done with this events masks
00899         if (attr_idx == max_umasks) {
00900             SUBDBG("EXIT: already processed all umasks: attr_idx: %d\n", attr_idx);
00901             return PAPI_ENOEVNT;
00902         }
00903 
00904         // find the event table for this event, we need the pmu name and event name without any masks
00905         int ntv_idx = _papi_hwi_get_ntv_idx(_papi_hwi_get_papi_event_code());
00906         if (ntv_idx < 0) {
00907             SUBDBG("EXIT: _papi_hwi_get_ntv_idx returned: %d\n", ntv_idx);
00908             return ntv_idx;
00909         }
00910         char *ename = event_table->native_events[ntv_idx].pmu_plus_name;
00911         if ((ename == NULL)  ||  (strlen(ename) >= sizeof(event_string))) {
00912             SUBDBG("EXIT: Event name will not fit into buffer\n");
00913             return PAPI_EBUF;
00914         }
00915         strcpy (event_string, ename);
00916         SUBDBG("event_string: %s\n", event_string);
00917 
00918         // go get the attribute information for this event
00919         // libpfm4 likes the table cleared
00920         pfm_event_attr_info_t ainfo;
00921         memset (&ainfo, 0, sizeof(pfm_event_attr_info_t));
00922         ainfo.size = sizeof(pfm_event_attr_info_t);
00923         ret = pfm_get_event_attr_info(*PapiEventCode, attr_idx, PFM_OS_PERF_EVENT_EXT, &ainfo);
00924         if (ret != PFM_SUCCESS) {
00925             SUBDBG("EXIT: Attribute info not found, EventCode: %#x, attr_idx: %d, ret: %d\n", *PapiEventCode, attr_idx, _papi_libpfm4_error(ret));
00926             return _papi_libpfm4_error(ret);
00927         }
00928         SUBDBG("*PapiEventCode: %#x, attr_idx: %d, type: %d, name: %s, description: %s\n", *PapiEventCode, attr_idx, ainfo.type, ainfo.name, ainfo.desc);
00929 
00930         if (strlen(event_string) + strlen(ainfo.name) + 35 > sizeof(event_string)) {
00931             SUBDBG("EXIT: Event name and mask will not fit into buffer\n");
00932             return PAPI_EBUF;
00933         }
00934 
00935         strcat (event_string, ":");
00936         strcat (event_string, ainfo.name);
00937         switch (ainfo.type) {
00938             case PFM_ATTR_UMASK:
00939                 break;
00940             case PFM_ATTR_MOD_BOOL:
00941             case PFM_ATTR_MOD_INTEGER:
00942                 // a few attributes require a non-zero value to encode correctly (most would accept zero here)
00943                 strcat(event_string,"=0");
00944                 break;
00945             default:
00946                 SUBDBG("EXIT: Unsupported attribute type: %d", ainfo.type);
00947                 return PAPI_EATTR;
00948         }
00949 
00950         // go allocate this event, need to create tables used by the get event info call that will follow
00951         if ((our_event = allocate_native_event(event_string, *PapiEventCode, event_table)) == NULL) {
00952             // allocate may have created the event table but returned NULL to tell the caller the event string was invalid.
00953             // if the caller wants to use this event to count something, it must report the error
00954             // but if the caller is just interested in listing the event (like this code), then find the table that was created and return its libpfm4 index
00955             int evt_idx;
00956             if ((evt_idx = find_existing_event(event_string, event_table)) < 0) {
00957                 SUBDBG("EXIT: Allocating event: '%s' failed\n", event_string);
00958                 return PAPI_ENOEVNT;
00959             }
00960             // bump so next time we will use next attribute
00961             attr_idx++;
00962             // give back the new event code
00963             *PapiEventCode = event_table->native_events[evt_idx].libpfm4_idx;
00964             SUBDBG("EXIT: event code: %#x\n", *PapiEventCode);
00965             return PAPI_OK;
00966         }
00967 
00968         // bump so next time we will use next attribute
00969         attr_idx++;
00970 
00971         // give back the new event code
00972         *PapiEventCode = our_event->libpfm4_idx;
00973 
00974         SUBDBG("EXIT: event code: %#x\n", *PapiEventCode);
00975         return PAPI_OK;
00976     }
00977 
00978     /* Enumerate PAPI_NTV_ENUM_GROUPS (groups on an event) */
00979     if ( modifier == PAPI_NTV_ENUM_GROUPS ) {
00980         SUBDBG("EXIT: do not support enumerating groups in this component\n");
00981         return PAPI_ENOIMPL;
00982     }
00983 
00984     /* An unknown enumeration method was indicated */
00985 
00986     SUBDBG("EXIT: Invalid modifier argument provided\n");
00987     return PAPI_ENOIMPL;
00988 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _pe_libpfm4_ntv_name_to_code ( char *  ntv_name,
unsigned int *  EventCode,
struct native_event_table_t event_table 
)

Definition at line 489 of file pe_libpfm4_events.c.

00491 {
00492   SUBDBG( "ENTER: name: %s, event_code: %p, *event_code: %#x, event_table: %p\n", name, event_code, *event_code, event_table);
00493 
00494   struct native_event_t *our_event;
00495   int event_num;
00496 
00497   // if we already know this event name, just return its native code
00498   event_num=find_existing_event(name, event_table);
00499   if (event_num >= 0) {
00500          *event_code=event_table->native_events[event_num].libpfm4_idx;
00501          // the following call needs to happen to prevent the internal layer from creating a new papi native event table
00502          _papi_hwi_set_papi_event_code(event_table->native_events[event_num].papi_event_code, 1);
00503          SUBDBG("EXIT: Found papi_event_code: %#x, libpfm4_idx: %#x\n", event_table->native_events[event_num].papi_event_code, event_table->native_events[event_num].libpfm4_idx);
00504          return PAPI_OK;
00505   }
00506 
00507      // Try to allocate this event to see if it is known by libpfm4, if allocate fails tell the caller it is not valid
00508      our_event=allocate_native_event(name, -1, event_table);
00509      if (our_event==NULL) {
00510          SUBDBG("EXIT: Allocating event: '%s' failed\n", name);
00511          return PAPI_ENOEVNT;
00512      }
00513 
00514      *event_code = our_event->libpfm4_idx;
00515      SUBDBG("EXIT: Found code: %#x\n",*event_code);
00516      return PAPI_OK;
00517 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _pe_libpfm4_setup_presets ( char *  name,
int  type,
int  cidx 
)
int _pe_libpfm4_shutdown ( papi_vector_t my_vector,
struct native_event_table_t event_table 
)

Definition at line 1002 of file pe_libpfm4_events.c.

01003                                                   {
01004   SUBDBG("ENTER: event_table: %p\n", event_table);
01005 
01006   int i;
01007 
01008   for (i=0 ; i<PAPI_PMU_MAX ; i++) {
01009       if (my_vector->cmp_info.pmu_names[i] != NULL) {
01010           free (my_vector->cmp_info.pmu_names[i]);
01011       }
01012   }
01013 
01014   /* clean out and free the native events structure */
01015   _papi_hwi_lock( NAMELIB_LOCK );
01016 
01017   /* free memory allocated with strdup or malloc */
01018   for( i=0; i<event_table->num_native_events; i++) {
01019      free(event_table->native_events[i].base_name);
01020      free(event_table->native_events[i].pmu_plus_name);
01021      free(event_table->native_events[i].pmu);
01022      free(event_table->native_events[i].allocated_name);
01023      free(event_table->native_events[i].mask_string);
01024      free(event_table->native_events[i].event_description);
01025      if (event_table->native_events[i].mask_description != NULL) {
01026           free(event_table->native_events[i].mask_description);
01027      }
01028   }
01029 
01030   free(event_table->native_events);
01031 
01032   _papi_hwi_unlock( NAMELIB_LOCK );
01033 
01034   SUBDBG("EXIT: PAPI_OK\n");
01035   return PAPI_OK;
01036 }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on 17 Nov 2016 for PAPI by  doxygen 1.6.1