diff options
author | Ali Saidi <Ali.Saidi@ARM.com> | 2010-08-23 11:18:39 -0500 |
---|---|---|
committer | Ali Saidi <Ali.Saidi@ARM.com> | 2010-08-23 11:18:39 -0500 |
commit | 77937738096e227ebfe5bd2fb999c35032c2c8c4 (patch) | |
tree | 2fb486b2b1f2ae214d30202f8fc45601d8ae4275 /src | |
parent | fa01fbddeb637efe5fc90c9777579008f0af39ed (diff) | |
download | gem5-77937738096e227ebfe5bd2fb999c35032c2c8c4.tar.xz |
stats: Fix off-by-one error in distributions.
bkt size isn't evenly divisible by max-min and it would round down,
it's possible to sample a distribution and have no place to put the sample.
When this case occured the simulator would assert.
Diffstat (limited to 'src')
-rw-r--r-- | src/base/statistics.hh | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/base/statistics.hh b/src/base/statistics.hh index 8c229d419..7eb769e43 100644 --- a/src/base/statistics.hh +++ b/src/base/statistics.hh @@ -2287,7 +2287,7 @@ class Distribution : public DistBase<Distribution, DistStor> params->min = min; params->max = max; params->bucket_size = bkt; - params->buckets = (size_type)rint((max - min + 1.0) / bkt ); + params->buckets = (size_type)ceil((max - min + 1.0) / bkt); this->setParams(params); this->doInit(); return this->self(); @@ -2352,7 +2352,7 @@ class VectorDistribution : public VectorDistBase<VectorDistribution, DistStor> params->min = min; params->max = max; params->bucket_size = bkt; - params->buckets = (size_type)rint((max - min + 1.0) / bkt); + params->buckets = (size_type)ceil((max - min + 1.0) / bkt); this->setParams(params); this->doInit(size); return this->self(); |