statistics.hh:

same - bin printing
statistics.cc:
printing of bins!  now all the nice binning functionality is actually useful cuz you can see the data it so nicely took.  this prints out only the individual bin values.  totals to come.
statistics.hh:
add a binned() function to each stat so that at print time, we can know if it's binned in order to print it right.

base/statistics.hh:
    add a binned() function to each stat so that at print time, we can know if it's binned in order to print it right.
base/statistics.cc:
    printing of bins!  now all the nice binning functionality is actually useful cuz you can see the data it so nicely took.  this prints out only the individual bin values.  totals to come.
base/statistics.hh:
    same - bin printing

--HG--
extra : convert_revision : 09df9aae62b0e522230ee6bedcb51079346735a4
This commit is contained in:
Lisa Hsu 2003-10-21 23:56:31 -04:00
parent 4489583dfe
commit 66f115a2df
2 changed files with 120 additions and 6 deletions

View file

@ -131,6 +131,10 @@ class Database
typedef list<Stat *> list_t;
typedef map<const Stat *, StatData *> map_t;
list<BinBase *> bins;
map<const BinBase *, std::string > bin_names;
list_t binnedStats;
list_t allStats;
list_t printStats;
map_t map;
@ -145,6 +149,7 @@ class Database
void check();
void regStat(Stat *stat);
StatData *print(Stat *stat);
void regBin(BinBase *bin, std::string name);
};
Database::Database()
@ -156,15 +161,51 @@ Database::~Database()
void
Database::dump(ostream &stream)
{
list_t::iterator i = printStats.begin();
list_t::iterator end = printStats.end();
while (i != end) {
Stat *stat = *i;
if (stat->dodisplay())
stat->display(stream);
if (stat->binned())
binnedStats.push_back(stat);
++i;
}
list<BinBase *>::iterator j = bins.begin();
list<BinBase *>::iterator bins_end=bins.end();
if (!bins.empty()) {
ccprintf(stream, "PRINTING BINNED STATS\n");
while (j != bins_end) {
(*j)->activate();
::map<const BinBase *, std::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);
list_t::iterator i = binnedStats.begin();
list_t::iterator end = binnedStats.end();
while (i != end) {
Stat *stat = *i;
if (stat->dodisplay())
stat->display(stream);
++i;
}
++j;
ccprintf(stream, "---------------------------------\n");
}
}
list_t::iterator k = printStats.begin();
list_t::iterator endprint = printStats.end();
ccprintf(stream, "*****ALL STATS*****\n");
while (k != endprint) {
Stat *stat = *k;
if (stat->dodisplay() && !stat->binned())
stat->display(stream);
++k;
}
}
StatData *
@ -221,6 +262,21 @@ Database::regStat(Stat *stat)
assert(success && "this should never fail");
}
void
Database::regBin(BinBase *bin, std::string name)
{
if (bin_names.find(bin) != bin_names.end())
panic("shouldn't register bin twice");
bins.push_back(bin);
bool success = (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);
}
bool
Stat::less(Stat *stat1, Stat *stat2)
{
@ -274,6 +330,7 @@ Stat::Stat(bool reg)
if (reg)
StatDB().regStat(this);
#ifdef STAT_DEBUG
number = ++total_stats;
cprintf("I'm stat number %d\n",number);
@ -828,6 +885,12 @@ BinBase::memory()
return mem;
}
void
BinBase::regBin(BinBase *bin, std::string name)
{
StatDB().regBin(bin, name);
}
} // namespace Detail
void

View file

@ -60,7 +60,7 @@
#include "sim/host.hh"
//
// Un-comment this to enable wierdo-stat debugging
// Un-comment this to enable weirdo-stat debugging
//
// #define STAT_DEBUG
@ -226,6 +226,8 @@ class Stat
*/
virtual bool zero() const = 0;
//need to document
virtual bool binned() const = 0;
/**
* Set the name and marks this stat to print at the end of simulation.
@ -320,6 +322,9 @@ class ScalarStat : public Stat
* @param stream The output stream.
*/
virtual void display(std::ostream &stream) const;
//need to document
virtual bool binned() const = 0;
};
void
@ -363,6 +368,9 @@ class VectorStat : public Stat
* @param stream The output stream.
*/
virtual void display(std::ostream &stream) const;
//need to document
virtual bool binned() const = 0;
};
//////////////////////////////////////////////////////////////////////
@ -608,6 +616,8 @@ class ScalarBase : public ScalarStat
* @return 1.
*/
virtual size_t size() const { return 1; }
virtual bool binned() const { return bin_t::binned; }
};
//////////////////////////////////////////////////////////////////////
@ -732,6 +742,8 @@ class VectorBase : public VectorStat
* @return The size of the vector.
*/
virtual size_t size() const { return bin.size(); }
virtual bool binned() const { return bin_t::binned; }
};
/**
@ -855,6 +867,8 @@ class ScalarProxy : public ScalarStat
* @return 1.
*/
virtual size_t size() const { return 1; }
virtual bool binned() const { return false; }
};
template <typename T, template <typename T> class Storage, class Bin>
@ -931,6 +945,7 @@ class Vector2dBase : public Stat
virtual size_t size() const { return bin.size(); }
virtual bool zero() const { return data(0)->value(params) == 0.0; }
virtual bool binned() const { return bin_t::binned; }
virtual void
display(std::ostream &out) const
@ -1058,6 +1073,8 @@ class VectorProxy : public VectorStat
assert (index >= 0 && index < size());
return ScalarProxy<T, Storage, Bin>(*bin, *params, offset + index);
}
virtual bool binned() const { return false; }
};
template <typename T, template <typename T> class Storage, class Bin>
@ -1433,6 +1450,8 @@ class DistBase : public Stat
data()->display(stream, myname(), mydesc(), myprecision(), myflags(),
params);
}
virtual bool binned() const { return bin_t::binned; }
};
template <typename T, template <typename T> class Storage, class Bin>
@ -1472,6 +1491,7 @@ class VectorDistBase : public Stat
virtual size_t size() const { return bin.size(); }
virtual bool zero() const { return false; }
virtual void display(std::ostream &stream) const;
virtual bool binned() const { return bin_t::binned; }
};
template <typename T, template <typename T> class Storage, class Bin>
@ -1528,6 +1548,8 @@ class VectorDistProxy : public Stat
data()->display(stream, name.str(), desc.str(),
cstat->myprecision(), cstat->myflags(), cstat->params);
}
virtual bool binned() const { return false; }
};
template <typename T, template <typename T> class Storage, class Bin>
@ -1598,6 +1620,8 @@ class Node : public RefCounted
* @return The total of the result vector.
*/
virtual result_t total() const = 0;
virtual bool binned() const = 0;
};
/** Reference counting pointer to a function Node. */
@ -1615,6 +1639,8 @@ class ScalarStatNode : public Node
virtual result_t total() const { return stat.val(); };
virtual size_t size() const { return 1; }
virtual bool binned() const { return stat.binned(); }
};
template <typename T, template <typename T> class Storage, class Bin>
@ -1631,6 +1657,8 @@ class ScalarProxyNode : public Node
virtual result_t total() const { return proxy.val(); };
virtual size_t size() const { return 1; }
virtual bool binned() const { return proxy.binned(); }
};
class VectorStatNode : public Node
@ -1644,6 +1672,8 @@ class VectorStatNode : public Node
virtual result_t total() const { return stat.total(); };
virtual size_t size() const { return stat.size(); }
virtual bool binned() const { return stat.binned(); }
};
template <typename T>
@ -1658,6 +1688,7 @@ class ConstNode : public Node
virtual result_t total() const { return data[0]; };
virtual size_t size() const { return 1; }
virtual bool binned() const { return false; }
};
template <typename T>
@ -1676,6 +1707,7 @@ class FunctorNode : public Node
virtual result_t total() const { return (result_t)functor(); };
virtual size_t size() const { return 1; }
virtual bool binned() const { return false; }
};
template <typename T>
@ -1694,6 +1726,7 @@ class ScalarNode : public Node
virtual result_t total() const { return (result_t)scalar; };
virtual size_t size() const { return 1; }
virtual bool binned() const { return false; }
};
template <class Op>
@ -1726,6 +1759,7 @@ class UnaryNode : public Node
}
virtual size_t size() const { return l->size(); }
virtual bool binned() const { return l->binned(); }
};
template <class Op>
@ -1786,6 +1820,8 @@ class BinaryNode : public Node
return ls;
}
}
virtual bool binned() const { return (l->binned() || r->binned()); }
};
template <class Op>
@ -1827,6 +1863,7 @@ class SumNode : public Node
}
virtual size_t size() const { return 1; }
virtual bool binned() const { return l->binned(); }
};
/**
@ -1953,7 +1990,9 @@ class BinBase
public:
BinBase(size_t size);
~BinBase();
virtual ~BinBase();
virtual void activate() = 0;
void regBin(BinBase *bin, std::string name);
};
} // namespace Detail
@ -1961,6 +2000,12 @@ class BinBase
template <class BinType>
struct StatBin : public Detail::BinBase
{
private:
std::string _name;
public:
std::string name() const { return _name;}
static StatBin *&curBin() {
static StatBin *current = NULL;
return current;
@ -1984,13 +2029,14 @@ struct StatBin : public Detail::BinBase
return off;
}
explicit StatBin(size_t size = 1024) : Detail::BinBase(size) {}
explicit StatBin(std::string name, size_t size = 1024) : Detail::BinBase(size) { _name = name; this->regBin(this, name); }
char *memory(off_t off) {
assert(offset() <= size());
return Detail::BinBase::memory() + off;
}
virtual void activate() { setCurBin(this); }
static void activate(StatBin &bin) { setCurBin(&bin); }
class BinBase
@ -2016,6 +2062,7 @@ struct StatBin : public Detail::BinBase
typedef typename Storage::Params Params;
public:
enum { binned = true };
Bin() { allocate(sizeof(Storage)); }
bool initialized() const { return true; }
void init(const Params &params) { }
@ -2081,6 +2128,7 @@ struct NoBin
{
public:
typedef typename Storage::Params Params;
enum { binned = false };
private:
char ptr[sizeof(Storage)];
@ -2102,6 +2150,7 @@ struct NoBin
{
public:
typedef typename Storage::Params Params;
enum { binned = false };
private:
char *ptr;
@ -2454,6 +2503,8 @@ class Formula : public Detail::VectorStat
else
return root->size();
}
virtual bool binned() const { return root->binned(); }
};
/**