gem5
v21.1.0.2

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. More...  
void  sample (Counter val, int number) 
Add a value to the distribution for the given number of times. More...  
size_type  size () const 
Return the number of buckets in this distribution. More...  
bool  zero () const 
Returns true if any calls to sample have been made. More...  
void  prepare (const StorageParams *const storage_params, DistData &data) 
void  reset (const StorageParams *const storage_params) 
Reset stat value to default. More...  
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]. More...  
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]. More...  
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. More...  
Private Attributes  
Counter  min_bucket 
Lower bound of the first bucket's range. More...  
Counter  max_bucket 
Lower bound of the last bucket's range. More...  
Counter  bucket_size 
The number of entries in each bucket. More...  
Counter  sum 
The current sum. More...  
Counter  logs 
The sum of logarithm of each sample, used to compute geometric mean. More...  
Counter  squares 
The sum of squares. More...  
Counter  samples 
The number of samples. More...  
VCounter  cvec 
Counter for each bucket. More...  
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 zerocentric. 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 399 of file storage.hh.

inline 
Definition at line 474 of file storage.hh.
References 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 210 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 [NB, 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 116 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 77 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 155 of file storage.cc.
References bucket_size, cvec, gem5::ArmISA::i, max_bucket, and size().

inline 
Definition at line 510 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, samples, squares, sum, and gem5::statistics::DistParams::type.
Referenced by prepareCheckHistStor(), and TEST().

inline 
Reset stat value to default.
Definition at line 538 of file storage.hh.
References bucket_size, gem5::statistics::HistStor::Params::buckets, cvec, gem5::ArmISA::i, logs, max_bucket, min_bucket, samples, size(), squares, and sum.
Referenced by HistStor(), and TEST().
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 177 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(), and TEST().

inline 
Return the number of buckets in this distribution.
Definition at line 497 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 504 of file storage.hh.
References samples.
Referenced by growDown(), growOut(), and TEST().

private 
The number of entries in each bucket.
Definition at line 407 of file storage.hh.
Referenced by add(), growDown(), growOut(), growUp(), prepare(), reset(), and sample().

private 
Counter for each bucket.
Definition at line 418 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 405 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 403 of file storage.hh.
Referenced by add(), growDown(), growOut(), prepare(), reset(), and sample().

private 

private 

private 