From: Hoa Nguyen Date: Fri, 23 Oct 2020 08:31:43 +0000 (-0700) Subject: sim,stats: Update stats style for power_model and thermal_domain X-Git-Tag: develop-gem5-snapshot~433 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e175be98fb7ea741b4026dad91c2aa2e08884a83;p=gem5.git sim,stats: Update stats style for power_model and thermal_domain Change-Id: Ie50553c301ff5790b51057dc117568374f0cbe36 Signed-off-by: Hoa Nguyen Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/36515 Tested-by: kokoro Reviewed-by: Daniel Carvalho Reviewed-by: Andreas Sandberg Maintainer: Andreas Sandberg --- diff --git a/src/sim/power/power_model.cc b/src/sim/power/power_model.cc index fa531e056..fbc67d34b 100644 --- a/src/sim/power/power_model.cc +++ b/src/sim/power/power_model.cc @@ -44,13 +44,21 @@ #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 diff --git a/src/sim/power/power_model.hh b/src/sim/power/power_model.hh index c8625ac96..e6f54311a 100644 --- a/src/sim/power/power_model.hh +++ b/src/sim/power/power_model.hh @@ -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 ± }; - Stats::Value dynamicPower, staticPower; - /** Actual power models (one per power state) */ std::vector 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 diff --git a/src/sim/power/thermal_domain.cc b/src/sim/power/thermal_domain.cc index 0b5bedd57..dabf2fe99 100644 --- a/src/sim/power/thermal_domain.cc +++ b/src/sim/power/thermal_domain.cc @@ -50,8 +50,11 @@ 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() { diff --git a/src/sim/power/thermal_domain.hh b/src/sim/power/thermal_domain.hh index 323ba2b60..421f3407b 100644 --- a/src/sim/power/thermal_domain.hh +++ b/src/sim/power/thermal_domain.hh @@ -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;