summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorNathan Binkert <binkertn@umich.edu>2003-12-23 21:45:48 -0500
committerNathan Binkert <binkertn@umich.edu>2003-12-23 21:45:48 -0500
commit8f912297abc4d6ff21e77eba474ef315658c3630 (patch)
treea73d67d9c2ae130938ec733f4ff5317f3b3a085e /base
parent42621e497dc6abe90dced3e753260270eed358da (diff)
downloadgem5-8f912297abc4d6ff21e77eba474ef315658c3630.tar.xz
- Allow the stats package user to determine in which mode to dump
- Factor out the formatted output into a display function - Make the stats package support tracing - Clean up output of binned data base/statistics.cc: - Factor out the formatted output into a display function and pass in the mode - Make the stats package support tracing - Clean up output of binned data - Get rid of the list of binned stats and the map of bins since it is no longer needed for output base/statistics.hh: - Allow the stats package user to determine in which mode to dump --HG-- extra : convert_revision : a1d5fc728f4dc22a851d58ea89d44018a94a64c7
Diffstat (limited to 'base')
-rw-r--r--base/statistics.cc124
-rw-r--r--base/statistics.hh2
2 files changed, 53 insertions, 73 deletions
diff --git a/base/statistics.cc b/base/statistics.cc
index 81b8856ca..b8672661d 100644
--- a/base/statistics.cc
+++ b/base/statistics.cc
@@ -38,6 +38,7 @@
#include "base/misc.hh"
#include "base/statistics.hh"
#include "base/str.hh"
+#include "base/trace.hh"
#include "sim/universe.hh"
#ifdef __M5_NAN
@@ -74,15 +75,14 @@ namespace Database
typedef map<void *, StatData *> map_t;
list<MainBin *> bins;
- map<const MainBin *, string > bin_names;
- list_t binnedStats;
list_t allStats;
list_t printStats;
map_t statMap;
public:
- void dump(ostream &stream);
+ void dump(ostream &stream, DisplayMode mode);
+ void display(ostream &stream, DisplayMode mode);
StatData *find(void *stat);
void mapStat(void *stat, StatData *data);
@@ -91,71 +91,63 @@ namespace Database
void reset();
void regBin(MainBin *bin, string name);
void regPrint(void *stat);
+
+ static std::string name() { return "Statistics Database"; }
};
void
-Data::dump(ostream &stream)
+Data::dump(ostream &stream, DisplayMode mode)
{
-#ifndef FS_MEASURE
- list_t::iterator i = printStats.begin();
- list_t::iterator end = printStats.end();
- while (i != end) {
- StatData *stat = *i;
- if (stat->binned())
- binnedStats.push_back(stat);
- ++i;
+ MainBin *orig = MainBin::curBin();
+
+ switch (mode) {
+ case mode_m5:
+ case mode_simplescalar:
+ display(stream, mode);
+ break;
+ default:
+ warn("invalid display mode!\n");
+ display(stream, mode_m5);
+ break;
}
-#endif //FS_MEASURE
- list<MainBin *>::iterator j = bins.begin();
- list<MainBin *>::iterator bins_end=bins.end();
+ if (orig)
+ orig->activate();
+}
+void
+Data::display(ostream &stream, DisplayMode mode)
+{
if (!bins.empty()) {
+ list<MainBin *>::iterator i = bins.begin();
+ list<MainBin *>::iterator bins_end = bins.end();
ccprintf(stream, "PRINTING BINNED STATS\n");
- while (j != bins_end) {
- (*j)->activate();
- map<const MainBin *, string>::const_iterator iter;
- iter = bin_names.find(*j);
- if (iter == bin_names.end())
- panic("a binned stat not found in names map!");
- ccprintf(stream,"---%s Bin------------\n", (*iter).second);
-
-#ifdef FS_MEASURE
- list_t::iterator i = printStats.begin();
+ while (i != bins_end) {
+ (*i)->activate();
+ ccprintf(stream,"---%s Bin------------\n", (*i)->name());
+
+ list_t::iterator j = printStats.begin();
list_t::iterator end = printStats.end();
-#else
- list_t::iterator i = binnedStats.begin();
- list_t::iterator end = binnedStats.end();
-#endif
- while (i != end) {
- StatData *stat = *i;
+ while (j != end) {
+ StatData *stat = *j;
if (stat->dodisplay())
stat->display(stream);
- ++i;
+ ++j;
}
- ++j;
+ ++i;
ccprintf(stream, "---------------------------------\n");
}
-#ifndef FS_MEASURE
- ccprintf(stream, "**************ALL STATS************\n");
-#endif
- }
-
-/**
- * get bin totals working, then print the stat here (as total), even if
- * its' binned. (this is only for the case you selectively bin a few stats
- */
-#ifndef FS_MEASURE
- list_t::iterator k = printStats.begin();
- list_t::iterator endprint = printStats.end();
- while (k != endprint) {
- StatData *stat = *k;
- if (stat->dodisplay() /*&& !stat->binned()*/)
- stat->display(stream);
- ++k;
+ } else {
+ list_t::iterator i = printStats.begin();
+ list_t::iterator end = printStats.end();
+ while (i != end) {
+ StatData *stat = *i;
+ if (stat->dodisplay() && !stat->binned())
+ stat->display(stream);
+ ++i;
+ }
}
-#endif
}
StatData *
@@ -232,21 +224,10 @@ Data::mapStat(void *stat, StatData *data)
}
void
-Data::regBin(MainBin *bin, string name)
+Data::regBin(MainBin *bin, string _name)
{
- if (bin_names.find(bin) != bin_names.end())
- panic("shouldn't register bin twice");
-
bins.push_back(bin);
-
-#ifndef NDEBUG
- bool success =
-#endif
- (bin_names.insert(make_pair(bin,name))).second;
- assert(bin_names.find(bin) != bin_names.end());
- assert(success && "this should not fail");
-
- cprintf("registering %s\n", name);
+ DPRINTF(Stats, "registering %s\n", _name);
}
void
@@ -254,14 +235,13 @@ Data::regPrint(void *stat)
{
StatData *data = find(stat);
- if (!data->print) {
- data->print = true;
+ if (data->print)
+ return;
- list_t::iterator j = printStats.insert(printStats.end(), data);
- inplace_merge(printStats.begin(), j,
- printStats.end(), StatData::less);
- }
+ data->print = true;
+ list_t::iterator j = printStats.insert(printStats.end(), data);
+ inplace_merge(printStats.begin(), j, printStats.end(), StatData::less);
}
Data &
@@ -1020,9 +1000,9 @@ check()
}
void
-dump(ostream &stream)
+dump(ostream &stream, DisplayMode mode)
{
- Database::StatDB().dump(stream);
+ Database::StatDB().dump(stream, mode);
}
CallbackQueue resetQueue;
diff --git a/base/statistics.hh b/base/statistics.hh
index 3fc019edc..6013c74e7 100644
--- a/base/statistics.hh
+++ b/base/statistics.hh
@@ -2956,7 +2956,7 @@ class Temp
*/
void check();
-void dump(std::ostream &stream);
+void dump(std::ostream &stream, DisplayMode mode = mode_simplescalar);
void reset();
void registerResetCallback(Callback *cb);