aboutsummaryrefslogtreecommitdiff
path: root/sim/ppc/mon.c
diff options
context:
space:
mode:
Diffstat (limited to 'sim/ppc/mon.c')
-rw-r--r--sim/ppc/mon.c86
1 files changed, 75 insertions, 11 deletions
diff --git a/sim/ppc/mon.c b/sim/ppc/mon.c
index 60b6fdb..f086049 100644
--- a/sim/ppc/mon.c
+++ b/sim/ppc/mon.c
@@ -26,12 +26,34 @@
#define STATIC_INLINE_MON STATIC_INLINE
#endif
-#include <string.h>
-
#include "basics.h"
#include "cpu.h"
#include "mon.h"
+#ifdef HAVE_STRING_H
+#include <string.h>
+#else
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_TIME_H
+#include <time.h>
+#endif
+
+#ifdef HAVE_SYS_TIMES_H
+#include <sys/times.h>
+#endif
+
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
+
struct _cpu_mon {
unsigned issue_count[nr_itable_entries];
unsigned read_count;
@@ -149,11 +171,15 @@ mon_print_info(mon *monitor,
int len_cpu;
int len_num = 0;
int len;
+ long total_insns = 0;
+ long cpu_insns_second;
+ double cpu_time = 0.0;
for (cpu_nr = 0; cpu_nr < monitor->nr_cpus; cpu_nr++) {
- len = strlen (mon_add_commas(buffer,
- sizeof(buffer),
- mon_get_number_of_insns(&monitor->cpu_monitor[cpu_nr])));
+ unsigned num_insns = mon_get_number_of_insns(&monitor->cpu_monitor[cpu_nr]);
+
+ total_insns += num_insns;
+ len = strlen (mon_add_commas(buffer, sizeof(buffer), num_insns));
if (len_num < len)
len_num = len;
}
@@ -161,10 +187,27 @@ mon_print_info(mon *monitor,
sprintf (buffer, "%d", (int)monitor->nr_cpus + 1);
len_cpu = strlen (buffer);
+#ifdef HAVE_GETRUSAGE
+ if (total_insns && verbose > 1)
+ {
+ struct rusage mytime;
+ if (getrusage (RUSAGE_SELF, &mytime) == 0
+ && (mytime.ru_utime.tv_sec > 0 || mytime.ru_utime.tv_usec > 0)) {
+
+ cpu_time = (double)mytime.ru_utime.tv_sec + (((double)mytime.ru_utime.tv_usec) / 1000000.0);
+ cpu_insns_second = (long)(((double)total_insns / cpu_time) + 0.5);
+ }
+ }
+#endif
+
for (cpu_nr = 0; cpu_nr < monitor->nr_cpus; cpu_nr++) {
if (verbose > 1) {
itable_index index;
+
+ if (cpu_nr)
+ printf_filtered ("\n");
+
for (index = 0; index < nr_itable_entries; index++) {
if (monitor->cpu_monitor[cpu_nr].issue_count[index])
printf_filtered("CPU #%*d executed %*s %s instruction%s.\n",
@@ -175,15 +218,36 @@ mon_print_info(mon *monitor,
itable[index].name,
(monitor->cpu_monitor[cpu_nr].issue_count[index] == 1) ? "" : "s");
}
+
+ if (monitor->cpu_monitor[cpu_nr].read_count)
+ printf_filtered ("CPU #%*d executed %*s data reads.\n",
+ len_cpu, cpu_nr+1,
+ len_num, mon_add_commas(buffer,
+ sizeof(buffer),
+ monitor->cpu_monitor[cpu_nr].read_count));
+
+ if (monitor->cpu_monitor[cpu_nr].write_count)
+ printf_filtered ("CPU #%*d executed %*s data writes.\n",
+ len_cpu, cpu_nr+1,
+ len_num, mon_add_commas(buffer,
+ sizeof(buffer),
+ monitor->cpu_monitor[cpu_nr].write_count));
}
- printf_filtered("CPU #%d executed %s instructions in total.\n",
- cpu_nr+1,
- mon_add_commas(buffer,
- sizeof(buffer),
- mon_get_number_of_insns(&monitor->cpu_monitor[cpu_nr])));
-
+ printf_filtered("CPU #%*d executed %*s instructions in total.\n",
+ len_cpu, cpu_nr+1,
+ len_num, mon_add_commas(buffer,
+ sizeof(buffer),
+ mon_get_number_of_insns(&monitor->cpu_monitor[cpu_nr])));
}
+
+ if (monitor->nr_cpus > 1)
+ printf_filtered("\nAll CPUs executed %s instructions in total.\n",
+ mon_add_commas(buffer, sizeof(buffer), total_insns));
+
+ if (cpu_insns_second)
+ printf_filtered ("\nSimulator speed was %s instructions/second\n",
+ mon_add_commas(buffer, sizeof(buffer), cpu_insns_second));
}
#endif /* _MON_C_ */