diff options
author | David Guillen Fandos <david.guillen@arm.com> | 2016-07-21 17:19:15 +0100 |
---|---|---|
committer | David Guillen Fandos <david.guillen@arm.com> | 2016-07-21 17:19:15 +0100 |
commit | d25b58036a040d8ac733b824e2865e1f5fe43e00 (patch) | |
tree | b8b2cd01c429e9c89555f738c14f975dbcc52313 /src/base/statistics.hh | |
parent | 0020662459fdd9efcfe9864ef12160515434ccdb (diff) | |
download | gem5-d25b58036a040d8ac733b824e2865e1f5fe43e00.tar.xz |
base: Add total() to Vector2D stat
This patch adds a total() function to the Vector2D
stat type. Similar to other stats such as Scalar or
Vector it is useful to be able to read the total for
a given stat.
Diffstat (limited to 'src/base/statistics.hh')
-rw-r--r-- | src/base/statistics.hh | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/base/statistics.hh b/src/base/statistics.hh index a21bf81d1..f8e651b97 100644 --- a/src/base/statistics.hh +++ b/src/base/statistics.hh @@ -159,6 +159,8 @@ class Vector2dInfoProxy : public InfoProxy<Stat, Vector2dInfo> { public: Vector2dInfoProxy(Stat &stat) : InfoProxy<Stat, Vector2dInfo>(stat) {} + + Result total() const { return this->s.total(); } }; struct StorageParams @@ -1298,6 +1300,19 @@ class Vector2dBase : public DataWrapVec2d<Derived, Vector2dInfoProxy> #endif } + /** + * Return a total of all entries in this vector. + * @return The total of all vector entries. + */ + Result + total() const + { + Result total = 0.0; + for (off_type i = 0; i < size(); ++i) + total += data(i)->result(); + return total; + } + void prepare() { |