summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLisa Hsu <Lisa.Hsu@amd.com>2010-06-03 11:06:12 -0700
committerLisa Hsu <Lisa.Hsu@amd.com>2010-06-03 11:06:12 -0700
commit4a3ce94386da669e82e1fd32fb201e2c9385938e (patch)
tree3e616122889bf7fe3d85e00a3a117c8b4f2b0934
parentaeb6e2e3ec920f8590f36bdb33c03c2968ab5dde (diff)
downloadgem5-4a3ce94386da669e82e1fd32fb201e2c9385938e.tar.xz
Stats: fix dist stat and enable VectorDistStat
-rw-r--r--src/base/statistics.hh23
-rw-r--r--src/base/stats/text.cc2
2 files changed, 15 insertions, 10 deletions
diff --git a/src/base/statistics.hh b/src/base/statistics.hh
index 06a9d465d..f7625779a 100644
--- a/src/base/statistics.hh
+++ b/src/base/statistics.hh
@@ -1698,7 +1698,11 @@ class VectorDistBase : public DataWrapVec<Derived, VectorDistInfoProxy>
delete [] reinterpret_cast<char *>(storage);
}
- Proxy operator[](off_type index);
+ Proxy operator[](off_type index)
+ {
+ assert(index >= 0 && index < size());
+ return Proxy(this->self(), index);
+ }
size_type
size() const
@@ -1739,15 +1743,15 @@ template <class Stat>
class DistProxy
{
private:
- Stat *stat;
+ Stat &stat;
off_type index;
protected:
- typename Stat::Storage *data() { return stat->data(index); }
- const typename Stat::Storage *data() const { return stat->data(index); }
+ typename Stat::Storage *data() { return stat.data(index); }
+ const typename Stat::Storage *data() const { return stat.data(index); }
public:
- DistProxy(Stat *s, off_type i)
+ DistProxy(Stat &s, off_type i)
: stat(s), index(i)
{}
@@ -1788,15 +1792,16 @@ class DistProxy
*/
void reset() { }
};
-
+/*
template <class Derived, class Stor>
inline typename VectorDistBase<Derived, Stor>::Proxy
VectorDistBase<Derived, Stor>::operator[](off_type index)
{
assert (index >= 0 && index < size());
typedef typename VectorDistBase<Derived, Stor>::Proxy Proxy;
- return Proxy(this, index);
+ return Proxy(this->self(), index);
}
+*/
#if 0
template <class Storage>
@@ -2267,7 +2272,7 @@ class Distribution : public DistBase<Distribution, DistStor>
params->min = min;
params->max = max;
params->bucket_size = bkt;
- params->buckets = (size_type)rint((max - min) / bkt + 1.0);
+ params->buckets = (size_type)rint((max - min + 1.0) / bkt );
this->setParams(params);
this->doInit();
return this->self();
@@ -2328,7 +2333,7 @@ class VectorDistribution : public VectorDistBase<VectorDistribution, DistStor>
params->min = min;
params->max = max;
params->bucket_size = bkt;
- params->buckets = (size_type)rint((max - min) / bkt + 1.0);
+ params->buckets = (size_type)rint((max - min + 1.0) / bkt);
this->setParams(params);
this->doInit(size);
return this->self();
diff --git a/src/base/stats/text.cc b/src/base/stats/text.cc
index 10983506f..090ddff7d 100644
--- a/src/base/stats/text.cc
+++ b/src/base/stats/text.cc
@@ -412,7 +412,7 @@ DistPrint::operator()(ostream &stream) const
namestr << base;
Counter low = i * bucket_size + min;
- Counter high = ::min(low + bucket_size, max);
+ Counter high = ::min(low + bucket_size - 1.0, max);
namestr << low;
if (low < high)
namestr << "-" << high;