From: Ali Saidi Date: Mon, 23 Aug 2010 16:18:39 +0000 (-0500) Subject: stats: Fix off-by-one error in distributions. X-Git-Tag: stable_2012_02_02~921 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=77937738096e227ebfe5bd2fb999c35032c2c8c4;p=gem5.git 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. --- 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 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 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();