Deleted Added
sdiff udiff text old ( 14175:8cf7610e44f8 ) new ( 14205:197360deaa20 )
full compact
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * Copyright (c) 2017, Centre National de la Recherche Scientifique
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;

--- 48 unchanged lines hidden (view full) ---

58#include <functional>
59#include <iosfwd>
60#include <list>
61#include <map>
62#include <memory>
63#include <string>
64#include <vector>
65
66#include "base/stats/info.hh"
67#include "base/stats/output.hh"
68#include "base/stats/types.hh"
69#include "base/cast.hh"
70#include "base/cprintf.hh"
71#include "base/intmath.hh"
72#include "base/str.hh"
73#include "base/types.hh"

--- 93 unchanged lines hidden (view full) ---

167
168struct StorageParams
169{
170 virtual ~StorageParams();
171};
172
173class InfoAccess
174{
175 protected:
176 /** Set up an info class for this statistic */
177 void setInfo(Info *info);
178 /** Save Storage class parameters if any */
179 void setParams(const StorageParams *params);
180 /** Save Storage class parameters if any */
181 void setInit();
182
183 /** Grab the information class for this statistic */
184 Info *info();
185 /** Grab the information class for this statistic */
186 const Info *info() const;
187
188 public:
189 /**
190 * Reset the stat to the default state.
191 */
192 void reset() { }
193
194 /**
195 * @return true if this stat has a value and satisfies its
196 * requirement as a prereq

--- 26 unchanged lines hidden (view full) ---

223
224 public:
225 const Info *
226 info() const
227 {
228 return safe_cast<const Info *>(InfoAccess::info());
229 }
230
231 protected:
232 /**
233 * Copy constructor, copies are not allowed.
234 */
235 DataWrap(const DataWrap &stat) = delete;
236
237 /**
238 * Can't copy stats.
239 */
240 void operator=(const DataWrap &) {}
241
242 public:
243 DataWrap()
244 {
245 this->setInfo(new Info(self()));
246 }
247
248 /**
249 * Set the name and marks this stat to print at the end of simulation.
250 * @param name The new name.
251 * @return A reference to this stat.
252 */
253 Derived &

--- 76 unchanged lines hidden (view full) ---

330};
331
332template <class Derived, template <class> class InfoProxyType>
333class DataWrapVec : public DataWrap<Derived, InfoProxyType>
334{
335 public:
336 typedef InfoProxyType<Derived> Info;
337
338 DataWrapVec()
339 {}
340
341 DataWrapVec(const DataWrapVec &ref)
342 {}
343
344 void operator=(const DataWrapVec &)
345 {}
346
347 // The following functions are specific to vectors. If you use them
348 // in a non vector context, you will get a nice compiler error!
349
350 /**
351 * Set the subfield name for the given index, and marks this stat to print
352 * at the end of simulation.
353 * @param index The subfield index.
354 * @param name The new name of the subfield.

--- 60 unchanged lines hidden (view full) ---

415};
416
417template <class Derived, template <class> class InfoProxyType>
418class DataWrapVec2d : public DataWrapVec<Derived, InfoProxyType>
419{
420 public:
421 typedef InfoProxyType<Derived> Info;
422
423 /**
424 * @warning This makes the assumption that if you're gonna subnames a 2d
425 * vector, you're subnaming across all y
426 */
427 Derived &
428 ysubnames(const char **names)
429 {
430 Derived &self = this->self();

--- 241 unchanged lines hidden (view full) ---

672 public:
673 /**
674 * Return the current value of this stat as its base type.
675 * @return The current value.
676 */
677 Counter value() const { return data()->value(); }
678
679 public:
680 ScalarBase()
681 {
682 this->doInit();
683 }
684
685 public:
686 // Common operators for stats
687 /**
688 * Increment the stat by 1. This calls the associated storage object inc

--- 113 unchanged lines hidden (view full) ---

802
803template <class Derived>
804class ValueBase : public DataWrap<Derived, ScalarInfoProxy>
805{
806 private:
807 ProxyInfo *proxy;
808
809 public:
810 ValueBase() : proxy(NULL) { }
811 ~ValueBase() { if (proxy) delete proxy; }
812
813 template <class T>
814 Derived &
815 scalar(T &value)
816 {
817 proxy = new ValueProxy<T>(value);
818 this->setInit();

--- 271 unchanged lines hidden (view full) ---

1090
1091 bool
1092 check() const
1093 {
1094 return storage != NULL;
1095 }
1096
1097 public:
1098 VectorBase()
1099 : storage(nullptr), _size(0)
1100 {}
1101
1102 ~VectorBase()
1103 {
1104 if (!storage)
1105 return;
1106
1107 for (off_type i = 0; i < _size; ++i)

--- 122 unchanged lines hidden (view full) ---

1230 size_type _size;
1231 Storage *storage;
1232
1233 protected:
1234 Storage *data(off_type index) { return &storage[index]; }
1235 const Storage *data(off_type index) const { return &storage[index]; }
1236
1237 public:
1238 Vector2dBase()
1239 : x(0), y(0), _size(0), storage(nullptr)
1240 {}
1241
1242 ~Vector2dBase()
1243 {
1244 if (!storage)
1245 return;
1246
1247 for (off_type i = 0; i < _size; ++i)

--- 598 unchanged lines hidden (view full) ---

1846 void
1847 doInit()
1848 {
1849 new (storage) Storage(this->info());
1850 this->setInit();
1851 }
1852
1853 public:
1854 DistBase() { }
1855
1856 /**
1857 * Add a value to the distribtion n times. Calls sample on the storage
1858 * class.
1859 * @param v The value to add.
1860 * @param n The number of times to add it, defaults to 1.
1861 */
1862 template <typename U>

--- 77 unchanged lines hidden (view full) ---

1940 Info *info = this->info();
1941 for (off_type i = 0; i < _size; ++i)
1942 new (&storage[i]) Storage(info);
1943
1944 this->setInit();
1945 }
1946
1947 public:
1948 VectorDistBase()
1949 : storage(NULL)
1950 {}
1951
1952 ~VectorDistBase()
1953 {
1954 if (!storage)
1955 return ;
1956
1957 for (off_type i = 0; i < _size; ++i)

--- 509 unchanged lines hidden (view full) ---

2467/**
2468 * This is a simple scalar statistic, like a counter.
2469 * @sa Stat, ScalarBase, StatStor
2470 */
2471class Scalar : public ScalarBase<Scalar, StatStor>
2472{
2473 public:
2474 using ScalarBase<Scalar, StatStor>::operator=;
2475};
2476
2477/**
2478 * A stat that calculates the per tick average of a value.
2479 * @sa Stat, ScalarBase, AvgStor
2480 */
2481class Average : public ScalarBase<Average, AvgStor>
2482{
2483 public:
2484 using ScalarBase<Average, AvgStor>::operator=;
2485};
2486
2487class Value : public ValueBase<Value>
2488{
2489};
2490
2491/**
2492 * A vector of scalar stats.
2493 * @sa Stat, VectorBase, StatStor
2494 */
2495class Vector : public VectorBase<Vector, StatStor>
2496{
2497};
2498
2499/**
2500 * A vector of Average stats.
2501 * @sa Stat, VectorBase, AvgStor
2502 */
2503class AverageVector : public VectorBase<AverageVector, AvgStor>
2504{
2505};
2506
2507/**
2508 * A 2-Dimensional vecto of scalar stats.
2509 * @sa Stat, Vector2dBase, StatStor
2510 */
2511class Vector2d : public Vector2dBase<Vector2d, StatStor>
2512{
2513};
2514
2515/**
2516 * A simple distribution stat.
2517 * @sa Stat, DistBase, DistStor
2518 */
2519class Distribution : public DistBase<Distribution, DistStor>
2520{
2521 public:
2522 /**
2523 * Set the parameters of this distribution. @sa DistStor::Params
2524 * @param min The minimum value of the distribution.
2525 * @param max The maximum value of the distribution.
2526 * @param bkt The number of values in each bucket.
2527 * @return A reference to this distribution.
2528 */
2529 Distribution &

--- 15 unchanged lines hidden (view full) ---

2545
2546/**
2547 * A simple histogram stat.
2548 * @sa Stat, DistBase, HistStor
2549 */
2550class Histogram : public DistBase<Histogram, HistStor>
2551{
2552 public:
2553 /**
2554 * Set the parameters of this histogram. @sa HistStor::Params
2555 * @param size The number of buckets in the histogram
2556 * @return A reference to this histogram.
2557 */
2558 Histogram &
2559 init(size_type size)
2560 {

--- 10 unchanged lines hidden (view full) ---

2571 * @sa DistBase, SampleStor
2572 */
2573class StandardDeviation : public DistBase<StandardDeviation, SampleStor>
2574{
2575 public:
2576 /**
2577 * Construct and initialize this distribution.
2578 */
2579 StandardDeviation()
2580 {
2581 SampleStor::Params *params = new SampleStor::Params;
2582 this->doInit();
2583 this->setParams(params);
2584 }
2585};
2586
2587/**
2588 * Calculates the per tick mean and variance of the samples.
2589 * @sa DistBase, AvgSampleStor
2590 */
2591class AverageDeviation : public DistBase<AverageDeviation, AvgSampleStor>
2592{
2593 public:
2594 /**
2595 * Construct and initialize this distribution.
2596 */
2597 AverageDeviation()
2598 {
2599 AvgSampleStor::Params *params = new AvgSampleStor::Params;
2600 this->doInit();
2601 this->setParams(params);
2602 }
2603};
2604
2605/**
2606 * A vector of distributions.
2607 * @sa VectorDistBase, DistStor
2608 */
2609class VectorDistribution : public VectorDistBase<VectorDistribution, DistStor>
2610{
2611 public:
2612 /**
2613 * Initialize storage and parameters for this distribution.
2614 * @param size The size of the vector (the number of distributions).
2615 * @param min The minimum value of the distribution.
2616 * @param max The maximum value of the distribution.
2617 * @param bkt The number of values in each bucket.
2618 * @return A reference to this distribution.
2619 */

--- 14 unchanged lines hidden (view full) ---

2634/**
2635 * This is a vector of StandardDeviation stats.
2636 * @sa VectorDistBase, SampleStor
2637 */
2638class VectorStandardDeviation
2639 : public VectorDistBase<VectorStandardDeviation, SampleStor>
2640{
2641 public:
2642 /**
2643 * Initialize storage for this distribution.
2644 * @param size The size of the vector.
2645 * @return A reference to this distribution.
2646 */
2647 VectorStandardDeviation &
2648 init(size_type size)
2649 {

--- 7 unchanged lines hidden (view full) ---

2657/**
2658 * This is a vector of AverageDeviation stats.
2659 * @sa VectorDistBase, AvgSampleStor
2660 */
2661class VectorAverageDeviation
2662 : public VectorDistBase<VectorAverageDeviation, AvgSampleStor>
2663{
2664 public:
2665 /**
2666 * Initialize storage for this distribution.
2667 * @param size The size of the vector.
2668 * @return A reference to this distribution.
2669 */
2670 VectorAverageDeviation &
2671 init(size_type size)
2672 {

--- 75 unchanged lines hidden (view full) ---

2748 void
2749 doInit()
2750 {
2751 new (storage) Storage(this->info());
2752 this->setInit();
2753 }
2754
2755 public:
2756 SparseHistBase() { }
2757
2758 /**
2759 * Add a value to the distribtion n times. Calls sample on the storage
2760 * class.
2761 * @param v The value to add.
2762 * @param n The number of times to add it, defaults to 1.
2763 */
2764 template <typename U>

--- 100 unchanged lines hidden (view full) ---

2865 cmap.clear();
2866 samples = 0;
2867 }
2868};
2869
2870class SparseHistogram : public SparseHistBase<SparseHistogram, SparseHistStor>
2871{
2872 public:
2873 /**
2874 * Set the parameters of this histogram. @sa HistStor::Params
2875 * @param size The number of buckets in the histogram
2876 * @return A reference to this histogram.
2877 */
2878 SparseHistogram &
2879 init(size_type size)
2880 {

--- 16 unchanged lines hidden (view full) ---

2897 /** The root of the tree which represents the Formula */
2898 NodePtr root;
2899 friend class Temp;
2900
2901 public:
2902 /**
2903 * Create and initialize thie formula, and register it with the database.
2904 */
2905 Formula();
2906
2907 /**
2908 * Create a formula with the given root node, register it with the
2909 * database.
2910 * @param r The root of the expression tree.
2911 */
2912 Formula(Temp r);
2913
2914 /**
2915 * Set an unitialized Formula to the given root.
2916 * @param r The root of the expression tree.
2917 * @return a reference to this formula.
2918 */
2919 const Formula &operator=(Temp r);
2920
2921 /**
2922 * Add the given tree to the existing one.
2923 * @param r The root of the expression tree.
2924 * @return a reference to this formula.
2925 */
2926 const Formula &operator+=(Temp r);
2927
2928 /**

--- 351 unchanged lines hidden ---