948 SUBDBG(
"ENTER: pmu_str: %s, pmu_type: %d, cidx: %d, preset_flag: %d\n", pmu_str, pmu_type,
cidx, preset_flag);
953 char *event_file_path=NULL;
954 char *event_table_ptr=NULL;
955 int event_type_bits = 0;
957 char *tok_save_ptr=NULL;
958 FILE *event_file = NULL;
961 int *event_count = NULL;
968 int found_events = 0;
976 if ((tmpn =
getenv(
"PAPI_CSV_EVENT_FILE")) && (strlen(tmpn) > 0)) {
977 event_file_path = tmpn;
987 event_file_path = path;
997 if ((event_file_path =
getenv(
"PAPI_USER_EVENTS_FILE" )) == NULL ) {
998 SUBDBG(
"EXIT: User event definition file not provided.\n");
1009 if (event_file_path != NULL) {
1012 SUBDBG(
"EXIT: Event file open failed.\n");
1015 strncpy(
name, event_file_path,
sizeof(
name)-1);
1017 }
else if (event_table_ptr == NULL) {
1019 SUBDBG(
"EXIT: Both event_file_path and event_table_ptr are NULL.\n");
1026 if (*pmu_str !=
',')
1040 t =
trim_string(strtok_r(line,
",", &tok_save_ptr));
1043 if ((t == NULL) || (strlen(t) == 0))
1051 if (strcasecmp(t,
"CPU") == 0) {
1052 if (get_events != 0 && found_events != 0) {
1053 SUBDBG(
"Ending event scanning at line %d of %s.\n", line_no,
name);
1058 t =
trim_string(strtok_r(NULL,
",", &tok_save_ptr));
1059 if ((t == NULL) || (strlen(t) == 0)) {
1060 PAPIERROR(
"Expected name after CPU token at line %d of %s -- ignoring", line_no,
name);
1064 if (strcasecmp(t, pmu_name) == 0) {
1067 SUBDBG(
"Process events for PMU %s found at line %d of %s.\n", t, line_no,
name);
1069 t =
trim_string(strtok_r(NULL,
",", &tok_save_ptr));
1070 if ((t == NULL) || (strlen(t) == 0)) {
1071 SUBDBG(
"No additional qualifier found, matching on string.\n");
1073 }
else if ((sscanf(t,
"%d", &type) == 1) && (type == pmu_type)) {
1074 SUBDBG(
"Found CPU %s type %d at line %d of %s.\n", pmu_name, type, line_no,
name);
1077 SUBDBG(
"Additional qualifier match failed %d vs %d.\n", pmu_type, type);
1083 if ((strcasecmp(t,
"PRESET") == 0) || (strcasecmp(t,
"EVENT") == 0)) {
1085 if (get_events == 0)
1089 t =
trim_string(strtok_r(NULL,
",", &tok_save_ptr));
1091 if ((t == NULL) || (strlen(t) == 0)) {
1092 PAPIERROR(
"Expected name after PRESET token at line %d of %s -- ignoring", line_no,
name);
1096 SUBDBG(
"Examining event %s\n", t);
1100 PAPIERROR(
"No room left for event %s -- ignoring", t);
1105 preset = res_idx | event_type_bits;
1110 t =
trim_string(strtok_r(NULL,
",", &tok_save_ptr));
1111 if ((t == NULL) || (strlen(t) == 0)) {
1113 if (results[res_idx].symbol != NULL){
1115 results[res_idx].
symbol = NULL;
1117 PAPIERROR(
"Expected derived type after PRESET token at line %d of %s -- ignoring", line_no,
name);
1123 if (results[res_idx].symbol != NULL){
1125 results[res_idx].
symbol = NULL;
1127 PAPIERROR(
"Invalid derived name %s after PRESET token at line %d of %s -- ignoring", t, line_no,
name);
1135 SUBDBG(
"Adding event: %s, code: %#x, derived: %d results[%d]: %p.\n", t,
preset, derived, res_idx, &results[res_idx]);
1143 t =
trim_string(strtok_r(NULL,
",", &tok_save_ptr));
1144 if ((t == NULL) || (strlen(t) == 0)) {
1146 if (results[res_idx].symbol != NULL){
1148 results[res_idx].
symbol = NULL;
1150 PAPIERROR(
"Expected Operation string after derived type DERIVED_POSTFIX or DERIVED_INFIX at line %d of %s -- ignoring", line_no,
name);
1156 SUBDBG(
"Converting InFix operations %s\n", t);
1161 SUBDBG(
"Saving PostFix operations %s\n", t);
1168 results[res_idx].
count = 0;
1170 t =
trim_string(strtok_r(NULL,
",", &tok_save_ptr));
1171 if ((t == NULL) || (strlen(t) == 0))
1173 if (strcasecmp(t,
"NOTE") == 0)
1175 if (strcasecmp(t,
"LDESC") == 0)
1177 if (strcasecmp(t,
"SDESC") == 0)
1180 SUBDBG(
"Adding term (%d) %s to derived event %#x, current native event count: %d.\n",
i, t,
preset, results[res_idx].
count);
1189 if (
is_event(t, results[res_idx].derived_int, &results[res_idx],
i) == 0) {
1191 PAPIERROR(
"Missing event %s, used in derived event %s", t, results[res_idx].symbol);
1203 if (invalid_event) {
1207 for (j = 0; j < results[res_idx].
count; j++){
1208 if (results[res_idx].
name[j] != NULL){
1210 results[res_idx].
name[j] = NULL;
1215 if(results[res_idx].symbol != NULL){
1217 results[res_idx].
symbol = NULL;
1230 if(results[res_idx].symbol != NULL){
1232 results[res_idx].
symbol = NULL;
1235 PAPIERROR(
"Expected PFM event after DERIVED token at line %d of %s -- ignoring", line_no,
name);
1240 t =
trim_string(strtok_r(NULL,
",", &tok_save_ptr));
1244 if ( t!= NULL && strlen(t) > 0 ) {
1250 t =
trim_note(strtok_r(NULL,
",", &tok_save_ptr));
1251 if ( t== NULL || strlen(t) == 0 ) {
1257 if (strcasecmp(fptr,
"SDESC") == 0) {
1260 if (strcasecmp(fptr,
"LDESC") == 0) {
1263 if (strcasecmp(fptr,
"NOTE") == 0) {
1267 SUBDBG(
"Found %s (%s) on line %d\n", fptr, t, line_no);
1271 t =
trim_string(strtok_r(NULL,
",", &tok_save_ptr));
1272 if ( t== NULL || strlen(t) == 0 ) {
1275 }
while (t != NULL);
1281 PAPIERROR(
"Unrecognized token %s at line %d of %s -- ignoring", t, line_no,
name);
1288 SUBDBG(
"EXIT: Done processing derived event file.\n");
static int find_event_index(hwi_presets_t *array, int size, char *tmp)
#define PAPI_EVENTS_IN_DERIVED_EVENT
static char * trim_note(char *in)
int _papi_hwi_derived_type(char *tmp, int *code)
static char * papi_events_table
#define PAPI_MAX_PRESET_EVENTS
#define PAPI_MAX_USER_EVENTS
static int is_event(char *event_name, int derived_type, hwi_presets_t *results, int token_index)
int user_defined_events_count
hwi_presets_t _papi_hwi_presets[PAPI_MAX_PRESET_EVENTS]
hwi_presets_t user_defined_events[]
#define SUBDBG(format, args...)
void PAPIERROR(char *format,...)
static int get_event_line(char *line, FILE *table, char **tmp_perfmon_events_table)
static FILE * open_event_table(char *name)
void _papi_hwi_set_papi_event_code(unsigned int event_code, int update_flag)
static char * infix_to_postfix(char *infix)
unsigned int code[PAPI_MAX_INFO_TERMS]
char * name[PAPI_MAX_INFO_TERMS]
static char * trim_string(char *in)
struct papi_vectors * _papi_hwd[]