Daniel Carvalho has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/43008 )
Change subject: base-stats: Make Rate's compilation smarter
......................................................................
base-stats: Make Rate's compilation smarter
A Rate should be supplied units of different types.
Rates between units of the same type are Ratios,
and should be declared as such.
An exception is applied to Count and Unspecified,
since those units represent unknown underlying units.
Change-Id: I36ab7c73b239ccc86d866c5b38e14fd765bbbd0f
Signed-off-by: Daniel R. Carvalho <[email protected]>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/43008
Tested-by: kokoro <[email protected]>
Maintainer: Giacomo Travaglini <[email protected]>
Reviewed-by: Hoa Nguyen <[email protected]>
---
M src/base/stats/units.hh
1 file changed, 35 insertions(+), 32 deletions(-)
Approvals:
Hoa Nguyen: Looks good to me, approved
Giacomo Travaglini: Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/base/stats/units.hh b/src/base/stats/units.hh
index b2dfefa..87e6025 100644
--- a/src/base/stats/units.hh
+++ b/src/base/stats/units.hh
@@ -272,38 +272,6 @@
std::string getUnitString() const override { return Count::toString();
}
};
-template <typename T1, typename T2>
-class Rate : public Base
-{
- static_assert(std::is_base_of<Base, T1>::value,
- "Rate(T1,T2) must have T1 and T2 derived from"
- "Stats::Units::Base");
- static_assert(std::is_base_of<Base, T2>::value,
- "Rate(T1,T2) must have T1 and T2 derived from"
- "Stats::Units::Base");
- private:
- Rate<T1,T2>() {}
- public:
- Rate<T1,T2>(Rate<T1,T2> const&) = delete;
- void operator=(Rate<T1,T2> const&) = delete;
- static Rate<T1,T2>*
- get()
- {
- static Rate<T1,T2> instance;
- return &instance;
- }
- static std::string
- toString()
- {
- return csprintf("(%s/%s)", T1::toString(), T2::toString());
- }
- std::string
- getUnitString() const override
- {
- return Rate<T1,T2>::toString();
- }
-};
-
class Ratio : public Base
{
private:
@@ -342,6 +310,41 @@
}
};
+template <typename T1, typename T2>
+class Rate : public Base
+{
+ static_assert(std::is_base_of<Base, T1>::value,
+ "Rate(T1,T2) must have T1 and T2 derived from Stats::Units::Base");
+ static_assert(std::is_base_of<Base, T2>::value,
+ "Rate(T1,T2) must have T1 and T2 derived from Stats::Units::Base");
+ static_assert(!std::is_same<T1, T2>::value ||
+ std::is_same<T1, Count>::value || std::is_same<T1,
Unspecified>::value,
+ "Rate(T1,T2) must have T1 and T2 of different types; "
+ "otherwise, it would be a Ratio");
+
+ private:
+ Rate<T1,T2>() {}
+ public:
+ Rate<T1,T2>(Rate<T1,T2> const&) = delete;
+ void operator=(Rate<T1,T2> const&) = delete;
+ static Rate<T1,T2>*
+ get()
+ {
+ static Rate<T1,T2> instance;
+ return &instance;
+ }
+ static std::string
+ toString()
+ {
+ return csprintf("(%s/%s)", T1::toString(), T2::toString());
+ }
+ std::string
+ getUnitString() const override
+ {
+ return Rate<T1,T2>::toString();
+ }
+};
+
} // namespace Units
} // namespace Stats
1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the
submitted one.
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/43008
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I36ab7c73b239ccc86d866c5b38e14fd765bbbd0f
Gerrit-Change-Number: 43008
Gerrit-PatchSet: 5
Gerrit-Owner: Daniel Carvalho <[email protected]>
Gerrit-Reviewer: Daniel Carvalho <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Hoa Nguyen <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s