diff options
Diffstat (limited to 'base/statistics.hh')
-rw-r--r-- | base/statistics.hh | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/base/statistics.hh b/base/statistics.hh index bd70cf8a0..45efbb864 100644 --- a/base/statistics.hh +++ b/base/statistics.hh @@ -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 ¶ms) { } @@ -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(); } }; /** |