sim, arch, base: Refactor the base remote GDB class.
[gem5.git] / src / sim / clocked_object.cc
index e679f03a09fff687c85f8698fbc92756a5af34f3..6982966aa85d80b4cfbf0bfd8b292d5d9ddd21b8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 ARM Limited
+ * Copyright (c) 2015-2016 ARM Limited
  * All rights reserved
  *
  * The license below extends only to copyright in the software and shall
@@ -40,7 +40,7 @@
 
 #include "sim/clocked_object.hh"
 
-#include "base/misc.hh"
+#include "base/logging.hh"
 #include "sim/power/power_model.hh"
 
 ClockedObject::ClockedObject(const ClockedObjectParams *p) :
@@ -49,8 +49,8 @@ ClockedObject::ClockedObject(const ClockedObjectParams *p) :
     prvEvalTick(0)
 {
     // Register the power_model with the object
-    if (p->power_model)
-        p->power_model->setClockedObject(this);
+    for (auto & power_model: p->power_model)
+        power_model->setClockedObject(this);
 }
 
 void
@@ -78,21 +78,22 @@ ClockedObject::pwrState(Enums::PwrState p)
 {
     // Function should ideally be called only when there is a state change
     if (_currPwrState == p) {
-        warn("ClockedObject: Already in the requested power state, request "\
-             "ignored");
+        warn_once("ClockedObject: Already in the requested power state, " \
+                  "request ignored");
         return;
     }
 
-    // No need to compute stats if in the same tick, update state
-    // though. This can happen in cases like a) during start of the
-    // simulation multiple state changes happens in init/startup phase,
-    // b) one takes a decision to migrate state but decides to reverts
-    // back to the original state in the same tick if other conditions
-    // are not met elsewhere. Any state change related stats would have
-    // been recorded on previous call to the pwrState() function.
-    if (prvEvalTick == curTick()) {
-        warn("ClockedObject: More than one power state change request "\
-             "encountered within the same simulation tick");
+    // No need to compute stats if in the same tick, update state though. This
+    // can happen in cases like a) during start of the simulation multiple
+    // state changes happens in init/startup phase, b) one takes a decision to
+    // migrate state but decides to reverts back to the original state in the
+    // same tick if other conditions are not met elsewhere.
+    // Any state change related stats would have been recorded on previous call
+    // to the pwrState() function.
+    if (prvEvalTick == curTick() && curTick() != 0) {
+       warn("ClockedObject %s: More than one power state change request "\
+             "encountered within the same simulation tick %d",
+             name(), prvEvalTick);
         _currPwrState = p;
         return;
     }
@@ -137,7 +138,7 @@ ClockedObject::pwrStateWeights() const
 
     ret.resize(Enums::PwrState::Num_PwrState);
     for (unsigned i = 0; i < Enums::PwrState::Num_PwrState; i++)
-        ret[i] = residencies[i] /
+        ret[i] = residencies[i] / \
                      (pwrStateResidencyTicks.total() + elapsed_time);
 
     return ret;
@@ -153,6 +154,7 @@ ClockedObject::regStats()
     numPwrStateTransitions
         .name(params()->name + ".numPwrStateTransitions")
         .desc("Number of power state transitions")
+        .flags(nozero)
         ;
 
     // Each sample is time in ticks
@@ -162,13 +164,14 @@ ClockedObject::regStats()
           (params()->p_state_clk_gate_max / num_bins))
         .name(params()->name + ".pwrStateClkGateDist")
         .desc("Distribution of time spent in the clock gated state")
-        .flags(pdf)
+        .flags(pdf | nozero | nonan)
         ;
 
     pwrStateResidencyTicks
         .init(Enums::PwrState::Num_PwrState)
         .name(params()->name + ".pwrStateResidencyTicks")
         .desc("Cumulative time (in ticks) in various power states")
+        .flags(nozero)
         ;
     for (int i = 0; i < Enums::PwrState::Num_PwrState; i++) {
         pwrStateResidencyTicks.subname(i, Enums::PwrStateStrings[i]);