PAPI  5.3.2.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
peu_libpfm4_events.c File Reference
Include dependency graph for peu_libpfm4_events.c:

Go to the source code of this file.

Macros

#define NATIVE_EVENT_CHUNK   1024
 

Functions

static int find_existing_event (char *name, struct native_event_table_t *event_table)
 
static struct native_event_tfind_existing_event_by_number (int eventnum, struct native_event_table_t *event_table)
 
static int pmu_is_present_and_right_type (pfm_pmu_info_t *pinfo, int type)
 
static int find_event (char *name, int pmu_type)
 
static int find_event_no_aliases (char *name, int pmu_type)
 
static int find_next_no_aliases (int code, int pmu_type)
 
static struct native_event_tallocate_native_event (char *name, int event_idx, struct native_event_table_t *event_table)
 
static int find_max_umask (struct native_event_t *current_event)
 
static int get_event_first_active (int pmu_type)
 
static int convert_libpfm4_to_string (int code, char **event_name)
 
static int convert_pfmidx_to_native (int code, unsigned int *PapiEventCode, struct native_event_table_t *event_table)
 
static int find_next_umask (struct native_event_t *current_event, int current, char *umask_name)
 
int _peu_libpfm4_ntv_name_to_code (char *name, unsigned int *event_code, struct native_event_table_t *event_table)
 
int _peu_libpfm4_ntv_code_to_name (unsigned int EventCode, char *ntv_name, int len, struct native_event_table_t *event_table)
 
int _peu_libpfm4_ntv_code_to_descr (unsigned int EventCode, char *ntv_descr, int len, struct native_event_table_t *event_table)
 
int _peu_libpfm4_ntv_code_to_info (unsigned int EventCode, PAPI_event_info_t *info, struct native_event_table_t *event_table)
 
int _peu_libpfm4_ntv_enum_events (unsigned int *PapiEventCode, int modifier, struct native_event_table_t *event_table)
 
int _peu_libpfm4_shutdown (struct native_event_table_t *event_table)
 
int _peu_libpfm4_init (papi_vector_t *my_vector, struct native_event_table_t *event_table, int pmu_type)
 
int _peu_libpfm4_setup_counters (struct perf_event_attr *attr, int event, struct native_event_table_t *event_table)
 

Variables

static int enum_call = 0
 

Macro Definition Documentation

#define NATIVE_EVENT_CHUNK   1024

Definition at line 20 of file peu_libpfm4_events.c.

Function Documentation

int _peu_libpfm4_init ( papi_vector_t my_vector,
struct native_event_table_t event_table,
int  pmu_type 
)

Definition at line 1366 of file peu_libpfm4_events.c.

1368  {
1369 
1370  int detected_pmus=0;
1371  int i;
1372  pfm_err_t retval = PFM_SUCCESS;
1373  unsigned int ncnt;
1374  pfm_pmu_info_t pinfo;
1375 
1376  /* allocate the native event structure */
1377 
1378  event_table->num_native_events=0;
1379  event_table->pmu_type=pmu_type;
1380 
1381  event_table->native_events=calloc(NATIVE_EVENT_CHUNK,
1382  sizeof(struct native_event_t));
1383  if (event_table->native_events==NULL) {
1384  return PAPI_ENOMEM;
1385  }
1387 
1388  /* Count number of present PMUs */
1389  detected_pmus=0;
1390  ncnt=0;
1391 
1392  my_vector->cmp_info.num_cntrs=0;
1393 
1394  SUBDBG("Detected pmus:\n");
1395  for(i=0;i<PFM_PMU_MAX;i++) {
1396  memset(&pinfo,0,sizeof(pfm_pmu_info_t));
1397  retval=pfm_get_pmu_info(i, &pinfo);
1398  if (retval!=PFM_SUCCESS) {
1399  continue;
1400  }
1401 
1402  if (pmu_is_present_and_right_type(&pinfo,pmu_type)) {
1403  SUBDBG("\t%d %s %s %d\n",i,pinfo.name,pinfo.desc,pinfo.type);
1404 
1405  detected_pmus++;
1406  ncnt+=pinfo.nevents;
1407 
1408  my_vector->cmp_info.num_cntrs += pinfo.num_cntrs+
1409  pinfo.num_fixed_cntrs;
1410  }
1411  }
1412  SUBDBG("%d native events detected on %d pmus\n",ncnt,detected_pmus);
1413 
1414  my_vector->cmp_info.num_native_events = ncnt;
1415 
1416  SUBDBG( "num_counters: %d\n", my_vector->cmp_info.num_cntrs );
1417 
1418  return PAPI_OK;
1419 }
memset(eventId, 0, size)
#define PAPI_ENOMEM
Definition: fpapi.h:107
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
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static int pmu_is_present_and_right_type(pfm_pmu_info_t *pinfo, int type)
ssize_t retval
Definition: libasync.c:338
#define NATIVE_EVENT_CHUNK

Here is the call graph for this function:

Here is the caller graph for this function:

int _peu_libpfm4_ntv_code_to_descr ( unsigned int  EventCode,
char *  ntv_descr,
int  len,
struct native_event_table_t event_table 
)

Definition at line 932 of file peu_libpfm4_events.c.

935 {
936  int ret,a,first_mask=1;
937  char *eventd, *tmp=NULL;
938  pfm_event_info_t gete;
939 
940  pfm_event_attr_info_t ainfo;
941  char *b;
942  char event_string[BUFSIZ],*ptr;
943 
944  struct native_event_t *our_event;
945 
946  SUBDBG("ENTER %#x\n",EventCode);
947 
948  our_event=find_existing_event_by_number(EventCode,event_table);
949  if (our_event==NULL) {
950  return PAPI_ENOEVNT;
951  }
952 
953  SUBDBG("Getting info on %#x\n",our_event->libpfm4_idx);
954 
955  /* libpfm requires the structure be zeroed */
956  memset( &gete, 0, sizeof ( gete ) );
957 
958  ret=pfm_get_event_info(our_event->libpfm4_idx, PFM_OS_PERF_EVENT, &gete);
959  if (ret<0) {
960  SUBDBG("Return=%d\n",ret);
961  return _papi_libpfm4_error(ret);
962  }
963 
964  eventd=strdup(gete.desc);
965 
966  tmp = ( char * ) malloc( strlen( eventd ) + 1 );
967  if ( tmp == NULL ) {
968  free( eventd );
969  return PAPI_ENOMEM;
970  }
971 
972  tmp[0] = '\0';
973  strcat( tmp, eventd );
974  free( eventd );
975 
976  /* Handle Umasks */
977 
978  /* attributes concactinated onto end of descr separated by ", masks" */
979  /* then comma separated */
980 
981  strcpy(event_string,our_event->allocated_name);
982 
983  /* Point to first umask */
984 
985  /* Skip the pmu name :: if one exists */
986  if (strstr(event_string,"::")) {
987  ptr=strstr(event_string,"::");
988  ptr+=2;
989  b=strtok(ptr,":");
990  }
991  else {
992  b=strtok(event_string,":");
993  }
994 
995  /* if no umask, then done */
996  if (!b) {
997  SUBDBG("No colon!\n"); /* no umask */
998  goto descr_in_tmp;
999  }
1000 
1001  /* skip event name, get first umask (but if it is a bool or int mask type, we only want the name part not the =x part) */
1002  b=strtok(NULL,":=");
1003  if (!b) {
1004  SUBDBG("Skipping to first mask failed\n");
1005  goto descr_in_tmp;
1006  }
1007 
1008  /* loop through all umasks, seeing which match */
1009  while(b) {
1010  a=0;
1011  while(1) {
1012 
1013 
1014  memset(&ainfo,0,sizeof(pfm_event_attr_info_t));
1015 
1016  ret = pfm_get_event_attr_info(our_event->libpfm4_idx, a,
1017  PFM_OS_PERF_EVENT, &ainfo);
1018  if (ret != PFM_SUCCESS) {
1019  free( tmp );
1020  SUBDBG("get_event_attr failed %s\n",pfm_strerror(ret));
1021  return _papi_libpfm4_error(ret);
1022  }
1023 
1024  SUBDBG("Compare: ainfo.name: %s, ainfo.type: %d, with event mask: %s\n", ainfo.name, ainfo.type, b);
1025 
1026  /* Plain UMASK case */
1027  if (ainfo.type == PFM_ATTR_UMASK) {
1028  if (!strcasecmp(ainfo.name, b)) {
1029  int new_length;
1030 
1031  SUBDBG("Found %s\n",b);
1032  new_length=strlen(ainfo.desc);
1033 
1034  if (first_mask) {
1035  tmp=realloc(tmp,strlen(tmp)+new_length+1+strlen(", masks:"));
1036  strcat(tmp,", masks:");
1037  first_mask=0;
1038  }
1039  else {
1040  tmp=realloc(tmp,strlen(tmp)+new_length+1+strlen(","));
1041  strcat(tmp,",");
1042  }
1043  strcat(tmp,ainfo.desc);
1044 
1045  goto found_attr;
1046  }
1047  }
1048 
1049  /* Boolean Case */
1050  if (ainfo.type == PFM_ATTR_MOD_BOOL) {
1051  if (!strcasecmp(ainfo.name, b)) {
1052  int new_length;
1053 
1054  SUBDBG("Found %s\n",b);
1055  new_length=strlen(ainfo.desc);
1056 
1057  if (first_mask) {
1058  tmp=realloc(tmp,strlen(tmp)+new_length+1+strlen(", masks:"));
1059  strcat(tmp,", masks:");
1060  first_mask=0;
1061  }
1062  else {
1063  tmp=realloc(tmp,strlen(tmp)+new_length+1+strlen(","));
1064  strcat(tmp,",");
1065  }
1066  strcat(tmp,ainfo.desc);
1067 
1068  b=strtok(NULL,":"); // skip value provided with this attribute
1069  goto found_attr;
1070  }
1071  }
1072 
1073  /* Integer Case */
1074  if (ainfo.type == PFM_ATTR_MOD_INTEGER) {
1075  if (!strcasecmp(ainfo.name, b)) {
1076  int new_length;
1077 
1078  SUBDBG("Found %s\n",b);
1079  new_length=strlen(ainfo.desc);
1080 
1081  if (first_mask) {
1082  tmp=realloc(tmp,strlen(tmp)+new_length+1+strlen(", masks:"));
1083  strcat(tmp,", masks:");
1084  first_mask=0;
1085  }
1086  else {
1087  tmp=realloc(tmp,strlen(tmp)+new_length+1+strlen(","));
1088  strcat(tmp,",");
1089  }
1090  strcat(tmp,ainfo.desc);
1091 
1092  b=strtok(NULL,":"); // skip value provided with this attribute
1093  goto found_attr;
1094  }
1095  }
1096 
1097  a++;
1098  }
1099 
1100  SUBDBG("attr=%s not found for event %s\n", b, ainfo.name);
1101 
1102  return PAPI_EATTR;
1103 
1104 found_attr:
1105 
1106  b=strtok(NULL,":=");
1107  }
1108 
1109  /* We are done and the description to copy is in tmp */
1110 descr_in_tmp:
1111  strncpy( ntv_descr, tmp, ( size_t ) len );
1112  if ( ( int ) strlen( tmp ) > len - 1 )
1113  ret = PAPI_EBUF;
1114  else
1115  ret = PAPI_OK;
1116  free( tmp );
1117 
1118  SUBDBG("PFM4 Code: %#x %s\n",EventCode,ntv_descr);
1119 
1120  return ret;
1121 }
memset(eventId, 0, size)
#define PAPI_ENOMEM
Definition: fpapi.h:107
#define PAPI_ENOEVNT
Definition: fpapi.h:112
#define PAPI_EATTR
Definition: fpapi.h:127
return PAPI_OK
Definition: linux-nvml.c:458
int _papi_libpfm4_error(int pfm_error)
static double a[MATRIX_SIZE][MATRIX_SIZE]
Definition: rapl_basic.c:37
long long ret
Definition: iozone.c:1346
free(dummyfile[xx])
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
strcat(command, mountname)
strcpy(filename, default_filename)
static struct native_event_t * find_existing_event_by_number(int eventnum, struct native_event_table_t *event_table)
static double b[MATRIX_SIZE][MATRIX_SIZE]
Definition: rapl_basic.c:38
#define PAPI_EBUF
Definition: fpapi.h:125
long long tmp
Definition: iozone.c:12031
char * ptr
Definition: iozone.c:23586

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1125 of file peu_libpfm4_events.c.

1128 {
1129 
1130 
1131  struct native_event_t *our_event;
1132 
1133  SUBDBG("ENTER %#x\n",EventCode);
1134 
1135  our_event=find_existing_event_by_number(EventCode,event_table);
1136  if (our_event==NULL) {
1137  return PAPI_ENOEVNT;
1138  }
1139 
1140  strncpy(info->symbol, our_event->allocated_name, sizeof(info->symbol));
1141 
1142  if (strlen(our_event->allocated_name) > sizeof(info->symbol)) {
1143  return PAPI_EBUF;
1144  }
1145 
1147  sizeof(info->long_descr),event_table);
1148 
1149  return PAPI_OK;
1150 }
#define PAPI_ENOEVNT
Definition: fpapi.h:112
char long_descr[PAPI_HUGE_STR_LEN]
Definition: papi.h:964
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:961
return PAPI_OK
Definition: linux-nvml.c:458
int _peu_libpfm4_ntv_code_to_descr(unsigned int EventCode, char *ntv_descr, int len, struct native_event_table_t *event_table)
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static struct native_event_t * find_existing_event_by_number(int eventnum, struct native_event_table_t *event_table)
#define PAPI_EBUF
Definition: fpapi.h:125

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 885 of file peu_libpfm4_events.c.

888 {
889 
890  struct native_event_t *our_event;
891 
892  SUBDBG("ENTER %#x\n",EventCode);
893 
894  our_event=find_existing_event_by_number(EventCode,event_table);
895  if (our_event==NULL) {
896  return PAPI_ENOEVNT;
897  }
898 
899  strncpy(ntv_name,our_event->allocated_name,len);
900 
901  if (strlen(our_event->allocated_name) > (unsigned)len) {
902  return PAPI_EBUF;
903  }
904 
905  return PAPI_OK;
906 }
#define PAPI_ENOEVNT
Definition: fpapi.h:112
return PAPI_OK
Definition: linux-nvml.c:458
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static struct native_event_t * find_existing_event_by_number(int eventnum, struct native_event_table_t *event_table)
#define PAPI_EBUF
Definition: fpapi.h:125

Here is the call graph for this function:

Here is the caller graph for this function:

int _peu_libpfm4_ntv_enum_events ( unsigned int PapiEventCode,
int  modifier,
struct native_event_table_t event_table 
)

Definition at line 1171 of file peu_libpfm4_events.c.

1173  {
1174 
1175  int code,ret;
1176  struct native_event_t *current_event;
1177 
1178  SUBDBG("ENTER\n");
1179 
1180  /* return first event if so specified */
1181  if ( modifier == PAPI_ENUM_FIRST ) {
1182 
1183  unsigned int papi_event=0;
1184 
1185  SUBDBG("ENUM_FIRST\n");
1186 
1187  code=get_event_first_active(event_table->pmu_type);
1188  SUBDBG("ENUM_FIRST code: %#x\n",code);
1189  if (code < 0 ) {
1190  return code;
1191  }
1192 
1193  /* convert the libpfm4 event to a PAPI event */
1194  ret=convert_pfmidx_to_native(code, &papi_event,event_table);
1195 
1196  *PapiEventCode=(unsigned int)papi_event;
1197 
1198  SUBDBG("FOUND %#x (from %#x) ret=%d\n",*PapiEventCode,code,ret);
1199 
1200  return ret;
1201  }
1202 
1203  /* If we get this far, we're looking for a */
1204  /* next-event. So gather info on the current one */
1205  current_event=find_existing_event_by_number(*PapiEventCode,
1206  event_table);
1207  if (current_event==NULL) {
1208  SUBDBG("EVENTS %#x not found\n",*PapiEventCode);
1209  return PAPI_ENOEVNT;
1210  }
1211 
1212 
1213  /* Handle looking for the next event */
1214 
1215  if ( modifier == PAPI_ENUM_EVENTS ) {
1216 
1217  unsigned int papi_event=0;
1218 
1219  SUBDBG("PAPI_ENUM_EVENTS %#x\n",*PapiEventCode);
1220 
1221  code=current_event->libpfm4_idx;
1222 
1223  ret=find_next_no_aliases(code,event_table->pmu_type);
1224  SUBDBG("find_next_no_aliases() Returned %#x\n",ret);
1225  if (ret<0) {
1226  return ret;
1227  }
1228 
1229  /* Convert libpfm4 event code to PAPI event code */
1230  ret=convert_pfmidx_to_native(ret, &papi_event, event_table);
1231  if (ret<0) {
1232  SUBDBG("Couldn't convert to native %d %s\n",
1233  ret,PAPI_strerror(ret));
1234  return ret;
1235  }
1236 
1237  *PapiEventCode=(unsigned int)papi_event;
1238 
1239  SUBDBG("Returning PAPI_OK\n");
1240 
1241  return ret;
1242  }
1243 
1244  /* We don't handle PAPI_NTV_ENUM_UMASK_COMBOS */
1245  if ( modifier == PAPI_NTV_ENUM_UMASK_COMBOS ) {
1246  return PAPI_ENOIMPL;
1247  }
1248 
1249  /* Enumerate PAPI_NTV_ENUM_UMASKS (umasks on an event) */
1250  if ( modifier == PAPI_NTV_ENUM_UMASKS ) {
1251 
1252  int max_umask,next_umask;
1253  char umask_string[BUFSIZ],new_name[BUFSIZ];
1254 
1255  SUBDBG("Finding maximum mask in event %s\n",
1256  current_event->allocated_name);
1257 
1258  max_umask=find_max_umask(current_event);
1259  SUBDBG("Found max %d\n",max_umask);
1260 
1261  if (max_umask<0) {
1262  if (max_umask==PFM_ERR_UMASK) {
1263  max_umask=-1; /* needed for find_next_umask() to work */
1264  /* indicates the event as passed had no */
1265  /* umask in it. */
1266  }
1267  else {
1268  return _papi_libpfm4_error(max_umask);
1269  }
1270  }
1271 
1272  next_umask=find_next_umask(current_event,max_umask,
1273  umask_string);
1274 
1275  SUBDBG("Found next umask index %d, umask_string: %s\n",next_umask, umask_string);
1276 
1277  if (next_umask>=0) {
1278 
1279  unsigned int papi_event;
1280 
1281  // Build the event name of next event to be listed (include pmu, event, and mask)
1282  sprintf(new_name,"%s::%s:%s",current_event->pmu,current_event->base_name, umask_string);
1283 
1284  SUBDBG("Found new name %s\n",new_name);
1285 
1286  // The _peu_libpfm4_ntv_name_to_code function calls code that needs to know if we are listing events or counting them.
1287  // If listing, then there is some special things it has to do with umasks to get the listing to work correctly.
1288  enum_call = 1;
1289  ret=_peu_libpfm4_ntv_name_to_code(new_name,&papi_event,
1290  event_table);
1291  enum_call = 0;
1292  if (ret!=PAPI_OK) {
1293  return PAPI_ENOEVNT;
1294  }
1295 
1296  *PapiEventCode=(unsigned int)papi_event;
1297  SUBDBG("found code %#x\n",*PapiEventCode);
1298 
1299  return PAPI_OK;
1300  }
1301 
1302  SUBDBG("couldn't find umask\n");
1303 
1304  return _papi_libpfm4_error(next_umask);
1305 
1306  }
1307 
1308  /* An unknown enumeration method was indicated */
1309 
1310  return PAPI_ENOIMPL;
1311 }
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
#define PAPI_ENOIMPL
Definition: fpapi.h:124
static int find_max_umask(struct native_event_t *current_event)
static int enum_call
#define PAPI_ENOEVNT
Definition: fpapi.h:112
static int find_next_no_aliases(int code, int pmu_type)
return PAPI_OK
Definition: linux-nvml.c:458
int _papi_libpfm4_error(int pfm_error)
long long ret
Definition: iozone.c:1346
int _peu_libpfm4_ntv_name_to_code(char *name, unsigned int *event_code, struct native_event_table_t *event_table)
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static int convert_pfmidx_to_native(int code, unsigned int *PapiEventCode, struct native_event_table_t *event_table)
static int get_event_first_active(int pmu_type)
static struct native_event_t * find_existing_event_by_number(int eventnum, struct native_event_table_t *event_table)
char * PAPI_strerror(int errorCode)
Definition: papi.c:4483
int
Definition: iozone.c:18528
static int find_next_umask(struct native_event_t *current_event, int current, char *umask_name)

Here is the call graph for this function:

Here is the caller graph for this function:

int _peu_libpfm4_ntv_name_to_code ( char *  name,
unsigned int event_code,
struct native_event_table_t event_table 
)

Definition at line 818 of file peu_libpfm4_events.c.

820 {
821 
822  int actual_idx;
823  struct native_event_t *our_event;
824  int event_num;
825 
826  SUBDBG( "Converting %s\n", name);
827 
828  event_num=find_existing_event(name,event_table);
829 
830  if (event_num<0) {
831 
832  /* event currently doesn't exist, so try to find it */
833  /* using libpfm4 */
834 
835  SUBDBG("Using pfm to look up event %s\n",name);
836 
837  actual_idx=find_event(name, event_table->pmu_type);
838  if (actual_idx<0) {
839  return _papi_libpfm4_error(actual_idx);
840  }
841 
842  SUBDBG("Using %#x as the index\n",actual_idx);
843 
844  /* We were found in libpfm4, so allocate our copy of the event */
845 
846  our_event=allocate_native_event(name,actual_idx,event_table);
847  if (our_event==NULL) return PAPI_ENOEVNT;
848 
849  event_num=find_existing_event(name,event_table);
850  }
851 
852  if (event_num>=0) {
853  *event_code=event_num;
854  SUBDBG("Found code: %#x\n",*event_code);
855  return PAPI_OK;
856  }
857 
858  /* Failure here means allocate_native_event failed */
859 
860  SUBDBG("Event %s not found\n",name);
861 
862  return PAPI_ENOEVNT;
863 
864 }
static struct native_event_t * allocate_native_event(char *name, int event_idx, struct native_event_table_t *event_table)
#define PAPI_ENOEVNT
Definition: fpapi.h:112
static int find_event(char *name, int pmu_type)
return PAPI_OK
Definition: linux-nvml.c:458
int _papi_libpfm4_error(int pfm_error)
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
char * name
Definition: iozone.c:23648
static int find_existing_event(char *name, struct native_event_table_t *event_table)

Here is the call graph for this function:

Here is the caller graph for this function:

int _peu_libpfm4_setup_counters ( struct perf_event_attr attr,
int  event,
struct native_event_table_t event_table 
)

Definition at line 1437 of file peu_libpfm4_events.c.

1439  {
1440 
1441  struct native_event_t *our_event;
1442 
1443  our_event=find_existing_event_by_number(event,event_table);
1444  if (our_event==NULL) {
1445  return PAPI_ENOEVNT;
1446  }
1447 
1448  attr->config=our_event->config;
1449  attr->config1=our_event->config1;
1450  attr->config2=our_event->config2;
1451  attr->type=our_event->type;
1452 
1453  SUBDBG( "pe_event: config %#lx config1 %#lx type %x\n",
1454  attr->config,
1455  attr->config1,
1456  attr->type);
1457 
1458  return PAPI_OK;
1459 }
#define PAPI_ENOEVNT
Definition: fpapi.h:112
device[deviceId] domain[domainId] event
Definition: linux-cuda.c:306
return PAPI_OK
Definition: linux-nvml.c:458
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static struct native_event_t * find_existing_event_by_number(int eventnum, struct native_event_table_t *event_table)

Here is the call graph for this function:

Here is the caller graph for this function:

int _peu_libpfm4_shutdown ( struct native_event_table_t event_table)

Definition at line 1324 of file peu_libpfm4_events.c.

1324  {
1325 
1326  int i;
1327 
1328  APIDBG("Entry\n");
1329 
1330  /* clean out and free the native events structure */
1332 
1333  /* Only free if we're the last user */
1334 
1335  /* free memory allocated with strdup */
1336  for( i=0; i<event_table->num_native_events; i++) {
1337  free(event_table->native_events[i].base_name);
1338  free(event_table->native_events[i].pmu_plus_name);
1339  free(event_table->native_events[i].pmu);
1340  free(event_table->native_events[i].allocated_name);
1341  }
1342 
1343  memset(event_table->native_events,0,
1344  sizeof(struct native_event_t)*event_table->allocated_native_events);
1345  event_table->num_native_events=0;
1346  event_table->allocated_native_events=0;
1347  free(event_table->native_events);
1348 
1350 
1351  return PAPI_OK;
1352 }
memset(eventId, 0, size)
struct native_event_t * native_events
return PAPI_OK
Definition: linux-nvml.c:458
#define APIDBG(format, args...)
Definition: papi_debug.h:64
int i
Definition: fileop.c:140
inline_static int _papi_hwi_lock(int lck)
Definition: threads.h:64
free(dummyfile[xx])
inline_static int _papi_hwi_unlock(int lck)
Definition: threads.h:78
#define NAMELIB_LOCK
Definition: papi_internal.h:93

Here is the call graph for this function:

Here is the caller graph for this function:

static struct native_event_t* allocate_native_event ( char *  name,
int  event_idx,
struct native_event_table_t event_table 
)
static

Definition at line 274 of file peu_libpfm4_events.c.

276  {
277 SUBDBG("Entry: name: %s, event_idx: %#x\n", name, event_idx);
278 
279  int new_event;
280 
281  pfm_err_t ret;
282  unsigned int i;
283  char *base_start;
284  pfm_event_info_t info;
285  pfm_pmu_info_t pinfo;
286  char base[BUFSIZ],pmuplusbase[BUFSIZ];
287  char fullname[BUFSIZ];
288 
289  pfm_perf_encode_arg_t perf_arg;
290 
291  struct perf_event_attr perf_attr;
292 
293  /* get the event name from libpfm */
294  memset(&info,0,sizeof(pfm_event_info_t));
295  ret = pfm_get_event_info(event_idx, PFM_OS_PERF_EVENT, &info);
296  if (ret!=PFM_SUCCESS) {
297  return NULL;
298  }
299 
300  /* get the PMU info */
301  memset(&pinfo,0,sizeof(pfm_pmu_info_t));
302  pfm_get_pmu_info(info.pmu, &pinfo);
303 
304  /* calculate the base name, meaning strip off pmu identifier */
305  strncpy(base,name,BUFSIZ);
306  i=0;
307  base_start=base;
308  while(i<strlen(base)) {
309  if (base[i]==':') {
310  if (base[i+1]==':') {
311  i++;
312  base_start=&base[i+1];
313  }
314  else {
315  base[i]=0;
316  }
317  }
318  i++;
319  }
320 
321  /* add the event */
323 
324  new_event=event_table->num_native_events;
325 
326  event_table->native_events[new_event].base_name=strdup(base_start);
327 
328  sprintf(fullname,"%s::%s",pinfo.name,info.name);
329  event_table->native_events[new_event].pmu_plus_name=strdup(fullname);
330 
331  sprintf(pmuplusbase,"%s::%s",pinfo.name,base_start);
332 
333  event_table->native_events[new_event].component=0;
334  event_table->native_events[new_event].pmu=strdup(pinfo.name);
335 
336  event_table->native_events[new_event].libpfm4_idx=
337  find_event_no_aliases(pmuplusbase,event_table->pmu_type);
338 
339  SUBDBG("Using %#x as index instead of %#x for %s\n",
340  event_table->native_events[new_event].libpfm4_idx,
341  event_idx,pmuplusbase);
342 
343  event_table->native_events[new_event].allocated_name=strdup(name);
344 
345  /* is this needed? */
346  event_table->native_events[new_event].users=0;
347 
348 
349  /* use name of the event to get the perf_event encoding */
350 
351  /* clear the attribute structure */
352  memset(&perf_arg,0,sizeof(pfm_perf_encode_arg_t));
353 
354  /* clear out the perf_attr struct */
355  memset(&perf_attr,0,sizeof(struct perf_event_attr));
356  perf_arg.attr=&perf_attr;
357 
358  // Put the event name into a work area that we can change if the umasks need to be adjusted.
359  // This may be necessary when we are doing a list, but we do not want to change the callers copy.
360  char new_name[BUFSIZ];
361  strcpy(new_name, name);
362 
363  // This code gets called both when setting up to count events and when just trying to list
364  // uncore events. When setting up to count, it is the users responsibility to provide the umasks.
365  // If we got here through _peu_libpfm4_ntv_enum_events (listing events), then we need to make
366  // sure that umasks which need to be used together are both provided so the pfm_get_os_event_encoding
367  // function below does not return an error. When and error is returned it gets sent back to the enum code
368  // which causes the loop looking for umasks to quit. This causes the event list to not report all of
369  // the umask's which are valid for some events. When listing events, there is always only one umask
370  // provided and it is always at the end of the event name string.
371 
372  // if we are listing events
373  if (enum_call != 0) {
374  // if these are sandy bridge uncore events
375  if (strstr(new_name, "snbep_unc_") != NULL) {
376  // If this event has an NID, NID_ALL, NID_EVECTION, NID_MISS_ALL, NID_MISS_OPCODE, or NID_OPCODE mask,
377  // then a nf= needs to be added. Since the NIDxxx mask will always be at the end of the event name
378  // string we can just concatenate the new nf= to the end of the name.
379  if (strstr(new_name, "NID") != NULL) {
380  strcat(new_name, ":nf=1");
381  } else {
382  // If this event has a nf= umask, then we need to insert an NID mask. If the event name is UNC_C_LLC_LOOKUP
383  // or UNC_C_LLC_VICTIMS then we need to use the NID umask. But if the event name is UNC_C_TOR_INSERTS or
384  // UNC_C_TOR_OCCUPANCY then we will always use NID_ALL. The purpose of adding the NIDxxx umask is just to
385  // get the nf= to show up in the list so it should not matter which NID type mask is used (but it must be
386  // valid for that event).
387  char *wrk;
388  if ((wrk = strstr(new_name, "nf=")) != NULL) {
389  if (strstr(new_name, "UNC_C_LLC_") != NULL) {
390  strcpy(wrk, "NID:nf=1");
391  }
392  if (strstr(new_name, "UNC_C_TOR_") != NULL) {
393  strcpy(wrk, "NID_ALL:nf=1");
394  }
395  }
396  }
397  }
398  }
399 
400  ret = pfm_get_os_event_encoding(new_name,
401  PFM_PLM0 | PFM_PLM3,
402  PFM_OS_PERF_EVENT,
403  &perf_arg);
404  /* If we error out on UMASK then enumeration doesn't work */
405  if ((ret==PFM_SUCCESS) || (ret==PFM_ERR_UMASK)) {
406  event_table->native_events[new_event].config=perf_arg.attr->config;
407  event_table->native_events[new_event].config1=perf_arg.attr->config1;
408  event_table->native_events[new_event].type=perf_arg.attr->type;
409 
410  SUBDBG( "pe_event: config %#lx config1 %lx type %#x\n",
411  perf_arg.attr->config,
412  perf_arg.attr->config1,
413  perf_arg.attr->type);
414 
415  SUBDBG("Creating event %s with perfidx %#x\n",
416  name, event_table->native_events[new_event].libpfm4_idx);
417 
418  event_table->num_native_events++;
419 
420  /* If we've allocated too many native events, then allocate more room */
421  if (event_table->num_native_events >=
422  event_table->allocated_native_events) {
423 
424  SUBDBG("Allocating more room for native events (%d %ld)\n",
426  (long)sizeof(struct native_event_t) *
428 
429  event_table->native_events=realloc(event_table->native_events,
430  sizeof(struct native_event_t) *
433  }
434  }
436 
437  if (event_table->native_events==NULL) {
438  SUBDBG("Event name: %s not found.\n", name);
439  return NULL;
440  }
441 
442  SUBDBG("Event name: %s found.\n", name);
443  return &event_table->native_events[new_event];
444 
445 }
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
memset(eventId, 0, size)
struct native_event_t * native_events
static int enum_call
long long ret
Definition: iozone.c:1346
static int find_event_no_aliases(char *name, int pmu_type)
int i
Definition: fileop.c:140
inline_static int _papi_hwi_lock(int lck)
Definition: threads.h:64
inline_static int _papi_hwi_unlock(int lck)
Definition: threads.h:78
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
strcat(command, mountname)
#define NAMELIB_LOCK
Definition: papi_internal.h:93
strcpy(filename, default_filename)
char * name
Definition: iozone.c:23648
#define NATIVE_EVENT_CHUNK

Here is the call graph for this function:

Here is the caller graph for this function:

static int convert_libpfm4_to_string ( int  code,
char **  event_name 
)
static

Definition at line 628 of file peu_libpfm4_events.c.

629 {
630 
631  int ret;
632  pfm_event_info_t gete;
633  pfm_pmu_info_t pinfo;
634  char name[BUFSIZ];
635 
636  SUBDBG("ENTER %#x\n",code);
637 
638  /* Clear structures, as wanted by libpfm4 */
639  memset( &gete, 0, sizeof (pfm_event_info_t) );
640 
641  ret=pfm_get_event_info(code, PFM_OS_PERF_EVENT, &gete);
642  if (ret!=PFM_SUCCESS) {
643  return ret;
644  }
645 
646  memset( &pinfo, 0, sizeof(pfm_pmu_info_t) );
647  ret=pfm_get_pmu_info(gete.pmu, &pinfo);
648  if (ret!=PFM_SUCCESS) {
649  return ret;
650  }
651 
652  sprintf(name,"%s::%s",pinfo.name,gete.name);
653  *event_name=strdup(name);
654 
655  SUBDBG("Found name: %s\n",*event_name);
656 
657  return PFM_SUCCESS;
658 
659 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:23
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
memset(eventId, 0, size)
long long ret
Definition: iozone.c:1346
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
char * name
Definition: iozone.c:23648

Here is the call graph for this function:

Here is the caller graph for this function:

static int convert_pfmidx_to_native ( int  code,
unsigned int PapiEventCode,
struct native_event_table_t event_table 
)
static

Definition at line 676 of file peu_libpfm4_events.c.

677  {
678 
679  int ret;
680  char *name=NULL;
681 
682  ret=convert_libpfm4_to_string( code, &name);
683  if (ret!=PFM_SUCCESS) {
684  return _papi_libpfm4_error(ret);
685  }
686 
687  SUBDBG("Converted %#x to %s\n",code,name);
688 
689  ret=_peu_libpfm4_ntv_name_to_code(name,PapiEventCode,event_table);
690 
691  SUBDBG("Converted %s to event %#x\n",name,*PapiEventCode);
692 
693  if (name) free(name);
694 
695  return ret;
696 
697 }
static int convert_libpfm4_to_string(int code, char **event_name)
int _papi_libpfm4_error(int pfm_error)
long long ret
Definition: iozone.c:1346
int _peu_libpfm4_ntv_name_to_code(char *name, unsigned int *event_code, struct native_event_table_t *event_table)
free(dummyfile[xx])
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
char * name
Definition: iozone.c:23648

Here is the call graph for this function:

Here is the caller graph for this function:

static int find_event ( char *  name,
int  pmu_type 
)
static

Definition at line 115 of file peu_libpfm4_events.c.

115  {
116 
117  int ret, actual_idx;
118  pfm_pmu_info_t pinfo;
119  pfm_event_info_t event_info;
120 
121  SUBDBG("Looking for %s\n",name);
122 
123  actual_idx=pfm_find_event(name);
124  if (actual_idx<0) {
125  return PFM_ERR_NOTFOUND;
126  }
127 
128  memset(&event_info,0,sizeof(pfm_event_info_t));
129  ret=pfm_get_event_info(actual_idx, PFM_OS_PERF_EVENT, &event_info);
130  if (ret<0) {
131  return PFM_ERR_NOTFOUND;
132  }
133 
134  memset(&pinfo,0,sizeof(pfm_pmu_info_t));
135  pfm_get_pmu_info(event_info.pmu, &pinfo);
136  if (pmu_is_present_and_right_type(&pinfo,pmu_type)) {
137  return actual_idx;
138  }
139 
140  return PFM_ERR_NOTFOUND;
141 }
memset(eventId, 0, size)
long long ret
Definition: iozone.c:1346
static struct counter_info * event_info
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
char * name
Definition: iozone.c:23648
static int pmu_is_present_and_right_type(pfm_pmu_info_t *pinfo, int type)

Here is the call graph for this function:

Here is the caller graph for this function:

static int find_event_no_aliases ( char *  name,
int  pmu_type 
)
static

Definition at line 155 of file peu_libpfm4_events.c.

155  {
156 
157  int j,i, ret;
158  pfm_pmu_info_t pinfo;
159  pfm_event_info_t event_info;
160  char full_name[BUFSIZ];
161 
162  SUBDBG("Looking for %s\n",name);
163 
164  pfm_for_all_pmus(j) {
165 
166  memset(&pinfo,0,sizeof(pfm_pmu_info_t));
167  pfm_get_pmu_info(j, &pinfo);
168  if (!pmu_is_present_and_right_type(&pinfo,pmu_type)) {
169  continue;
170  }
171 
172  SUBDBG("Looking in pmu %d\n",j);
173  i = pinfo.first_event;
174  while(1) {
175  memset(&event_info,0,sizeof(pfm_event_info_t));
176  ret=pfm_get_event_info(i, PFM_OS_PERF_EVENT, &event_info);
177  if (ret<0) break;
178 
179  sprintf(full_name,"%s::%s",pinfo.name,event_info.name);
180 
181  if (!strcmp(name,full_name)) {
182  SUBDBG("FOUND %s %s %#x\n",name,full_name,i);
183  return i;
184  }
185 
186  if (!strcmp(name,event_info.name)) {
187  SUBDBG("FOUND %s %s %#x\n",name,event_info.name,i);
188  return i;
189  }
190  i=pfm_get_event_next(i);
191  }
192  }
193  return PFM_ERR_NOTFOUND;
194 }
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
memset(eventId, 0, size)
long long ret
Definition: iozone.c:1346
static struct counter_info * event_info
int i
Definition: fileop.c:140
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
char * name
Definition: iozone.c:23648
static int pmu_is_present_and_right_type(pfm_pmu_info_t *pinfo, int type)
long j
Definition: iozone.c:19135

Here is the call graph for this function:

Here is the caller graph for this function:

static int find_existing_event ( char *  name,
struct native_event_table_t event_table 
)
static

Definition at line 37 of file peu_libpfm4_events.c.

38  {
39 
40  int i,event=PAPI_ENOEVNT;
41 
42  SUBDBG("Looking for %s in %d events\n",
43  name,event_table->num_native_events);
44 
46 
47  for(i=0;i<event_table->num_native_events;i++) {
48 
49  if (!strcmp(name,event_table->native_events[i].allocated_name)) {
50  SUBDBG("Found %s (%#x)\n",
51  event_table->native_events[i].allocated_name,
52  event_table->native_events[i].libpfm4_idx);
53  event=i;
54  break;
55  }
56  }
58 
59  if (event<0) { SUBDBG("%s not allocated yet\n",name); }
60 
61  return event;
62 }
struct native_event_t * native_events
#define PAPI_ENOEVNT
Definition: fpapi.h:112
device[deviceId] domain[domainId] event
Definition: linux-cuda.c:306
int i
Definition: fileop.c:140
inline_static int _papi_hwi_lock(int lck)
Definition: threads.h:64
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
char * name
Definition: iozone.c:23648

Here is the call graph for this function:

Here is the caller graph for this function:

static struct native_event_t* find_existing_event_by_number ( int  eventnum,
struct native_event_table_t event_table 
)
static

Definition at line 76 of file peu_libpfm4_events.c.

77  {
78 
79  struct native_event_t *temp_event=NULL;
80 
82 
83  temp_event=&(event_table->native_events[eventnum]);
84 
86 
87  SUBDBG("Found %p for %#x\n",temp_event,eventnum);
88 
89  return temp_event;
90 }
struct native_event_t * native_events
inline_static int _papi_hwi_lock(int lck)
Definition: threads.h:64
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:

static int find_max_umask ( struct native_event_t current_event)
static

Definition at line 461 of file peu_libpfm4_events.c.

461  {
462 
463  pfm_event_attr_info_t ainfo;
464  char *b;
465  int a, ret, max =0;
466  pfm_event_info_t info;
467  char event_string[BUFSIZ],*ptr;
468 
469  SUBDBG("Trying to find max umask in %s\n",current_event->allocated_name);
470 
471  strcpy(event_string,current_event->allocated_name);
472 
473  /* Skip leading :: delimited PMU name and point to first umask */
474  if (strstr(event_string,"::")) {
475  ptr=strstr(event_string,"::");
476  ptr+=2;
477  b=strtok(ptr,":");
478  }
479  else {
480  b=strtok(event_string,":");
481  }
482 
483  if (!b) {
484  SUBDBG("No colon!\n");
485  return PFM_ERR_UMASK; /* Must be this value!! */
486  }
487 
488  memset(&info,0,sizeof(pfm_event_info_t));
489  ret = pfm_get_event_info(current_event->libpfm4_idx,
490  PFM_OS_PERF_EVENT, &info);
491  if (ret!=PFM_SUCCESS) {
492  SUBDBG("get_event_info failed\n");
493  return PFM_ERR_NOTFOUND;
494  }
495 
496  /* skip event name, get first mask */
497  b=strtok(NULL,":=");
498  if (!b) {
499  SUBDBG("Skipping to first mask failed\n");
500  return PFM_ERR_UMASK; /* Must be this value!! */
501  }
502 
503  while(b) {
504  a=0;
505  while(1) {
506 
507  SUBDBG("get_event_attr %#x %d %p\n",current_event->libpfm4_idx,a,&ainfo);
508 
509  memset(&ainfo,0,sizeof(pfm_event_attr_info_t));
510 
511  ret = pfm_get_event_attr_info(current_event->libpfm4_idx, a,
512  PFM_OS_PERF_EVENT, &ainfo);
513 
514  if (ret != PFM_SUCCESS) {
515  SUBDBG("get_event_attr failed %s\n",pfm_strerror(ret));
516  return ret;
517  }
518 
519  SUBDBG("Compare: ainfo.name: %s, ainfo.type: %d, with event mask: %s\n", ainfo.name, ainfo.type, b);
520 
521  if (ainfo.type == PFM_ATTR_MOD_BOOL) {
522  if (!strcasecmp(ainfo.name, b)) {
523  SUBDBG("Found attr name: %s, attr idx: %d\n", b, a);
524  b=strtok(NULL,":"); // skip the value provided with this attribute
525  if (a>max) max=a;
526  goto found_attr;
527  }
528  }
529  else if (ainfo.type == PFM_ATTR_MOD_INTEGER) {
530  if (!strcasecmp(ainfo.name, b)) {
531  SUBDBG("Found attr name: %s, attr idx: %d\n", b, a);
532  b=strtok(NULL,":"); // skip the value provided with this attribute
533  if (a>max) max=a;
534  goto found_attr;
535  }
536  }
537  else {
538  if (!strcasecmp(ainfo.name, b)) {
539  SUBDBG("Found %s %d\n",b,a);
540  if (a>max) max=a;
541  goto found_attr;
542  }
543  }
544  a++;
545  }
546 
547  SUBDBG("attr=%s not found for event %s\n", b, info.name);
548 
549  return PFM_ERR_ATTR;
550 
551 found_attr:
552 
553  b=strtok(NULL,":=");
554  }
555 
556  SUBDBG("Found max %d\n", max);
557 
558  return max;
559 }
memset(eventId, 0, size)
off64_t max
Definition: libasync.c:331
static double a[MATRIX_SIZE][MATRIX_SIZE]
Definition: rapl_basic.c:37
long long ret
Definition: iozone.c:1346
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
strcpy(filename, default_filename)
static double b[MATRIX_SIZE][MATRIX_SIZE]
Definition: rapl_basic.c:38
char * ptr
Definition: iozone.c:23586

Here is the call graph for this function:

Here is the caller graph for this function:

static int find_next_no_aliases ( int  code,
int  pmu_type 
)
static

Definition at line 208 of file peu_libpfm4_events.c.

208  {
209 
210  int current_pmu=0,current_event=0;
211  pfm_err_t ret;
212  pfm_pmu_info_t pinfo;
213  pfm_event_info_t event_info;
214 
215  /* Clear the structures, as libpfm4 requires it */
216  memset(&event_info,0,sizeof(pfm_event_info_t));
217 
218  ret=pfm_get_event_info(code, PFM_OS_PERF_EVENT, &event_info);
219  if (ret!=PFM_SUCCESS) {
220  return ret;
221  }
222 
223  current_pmu=event_info.pmu;
224  current_event=pfm_get_event_next(code);
225 
226  SUBDBG("Current is %#x guessing next is %#x\n",code,current_event);
227 
228  while(1) {
229 
230  memset(&event_info,0,sizeof(pfm_event_info_t));
231  ret=pfm_get_event_info(current_event, PFM_OS_PERF_EVENT, &event_info);
232  if (ret==PFM_SUCCESS) {
233  SUBDBG("Returning %#x\n",current_event);
234  return current_event;
235  }
236 
237  /* next event not found, so try moving to next PMU */
238 
239  while(1) {
240 
241  current_pmu++;
242  SUBDBG("Incrementing PMU: %#x\n",current_pmu);
243 
244  /* Off the end, so done iterating */
245  if (current_pmu>PFM_PMU_MAX) {
246  return PFM_ERR_NOTFOUND;
247  }
248 
249  memset(&pinfo,0,sizeof(pfm_pmu_info_t));
250  pfm_get_pmu_info(current_pmu, &pinfo);
251  if (pmu_is_present_and_right_type(&pinfo,pmu_type)) break;
252  }
253 
254  current_event=pinfo.first_event;
255 
256  }
257 
258 }
memset(eventId, 0, size)
long long ret
Definition: iozone.c:1346
static struct counter_info * event_info
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static int pmu_is_present_and_right_type(pfm_pmu_info_t *pinfo, int type)

Here is the call graph for this function:

Here is the caller graph for this function:

static int find_next_umask ( struct native_event_t current_event,
int  current,
char *  umask_name 
)
static

Definition at line 718 of file peu_libpfm4_events.c.

719  {
720 
721  char temp_string[BUFSIZ];
722  pfm_event_info_t event_info;
723  pfm_event_attr_info_t ainfo;
724  int num_masks=0;
725  pfm_err_t ret;
726  int i;
727 
728  /* get number of attributes */
729 
730  memset(&event_info, 0, sizeof(event_info));
731  ret=pfm_get_event_info(current_event->libpfm4_idx,
732  PFM_OS_PERF_EVENT, &event_info);
733  if (ret!=PFM_SUCCESS) {
734  return ret;
735  }
736 
737  SUBDBG("%d possible attributes for event %s\n",
738  event_info.nattrs,
739  event_info.name);
740 
741  pfm_for_each_event_attr(i, &event_info) {
742 
743  ainfo.size = sizeof(ainfo);
744 
745  ret = pfm_get_event_attr_info(event_info.idx, i, PFM_OS_PERF_EVENT,
746  &ainfo);
747  if (ret != PFM_SUCCESS) {
748  SUBDBG("Not found\n");
749  return PFM_ERR_NOTFOUND;
750  }
751 
752  SUBDBG("Looking at attribute idx: %d, mask number: %d, current: %d\n", i, num_masks, current);
753 
754  if (ainfo.type == PFM_ATTR_UMASK) {
755  if (num_masks==current+1) {
756  SUBDBG("Found attribute index: %d, name: %s, type: %d\n",
757  i,ainfo.name,ainfo.type);
758 
759  sprintf(temp_string,"%s",ainfo.name);
760  strncpy(umask_name,temp_string,BUFSIZ);
761 
762  return current+1;
763  }
764  }
765 
766  if (ainfo.type == PFM_ATTR_MOD_BOOL) {
767  if (num_masks==current+1) {
768  SUBDBG("Found attribute index: %d, name: %s, type: %d\n",
769  i,ainfo.name,ainfo.type);
770 
771  sprintf(temp_string,"%s=0",ainfo.name);
772  strncpy(umask_name,temp_string,BUFSIZ);
773 
774  return current+1;
775  }
776  }
777 
778  if (ainfo.type == PFM_ATTR_MOD_INTEGER) {
779  if (num_masks==current+1) {
780  SUBDBG("Found attribute index: %d, name: %s, type: %d\n",
781  i,ainfo.name,ainfo.type);
782 
783  sprintf(temp_string,"%s=0",ainfo.name);
784  strncpy(umask_name,temp_string,BUFSIZ);
785 
786  return current+1;
787  }
788  }
789  num_masks++;
790  }
791 
792  SUBDBG("Attribute index: %d not found.\n", current+1);
793  return PFM_ERR_ATTR;
794 
795 }
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
memset(eventId, 0, size)
off64_t current
Definition: iozone.c:19505
long long ret
Definition: iozone.c:1346
static struct counter_info * event_info
int i
Definition: fileop.c:140
#define SUBDBG(format, args...)
Definition: papi_debug.h:63

Here is the call graph for this function:

Here is the caller graph for this function:

static int get_event_first_active ( int  pmu_type)
static

Definition at line 572 of file peu_libpfm4_events.c.

573 {
574  int pidx, pmu_idx, ret;
575 
576  pfm_pmu_info_t pinfo;
577 
578  pmu_idx=0;
579 
580  while(pmu_idx<PFM_PMU_MAX) {
581 
582  /* clear the PMU structure (required by libpfm4) */
583  memset(&pinfo,0,sizeof(pfm_pmu_info_t));
584  ret=pfm_get_pmu_info(pmu_idx, &pinfo);
585 
586  if ((ret==PFM_SUCCESS) && pmu_is_present_and_right_type(&pinfo,pmu_type)) {
587 
588  pidx=pinfo.first_event;
589 
590  SUBDBG("First event in %s is %#x\n",pinfo.name,pidx);
591 
592  if (pidx<0) {
593  /* For some reason no events available */
594  /* despite the PMU being active. */
595  /* This can happen, for example with ix86arch */
596  /* inside of VMware */
597  }
598  else {
599  return pidx;
600  }
601  }
602 
603  pmu_idx++;
604 
605  }
606 
607  return PAPI_ENOEVNT;
608 
609 }
memset(eventId, 0, size)
#define PAPI_ENOEVNT
Definition: fpapi.h:112
long long ret
Definition: iozone.c:1346
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static int pmu_is_present_and_right_type(pfm_pmu_info_t *pinfo, int type)

Here is the call graph for this function:

Here is the caller graph for this function:

static int pmu_is_present_and_right_type ( pfm_pmu_info_t *  pinfo,
int  type 
)
static

Definition at line 92 of file peu_libpfm4_events.c.

92  {
93 
94  if (!pinfo->is_present) return 0;
95 
96  if ((pinfo->type==PFM_PMU_TYPE_UNCORE) && (type&PMU_TYPE_UNCORE)) return 1;
97  if ((pinfo->type==PFM_PMU_TYPE_CORE) && (type&PMU_TYPE_CORE)) return 1;
98  if ((pinfo->type==PFM_PMU_TYPE_OS_GENERIC) && (type&PMU_TYPE_OS)) return 1;
99 
100  return 0;
101 }
#define PMU_TYPE_OS
#define PMU_TYPE_CORE
#define PMU_TYPE_UNCORE

Here is the caller graph for this function:

Variable Documentation

int enum_call = 0
static

Definition at line 23 of file peu_libpfm4_events.c.