gem5 v24.0.0.0
|
Templatized storage and interface for a histogram stat. More...
#include <storage.hh>
Classes | |
struct | Params |
The parameters for a distribution stat. More... | |
Public Member Functions | |
HistStor (const StorageParams *const storage_params) | |
void | add (HistStor *other) |
Adds the contents of the given storage to this storage. | |
void | sample (Counter val, int number) |
Add a value to the distribution for the given number of times. | |
size_type | size () const |
Return the number of buckets in this distribution. | |
bool | zero () const |
Returns true if any calls to sample have been made. | |
void | prepare (const StorageParams *const storage_params, DistData &data) |
void | reset (const StorageParams *const storage_params) |
Reset stat value to default. | |
Private Member Functions | |
void | growUp () |
Given a bucket size B, and a range of values [0, N], this function doubles the bucket size to double the range of values towards the positive infinite; that is, double the upper range of this storage so that the range becomes [0, 2*N]. | |
void | growOut () |
Given a bucket size B, and a range of values [M, N], where M < 0, this function doubles the bucket size to double the range of values towards both positive and negative infinites; that is, it doubles both the lower and the upper range of this storage so that the range becomes [2*M, 2*N]. | |
void | growDown () |
Given a bucket size B, and a range of values [0, N], this function doubles the bucket size to double the range of values towards the negative infinite; that is, it doubles the lower range of this storage so that the middle buckes contaihs zero as a lower bound. | |
Private Attributes | |
Counter | min_bucket |
Lower bound of the first bucket's range. | |
Counter | max_bucket |
Lower bound of the last bucket's range. | |
Counter | bucket_size |
The number of entries in each bucket. | |
Counter | sum |
The current sum. | |
Counter | logs |
The sum of logarithm of each sample, used to compute geometric mean. | |
Counter | squares |
The sum of squares. | |
Counter | samples |
The number of samples. | |
VCounter | cvec |
Counter for each bucket. | |
Templatized storage and interface for a histogram stat.
The number of buckets is fixed on initialization; however, the bucket size isn't. That means that when samples that are outside the current range are seen, the bucket size will be increased so that each bucket can hold a bigger range of values. When that happens, the bucket's contents are re- located.
The min and max bucket values can only be, respectively, decreased and increased when sampling. If this wasn't true, samples that were previously within the buclet range could not be anymore within the valid range, making the storage's state incoherent. These values are set back to their initial states on reset().
The bucket range always is zero-centric. While the storage does not contain negative values the bucket range will keep its lower bound at zero, doubling the upper bound when needed; However, as soon a negative value is sampled, zero becomes the lower bound of the middle (rounded up) bucket. Although this means that the histogram will not be symmetric if negative values are sampled, it makes it possible to grow the buckets without keeping track of the individual values.
This happens because if zero was not a lower or upper bound, when its value was doubled, the lower and upper bound of the bucket containing zero would intersect with middle values of the previous and next buckets. For example, if the bucket containing zero has range [-2,2[, therefore its neighbor buckets would have ranges at [-6,-2[ and [2,6[. When the buckets are grown, the zero bucket would grow its range to [-4,4[, which cannot be easily extracted from the neighor buckets.
Definition at line 398 of file storage.hh.
|
inline |
Definition at line 473 of file storage.hh.
References gem5::statistics::reset().
void gem5::statistics::HistStor::add | ( | HistStor * | other | ) |
Adds the contents of the given storage to this storage.
other | The other storage to be added. |
Definition at line 209 of file storage.cc.
References bucket_size, cvec, growUp(), gem5::ArmISA::i, logs, min_bucket, samples, size(), squares, and sum.
Referenced by TEST().
|
private |
Given a bucket size B, and a range of values [0, N], this function doubles the bucket size to double the range of values towards the negative infinite; that is, it doubles the lower range of this storage so that the middle buckes contaihs zero as a lower bound.
As such, the storage range becomes [-N, N+B] if there is an odd number of buckets, and [-N-B, N+B] if there is an even number of buckets.
Because the bucket size is doubled, the buckets contents are rearranged, and the original range of values are redistributed to free buckets for the newly appended ranges.
Definition at line 115 of file storage.cc.
References bucket_size, cvec, gem5::ArmISA::i, max_bucket, min_bucket, size(), and zero().
Referenced by sample().
|
private |
Given a bucket size B, and a range of values [M, N], where M < 0, this function doubles the bucket size to double the range of values towards both positive and negative infinites; that is, it doubles both the lower and the upper range of this storage so that the range becomes [2*M, 2*N].
Because the bucket size is doubled, the buckets contents are rearranged, and the original range of values are redistributed to free buckets for the newly appended ranges.
Definition at line 76 of file storage.cc.
References bucket_size, cvec, gem5::ArmISA::i, max_bucket, min_bucket, size(), and zero().
Referenced by sample().
|
private |
Given a bucket size B, and a range of values [0, N], this function doubles the bucket size to double the range of values towards the positive infinite; that is, double the upper range of this storage so that the range becomes [0, 2*N].
Because the bucket size is doubled, the buckets contents are rearranged, since the original range of values is mapped to the lower half buckets.
Definition at line 154 of file storage.cc.
References bucket_size, cvec, gem5::ArmISA::i, max_bucket, and size().
|
inline |
Definition at line 509 of file storage.hh.
References bucket_size, gem5::statistics::HistStor::Params::buckets, cvec, data, gem5::statistics::Hist, gem5::ArmISA::i, logs, max_bucket, min_bucket, gem5::safe_cast(), samples, squares, sum, and gem5::statistics::DistParams::type.
Referenced by prepareCheckHistStor(), TEST(), and TEST().
|
inline |
Reset stat value to default.
Definition at line 537 of file storage.hh.
References bucket_size, gem5::statistics::HistStor::Params::buckets, cvec, gem5::ArmISA::i, logs, max_bucket, min_bucket, gem5::safe_cast(), samples, size(), squares, and sum.
void gem5::statistics::HistStor::sample | ( | Counter | val, |
int | number ) |
Add a value to the distribution for the given number of times.
val | The value to add. |
number | The number of times to add the value. |
Definition at line 176 of file storage.cc.
References bucket_size, cvec, growDown(), growOut(), growUp(), gem5::MipsISA::index, logs, max_bucket, min_bucket, samples, size(), squares, sum, and gem5::X86ISA::val.
Referenced by prepareCheckHistStor(), TEST(), TEST(), TEST(), and TEST().
|
inline |
Return the number of buckets in this distribution.
Definition at line 496 of file storage.hh.
References cvec.
Referenced by add(), growDown(), growOut(), growUp(), reset(), sample(), and TEST().
|
inline |
Returns true if any calls to sample have been made.
Definition at line 503 of file storage.hh.
References samples.
Referenced by growDown(), growOut(), TEST(), and TEST().
|
private |
The number of entries in each bucket.
Definition at line 406 of file storage.hh.
Referenced by add(), growDown(), growOut(), growUp(), prepare(), reset(), and sample().
|
private |
Counter for each bucket.
Definition at line 417 of file storage.hh.
Referenced by add(), growDown(), growOut(), growUp(), prepare(), reset(), sample(), and size().
|
private |
|
private |
Lower bound of the last bucket's range.
Definition at line 404 of file storage.hh.
Referenced by growDown(), growOut(), growUp(), prepare(), reset(), and sample().
|
private |
Lower bound of the first bucket's range.
Definition at line 402 of file storage.hh.
Referenced by add(), growDown(), growOut(), prepare(), reset(), and sample().
|
private |
|
private |
|
private |