diff -up papi-5.2.0/src/components/perf_event/pe_libpfm4_events.c.orig papi-5.2.0/src/components/perf_event/pe_libpfm4_events.c --- papi-5.2.0/src/components/perf_event/pe_libpfm4_events.c.orig 2013-08-06 12:12:20.000000000 -0400 +++ papi-5.2.0/src/components/perf_event/pe_libpfm4_events.c 2017-06-15 22:41:58.784904523 -0400 @@ -236,14 +236,15 @@ static int find_next_no_aliases(int code current_pmu++; SUBDBG("Incrementing PMU: %#x\n",current_pmu); + memset(&pinfo,0,sizeof(pfm_pmu_info_t)); + ret = pfm_get_pmu_info(current_pmu, &pinfo); + /* Off the end, so done iterating */ - if (current_pmu>PFM_PMU_MAX) { + if (ret==PFM_ERR_INVAL) { return PFM_ERR_NOTFOUND; } - memset(&pinfo,0,sizeof(pfm_pmu_info_t)); - pfm_get_pmu_info(current_pmu, &pinfo); - if (pmu_is_present_and_right_type(&pinfo,pmu_type)) break; + if ((ret==PFM_SUCCESS) && pmu_is_present_and_right_type(&pinfo,pmu_type)) break; } current_event=pinfo.first_event; @@ -533,12 +534,21 @@ get_event_first_active(int pmu_type) pmu_idx=0; - while(pmu_idxdefault_pmu)); SUBDBG("Detected pmus:\n"); - for(i=0;idefault_pmu.num_fixed_cntrs; SUBDBG( "num_counters: %d\n", my_vector->cmp_info.num_cntrs ); - + /* Setup presets, only if Component 0 */ if (cidx==0) { retval = _papi_load_preset_table( (char *)event_table->default_pmu.name, diff -up papi-5.2.0/src/components/perf_event_uncore/peu_libpfm4_events.c.orig papi-5.2.0/src/components/perf_event_uncore/peu_libpfm4_events.c --- papi-5.2.0/src/components/perf_event_uncore/peu_libpfm4_events.c.orig 2013-08-06 12:12:20.000000000 -0400 +++ papi-5.2.0/src/components/perf_event_uncore/peu_libpfm4_events.c 2017-06-15 22:50:08.700238377 -0400 @@ -238,14 +238,15 @@ static int find_next_no_aliases(int code current_pmu++; SUBDBG("Incrementing PMU: %#x\n",current_pmu); + memset(&pinfo,0,sizeof(pfm_pmu_info_t)); + ret=pfm_get_pmu_info(current_pmu, &pinfo); + /* Off the end, so done iterating */ - if (current_pmu>PFM_PMU_MAX) { + if (ret==PFM_ERR_INVAL) { return PFM_ERR_NOTFOUND; } - memset(&pinfo,0,sizeof(pfm_pmu_info_t)); - pfm_get_pmu_info(current_pmu, &pinfo); - if (pmu_is_present_and_right_type(&pinfo,pmu_type)) break; + if ((ret==PFM_SUCCESS) && pmu_is_present_and_right_type(&pinfo,pmu_type)) break; } current_event=pinfo.first_event; @@ -531,12 +532,20 @@ get_event_first_active(int pmu_type) pmu_idx=0; - while(pmu_idxcmp_info.num_cntrs=0; SUBDBG("Detected pmus:\n"); - for(i=0;icmp_info.num_cntrs += pinfo.num_cntrs+ pinfo.num_fixed_cntrs; } + i++; } SUBDBG("%d native events detected on %d pmus\n",ncnt,detected_pmus);