base,tests: Create unit tests for Stats::Stor
authorDaniel R. Carvalho <odanrc@yahoo.com.br>
Wed, 5 Feb 2020 21:12:38 +0000 (22:12 +0100)
committerDaniel Carvalho <odanrc@yahoo.com.br>
Wed, 3 Feb 2021 01:12:27 +0000 (01:12 +0000)
commitc9e069a2f279cb4b51cce13a9db5fc7978c4938c
tree366858818d8deb308294c77df56203abe7d11933
parente59557af500d1633b1f41b023d6c072acaf145a0
base,tests: Create unit tests for Stats::Stor

Create unit tests for the stats storage types. As a side effect
storage-related classes have been moved to separate files.

HistStor's grow_up, grow_out, and grow_convert have been made
private and renamed to comply with gem5's naming convention
and make grow_convert match its grow_up counterpart (growDown)
which is more suitable for its expected behavior.

The params declarations have been moved to be close to their
storage class' constructor.

HistStor has a explicit condition stating that there must be
at least 2 buckets.

Added documentation!

Fixed grow_convert so that it yields consistent histograms.
Previously buckets could not fully intersect, so doubling their
bucket size would make them steal contents innaproprietly. For
example, the neighbors [-6,-2[, [-2,2[, [2,6[, when doubled,
become [-12,-4[, [-4,4[, [4,12[; however, since the individual
values are not stored, it is impossible to know how to populate
the middle bucket with its neighbor's partial contents.
This fix forces the middle bucket of a storage to have its lower
bound at 0, solving the partial intersection issue.

Change-Id: Idb063e3dbda3cce3a8969e347660143162146eb9
Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/25425
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/base/statistics.cc
src/base/statistics.hh
src/base/stats/SConscript
src/base/stats/storage.cc [new file with mode: 0644]
src/base/stats/storage.hh [new file with mode: 0644]
src/base/stats/storage.test.cc [new file with mode: 0644]