sim,stats: Update stats style for power_model and thermal_domain
authorHoa Nguyen <hoanguyen@ucdavis.edu>
Fri, 23 Oct 2020 08:31:43 +0000 (01:31 -0700)
committerHoa Nguyen <hoanguyen@ucdavis.edu>
Fri, 20 Nov 2020 06:05:14 +0000 (06:05 +0000)
Change-Id: Ie50553c301ff5790b51057dc117568374f0cbe36
Signed-off-by: Hoa Nguyen <hoanguyen@ucdavis.edu>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/36515
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>

src/sim/power/power_model.cc
src/sim/power/power_model.hh
src/sim/power/thermal_domain.cc
src/sim/power/thermal_domain.hh

index fa531e056f35a66ee5c7aa48db2b8e21ff9144d1..fbc67d34b95efea08d9f707853b63daae9934e84 100644 (file)
 #include "sim/sub_system.hh"
 
 PowerModelState::PowerModelState(const Params &p)
-    : SimObject(p), _temp(0), clocked_object(NULL)
+    : SimObject(p), _temp(0), clocked_object(NULL),
+      ADD_STAT(dynamicPower, "Dynamic power for this object (Watts)"),
+      ADD_STAT(staticPower, "Static power for this object (Watts)")
 {
+    dynamicPower
+      .method(this, &PowerModelState::getDynamicPower);
+    staticPower
+      .method(this, &PowerModelState::getStaticPower);
 }
 
 PowerModel::PowerModel(const Params &p)
     : SimObject(p), states_pm(p.pm), subsystem(p.subsystem),
-      clocked_object(NULL), power_model_type(p.pm_type)
+      clocked_object(NULL), power_model_type(p.pm_type),
+      ADD_STAT(dynamicPower, "Dynamic power for this power state"),
+      ADD_STAT(staticPower, "Static power for this power state")
 {
     panic_if(subsystem == NULL,
              "Subsystem is NULL! This is not acceptable for a PowerModel!\n");
@@ -61,6 +69,11 @@ PowerModel::PowerModel(const Params &p)
         pms->setTemperature(p.ambient_temp);
     }
 
+    dynamicPower
+      .method(this, &PowerModel::getDynamicPower);
+    staticPower
+      .method(this, &PowerModel::getStaticPower);
+
 }
 
 void
index c8625ac96c3879429a9a3129de60721fa20cbeea..e6f54311ace53b34c9bf6eb9412f3f937983a125 100644 (file)
@@ -83,30 +83,15 @@ class PowerModelState : public SimObject
         clocked_object = clkobj;
     }
 
-    void regStats() {
-        SimObject::regStats();
-
-        dynamicPower
-          .method(this, &PowerModelState::getDynamicPower)
-          .name(params().name + ".dynamic_power")
-          .desc("Dynamic power for this object (Watts)")
-        ;
-
-        staticPower
-          .method(this, &PowerModelState::getStaticPower)
-          .name(params().name + ".static_power")
-          .desc("Static power for this object (Watts)")
-        ;
-    }
-
   protected:
-    Stats::Value dynamicPower, staticPower;
 
     /** Current temperature */
     double _temp;
 
     /** The clocked object we belong to */
     ClockedObject * clocked_object;
+
+    Stats::Value dynamicPower, staticPower;
 };
 
 /**
@@ -136,22 +121,6 @@ class PowerModel : public SimObject
      */
     double getStaticPower() const;
 
-    void regStats() {
-        SimObject::regStats();
-
-        dynamicPower
-          .method(this, &PowerModel::getDynamicPower)
-          .name(params().name + ".dynamic_power")
-          .desc("Dynamic power for this power state")
-        ;
-
-        staticPower
-          .method(this, &PowerModel::getStaticPower)
-          .name(params().name + ".static_power")
-          .desc("Static power for this power state")
-        ;
-    }
-
     void setClockedObject(ClockedObject *clkobj);
 
     virtual void regProbePoints();
@@ -176,8 +145,6 @@ class PowerModel : public SimObject
         PowerModel &pm;
     };
 
-    Stats::Value dynamicPower, staticPower;
-
     /** Actual power models (one per power state) */
     std::vector<PowerModelState*> states_pm;
 
@@ -192,6 +159,8 @@ class PowerModel : public SimObject
 
     /** The type of power model - collects all power, static or dynamic only */
     Enums::PMType power_model_type;
+
+    Stats::Value dynamicPower, staticPower;
 };
 
 #endif
index 0b5bedd57e88247f31c90f1f808a8f3cf36fb2fc..dabf2fe996e993f1dbea4a71358b295b36a1b46f 100644 (file)
 
 ThermalDomain::ThermalDomain(const Params &p)
     : SimObject(p), _initTemperature(p.initial_temperature),
-    node(NULL), subsystem(NULL)
+    node(NULL), subsystem(NULL),
+    ADD_STAT(currentTemp, "Temperature in centigrade degrees")
 {
+    currentTemp
+        .method(this, &ThermalDomain::currentTemperature);
 }
 
 double
@@ -70,18 +73,6 @@ ThermalDomain::setSubSystem(SubSystem * ss)
                                                 "thermalUpdate");
 }
 
-void
-ThermalDomain::regStats()
-{
-    SimObject::regStats();
-
-    currentTemp
-        .method(this, &ThermalDomain::currentTemperature)
-        .name(params().name + ".temp")
-        .desc("Temperature in centigrate degrees")
-        ;
-}
-
 void
 ThermalDomain::emitUpdate()
 {
index 323ba2b605040f4017b193c9d34e953e5320b985..421f3407b4eedd4aaec38e826b079d2ef8c8d56c 100644 (file)
@@ -93,7 +93,6 @@ class ThermalDomain : public SimObject, public ThermalEntity
       */
     void setSubSystem(SubSystem * ss);
 
-    void regStats() override;
     void serialize(CheckpointOut &cp) const override;
     void unserialize(CheckpointIn &cp) override;