changeset 02e5bc7ca9ba in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=02e5bc7ca9ba
description:
stats: reorganize how parameters are stored and accessed.
diffstat:
4 files changed, 209 insertions(+), 197 deletions(-)
src/base/statistics.cc | 24 ++-
src/base/statistics.hh | 337 ++++++++++++++++++++++-------------------------
src/base/stats/mysql.cc | 18 +-
src/base/stats/text.cc | 27 ++-
diffs (truncated from 1139 to 300 lines):
diff -r 9775f70fbe66 -r 02e5bc7ca9ba src/base/statistics.cc
--- a/src/base/statistics.cc Mon Feb 23 12:22:18 2009 -0800
+++ b/src/base/statistics.cc Mon Feb 23 12:22:19 2009 -0800
@@ -36,6 +36,7 @@
#include "base/callback.hh"
#include "base/cprintf.hh"
+#include "base/debug.hh"
#include "base/hostinfo.hh"
#include "base/misc.hh"
#include "base/statistics.hh"
@@ -81,6 +82,12 @@
}
void
+InfoAccess::setParams(const StorageParams *params)
+{
+ info()->storageParams = params;
+}
+
+void
InfoAccess::setInit()
{
info()->flags |= init;
@@ -102,11 +109,20 @@
return (*i).second;
}
+StorageParams::~StorageParams()
+{
+}
+
+int Info::id_count = 0;
+
+int debug_break_id = -1;
+
Info::Info()
- : flags(none), precision(-1), prereq(0)
+ : flags(none), precision(-1), prereq(0), storageParams(NULL)
{
- static int count = 0;
- id = count++;
+ id = id_count++;
+ if (debug_break_id >= 0 and debug_break_id == id)
+ debug_break();
}
Info::~Info()
@@ -249,7 +265,7 @@
Info *info = *i;
assert(info);
if (!info->check() || !info->baseCheck())
- panic("stat check failed for %s\n", info->name);
+ panic("stat check failed for '%s' %d\n", info->name, info->id);
}
off_t j = 0;
diff -r 9775f70fbe66 -r 02e5bc7ca9ba src/base/statistics.hh
--- a/src/base/statistics.hh Mon Feb 23 12:22:18 2009 -0800
+++ b/src/base/statistics.hh Mon Feb 23 12:22:19 2009 -0800
@@ -77,6 +77,10 @@
/* A namespace for all of the Statistics */
namespace Stats {
+struct StorageParams
+{
+ virtual ~StorageParams();
+};
//////////////////////////////////////////////////////////////////////
//
@@ -100,9 +104,13 @@
* A unique stat ID for each stat in the simulator.
* Can be used externally for lookups as well as for debugging.
*/
+ static int id_count;
int id;
public:
+ const StorageParams *storageParams;
+
+ public:
Info();
virtual ~Info();
@@ -247,10 +255,6 @@
Counter squares;
Counter samples;
- Counter min;
- Counter max;
- Counter bucket_size;
- size_type size;
bool fancy;
};
@@ -383,9 +387,13 @@
/** Set up an info class for this statistic */
void setInfo(Info *info);
/** Save Storage class parameters if any */
+ void setParams(const StorageParams *params);
+ /** Save Storage class parameters if any */
void setInit();
+ /** Grab the information class for this statistic */
Info *info();
+ /** Grab the information class for this statistic */
const Info *info() const;
};
@@ -591,55 +599,51 @@
*/
class StatStor
{
- public:
- /** The paramaters for this storage type, none for a scalar. */
- struct Params { };
-
private:
/** The statistic value. */
Counter data;
public:
+ struct Params : public StorageParams {};
+
+ public:
/**
* Builds this storage element and calls the base constructor of the
* datatype.
*/
- StatStor(const Params &) : data(Counter()) {}
+ StatStor(Info *info)
+ : data(Counter())
+ { }
/**
* The the stat to the given value.
* @param val The new value.
- * @param p The paramters of this storage type.
*/
- void set(Counter val, const Params &p) { data = val; }
+ void set(Counter val) { data = val; }
/**
* Increment the stat by the given value.
* @param val The new value.
- * @param p The paramters of this storage type.
*/
- void inc(Counter val, const Params &p) { data += val; }
+ void inc(Counter val) { data += val; }
/**
* Decrement the stat by the given value.
* @param val The new value.
- * @param p The paramters of this storage type.
*/
- void dec(Counter val, const Params &p) { data -= val; }
+ void dec(Counter val) { data -= val; }
/**
* Return the value of this stat as its base type.
- * @param p The params of this storage type.
* @return The value of this stat.
*/
- Counter value(const Params &p) const { return data; }
+ Counter value() const { return data; }
/**
* Return the value of this stat as a result type.
- * @param p The parameters of this storage type.
* @return The value of this stat.
*/
- Result result(const Params &p) const { return (Result)data; }
+ Result result() const { return (Result)data; }
/**
* Reset stat value to default
*/
- void reset() { data = Counter(); }
+ void reset(Info *info) { data = Counter(); }
/**
* @return true if zero value
@@ -656,10 +660,6 @@
*/
class AvgStor
{
- public:
- /** The paramaters for this storage type */
- struct Params { };
-
private:
/** The current count. */
Counter current;
@@ -669,19 +669,23 @@
mutable Tick last;
public:
+ struct Params : public StorageParams {};
+
+ public:
/**
* Build and initializes this stat storage.
*/
- AvgStor(Params &p) : current(0), total(0), last(0) { }
+ AvgStor(Info *info)
+ : current(0), total(0), last(0)
+ { }
/**
* Set the current count to the one provided, update the total and last
* set values.
* @param val The new count.
- * @param p The parameters for this storage.
*/
void
- set(Counter val, Params &p)
+ set(Counter val)
{
total += current * (curTick - last);
last = curTick;
@@ -691,31 +695,27 @@
/**
* Increment the current count by the provided value, calls set.
* @param val The amount to increment.
- * @param p The parameters for this storage.
*/
- void inc(Counter val, Params &p) { set(current + val, p); }
+ void inc(Counter val) { set(current + val); }
/**
* Deccrement the current count by the provided value, calls set.
* @param val The amount to decrement.
- * @param p The parameters for this storage.
*/
- void dec(Counter val, Params &p) { set(current - val, p); }
+ void dec(Counter val) { set(current - val); }
/**
* Return the current count.
- * @param p The parameters for this storage.
* @return The current count.
*/
- Counter value(const Params &p) const { return current; }
+ Counter value() const { return current; }
/**
* Return the current average.
- * @param p The parameters for this storage.
* @return The current average.
*/
Result
- result(const Params &p) const
+ result() const
{
total += current * (curTick - last);
last = curTick;
@@ -726,7 +726,7 @@
* Reset stat value to default
*/
void
- reset()
+ reset(Info *info)
{
total = 0;
last = curTick;
@@ -747,17 +747,12 @@
{
public:
typedef Stor Storage;
-
- /** Define the params of the storage class. */
- typedef typename Storage::Params Params;
+ typedef typename Stor::Params Params;
protected:
/** The storage of this stat. */
char storage[sizeof(Storage)] __attribute__ ((aligned (8)));
- /** The parameters for this stat. */
- Params params;
-
protected:
/**
* Retrieve the storage.
@@ -785,7 +780,7 @@
void
doInit()
{
- new (storage) Storage(params);
+ new (storage) Storage(info());
setInit();
}
@@ -794,14 +789,10 @@
* Return the current value of this stat as its base type.
* @return The current value.
*/
- Counter value() const { return data()->value(params); }
+ Counter value() const { return data()->value(); }
public:
- /**
- * Create and initialize this stat, register it with the database.
- */
_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev