From 8f912297abc4d6ff21e77eba474ef315658c3630 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Tue, 23 Dec 2003 21:45:48 -0500 Subject: - 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 --- base/statistics.cc | 124 ++++++++++++++++++++++------------------------------- 1 file changed, 52 insertions(+), 72 deletions(-) (limited to 'base/statistics.cc') 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 map_t; list bins; - map 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::iterator j = bins.begin(); - list::iterator bins_end=bins.end(); + if (orig) + orig->activate(); +} +void +Data::display(ostream &stream, DisplayMode mode) +{ if (!bins.empty()) { + list::iterator i = bins.begin(); + list::iterator bins_end = bins.end(); ccprintf(stream, "PRINTING BINNED STATS\n"); - while (j != bins_end) { - (*j)->activate(); - map::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; -- cgit v1.2.3