Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Diff of /libperf_events/operf_utils.cpp [3795ee] .. [ebde58] Maximize Restore

  Switch to side-by-side view

--- a/libperf_events/operf_utils.cpp
+++ b/libperf_events/operf_utils.cpp
@@ -64,161 +64,6 @@
 static list<event_t *> unresolved_events;
 static struct operf_transient trans;
 static bool sfile_init_done;
-
-/* Some architectures (e.g., ppc64) do not use the same event value (code) for oprofile
- * and for perf_events.  The operf-record process requires event values that perf_events
- * understands, but the operf-read process requires oprofile event values.  The purpose of
- * the following method is to map the operf-record event value to a value that
- * opreport can understand.
- */
-#if PPC64_ARCH
-extern op_cpu cpu_type;
-#define NIL_CODE ~0U
-
-#if HAVE_LIBPFM3
-static bool _get_codes_for_match(unsigned int pfm_idx, const char name[],
-                                 vector<operf_event_t> * evt_vec)
-{
-	unsigned int num_events = evt_vec->size();
-	int tmp_code, ret;
-	char evt_name[OP_MAX_EVT_NAME_LEN];
-	unsigned int events_converted = 0;
-	for (unsigned int i = 0; i < num_events; i++) {
-		operf_event_t event = (*evt_vec)[i];
-		if (event.evt_code != NIL_CODE) {
-			events_converted++;
-			continue;
-		}
-		memset(evt_name, 0, OP_MAX_EVT_NAME_LEN);
-		if (!strcmp(event.name, "CYCLES")) {
-			strcpy(evt_name ,"PM_CYC") ;
-		} else if (strstr(event.name, "_GRP")) {
-			string str = event.name;
-			strncpy(evt_name, event.name, str.rfind("_GRP"));
-		} else {
-			strncpy(evt_name, event.name, strlen(event.name));
-		}
-		if (strncmp(name, evt_name, OP_MAX_EVT_NAME_LEN))
-			continue;
-		ret = pfm_get_event_code(pfm_idx, &tmp_code);
-		if (ret != PFMLIB_SUCCESS) {
-			string evt_name_str = event.name;
-			string msg = "libpfm cannot find event code for " + evt_name_str +
-					"; cannot continue";
-			throw runtime_error(msg);
-		}
-		event.evt_code = tmp_code;
-		(*evt_vec)[i] = event;
-		events_converted++;
-		cverb << vrecord << "Successfully converted " << event.name << " to perf_event code "
-		      << hex << tmp_code << endl;
-	}
-	return (events_converted == num_events);
-}
-#else
-static bool _op_get_event_codes(vector<operf_event_t> * evt_vec)
-{
-	int ret, i;
-	unsigned int num_events = evt_vec->size();
-	char evt_name[OP_MAX_EVT_NAME_LEN];
-	unsigned int events_converted = 0;
-	uint64_t code[1];
-
-	typedef struct {
-		uint64_t    *codes;
-		char        **fstr;
-		size_t      size;
-		int         count;
-		int         idx;
-	} pfm_raw_pmu_encode_t;
-
-	pfm_raw_pmu_encode_t raw;
-	raw.codes = code;
-	raw.count = 1;
-	raw.fstr = NULL;
-
-	if (pfm_initialize() != PFM_SUCCESS)
-		throw runtime_error("Unable to initialize libpfm; cannot continue");
-
-	for (unsigned int i = 0; i < num_events; i++) {
-		operf_event_t event = (*evt_vec)[i];
-		if (event.evt_code != NIL_CODE) {
-			events_converted++;
-			continue;
-		}
-		memset(evt_name, 0, OP_MAX_EVT_NAME_LEN);
-		if (!strcmp(event.name, "CYCLES")) {
-			strcpy(evt_name ,"PM_CYC") ;
-		} else if (strstr(event.name, "_GRP")) {
-			string str = event.name;
-			strncpy(evt_name, event.name, str.rfind("_GRP"));
-		} else {
-			strncpy(evt_name, event.name, strlen(event.name));
-		}
-
-		memset(&raw, 0, sizeof(raw));
-		ret = pfm_get_os_event_encoding(evt_name, PFM_PLM3, PFM_OS_NONE, &raw);
-		if (ret != PFM_SUCCESS) {
-			string evt_name_str = event.name;
-			string msg = "libpfm cannot find event code for " + evt_name_str +
-					"; cannot continue";
-			throw runtime_error(msg);
-		}
-
-		event.evt_code = raw.codes[0];
-		(*evt_vec)[i] = event;
-		events_converted++;
-		cverb << vrecord << "Successfully converted " << event.name << " to perf_event code "
-		      << hex << event.evt_code << endl;
-	}
-	return (events_converted == num_events);
-}
-#endif
-
-bool OP_perf_utils::op_convert_event_vals(vector<operf_event_t> * evt_vec)
-{
-	unsigned int i, count;
-	char name[256];
-	int ret;
-	for (unsigned int i = 0; i < evt_vec->size(); i++) {
-		operf_event_t event = (*evt_vec)[i];
-		if (cpu_type == CPU_PPC64_POWER7) {
-			if (!strncmp(event.name, "PM_RUN_CYC", strlen("PM_RUN_CYC"))) {
-				event.evt_code = 0x600f4;
-			} else if (!strncmp(event.name, "PM_RUN_INST_CMPL", strlen("PM_RUN_INST_CMPL"))) {
-				event.evt_code = 0x500fa;
-			} else {
-				event.evt_code = NIL_CODE;
-			}
-		} else {
-			event.evt_code = NIL_CODE;
-		}
-		(*evt_vec)[i] = event;
-	}
-
-#if HAVE_LIBPFM3
-	if (pfm_initialize() != PFMLIB_SUCCESS)
-		throw runtime_error("Unable to initialize libpfm; cannot continue");
-
-	ret = pfm_get_num_events(&count);
-	if (ret != PFMLIB_SUCCESS)
-		throw runtime_error("Unable to use libpfm to obtain event code; cannot continue");
-	for(i =0 ; i < count; i++)
-	{
-		ret = pfm_get_event_name(i, name, 256);
-		if (ret != PFMLIB_SUCCESS)
-			continue;
-		if (_get_codes_for_match(i, name, evt_vec))
-			break;
-	}
-	return (i != count);
-#else
-	return _op_get_event_codes(evt_vec);
-#endif
-}
-
-#endif // PPC64_ARCH
-
 
 static inline void update_trans_last(struct operf_transient * trans)
 {
@@ -1465,38 +1310,3 @@
 	md->prev = old;
 	pc->data_tail = old;
 }
-
-
-int OP_perf_utils::op_get_next_online_cpu(DIR * dir, struct dirent *entry)
-{
-#define OFFLINE 0x30
-	unsigned int cpu_num;
-	char cpu_online_pathname[40];
-	int res;
-	FILE * online;
-	again:
-	do {
-		entry = readdir(dir);
-		if (!entry)
-			return -1;
-	} while (entry->d_type != DT_DIR);
-
-	res = sscanf(entry->d_name, "cpu%u", &cpu_num);
-	if (res <= 0)
-		goto again;
-
-	errno = 0;
-	snprintf(cpu_online_pathname, 40, "/sys/devices/system/cpu/cpu%u/online", cpu_num);
-	if ((online = fopen(cpu_online_pathname, "r")) == NULL) {
-		cerr << "Unable to open " << cpu_online_pathname << endl;
-		if (errno)
-			cerr << strerror(errno) << endl;
-		return -1;
-	}
-	res = fgetc(online);
-	fclose(online);
-	if (res == OFFLINE)
-		goto again;
-	else
-		return cpu_num;
-}