Merge with head.
[gem5.git] / src / base / statistics.hh
index 59f219c07c7f7d5090994a23c4e7d3cd169925d9..8d3f53d4cb492e12fe519ec9b2ae6388da2cfe8d 100644 (file)
@@ -50,6 +50,9 @@
 
 #include <algorithm>
 #include <cassert>
+#ifdef __SUNPRO_CC
+#include <math.h>
+#endif
 #include <cmath>
 #include <functional>
 #include <iosfwd>
@@ -67,7 +70,7 @@
 
 class Callback;
 
-/** The current simulated cycle. */
+/** The current simulated tick. */
 extern Tick curTick;
 
 /* A namespace for all of the Statistics */
@@ -395,7 +398,7 @@ class Wrap : public Child
   public:
     Wrap()
     {
-      map(new Data<Child>(*this));
+      this->map(new Data<Child>(*this));
     }
 
     /**
@@ -595,9 +598,9 @@ struct StatStor
 };
 
 /**
- * Templatized storage and interface to a per-cycle average stat. This keeps
- * a current count and updates a total (count * cycles) when this count
- * changes. This allows the quick calculation of a per cycle count of the item
+ * Templatized storage and interface to a per-tick average stat. This keeps
+ * a current count and updates a total (count * ticks) when this count
+ * changes. This allows the quick calculation of a per tick count of the item
  * being watched. This is good for keeping track of residencies in structures
  * among other things.
  */
@@ -610,9 +613,9 @@ struct AvgStor
   private:
     /** The current count. */
     Counter current;
-    /** The total count for all cycles. */
+    /** The total count for all tick. */
     mutable Result total;
-    /** The cycle that current last changed. */
+    /** The tick that current last changed. */
     mutable Tick last;
 
   public:
@@ -696,7 +699,7 @@ class ScalarBase : public DataAccess
 
   protected:
     /** The storage of this stat. */
-    char storage[sizeof(Storage)];
+    char storage[sizeof(Storage)] __attribute__ ((aligned (8)));
 
     /** The parameters for this stat. */
     Params params;
@@ -1410,7 +1413,7 @@ struct DistStor
         else if (val > params.max)
             overflow += number;
         else {
-            int index = (int)floor((val - params.min) / params.bucket_size);
+            int index = (int)std::floor((val - params.min) / params.bucket_size);
             assert(index < size(params));
             cvec[index] += number;
         }
@@ -1560,7 +1563,7 @@ struct FancyStor
 };
 
 /**
- * Templatized storage for distribution that calculates per cycle mean and
+ * Templatized storage for distribution that calculates per tick mean and
  * variance.
  */
 struct AvgFancy
@@ -1637,7 +1640,7 @@ class DistBase : public DataAccess
 
   protected:
     /** The storage for this stat. */
-    char storage[sizeof(Storage)];
+    char storage[sizeof(Storage)] __attribute__ ((aligned (8)));
 
     /** The parameters for this stat. */
     Params params;
@@ -2091,9 +2094,13 @@ class UnaryNode : public Node
         return vresult;
     }
 
-    Result total() const {
-        Op op;
-        return op(l->total());
+    Result total() const
+    {
+        const VResult &vec = this->result();
+        Result total = 0;
+        for (int i = 0; i < size(); i++)
+            total += vec[i];
+        return total;
     }
 
     virtual size_t size() const { return l->size(); }
@@ -2146,9 +2153,13 @@ class BinaryNode : public Node
         return vresult;
     }
 
-    Result total() const {
-        Op op;
-        return op(l->total(), r->total());
+    Result total() const
+    {
+        const VResult &vec = this->result();
+        Result total = 0;
+        for (int i = 0; i < size(); i++)
+            total += vec[i];
+        return total;
     }
 
     virtual size_t size() const {
@@ -2277,7 +2288,7 @@ class Value : public Wrap<Value, ValueBase, ScalarStatData>
 };
 
 /**
- * A stat that calculates the per cycle average of a value.
+ * A stat that calculates the per tick average of a value.
  * @sa Stat, ScalarBase, AvgStor
  */
 template<int N = 0>
@@ -2414,7 +2425,7 @@ class StandardDeviation
 };
 
 /**
- * Calculates the per cycle mean and variance of the samples.
+ * Calculates the per tick mean and variance of the samples.
  * @sa Stat, DistBase, AvgFancy
  */
 template<int N = 0>
@@ -2836,6 +2847,7 @@ class Temp
  */
 
 void check();
+void dump();
 void reset();
 void registerResetCallback(Callback *cb);