PAPI  5.4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 71 of file perf_event.c.

71  {
72  return our_cidx;
73 }
static int our_cidx
Definition: perf_event.c:69

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 1045 of file pe_libpfm4_events.c.

1047  {
1048 
1049  int detected_pmus=0, found_default=0;
1050  int i;
1051  int j=0;
1052  pfm_err_t retval = PFM_SUCCESS;
1053  unsigned int ncnt;
1054  pfm_pmu_info_t pinfo;
1055 
1056  /* allocate the native event structure */
1057 
1058  event_table->num_native_events=0;
1059  event_table->pmu_type=pmu_type;
1060 
1061  event_table->native_events=calloc(NATIVE_EVENT_CHUNK,
1062  sizeof(struct native_event_t));
1063  if (event_table->native_events==NULL) {
1064  return PAPI_ENOMEM;
1065  }
1067 
1068  /* Count number of present PMUs */
1069  detected_pmus=0;
1070  ncnt=0;
1071 
1072  /* init default pmu */
1073  /* need to init pinfo or pfmlib might complain */
1074  memset(&(event_table->default_pmu), 0, sizeof(pfm_pmu_info_t));
1075  event_table->default_pmu.size = sizeof(pfm_pmu_info_t);
1076  retval=pfm_get_pmu_info(0, &(event_table->default_pmu));
1077 
1078  SUBDBG("Detected pmus:\n");
1079  for(i=0;i<PFM_PMU_MAX;i++) {
1080  memset(&pinfo,0,sizeof(pfm_pmu_info_t));
1081  pinfo.size = sizeof(pfm_pmu_info_t);
1082  retval=pfm_get_pmu_info(i, &pinfo);
1083  if ((retval!=PFM_SUCCESS) || (pinfo.name == NULL)) {
1084  continue;
1085  }
1086 
1087  if (pmu_is_present_and_right_type(&pinfo,pmu_type)) {
1088  SUBDBG("\t%d %s %s %d\n",i,pinfo.name,pinfo.desc,pinfo.type);
1089 
1090  detected_pmus++;
1091  ncnt+=pinfo.nevents;
1092 
1093  if (j < PAPI_PMU_MAX) {
1094  my_vector->cmp_info.pmu_names[j++] = strdup(pinfo.name);
1095  }
1096 
1097  if (pmu_type&PMU_TYPE_CORE) {
1098 
1099  /* Hack to have "default" PMU */
1100  if ( (pinfo.type==PFM_PMU_TYPE_CORE) &&
1101  strcmp(pinfo.name,"ix86arch")) {
1102 
1103  SUBDBG("\t %s is default\n",pinfo.name);
1104  memcpy(&(event_table->default_pmu),
1105  &pinfo,sizeof(pfm_pmu_info_t));
1106  found_default++;
1107  }
1108  }
1109  if (pmu_type==PMU_TYPE_UNCORE) {
1110  /* To avoid confusion, no "default" CPU for uncore */
1111  found_default=1;
1112  }
1113  }
1114  }
1115  SUBDBG("%d native events detected on %d pmus\n",ncnt,detected_pmus);
1116 
1117  if (!found_default) {
1118  SUBDBG("Could not find default PMU\n");
1119  return PAPI_ECMP;
1120  }
1121 
1122  if (found_default>1) {
1123  PAPIERROR("Found too many default PMUs!\n");
1124  return PAPI_ECMP;
1125  }
1126 
1127  my_vector->cmp_info.num_native_events = ncnt;
1128 
1129  my_vector->cmp_info.num_cntrs = event_table->default_pmu.num_cntrs+
1130  event_table->default_pmu.num_fixed_cntrs;
1131 
1132  SUBDBG( "num_counters: %d\n", my_vector->cmp_info.num_cntrs );
1133 
1134  /* Setup presets, only if Component 0 */
1135  if (cidx==0) {
1136  retval = _papi_load_preset_table( (char *)event_table->default_pmu.name,
1137  event_table->default_pmu.pmu, cidx );
1138  if ( retval ) {
1139  return retval;
1140  }
1141  }
1142 
1143  return PAPI_OK;
1144 }
memset(eventId, 0, size)
struct native_event_t * native_events
#define NATIVE_EVENT_CHUNK
return PAPI_OK
Definition: linux-nvml.c:458
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
int i
Definition: fileop.c:140
#define PAPI_PMU_MAX
Definition: papi.h:467
static int cidx
Definition: event_info.c:40
char * pmu_names[PAPI_PMU_MAX]
Definition: papi.h:647
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
void PAPIERROR(char *format,...)
#define PAPI_ECMP
Definition: papi.h:254
#define PMU_TYPE_CORE
int _papi_load_preset_table(char *pmu_str, int pmu_type, int cidx)
Definition: papi_preset.c:299
#define PAPI_ENOMEM
Definition: papi.h:252
static int pmu_is_present_and_right_type(pfm_pmu_info_t *pinfo, int type)
#define PMU_TYPE_UNCORE
pfm_pmu_info_t default_pmu
long j
Definition: iozone.c:19135
ssize_t retval
Definition: libasync.c:338

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 625 of file pe_libpfm4_events.c.

628 {
629  SUBDBG("ENTER: EventCode: %#x, ntv_descr: %p, len: %d: event_table: %p\n", EventCode, ntv_descr, len, event_table);
630 
631  int eidx;
632  int papi_event_code;
633 
634  // get the attribute index for this papi event
635  papi_event_code = _papi_hwi_get_papi_event_code();
636 
637  // a papi event code less than 0 is invalid, return error
638  if (papi_event_code <= 0) {
639  SUBDBG("EXIT: PAPI_ENOEVNT\n");
640  return PAPI_ENOEVNT;
641  }
642 
643  // find our native event table for this papi event code (search list backwards because it improves chances of finding it quickly)
644  for (eidx=event_table->num_native_events-1 ; eidx>=0 ; eidx--) {
645  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);
646  if ((papi_event_code == event_table->native_events[eidx].papi_event_code) && (EventCode == ((unsigned)event_table->native_events[eidx].libpfm4_idx))) {
647  break;
648  }
649  }
650 
651  // if we did not find a match, return an error
652  if (eidx < 0) {
653  // If we did not find a match in our native event table, then the code passed in has not been
654  // allocated yet It should not be possible to get to this code. The user has to call the papi
655  // code_to_name api with a papi event code for a native event. But the only way to get one of
656  // those is to call either name_to_code or enum_cmp_events first. When one of these calls is
657  // done we allocate the event so it should always be there.
658 
659  SUBDBG("EXIT: PAPI_ENOEVNT\n");
660  return PAPI_ENOEVNT;
661  }
662 
663  char *edesc = event_table->native_events[eidx].event_description;
664 
665  // if it will not fit, return error
666  if (strlen (edesc) >= (unsigned)len) {
667  SUBDBG("EXIT: event name %s will not fit in buffer provided\n", edesc);
668  return PAPI_EBUF;
669  }
670  strcpy (ntv_descr, edesc);
671 
672  // if this event had masks, also add their descriptions
673  char *mdesc = event_table->native_events[eidx].mask_description;
674  if ((mdesc != NULL) && (strlen(mdesc) > 0)) {
675  if ((strlen(edesc) + 8 + strlen(mdesc)) >= (unsigned)len) {
676  SUBDBG("EXIT: Not enough room for event and mask descriptions: need: %u, have: %u", (unsigned)(strlen(edesc) + 8 + strlen(mdesc)), (unsigned)len);
677  return PAPI_EBUF;
678  }
679  strcat (ntv_descr, ", masks:");
680  strcat (ntv_descr, mdesc);
681  }
682 
683  SUBDBG("EXIT: event description: %s\n", ntv_descr);
684  return PAPI_OK;
685 }
#define PAPI_ENOEVNT
Definition: papi.h:258
static unsigned int papi_event_code
unsigned int _papi_hwi_get_papi_event_code()
struct native_event_t * native_events
return PAPI_OK
Definition: linux-nvml.c:458
#define PAPI_EBUF
Definition: papi.h:271
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
strcat(command, mountname)
strcpy(filename, default_filename)

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 689 of file pe_libpfm4_events.c.

692 {
693  SUBDBG("ENTER: EventCode: %#x, info: %p, event_table: %p\n", EventCode, info, event_table);
694 
695  int ret;
696 
697  // get the event name first
698  if ((ret = _pe_libpfm4_ntv_code_to_name(EventCode, info->symbol, sizeof(info->symbol), event_table)) != PAPI_OK) {
699  SUBDBG("EXIT: _pe_libpfm4_ntv_code_to_name returned: %d\n", ret);
700  return PAPI_ENOEVNT;
701  }
702 
703  if ((ret = _pe_libpfm4_ntv_code_to_descr(EventCode, info->long_descr, sizeof(info->long_descr), event_table)) != PAPI_OK) {
704  SUBDBG("EXIT: _pe_libpfm4_ntv_code_to_descr returned: %d\n", ret);
705  return PAPI_ENOEVNT;
706  }
707 
708  SUBDBG("EXIT: EventCode: %#x, name: %s, desc: %s\n", EventCode, info->symbol, info->long_descr);
709  return PAPI_OK;
710 }
#define PAPI_ENOEVNT
Definition: papi.h:258
char long_descr[PAPI_HUGE_STR_LEN]
Definition: papi.h:966
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:963
return PAPI_OK
Definition: linux-nvml.c:458
long long ret
Definition: iozone.c:1346
int _pe_libpfm4_ntv_code_to_name(unsigned int EventCode, char *ntv_name, int len, struct native_event_table_t *event_table)
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
int _pe_libpfm4_ntv_code_to_descr(unsigned int EventCode, char *ntv_descr, int len, struct native_event_table_t *event_table)

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 532 of file pe_libpfm4_events.c.

535 {
536  SUBDBG("ENTER: EventCode: %#x, ntv_name: %p, len: %d, event_table: %p\n", EventCode, ntv_name, len, event_table);
537 
538  int eidx;
539  int papi_event_code;
540 
541  // get the attribute index for this papi event
542  papi_event_code = _papi_hwi_get_papi_event_code();
543 
544  // a papi event code less than 0 is invalid, return error
545  if (papi_event_code <= 0) {
546  SUBDBG("EXIT: PAPI_ENOEVNT\n");
547  return PAPI_ENOEVNT;
548  }
549 
550  // find our native event table for this papi event code (search list backwards because it improves chances of finding it quickly)
551  for (eidx=event_table->num_native_events-1 ; eidx>=0 ; eidx--) {
552  if ((papi_event_code == event_table->native_events[eidx].papi_event_code) && (EventCode == ((unsigned)event_table->native_events[eidx].libpfm4_idx))) {
553  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);
554  break;
555  }
556  }
557 
558  // if we did not find a match, return an error
559  if (eidx < 0) {
560  // If we did not find a match in our native event table, then the code passed in has not been
561  // allocated yet It should not be possible to get to this code. The user has to call the papi
562  // code_to_name api with a papi event code for a native event. But the only way to get one of
563  // those is to call either name_to_code or enum_cmp_events first. When one of these calls is
564  // done we allocate the event so it should always be there.
565 
566  SUBDBG("EXIT: PAPI_ENOEVNT\n");
567  return PAPI_ENOEVNT;
568  }
569 
570  // if this event is defined by the default pmu, then use only the event name
571  // if it is not defined by the default pmu, then use both the pmu name and event name
572  char *ename;
573  if (strcmp(event_table->default_pmu.name, event_table->native_events[eidx].pmu) == 0) {
574  ename = event_table->native_events[eidx].base_name;
575  } else {
576  ename = event_table->native_events[eidx].pmu_plus_name;
577  }
578 
579  // if it will not fit, return error
580  if (strlen (ename) >= (unsigned)len) {
581  SUBDBG("EXIT: event name %s will not fit in buffer provided\n", ename);
582  return PAPI_EBUF;
583  }
584  strcpy (ntv_name, ename);
585 
586  // if this event had masks, also add their names
587  char *mname = event_table->native_events[eidx].mask_string;
588  if ((mname != NULL) && (strlen(mname) > 0)) {
589  if ((strlen(ename) + 8 + strlen(mname)) >= (unsigned)len) {
590  SUBDBG("EXIT: Not enough room for event and mask descriptions: need: %u, have: %u", (unsigned)(strlen(ename) + 8 + strlen(mname)), (unsigned)len);
591  return PAPI_EBUF;
592  }
593  strcat (ntv_name, ":");
594  strcat (ntv_name, mname);
595  }
596 
597  SUBDBG("EXIT: event name: %s\n", ntv_name);
598  return PAPI_OK;
599 }
#define PAPI_ENOEVNT
Definition: papi.h:258
static unsigned int papi_event_code
unsigned int _papi_hwi_get_papi_event_code()
struct native_event_t * native_events
return PAPI_OK
Definition: linux-nvml.c:458
#define PAPI_EBUF
Definition: papi.h:271
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
strcat(command, mountname)
strcpy(filename, default_filename)
pfm_pmu_info_t default_pmu

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 730 of file pe_libpfm4_events.c.

732  {
733 
734  SUBDBG("ENTER: PapiEventCode: %p, *PapiEventCode: %#x, modifier: %d, event_table: %p\n", PapiEventCode, *PapiEventCode, modifier, event_table);
735 
736  int code,ret, pnum;
737  int max_umasks;
738  char event_string[BUFSIZ];
739  pfm_pmu_info_t pinfo;
740  pfm_event_info_t einfo;
741  struct native_event_t *our_event;
742 
743  /* return first event if so specified */
744  if ( modifier == PAPI_ENUM_FIRST ) {
745  attr_idx = 0; // set so if they want attribute information, it will start with the first attribute
746  code=get_first_event_next_pmu(-1, event_table->pmu_type);
747  if (code < 0 ) {
748  SUBDBG("EXIT: Invalid component first event code: %d\n", code);
749  return code;
750  }
751 
752  // get the event information from libpfm4 (must zero structure)
753  memset( &einfo, 0, sizeof( pfm_event_info_t ));
754  einfo.size = sizeof(pfm_event_info_t);
755  if ((ret = pfm_get_event_info(code, PFM_OS_PERF_EVENT_EXT, &einfo)) != PFM_SUCCESS) {
756  SUBDBG("EXIT: pfm_get_event_info returned: %d\n", ret);
757  return PAPI_ENOIMPL;
758  }
759 
760  // get the pmu information from libpfm4 (must zero structure)
761  memset( &pinfo, 0, sizeof(pfm_pmu_info_t) );
762  pinfo.size = sizeof(pfm_pmu_info_t);
763  ret=pfm_get_pmu_info(einfo.pmu, &pinfo);
764  if (ret!=PFM_SUCCESS) {
765  SUBDBG("EXIT: pfm_get_pmu_info returned: %d\n", ret);
766  return ret;
767  }
768 
769  // build full event name
770  sprintf (event_string, "%s::%s", pinfo.name, einfo.name);
771  SUBDBG("code: %#x, pmu: %s, event: %s, event_string: %s\n", code, pinfo.name, einfo.name, event_string);
772 
773  // go allocate this event, need to create tables used by the get event info call that will probably follow
774  if ((our_event = allocate_native_event(event_string, code, event_table)) == NULL) {
775  // allocate may have created the event table but returned NULL to tell the caller the event string was invalid (attempt to encode it failed).
776  // if the caller wants to use this event to count something, it will report an error
777  // but if the caller is just interested in listing the event, then we need an event table with an event name and libpfm4 index
778  int evt_idx;
779  if ((evt_idx = find_existing_event(event_string, event_table)) < 0) {
780  SUBDBG("EXIT: Allocating event: '%s' failed\n", event_string);
781  return PAPI_ENOEVNT;
782  }
783 
784  // give back the new event code
785  *PapiEventCode = event_table->native_events[evt_idx].libpfm4_idx;
786  SUBDBG("EXIT: event code: %#x\n", *PapiEventCode);
787  return PAPI_OK;
788  }
789 
790  *PapiEventCode = our_event->libpfm4_idx;
791 
792  SUBDBG("EXIT: *PapiEventCode: %#x\n", *PapiEventCode);
793  return PAPI_OK;
794  }
795 
796  /* Handle looking for the next event */
797  if ( modifier == PAPI_ENUM_EVENTS ) {
798  attr_idx = 0; // set so if they want attribute information, it will start with the first attribute
799 
800  // get the next event code from libpfm4, if there are no more in this pmu find first event in next pmu
801  if ((code = pfm_get_event_next(*PapiEventCode)) < 0) {
802 
803  // get this events information from libpfm4, we need the pmu number of the last event we processed (table must be cleared)
804  memset( &einfo, 0, sizeof( pfm_event_info_t ));
805  einfo.size = sizeof(pfm_event_info_t);
806  if ((ret = pfm_get_event_info(*PapiEventCode, PFM_OS_PERF_EVENT_EXT, &einfo)) != PFM_SUCCESS) {
807  SUBDBG("EXIT: pfm_get_event_info returned: %d\n", ret);
808  return PAPI_ENOIMPL;
809  }
810  SUBDBG("*PapiEventCode: %#x, event: %s\n", *PapiEventCode, einfo.name);
811 
812  // get the pmu number of the last event
813  pnum = einfo.pmu;
814 
815  while ( pnum<PFM_PMU_MAX) {
816  SUBDBG("pnum: %d\n", pnum);
817  code=get_first_event_next_pmu(pnum, event_table->pmu_type);
818  if (code < 0) {
819  SUBDBG("EXIT: No more pmu's to list, returning: %d\n", code);
820  return code;
821  }
822  break;
823  }
824  }
825 
826 
827  // get the event information from libpfm4 (must zero structure)
828  memset( &einfo, 0, sizeof( pfm_event_info_t ));
829  einfo.size = sizeof(pfm_event_info_t);
830  if ((ret = pfm_get_event_info(code, PFM_OS_PERF_EVENT_EXT, &einfo)) != PFM_SUCCESS) {
831  SUBDBG("EXIT: pfm_get_event_info returned: %d\n", ret);
832  return PAPI_ENOIMPL;
833  }
834 
835  // get the pmu information from libpfm4 (must zero structure)
836  memset( &pinfo, 0, sizeof(pfm_pmu_info_t) );
837  pinfo.size = sizeof(pfm_pmu_info_t);
838  ret=pfm_get_pmu_info(einfo.pmu, &pinfo);
839  if (ret!=PFM_SUCCESS) {
840  SUBDBG("EXIT: pfm_get_pmu_info returned: %d\n", ret);
841  return ret;
842  }
843 
844  // build full event name
845  sprintf (event_string, "%s::%s", pinfo.name, einfo.name);
846  SUBDBG("code: %#x, pmu: %s, event: %s, event_string: %s\n", code, pinfo.name, einfo.name, event_string);
847 
848  // go allocate this event, need to create tables used by the get event info call that will follow
849  if ((our_event = allocate_native_event(event_string, code, event_table)) == NULL) {
850  // allocate may have created the event table but returned NULL to tell the caller the event string was invalid (attempt to encode it failed).
851  // if the caller wants to use this event to count something, it will report an error
852  // but if the caller is just interested in listing the event, then we need an event table with an event name and libpfm4 index
853  int evt_idx;
854  if ((evt_idx = find_existing_event(event_string, event_table)) < 0) {
855  SUBDBG("EXIT: Allocating event: '%s' failed\n", event_string);
856  return PAPI_ENOEVNT;
857  }
858 
859  // give back the new event code
860  *PapiEventCode = event_table->native_events[evt_idx].libpfm4_idx;
861  SUBDBG("EXIT: event code: %#x\n", *PapiEventCode);
862  return PAPI_OK;
863  }
864 
865  // give back the new event code
866  *PapiEventCode = our_event->libpfm4_idx;
867 
868  SUBDBG("EXIT: *PapiEventCode: %#x\n", *PapiEventCode);
869  return PAPI_OK;
870  }
871 
872  /* We don't handle PAPI_NTV_ENUM_UMASK_COMBOS */
873  if ( modifier == PAPI_NTV_ENUM_UMASK_COMBOS ) {
874  SUBDBG("EXIT: do not support umask combos yet\n");
875  return PAPI_ENOIMPL;
876  }
877 
878  /* Enumerate PAPI_NTV_ENUM_UMASKS (umasks on an event) */
879  if ( modifier == PAPI_NTV_ENUM_UMASKS ) {
880  // get this events information from libpfm4, we need the number of masks this event knows about (table must be cleared)
881  memset( &einfo, 0, sizeof( pfm_event_info_t ));
882  einfo.size = sizeof(pfm_event_info_t);
883  if ((ret = pfm_get_event_info(*PapiEventCode, PFM_OS_PERF_EVENT_EXT, &einfo)) != PFM_SUCCESS) {
884  SUBDBG("EXIT: pfm_get_event_info returned: %d\n", ret);
885  return PAPI_ENOIMPL;
886  }
887 // SUBDBG("*PapiEventCode: %#x, einfo.name: %s, einfo.code: %#x, einfo.nattrs: %d\n", *PapiEventCode, einfo.name, einfo.code, einfo.nattrs);
888 
889  // set max number of masks
890  max_umasks = einfo.nattrs;
891 
892  // if we reached last attribute, return error to show we are done with this events masks
893  if (attr_idx == max_umasks) {
894  SUBDBG("EXIT: already processed all umasks: attr_idx: %d\n", attr_idx);
895  return PAPI_ENOEVNT;
896  }
897 
898  // find the event table for this event, we need the pmu name and event name without any masks
900  if (ntv_idx < 0) {
901  SUBDBG("EXIT: _papi_hwi_get_ntv_idx returned: %d\n", ntv_idx);
902  return ntv_idx;
903  }
904  char *ename = event_table->native_events[ntv_idx].pmu_plus_name;
905  if ((ename == NULL) || (strlen(ename) >= sizeof(event_string))) {
906  SUBDBG("EXIT: Event name will not fit into buffer\n");
907  return PAPI_EBUF;
908  }
909  strcpy (event_string, ename);
910  SUBDBG("event_string: %s\n", event_string);
911 
912  // go get the attribute information for this event
913  // libpfm4 likes the table cleared
914  pfm_event_attr_info_t ainfo;
915  memset (&ainfo, 0, sizeof(pfm_event_attr_info_t));
916  ainfo.size = sizeof(pfm_event_attr_info_t);
917  ret = pfm_get_event_attr_info(*PapiEventCode, attr_idx, PFM_OS_PERF_EVENT_EXT, &ainfo);
918  if (ret != PFM_SUCCESS) {
919  SUBDBG("EXIT: Attribute info not found, EventCode: %#x, attr_idx: %d, ret: %d\n", *PapiEventCode, attr_idx, _papi_libpfm4_error(ret));
920  return _papi_libpfm4_error(ret);
921  }
922  SUBDBG("*PapiEventCode: %#x, attr_idx: %d, type: %d, name: %s, description: %s\n", *PapiEventCode, attr_idx, ainfo.type, ainfo.name, ainfo.desc);
923 
924  if (strlen(event_string) + strlen(ainfo.name) + 35 > sizeof(event_string)) {
925  SUBDBG("EXIT: Event name and mask will not fit into buffer\n");
926  return PAPI_EBUF;
927  }
928 
929  strcat (event_string, ":");
930  strcat (event_string, ainfo.name);
931  switch (ainfo.type) {
932  case PFM_ATTR_UMASK:
933  break;
934  case PFM_ATTR_MOD_BOOL:
935  case PFM_ATTR_MOD_INTEGER:
936  // a few attributes require a non-zero value to encode correctly (most would accept zero here)
937  strcat(event_string,"=0");
938  break;
939  default:
940  SUBDBG("EXIT: Unsupported attribute type: %d", ainfo.type);
941  return PAPI_EATTR;
942  }
943 
944  // go allocate this event, need to create tables used by the get event info call that will follow
945  if ((our_event = allocate_native_event(event_string, *PapiEventCode, event_table)) == NULL) {
946  // allocate may have created the event table but returned NULL to tell the caller the event string was invalid.
947  // if the caller wants to use this event to count something, it must report the error
948  // 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
949  int evt_idx;
950  if ((evt_idx = find_existing_event(event_string, event_table)) < 0) {
951  SUBDBG("EXIT: Allocating event: '%s' failed\n", event_string);
952  return PAPI_ENOEVNT;
953  }
954  // bump so next time we will use next attribute
955  attr_idx++;
956  // give back the new event code
957  *PapiEventCode = event_table->native_events[evt_idx].libpfm4_idx;
958  SUBDBG("EXIT: event code: %#x\n", *PapiEventCode);
959  return PAPI_OK;
960  }
961 
962  // bump so next time we will use next attribute
963  attr_idx++;
964 
965  // give back the new event code
966  *PapiEventCode = our_event->libpfm4_idx;
967 
968  SUBDBG("EXIT: event code: %#x\n", *PapiEventCode);
969  return PAPI_OK;
970  }
971 
972  /* Enumerate PAPI_NTV_ENUM_GROUPS (groups on an event) */
973  if ( modifier == PAPI_NTV_ENUM_GROUPS ) {
974  SUBDBG("EXIT: do not support enumerating groups in this component\n");
975  return PAPI_ENOIMPL;
976  }
977 
978  /* An unknown enumeration method was indicated */
979 
980  SUBDBG("EXIT: Invalid modifier argument provided\n");
981  return PAPI_ENOIMPL;
982 }
#define PAPI_ENOEVNT
Definition: papi.h:258
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
memset(eventId, 0, size)
static int get_first_event_next_pmu(int pmu_idx, int pmu_type)
int _papi_hwi_get_ntv_idx(unsigned int papi_evt_code)
unsigned int _papi_hwi_get_papi_event_code()
struct native_event_t * native_events
return PAPI_OK
Definition: linux-nvml.c:458
#define PAPI_EBUF
Definition: papi.h:271
int _papi_libpfm4_error(int pfm_error)
static int attr_idx
long long ret
Definition: iozone.c:1346
static struct native_event_t * allocate_native_event(char *name, int libpfm4_index, struct native_event_table_t *event_table)
static int find_existing_event(char *name, struct native_event_table_t *event_table)
#define PAPI_EATTR
Definition: papi.h:273
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
strcat(command, mountname)
#define PAPI_ENOIMPL
Definition: papi.h:270
strcpy(filename, default_filename)

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 483 of file pe_libpfm4_events.c.

485 {
486  SUBDBG( "ENTER: name: %s, event_code: %p, *event_code: %#x, event_table: %p\n", name, event_code, *event_code, event_table);
487 
488  struct native_event_t *our_event;
489  int event_num;
490 
491  // if we already know this event name, just return its native code
492  event_num=find_existing_event(name, event_table);
493  if (event_num >= 0) {
494  *event_code=event_table->native_events[event_num].libpfm4_idx;
495  // the following call needs to happen to prevent the internal layer from creating a new papi native event table
496  _papi_hwi_set_papi_event_code(event_table->native_events[event_num].papi_event_code, 1);
497  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);
498  return PAPI_OK;
499  }
500 
501  // Try to allocate this event to see if it is known by libpfm4, if allocate fails tell the caller it is not valid
502  our_event=allocate_native_event(name, -1, event_table);
503  if (our_event==NULL) {
504  SUBDBG("EXIT: Allocating event: '%s' failed\n", name);
505  return PAPI_ENOEVNT;
506  }
507 
508  *event_code = our_event->libpfm4_idx;
509  SUBDBG("EXIT: Found code: %#x\n",*event_code);
510  return PAPI_OK;
511 }
#define PAPI_ENOEVNT
Definition: papi.h:258
struct native_event_t * native_events
return PAPI_OK
Definition: linux-nvml.c:458
static struct native_event_t * allocate_native_event(char *name, int libpfm4_index, struct native_event_table_t *event_table)
static int find_existing_event(char *name, struct native_event_table_t *event_table)
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
void _papi_hwi_set_papi_event_code(unsigned int event_code, int update_flag)
char * name
Definition: iozone.c:23648

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 996 of file pe_libpfm4_events.c.

997  {
998  SUBDBG("ENTER: event_table: %p\n", event_table);
999 
1000  int i;
1001 
1002  for (i=0 ; i<PAPI_PMU_MAX ; i++) {
1003  if (my_vector->cmp_info.pmu_names[i] != NULL) {
1004  free (my_vector->cmp_info.pmu_names[i]);
1005  }
1006  }
1007 
1008  /* clean out and free the native events structure */
1010 
1011  /* free memory allocated with strdup or malloc */
1012  for( i=0; i<event_table->num_native_events; i++) {
1013  free(event_table->native_events[i].base_name);
1014  free(event_table->native_events[i].pmu_plus_name);
1015  free(event_table->native_events[i].pmu);
1016  free(event_table->native_events[i].allocated_name);
1017  free(event_table->native_events[i].mask_string);
1018  free(event_table->native_events[i].event_description);
1019  if (event_table->native_events[i].mask_description != NULL) {
1020  free(event_table->native_events[i].mask_description);
1021  }
1022  }
1023 
1024  free(event_table->native_events);
1025 
1027 
1028  SUBDBG("EXIT: PAPI_OK\n");
1029  return PAPI_OK;
1030 }
struct native_event_t * native_events
return PAPI_OK
Definition: linux-nvml.c:458
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
int i
Definition: fileop.c:140
inline_static int _papi_hwi_lock(int lck)
Definition: threads.h:64
#define PAPI_PMU_MAX
Definition: papi.h:467
free(dummyfile[xx])
char * pmu_names[PAPI_PMU_MAX]
Definition: papi.h:647
inline_static int _papi_hwi_unlock(int lck)
Definition: threads.h:78
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
#define NAMELIB_LOCK
Definition: papi_internal.h:93

Here is the call graph for this function:

Here is the caller graph for this function: