diff options
author | Nathan Binkert <nate@binkert.org> | 2010-07-21 18:54:53 -0700 |
---|---|---|
committer | Nathan Binkert <nate@binkert.org> | 2010-07-21 18:54:53 -0700 |
commit | 21bf6ff1019cb1334596da8488268eeaea3753cc (patch) | |
tree | cbcfd55b702e7e235aad41031c6840e2c3c571b1 /src/base | |
parent | 2a1309f2134986edcbff846aff5951ec1e8df6e1 (diff) | |
download | gem5-21bf6ff1019cb1334596da8488268eeaea3753cc.tar.xz |
stats: unify the two stats distribution type better
Diffstat (limited to 'src/base')
-rw-r--r-- | src/base/statistics.hh | 34 | ||||
-rw-r--r-- | src/base/stats/info.hh | 31 | ||||
-rw-r--r-- | src/base/stats/mysql.cc | 14 | ||||
-rw-r--r-- | src/base/stats/text.cc | 36 |
4 files changed, 58 insertions, 57 deletions
diff --git a/src/base/statistics.hh b/src/base/statistics.hh index 5fca376e3..8c229d419 100644 --- a/src/base/statistics.hh +++ b/src/base/statistics.hh @@ -160,6 +160,11 @@ class Vector2dInfoProxy : public InfoProxy<Stat, Vector2dInfo> Vector2dInfoProxy(Stat &stat) : InfoProxy<Stat, Vector2dInfo>(stat) {} }; +struct StorageParams +{ + virtual ~StorageParams(); +}; + class InfoAccess { protected: @@ -1269,6 +1274,12 @@ class Vector2dBase : public DataWrapVec2d<Derived, Vector2dInfoProxy> // Non formula statistics // ////////////////////////////////////////////////////////////////////// +/** The parameters for a distribution stat. */ +struct DistParams : public StorageParams +{ + const DistType type; + DistParams(DistType t) : type(t) {} +}; /** * Templatized storage and interface for a distrbution stat. @@ -1279,6 +1290,15 @@ class DistStor /** The parameters for a distribution stat. */ struct Params : public DistParams { + /** The minimum value to track. */ + Counter min; + /** The maximum value to track. */ + Counter max; + /** The number of entries in each bucket. */ + Counter bucket_size; + /** The number of buckets. Equal to (max-min)/bucket_size. */ + size_type buckets; + Params() : DistParams(Dist) {} }; @@ -1368,6 +1388,12 @@ class DistStor { const Params *params = safe_cast<const Params *>(info->storageParams); + assert(params->type == Dist); + data.type = params->type; + data.min = params->min; + data.max = params->max; + data.bucket_size = params->bucket_size; + data.min_val = (min_val == CounterLimits::max()) ? 0 : min_val; data.max_val = (max_val == CounterLimits::min()) ? 0 : max_val; data.underflow = underflow; @@ -1468,6 +1494,10 @@ class SampleStor void prepare(Info *info, DistData &data) { + const Params *params = safe_cast<const Params *>(info->storageParams); + + assert(params->type == Deviation); + data.type = params->type; data.sum = sum; data.squares = squares; data.samples = samples; @@ -1540,6 +1570,10 @@ class AvgSampleStor void prepare(Info *info, DistData &data) { + const Params *params = safe_cast<const Params *>(info->storageParams); + + assert(params->type == Deviation); + data.type = params->type; data.sum = sum; data.squares = squares; data.samples = curTick; diff --git a/src/base/stats/info.hh b/src/base/stats/info.hh index 4987fa810..e5b9e4a65 100644 --- a/src/base/stats/info.hh +++ b/src/base/stats/info.hh @@ -61,11 +61,7 @@ const FlagsType nonan = 0x0200; /** Mask of flags that can't be set directly */ const FlagsType __reserved = init | display; -struct StorageParams -{ - virtual ~StorageParams(); -}; - +struct StorageParams; struct Visit; class Info @@ -168,8 +164,15 @@ class VectorInfo : public Info virtual Result total() const = 0; }; +enum DistType { Deviation, Dist }; + struct DistData { + DistType type; + Counter min; + Counter max; + Counter bucket_size; + Counter min_val; Counter max_val; Counter underflow; @@ -180,24 +183,6 @@ struct DistData Counter samples; }; -enum DistType { Deviation, Dist }; - -struct DistParams : public StorageParams -{ - const DistType type; - - /** The minimum value to track. */ - Counter min; - /** The maximum value to track. */ - Counter max; - /** The number of entries in each bucket. */ - Counter bucket_size; - /** The number of buckets. Equal to (max-min)/bucket_size. */ - size_type buckets; - - explicit DistParams(DistType t) : type(t) {} -}; - class DistInfo : public Info { public: diff --git a/src/base/stats/mysql.cc b/src/base/stats/mysql.cc index 6ef173f50..9d2dadb01 100644 --- a/src/base/stats/mysql.cc +++ b/src/base/stats/mysql.cc @@ -481,9 +481,10 @@ MySql::configure(const DistInfo &info) if (!configure(info, "DIST")) return; - const DistParams *params = - safe_cast<const DistParams *>(info.storageParams); - if (params->type == Dist) { + const DistStor::Params *params = + dynamic_cast<const DistStor::Params *>(info.storageParams); + if (params) { + assert(params->type == Dist); stat.size = params->buckets; stat.min = params->min; stat.max = params->max; @@ -498,9 +499,10 @@ MySql::configure(const VectorDistInfo &info) if (!configure(info, "VECTORDIST")) return; - const DistParams *params = - safe_cast<const DistParams *>(info.storageParams); - if (params->type == Dist) { + const DistStor::Params *params = + dynamic_cast<const DistStor::Params *>(info.storageParams); + if (params) { + assert(params->type == Dist); stat.size = params->buckets; stat.min = params->min; stat.max = params->max; diff --git a/src/base/stats/text.cc b/src/base/stats/text.cc index 87bb05323..425a917ef 100644 --- a/src/base/stats/text.cc +++ b/src/base/stats/text.cc @@ -306,30 +306,24 @@ struct DistPrint bool descriptions; int precision; - Counter min; - Counter max; - Counter bucket_size; - size_type size; - DistType type; - const DistData &data; DistPrint(const Text *text, const DistInfo &info); DistPrint(const Text *text, const VectorDistInfo &info, int i); - void init(const Text *text, const Info &info, const DistParams *params); + void init(const Text *text, const Info &info); void operator()(ostream &stream) const; }; DistPrint::DistPrint(const Text *text, const DistInfo &info) : data(info.data) { - init(text, info, safe_cast<const DistParams *>(info.storageParams)); + init(text, info); } DistPrint::DistPrint(const Text *text, const VectorDistInfo &info, int i) : data(info.data[i]) { - init(text, info, safe_cast<const DistParams *>(info.storageParams)); + init(text, info); name = info.name + "_" + (info.subnames[i].empty() ? (to_string(i)) : info.subnames[i]); @@ -339,27 +333,13 @@ DistPrint::DistPrint(const Text *text, const VectorDistInfo &info, int i) } void -DistPrint::init(const Text *text, const Info &info, const DistParams *params) +DistPrint::init(const Text *text, const Info &info) { name = info.name; desc = info.desc; flags = info.flags; precision = info.precision; descriptions = text->descriptions; - - type = params->type; - switch (type) { - case Dist: - min = params->min; - max = params->max; - bucket_size = params->bucket_size; - size = params->buckets; - break; - case Deviation: - break; - default: - panic("unknown distribution type"); - } } void @@ -391,10 +371,10 @@ DistPrint::operator()(ostream &stream) const print.value = stdev; print(stream); - if (type == Deviation) + if (data.type == Deviation) return; - assert(size == data.cvec.size()); + size_t size = data.cvec.size(); Result total = 0.0; if (data.underflow != NAN) @@ -419,8 +399,8 @@ DistPrint::operator()(ostream &stream) const stringstream namestr; namestr << base; - Counter low = i * bucket_size + min; - Counter high = ::min(low + bucket_size - 1.0, max); + Counter low = i * data.bucket_size + data.min; + Counter high = ::min(low + data.bucket_size - 1.0, data.max); namestr << low; if (low < high) namestr << "-" << high; |