gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
statistics.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 Arm Limited
3  * All rights reserved.
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Copyright (c) 2003-2005 The Regents of The University of Michigan
15  * Copyright (c) 2017, Centre National de la Recherche Scientifique
16  * All rights reserved.
17  *
18  * Redistribution and use in source and binary forms, with or without
19  * modification, are permitted provided that the following conditions are
20  * met: redistributions of source code must retain the above copyright
21  * notice, this list of conditions and the following disclaimer;
22  * redistributions in binary form must reproduce the above copyright
23  * notice, this list of conditions and the following disclaimer in the
24  * documentation and/or other materials provided with the distribution;
25  * neither the name of the copyright holders nor the names of its
26  * contributors may be used to endorse or promote products derived from
27  * this software without specific prior written permission.
28  *
29  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40  *
41  * Authors: Nathan Binkert
42  * Pierre-Yves Peneau
43  */
44 
61 #ifndef __BASE_STATISTICS_HH__
62 #define __BASE_STATISTICS_HH__
63 
64 #include <algorithm>
65 #include <cassert>
66 #ifdef __SUNPRO_CC
67 #include <math.h>
68 #endif
69 #include <cmath>
70 #include <functional>
71 #include <iosfwd>
72 #include <list>
73 #include <map>
74 #include <memory>
75 #include <string>
76 #include <vector>
77 
78 #include "base/stats/group.hh"
79 #include "base/stats/info.hh"
80 #include "base/stats/output.hh"
81 #include "base/stats/types.hh"
82 #include "base/cast.hh"
83 #include "base/cprintf.hh"
84 #include "base/intmath.hh"
85 #include "base/str.hh"
86 #include "base/types.hh"
87 
88 class Callback;
89 
91 extern Tick curTick();
92 
93 /* A namespace for all of the Statistics */
94 namespace Stats {
95 
96 template <class Stat, class Base>
97 class InfoProxy : public Base
98 {
99  protected:
100  Stat &s;
101 
102  public:
103  InfoProxy(Stat &stat) : s(stat) {}
104 
105  bool check() const { return s.check(); }
106  void prepare() { s.prepare(); }
107  void reset() { s.reset(); }
108  void
109  visit(Output &visitor)
110  {
111  visitor.visit(*static_cast<Base *>(this));
112  }
113  bool zero() const { return s.zero(); }
114 };
115 
116 template <class Stat>
117 class ScalarInfoProxy : public InfoProxy<Stat, ScalarInfo>
118 {
119  public:
120  ScalarInfoProxy(Stat &stat) : InfoProxy<Stat, ScalarInfo>(stat) {}
121 
122  Counter value() const { return this->s.value(); }
123  Result result() const { return this->s.result(); }
124  Result total() const { return this->s.total(); }
125 };
126 
127 template <class Stat>
128 class VectorInfoProxy : public InfoProxy<Stat, VectorInfo>
129 {
130  protected:
131  mutable VCounter cvec;
132  mutable VResult rvec;
133 
134  public:
135  VectorInfoProxy(Stat &stat) : InfoProxy<Stat, VectorInfo>(stat) {}
136 
137  size_type size() const { return this->s.size(); }
138 
139  VCounter &
140  value() const
141  {
142  this->s.value(cvec);
143  return cvec;
144  }
145 
146  const VResult &
147  result() const
148  {
149  this->s.result(rvec);
150  return rvec;
151  }
152 
153  Result total() const { return this->s.total(); }
154 };
155 
156 template <class Stat>
157 class DistInfoProxy : public InfoProxy<Stat, DistInfo>
158 {
159  public:
160  DistInfoProxy(Stat &stat) : InfoProxy<Stat, DistInfo>(stat) {}
161 };
162 
163 template <class Stat>
164 class VectorDistInfoProxy : public InfoProxy<Stat, VectorDistInfo>
165 {
166  public:
167  VectorDistInfoProxy(Stat &stat) : InfoProxy<Stat, VectorDistInfo>(stat) {}
168 
169  size_type size() const { return this->s.size(); }
170 };
171 
172 template <class Stat>
173 class Vector2dInfoProxy : public InfoProxy<Stat, Vector2dInfo>
174 {
175  public:
176  Vector2dInfoProxy(Stat &stat) : InfoProxy<Stat, Vector2dInfo>(stat) {}
177 
178  Result total() const { return this->s.total(); }
179 };
180 
182 {
183  virtual ~StorageParams();
184 };
185 
187 {
188  private:
190 
191  protected:
193  void setInfo(Group *parent, Info *info);
195  void setParams(const StorageParams *params);
197  void setInit();
198 
200  Info *info();
202  const Info *info() const;
203 
204  public:
206  : _info(nullptr) {};
207 
211  void reset() { }
212 
217  bool zero() const { return true; }
218 
224  bool check() const { return true; }
225 };
226 
227 template <class Derived, template <class> class InfoProxyType>
228 class DataWrap : public InfoAccess
229 {
230  public:
231  typedef InfoProxyType<Derived> Info;
232 
233  protected:
234  Derived &self() { return *static_cast<Derived *>(this); }
235 
236  protected:
237  Info *
239  {
240  return safe_cast<Info *>(InfoAccess::info());
241  }
242 
243  public:
244  const Info *
245  info() const
246  {
247  return safe_cast<const Info *>(InfoAccess::info());
248  }
249 
250  public:
251  DataWrap() = delete;
252  DataWrap(const DataWrap &) = delete;
253  DataWrap &operator=(const DataWrap &) = delete;
254 
255 
256  DataWrap(Group *parent, const char *name, const char *desc)
257  {
258  auto info = new Info(self());
259  this->setInfo(parent, info);
260 
261  if (parent)
262  parent->addStat(info);
263 
264  if (name) {
265  info->setName(parent, name);
266  info->flags.set(display);
267  }
268 
269  if (desc)
270  info->desc = desc;
271  }
272 
278  Derived &
279  name(const std::string &name)
280  {
281  Info *info = this->info();
282  info->setName(name);
283  info->flags.set(display);
284  return this->self();
285  }
286  const std::string &name() const { return this->info()->name; }
287 
294  Derived &
295  setSeparator(const std::string &_sep)
296  {
297  this->info()->setSeparator(_sep);
298  return this->self();
299  }
300  const std::string &setSeparator() const
301  {
302  return this->info()->separatorString;
303  }
304 
311  Derived &
312  desc(const std::string &_desc)
313  {
314  this->info()->desc = _desc;
315  return this->self();
316  }
317 
323  Derived &
324  precision(int _precision)
325  {
326  this->info()->precision = _precision;
327  return this->self();
328  }
329 
335  Derived &
336  flags(Flags _flags)
337  {
338  this->info()->flags.set(_flags);
339  return this->self();
340  }
341 
348  template <class Stat>
349  Derived &
350  prereq(const Stat &prereq)
351  {
352  this->info()->prereq = prereq.info();
353  return this->self();
354  }
355 };
356 
357 template <class Derived, template <class> class InfoProxyType>
358 class DataWrapVec : public DataWrap<Derived, InfoProxyType>
359 {
360  public:
361  typedef InfoProxyType<Derived> Info;
362 
363  DataWrapVec(Group *parent = nullptr, const char *name = nullptr,
364  const char *desc = nullptr)
365  : DataWrap<Derived, InfoProxyType>(parent, name, desc)
366  {}
367 
368  // The following functions are specific to vectors. If you use them
369  // in a non vector context, you will get a nice compiler error!
370 
378  Derived &
379  subname(off_type index, const std::string &name)
380  {
381  Derived &self = this->self();
382  Info *info = self.info();
383 
384  std::vector<std::string> &subn = info->subnames;
385  if (subn.size() <= index)
386  subn.resize(index + 1);
387  subn[index] = name;
388  return self;
389  }
390 
391  // The following functions are specific to 2d vectors. If you use
392  // them in a non vector context, you will get a nice compiler
393  // error because info doesn't have the right variables.
394 
402  Derived &
403  subdesc(off_type index, const std::string &desc)
404  {
405  Info *info = this->info();
406 
407  std::vector<std::string> &subd = info->subdescs;
408  if (subd.size() <= index)
409  subd.resize(index + 1);
410  subd[index] = desc;
411 
412  return this->self();
413  }
414 
415  void
417  {
418  Derived &self = this->self();
419  Info *info = this->info();
420 
421  size_t size = self.size();
422  for (off_type i = 0; i < size; ++i)
423  self.data(i)->prepare(info);
424  }
425 
426  void
428  {
429  Derived &self = this->self();
430  Info *info = this->info();
431 
432  size_t size = self.size();
433  for (off_type i = 0; i < size; ++i)
434  self.data(i)->reset(info);
435  }
436 };
437 
438 template <class Derived, template <class> class InfoProxyType>
439 class DataWrapVec2d : public DataWrapVec<Derived, InfoProxyType>
440 {
441  public:
442  typedef InfoProxyType<Derived> Info;
443 
444  DataWrapVec2d(Group *parent, const char *name, const char *desc)
445  : DataWrapVec<Derived, InfoProxyType>(parent, name, desc)
446  {
447  }
448 
453  Derived &
454  ysubnames(const char **names)
455  {
456  Derived &self = this->self();
457  Info *info = this->info();
458 
459  info->y_subnames.resize(self.y);
460  for (off_type i = 0; i < self.y; ++i)
461  info->y_subnames[i] = names[i];
462  return self;
463  }
464 
465  Derived &
466  ysubname(off_type index, const std::string &subname)
467  {
468  Derived &self = this->self();
469  Info *info = this->info();
470 
471  assert(index < self.y);
472  info->y_subnames.resize(self.y);
473  info->y_subnames[index] = subname.c_str();
474  return self;
475  }
476 
477  std::string
479  {
480  return this->info()->y_subnames[i];
481  }
482 
483 };
484 
486 //
487 // Simple Statistics
488 //
490 
494 class StatStor
495 {
496  private:
499 
500  public:
501  struct Params : public StorageParams {};
502 
503  public:
508  StatStor(Info *info)
509  : data(Counter())
510  { }
511 
516  void set(Counter val) { data = val; }
521  void inc(Counter val) { data += val; }
526  void dec(Counter val) { data -= val; }
531  Counter value() const { return data; }
536  Result result() const { return (Result)data; }
540  void prepare(Info *info) { }
544  void reset(Info *info) { data = Counter(); }
545 
549  bool zero() const { return data == Counter(); }
550 };
551 
559 class AvgStor
560 {
561  private:
567  mutable Result total;
569  mutable Tick last;
570 
571  public:
572  struct Params : public StorageParams {};
573 
574  public:
578  AvgStor(Info *info)
579  : current(0), lastReset(0), total(0), last(0)
580  { }
581 
587  void
589  {
590  total += current * (curTick() - last);
591  last = curTick();
592  current = val;
593  }
594 
599  void inc(Counter val) { set(current + val); }
600 
605  void dec(Counter val) { set(current - val); }
606 
611  Counter value() const { return current; }
612 
617  Result
618  result() const
619  {
620  assert(last == curTick());
621  return (Result)(total + current) / (Result)(curTick() - lastReset + 1);
622  }
623 
627  bool zero() const { return total == 0.0; }
628 
632  void
633  prepare(Info *info)
634  {
635  total += current * (curTick() - last);
636  last = curTick();
637  }
638 
642  void
643  reset(Info *info)
644  {
645  total = 0.0;
646  last = curTick();
647  lastReset = curTick();
648  }
649 
650 };
651 
656 template <class Derived, class Stor>
657 class ScalarBase : public DataWrap<Derived, ScalarInfoProxy>
658 {
659  public:
660  typedef Stor Storage;
661  typedef typename Stor::Params Params;
662 
663  protected:
665  char storage[sizeof(Storage)] __attribute__ ((aligned (8)));
666 
667  protected:
673  Storage *
675  {
676  return reinterpret_cast<Storage *>(storage);
677  }
678 
685  const Storage *
686  data() const
687  {
688  return reinterpret_cast<const Storage *>(storage);
689  }
690 
691  void
693  {
694  new (storage) Storage(this->info());
695  this->setInit();
696  }
697 
698  public:
703  Counter value() const { return data()->value(); }
704 
705  public:
706  ScalarBase(Group *parent = nullptr, const char *name = nullptr,
707  const char *desc = nullptr)
708  : DataWrap<Derived, ScalarInfoProxy>(parent, name, desc)
709  {
710  this->doInit();
711  }
712 
713  public:
714  // Common operators for stats
719  void operator++() { data()->inc(1); }
724  void operator--() { data()->dec(1); }
725 
727  void operator++(int) { ++*this; }
729  void operator--(int) { --*this; }
730 
736  template <typename U>
737  void operator=(const U &v) { data()->set(v); }
738 
744  template <typename U>
745  void operator+=(const U &v) { data()->inc(v); }
746 
752  template <typename U>
753  void operator-=(const U &v) { data()->dec(v); }
754 
759  size_type size() const { return 1; }
760 
761  Counter value() { return data()->value(); }
762 
763  Result result() { return data()->result(); }
764 
765  Result total() { return result(); }
766 
767  bool zero() { return result() == 0.0; }
768 
769  void reset() { data()->reset(this->info()); }
770  void prepare() { data()->prepare(this->info()); }
771 };
772 
773 class ProxyInfo : public ScalarInfo
774 {
775  public:
776  std::string str() const { return std::to_string(value()); }
777  size_type size() const { return 1; }
778  bool check() const { return true; }
779  void prepare() { }
780  void reset() { }
781  bool zero() const { return value() == 0; }
782 
783  void visit(Output &visitor) { visitor.visit(*this); }
784 };
785 
786 template <class T>
787 class ValueProxy : public ProxyInfo
788 {
789  private:
790  T *scalar;
791 
792  public:
793  ValueProxy(T &val) : scalar(&val) {}
794  Counter value() const { return *scalar; }
795  Result result() const { return *scalar; }
796  Result total() const { return *scalar; }
797 };
798 
799 template <class T>
800 class FunctorProxy : public ProxyInfo
801 {
802  private:
804 
805  public:
806  FunctorProxy(T &func) : functor(&func) {}
807  Counter value() const { return (*functor)(); }
808  Result result() const { return (*functor)(); }
809  Result total() const { return (*functor)(); }
810 };
811 
816 template <class T, class V>
817 class MethodProxy : public ProxyInfo
818 {
819  private:
820  T *object;
821  typedef V (T::*MethodPointer) () const;
822  MethodPointer method;
823 
824  public:
825  MethodProxy(T *obj, MethodPointer meth) : object(obj), method(meth) {}
826  Counter value() const { return (object->*method)(); }
827  Result result() const { return (object->*method)(); }
828  Result total() const { return (object->*method)(); }
829 };
830 
831 template <class Derived>
832 class ValueBase : public DataWrap<Derived, ScalarInfoProxy>
833 {
834  private:
836 
837  public:
838  ValueBase(Group *parent, const char *name, const char *desc)
839  : DataWrap<Derived, ScalarInfoProxy>(parent, name, desc),
840  proxy(NULL)
841  {
842  }
843 
844  ~ValueBase() { if (proxy) delete proxy; }
845 
846  template <class T>
847  Derived &
848  scalar(T &value)
849  {
850  proxy = new ValueProxy<T>(value);
851  this->setInit();
852  return this->self();
853  }
854 
855  template <class T>
856  Derived &
857  functor(T &func)
858  {
859  proxy = new FunctorProxy<T>(func);
860  this->setInit();
861  return this->self();
862  }
863 
871  template <class T, class V>
872  Derived &
873  method(T *obj, V (T::*method)() const)
874  {
875  proxy = new MethodProxy<T,V>(obj, method);
876  this->setInit();
877  return this->self();
878  }
879 
880  Counter value() { return proxy->value(); }
881  Result result() const { return proxy->result(); }
882  Result total() const { return proxy->total(); };
883  size_type size() const { return proxy->size(); }
884 
885  std::string str() const { return proxy->str(); }
886  bool zero() const { return proxy->zero(); }
887  bool check() const { return proxy != NULL; }
888  void prepare() { }
889  void reset() { }
890 };
891 
893 //
894 // Vector Statistics
895 //
897 
902 template <class Stat>
904 {
905  private:
907  Stat &stat;
908 
911 
912  public:
917  Counter value() const { return stat.data(index)->value(); }
918 
923  Result result() const { return stat.data(index)->result(); }
924 
925  public:
931  : stat(s), index(i)
932  {
933  }
934 
940  : stat(sp.stat), index(sp.index)
941  {}
942 
948  const ScalarProxy &
950  {
951  stat = sp.stat;
952  index = sp.index;
953  return *this;
954  }
955 
956  public:
957  // Common operators for stats
962  void operator++() { stat.data(index)->inc(1); }
967  void operator--() { stat.data(index)->dec(1); }
968 
970  void operator++(int) { ++*this; }
972  void operator--(int) { --*this; }
973 
979  template <typename U>
980  void
981  operator=(const U &v)
982  {
983  stat.data(index)->set(v);
984  }
985 
991  template <typename U>
992  void
993  operator+=(const U &v)
994  {
995  stat.data(index)->inc(v);
996  }
997 
1003  template <typename U>
1004  void
1005  operator-=(const U &v)
1006  {
1007  stat.data(index)->dec(v);
1008  }
1009 
1014  size_type size() const { return 1; }
1015 
1016  public:
1017  std::string
1018  str() const
1019  {
1020  return csprintf("%s[%d]", stat.info()->name, index);
1021  }
1022 };
1023 
1028 template <class Derived, class Stor>
1029 class VectorBase : public DataWrapVec<Derived, VectorInfoProxy>
1030 {
1031  public:
1032  typedef Stor Storage;
1033  typedef typename Stor::Params Params;
1034 
1037  friend class ScalarProxy<Derived>;
1038  friend class DataWrapVec<Derived, VectorInfoProxy>;
1039 
1040  protected:
1042  Storage *storage;
1044 
1045  protected:
1051  Storage *data(off_type index) { return &storage[index]; }
1052 
1058  const Storage *data(off_type index) const { return &storage[index]; }
1059 
1060  void
1062  {
1063  assert(s > 0 && "size must be positive!");
1064  assert(!storage && "already initialized");
1065  _size = s;
1066 
1067  char *ptr = new char[_size * sizeof(Storage)];
1068  storage = reinterpret_cast<Storage *>(ptr);
1069 
1070  for (off_type i = 0; i < _size; ++i)
1071  new (&storage[i]) Storage(this->info());
1072 
1073  this->setInit();
1074  }
1075 
1076  public:
1077  void
1078  value(VCounter &vec) const
1079  {
1080  vec.resize(size());
1081  for (off_type i = 0; i < size(); ++i)
1082  vec[i] = data(i)->value();
1083  }
1084 
1089  void
1090  result(VResult &vec) const
1091  {
1092  vec.resize(size());
1093  for (off_type i = 0; i < size(); ++i)
1094  vec[i] = data(i)->result();
1095  }
1096 
1101  Result
1102  total() const
1103  {
1104  Result total = 0.0;
1105  for (off_type i = 0; i < size(); ++i)
1106  total += data(i)->result();
1107  return total;
1108  }
1109 
1113  size_type size() const { return _size; }
1114 
1115  bool
1116  zero() const
1117  {
1118  for (off_type i = 0; i < size(); ++i)
1119  if (data(i)->zero())
1120  return false;
1121  return true;
1122  }
1123 
1124  bool
1125  check() const
1126  {
1127  return storage != NULL;
1128  }
1129 
1130  public:
1131  VectorBase(Group *parent, const char *name, const char *desc)
1132  : DataWrapVec<Derived, VectorInfoProxy>(parent, name, desc),
1133  storage(nullptr), _size(0)
1134  {}
1135 
1137  {
1138  if (!storage)
1139  return;
1140 
1141  for (off_type i = 0; i < _size; ++i)
1142  data(i)->~Storage();
1143  delete [] reinterpret_cast<char *>(storage);
1144  }
1145 
1151  Derived &
1153  {
1154  Derived &self = this->self();
1155  self.doInit(size);
1156  return self;
1157  }
1158 
1164  Proxy
1166  {
1167  assert (index >= 0 && index < size());
1168  return Proxy(this->self(), index);
1169  }
1170 };
1171 
1172 template <class Stat>
1174 {
1175  private:
1176  Stat &stat;
1179 
1180  private:
1181  mutable VResult vec;
1182 
1183  typename Stat::Storage *
1185  {
1186  assert(index < len);
1187  return stat.data(offset + index);
1188  }
1189 
1190  const typename Stat::Storage *
1192  {
1193  assert(index < len);
1194  return stat.data(offset + index);
1195  }
1196 
1197  public:
1198  const VResult &
1199  result() const
1200  {
1201  vec.resize(size());
1202 
1203  for (off_type i = 0; i < size(); ++i)
1204  vec[i] = data(i)->result();
1205 
1206  return vec;
1207  }
1208 
1209  Result
1210  total() const
1211  {
1212  Result total = 0.0;
1213  for (off_type i = 0; i < size(); ++i)
1214  total += data(i)->result();
1215  return total;
1216  }
1217 
1218  public:
1220  : stat(s), offset(o), len(l)
1221  {
1222  }
1223 
1225  : stat(sp.stat), offset(sp.offset), len(sp.len)
1226  {
1227  }
1228 
1229  const VectorProxy &
1231  {
1232  stat = sp.stat;
1233  offset = sp.offset;
1234  len = sp.len;
1235  return *this;
1236  }
1237 
1240  {
1241  assert (index >= 0 && index < size());
1242  return ScalarProxy<Stat>(stat, offset + index);
1243  }
1244 
1245  size_type size() const { return len; }
1246 };
1247 
1248 template <class Derived, class Stor>
1249 class Vector2dBase : public DataWrapVec2d<Derived, Vector2dInfoProxy>
1250 {
1251  public:
1253  typedef Stor Storage;
1254  typedef typename Stor::Params Params;
1256  friend class ScalarProxy<Derived>;
1257  friend class VectorProxy<Derived>;
1258  friend class DataWrapVec<Derived, Vector2dInfoProxy>;
1259  friend class DataWrapVec2d<Derived, Vector2dInfoProxy>;
1260 
1261  protected:
1265  Storage *storage;
1266 
1267  protected:
1268  Storage *data(off_type index) { return &storage[index]; }
1269  const Storage *data(off_type index) const { return &storage[index]; }
1270 
1271  public:
1272  Vector2dBase(Group *parent, const char *name, const char *desc)
1273  : DataWrapVec2d<Derived, Vector2dInfoProxy>(parent, name, desc),
1274  x(0), y(0), _size(0), storage(nullptr)
1275  {}
1276 
1278  {
1279  if (!storage)
1280  return;
1281 
1282  for (off_type i = 0; i < _size; ++i)
1283  data(i)->~Storage();
1284  delete [] reinterpret_cast<char *>(storage);
1285  }
1286 
1287  Derived &
1289  {
1290  assert(_x > 0 && _y > 0 && "sizes must be positive!");
1291  assert(!storage && "already initialized");
1292 
1293  Derived &self = this->self();
1294  Info *info = this->info();
1295 
1296  x = _x;
1297  y = _y;
1298  info->x = _x;
1299  info->y = _y;
1300  _size = x * y;
1301 
1302  char *ptr = new char[_size * sizeof(Storage)];
1303  storage = reinterpret_cast<Storage *>(ptr);
1304 
1305  for (off_type i = 0; i < _size; ++i)
1306  new (&storage[i]) Storage(info);
1307 
1308  this->setInit();
1309 
1310  return self;
1311  }
1312 
1313  Proxy
1315  {
1316  off_type offset = index * y;
1317  assert (index >= 0 && offset + y <= size());
1318  return Proxy(this->self(), offset, y);
1319  }
1320 
1321 
1322  size_type
1323  size() const
1324  {
1325  return _size;
1326  }
1327 
1328  bool
1329  zero() const
1330  {
1331  return data(0)->zero();
1332  }
1333 
1338  Result
1339  total() const
1340  {
1341  Result total = 0.0;
1342  for (off_type i = 0; i < size(); ++i)
1343  total += data(i)->result();
1344  return total;
1345  }
1346 
1347  void
1349  {
1350  Info *info = this->info();
1351  size_type size = this->size();
1352 
1353  for (off_type i = 0; i < size; ++i)
1354  data(i)->prepare(info);
1355 
1356  info->cvec.resize(size);
1357  for (off_type i = 0; i < size; ++i)
1358  info->cvec[i] = data(i)->value();
1359  }
1360 
1364  void
1366  {
1367  Info *info = this->info();
1368  size_type size = this->size();
1369  for (off_type i = 0; i < size; ++i)
1370  data(i)->reset(info);
1371  }
1372 
1373  bool
1374  check() const
1375  {
1376  return storage != NULL;
1377  }
1378 };
1379 
1381 //
1382 // Non formula statistics
1383 //
1385 
1386 struct DistParams : public StorageParams
1387 {
1389  DistParams(DistType t) : type(t) {}
1390 };
1391 
1396 {
1397  public:
1399  struct Params : public DistParams
1400  {
1409 
1410  Params() : DistParams(Dist), min(0), max(0), bucket_size(0),
1411  buckets(0) {}
1412  };
1413 
1414  private:
1421 
1438 
1439  public:
1441  : cvec(safe_cast<const Params *>(info->storageParams)->buckets)
1442  {
1443  reset(info);
1444  }
1445 
1451  void
1452  sample(Counter val, int number)
1453  {
1454  if (val < min_track)
1455  underflow += number;
1456  else if (val > max_track)
1457  overflow += number;
1458  else {
1459  size_type index =
1460  (size_type)std::floor((val - min_track) / bucket_size);
1461  assert(index < size());
1462  cvec[index] += number;
1463  }
1464 
1465  if (val < min_val)
1466  min_val = val;
1467 
1468  if (val > max_val)
1469  max_val = val;
1470 
1471  sum += val * number;
1472  squares += val * val * number;
1473  samples += number;
1474  }
1475 
1480  size_type size() const { return cvec.size(); }
1481 
1486  bool
1487  zero() const
1488  {
1489  return samples == Counter();
1490  }
1491 
1492  void
1494  {
1495  const Params *params = safe_cast<const Params *>(info->storageParams);
1496 
1497  assert(params->type == Dist);
1498  data.type = params->type;
1499  data.min = params->min;
1500  data.max = params->max;
1501  data.bucket_size = params->bucket_size;
1502 
1503  data.min_val = (min_val == CounterLimits::max()) ? 0 : min_val;
1504  data.max_val = (max_val == CounterLimits::min()) ? 0 : max_val;
1505  data.underflow = underflow;
1506  data.overflow = overflow;
1507 
1508  data.cvec.resize(params->buckets);
1509  for (off_type i = 0; i < params->buckets; ++i)
1510  data.cvec[i] = cvec[i];
1511 
1512  data.sum = sum;
1513  data.squares = squares;
1514  data.samples = samples;
1515  }
1516 
1520  void
1521  reset(Info *info)
1522  {
1523  const Params *params = safe_cast<const Params *>(info->storageParams);
1524  min_track = params->min;
1525  max_track = params->max;
1526  bucket_size = params->bucket_size;
1527 
1528  min_val = CounterLimits::max();
1529  max_val = CounterLimits::min();
1530  underflow = Counter();
1531  overflow = Counter();
1532 
1533  size_type size = cvec.size();
1534  for (off_type i = 0; i < size; ++i)
1535  cvec[i] = Counter();
1536 
1537  sum = Counter();
1538  squares = Counter();
1539  samples = Counter();
1540  }
1541 };
1542 
1547 {
1548  public:
1550  struct Params : public DistParams
1551  {
1554 
1555  Params() : DistParams(Hist), buckets(0) {}
1556  };
1557 
1558  private:
1565 
1576 
1577  public:
1579  : cvec(safe_cast<const Params *>(info->storageParams)->buckets)
1580  {
1581  reset(info);
1582  }
1583 
1584  void grow_up();
1585  void grow_out();
1586  void grow_convert();
1587  void add(HistStor *);
1588 
1594  void
1595  sample(Counter val, int number)
1596  {
1597  assert(min_bucket < max_bucket);
1598  if (val < min_bucket) {
1599  if (min_bucket == 0)
1600  grow_convert();
1601 
1602  while (val < min_bucket)
1603  grow_out();
1604  } else if (val >= max_bucket + bucket_size) {
1605  if (min_bucket == 0) {
1606  while (val >= max_bucket + bucket_size)
1607  grow_up();
1608  } else {
1609  while (val >= max_bucket + bucket_size)
1610  grow_out();
1611  }
1612  }
1613 
1614  size_type index =
1615  (int64_t)std::floor((val - min_bucket) / bucket_size);
1616 
1617  assert(index < size());
1618  cvec[index] += number;
1619 
1620  sum += val * number;
1621  squares += val * val * number;
1622  logs += log(val) * number;
1623  samples += number;
1624  }
1625 
1630  size_type size() const { return cvec.size(); }
1631 
1636  bool
1637  zero() const
1638  {
1639  return samples == Counter();
1640  }
1641 
1642  void
1644  {
1645  const Params *params = safe_cast<const Params *>(info->storageParams);
1646 
1647  assert(params->type == Hist);
1648  data.type = params->type;
1649  data.min = min_bucket;
1650  data.max = max_bucket + bucket_size - 1;
1651  data.bucket_size = bucket_size;
1652 
1653  data.min_val = min_bucket;
1654  data.max_val = max_bucket;
1655 
1656  int buckets = params->buckets;
1657  data.cvec.resize(buckets);
1658  for (off_type i = 0; i < buckets; ++i)
1659  data.cvec[i] = cvec[i];
1660 
1661  data.sum = sum;
1662  data.logs = logs;
1663  data.squares = squares;
1664  data.samples = samples;
1665  }
1666 
1670  void
1671  reset(Info *info)
1672  {
1673  const Params *params = safe_cast<const Params *>(info->storageParams);
1674  min_bucket = 0;
1675  max_bucket = params->buckets - 1;
1676  bucket_size = 1;
1677 
1678  size_type size = cvec.size();
1679  for (off_type i = 0; i < size; ++i)
1680  cvec[i] = Counter();
1681 
1682  sum = Counter();
1683  squares = Counter();
1684  samples = Counter();
1685  logs = Counter();
1686  }
1687 };
1688 
1694 {
1695  public:
1696  struct Params : public DistParams
1697  {
1699  };
1700 
1701  private:
1708 
1709  public:
1714  : sum(Counter()), squares(Counter()), samples(Counter())
1715  { }
1716 
1724  void
1725  sample(Counter val, int number)
1726  {
1727  sum += val * number;
1728  squares += val * val * number;
1729  samples += number;
1730  }
1731 
1736  size_type size() const { return 1; }
1737 
1742  bool zero() const { return samples == Counter(); }
1743 
1744  void
1746  {
1747  const Params *params = safe_cast<const Params *>(info->storageParams);
1748 
1749  assert(params->type == Deviation);
1750  data.type = params->type;
1751  data.sum = sum;
1752  data.squares = squares;
1753  data.samples = samples;
1754  }
1755 
1759  void
1760  reset(Info *info)
1761  {
1762  sum = Counter();
1763  squares = Counter();
1764  samples = Counter();
1765  }
1766 };
1767 
1773 {
1774  public:
1775  struct Params : public DistParams
1776  {
1778  };
1779 
1780  private:
1785 
1786  public:
1791  : sum(Counter()), squares(Counter())
1792  {}
1793 
1800  void
1801  sample(Counter val, int number)
1802  {
1803  sum += val * number;
1804  squares += val * val * number;
1805  }
1806 
1811  size_type size() const { return 1; }
1812 
1817  bool zero() const { return sum == Counter(); }
1818 
1819  void
1821  {
1822  const Params *params = safe_cast<const Params *>(info->storageParams);
1823 
1824  assert(params->type == Deviation);
1825  data.type = params->type;
1826  data.sum = sum;
1827  data.squares = squares;
1828  data.samples = curTick();
1829  }
1830 
1834  void
1835  reset(Info *info)
1836  {
1837  sum = Counter();
1838  squares = Counter();
1839  }
1840 };
1841 
1846 template <class Derived, class Stor>
1847 class DistBase : public DataWrap<Derived, DistInfoProxy>
1848 {
1849  public:
1851  typedef Stor Storage;
1852  typedef typename Stor::Params Params;
1853 
1854  protected:
1856  char storage[sizeof(Storage)] __attribute__ ((aligned (8)));
1857 
1858  protected:
1863  Storage *
1865  {
1866  return reinterpret_cast<Storage *>(storage);
1867  }
1868 
1873  const Storage *
1874  data() const
1875  {
1876  return reinterpret_cast<const Storage *>(storage);
1877  }
1878 
1879  void
1881  {
1882  new (storage) Storage(this->info());
1883  this->setInit();
1884  }
1885 
1886  public:
1887  DistBase(Group *parent, const char *name, const char *desc)
1888  : DataWrap<Derived, DistInfoProxy>(parent, name, desc)
1889  {
1890  }
1891 
1898  template <typename U>
1899  void sample(const U &v, int n = 1) { data()->sample(v, n); }
1900 
1905  size_type size() const { return data()->size(); }
1910  bool zero() const { return data()->zero(); }
1911 
1912  void
1914  {
1915  Info *info = this->info();
1916  data()->prepare(info, info->data);
1917  }
1918 
1922  void
1924  {
1925  data()->reset(this->info());
1926  }
1927 
1931  void add(DistBase &d) { data()->add(d.data()); }
1932 
1933 };
1934 
1935 template <class Stat>
1937 
1938 template <class Derived, class Stor>
1939 class VectorDistBase : public DataWrapVec<Derived, VectorDistInfoProxy>
1940 {
1941  public:
1943  typedef Stor Storage;
1944  typedef typename Stor::Params Params;
1946  friend class DistProxy<Derived>;
1947  friend class DataWrapVec<Derived, VectorDistInfoProxy>;
1948 
1949  protected:
1950  Storage *storage;
1952 
1953  protected:
1954  Storage *
1956  {
1957  return &storage[index];
1958  }
1959 
1960  const Storage *
1962  {
1963  return &storage[index];
1964  }
1965 
1966  void
1968  {
1969  assert(s > 0 && "size must be positive!");
1970  assert(!storage && "already initialized");
1971  _size = s;
1972 
1973  char *ptr = new char[_size * sizeof(Storage)];
1974  storage = reinterpret_cast<Storage *>(ptr);
1975 
1976  Info *info = this->info();
1977  for (off_type i = 0; i < _size; ++i)
1978  new (&storage[i]) Storage(info);
1979 
1980  this->setInit();
1981  }
1982 
1983  public:
1984  VectorDistBase(Group *parent, const char *name, const char *desc)
1985  : DataWrapVec<Derived, VectorDistInfoProxy>(parent, name, desc),
1986  storage(NULL)
1987  {}
1988 
1990  {
1991  if (!storage)
1992  return ;
1993 
1994  for (off_type i = 0; i < _size; ++i)
1995  data(i)->~Storage();
1996  delete [] reinterpret_cast<char *>(storage);
1997  }
1998 
2000  {
2001  assert(index >= 0 && index < size());
2002  return Proxy(this->self(), index);
2003  }
2004 
2005  size_type
2006  size() const
2007  {
2008  return _size;
2009  }
2010 
2011  bool
2012  zero() const
2013  {
2014  for (off_type i = 0; i < size(); ++i)
2015  if (!data(i)->zero())
2016  return false;
2017  return true;
2018  }
2019 
2020  void
2022  {
2023  Info *info = this->info();
2024  size_type size = this->size();
2025  info->data.resize(size);
2026  for (off_type i = 0; i < size; ++i)
2027  data(i)->prepare(info, info->data[i]);
2028  }
2029 
2030  bool
2031  check() const
2032  {
2033  return storage != NULL;
2034  }
2035 };
2036 
2037 template <class Stat>
2038 class DistProxy
2039 {
2040  private:
2041  Stat &stat;
2043 
2044  protected:
2045  typename Stat::Storage *data() { return stat.data(index); }
2046  const typename Stat::Storage *data() const { return stat.data(index); }
2047 
2048  public:
2050  : stat(s), index(i)
2051  {}
2052 
2054  : stat(sp.stat), index(sp.index)
2055  {}
2056 
2057  const DistProxy &
2059  {
2060  stat = sp.stat;
2061  index = sp.index;
2062  return *this;
2063  }
2064 
2065  public:
2066  template <typename U>
2067  void
2068  sample(const U &v, int n = 1)
2069  {
2070  data()->sample(v, n);
2071  }
2072 
2073  size_type
2074  size() const
2075  {
2076  return 1;
2077  }
2078 
2079  bool
2080  zero() const
2081  {
2082  return data()->zero();
2083  }
2084 
2088  void reset() { }
2089 };
2090 
2092 //
2093 // Formula Details
2094 //
2096 
2101 class Node
2102 {
2103  public:
2108  virtual size_type size() const = 0;
2113  virtual const VResult &result() const = 0;
2118  virtual Result total() const = 0;
2119 
2123  virtual std::string str() const = 0;
2124 
2125  virtual ~Node() {};
2126 };
2127 
2129 typedef std::shared_ptr<Node> NodePtr;
2130 
2131 class ScalarStatNode : public Node
2132 {
2133  private:
2135  mutable VResult vresult;
2136 
2137  public:
2138  ScalarStatNode(const ScalarInfo *d) : data(d), vresult(1) {}
2139 
2140  const VResult &
2141  result() const
2142  {
2143  vresult[0] = data->result();
2144  return vresult;
2145  }
2146 
2147  Result total() const { return data->result(); };
2148 
2149  size_type size() const { return 1; }
2150 
2154  std::string str() const { return data->name; }
2155 };
2156 
2157 template <class Stat>
2158 class ScalarProxyNode : public Node
2159 {
2160  private:
2162  mutable VResult vresult;
2163 
2164  public:
2166  : proxy(p), vresult(1)
2167  { }
2168 
2169  const VResult &
2170  result() const
2171  {
2172  vresult[0] = proxy.result();
2173  return vresult;
2174  }
2175 
2176  Result
2177  total() const
2178  {
2179  return proxy.result();
2180  }
2181 
2182  size_type
2183  size() const
2184  {
2185  return 1;
2186  }
2187 
2191  std::string
2192  str() const
2193  {
2194  return proxy.str();
2195  }
2196 };
2197 
2198 class VectorStatNode : public Node
2199 {
2200  private:
2202 
2203  public:
2204  VectorStatNode(const VectorInfo *d) : data(d) { }
2205  const VResult &result() const { return data->result(); }
2206  Result total() const { return data->total(); };
2207 
2208  size_type size() const { return data->size(); }
2209 
2210  std::string str() const { return data->name; }
2211 };
2212 
2213 template <class T>
2214 class ConstNode : public Node
2215 {
2216  private:
2218 
2219  public:
2220  ConstNode(T s) : vresult(1, (Result)s) {}
2221  const VResult &result() const { return vresult; }
2222  Result total() const { return vresult[0]; };
2223  size_type size() const { return 1; }
2224  std::string str() const { return std::to_string(vresult[0]); }
2225 };
2226 
2227 template <class T>
2228 class ConstVectorNode : public Node
2229 {
2230  private:
2232 
2233  public:
2234  ConstVectorNode(const T &s) : vresult(s.begin(), s.end()) {}
2235  const VResult &result() const { return vresult; }
2236 
2237  Result
2238  total() const
2239  {
2240  size_type size = this->size();
2241  Result tmp = 0;
2242  for (off_type i = 0; i < size; i++)
2243  tmp += vresult[i];
2244  return tmp;
2245  }
2246 
2247  size_type size() const { return vresult.size(); }
2248  std::string
2249  str() const
2250  {
2251  size_type size = this->size();
2252  std::string tmp = "(";
2253  for (off_type i = 0; i < size; i++)
2254  tmp += csprintf("%s ", std::to_string(vresult[i]));
2255  tmp += ")";
2256  return tmp;
2257  }
2258 };
2259 
2260 template <class Op>
2261 struct OpString;
2262 
2263 template<>
2264 struct OpString<std::plus<Result> >
2265 {
2266  static std::string str() { return "+"; }
2267 };
2268 
2269 template<>
2270 struct OpString<std::minus<Result> >
2271 {
2272  static std::string str() { return "-"; }
2273 };
2274 
2275 template<>
2276 struct OpString<std::multiplies<Result> >
2277 {
2278  static std::string str() { return "*"; }
2279 };
2280 
2281 template<>
2282 struct OpString<std::divides<Result> >
2283 {
2284  static std::string str() { return "/"; }
2285 };
2286 
2287 template<>
2288 struct OpString<std::modulus<Result> >
2289 {
2290  static std::string str() { return "%"; }
2291 };
2292 
2293 template<>
2294 struct OpString<std::negate<Result> >
2295 {
2296  static std::string str() { return "-"; }
2297 };
2298 
2299 template <class Op>
2300 class UnaryNode : public Node
2301 {
2302  public:
2303  NodePtr l;
2304  mutable VResult vresult;
2305 
2306  public:
2307  UnaryNode(NodePtr &p) : l(p) {}
2308 
2309  const VResult &
2310  result() const
2311  {
2312  const VResult &lvec = l->result();
2313  size_type size = lvec.size();
2314 
2315  assert(size > 0);
2316 
2317  vresult.resize(size);
2318  Op op;
2319  for (off_type i = 0; i < size; ++i)
2320  vresult[i] = op(lvec[i]);
2321 
2322  return vresult;
2323  }
2324 
2325  Result
2326  total() const
2327  {
2328  const VResult &vec = this->result();
2329  Result total = 0.0;
2330  for (off_type i = 0; i < size(); i++)
2331  total += vec[i];
2332  return total;
2333  }
2334 
2335  size_type size() const { return l->size(); }
2336 
2337  std::string
2338  str() const
2339  {
2340  return OpString<Op>::str() + l->str();
2341  }
2342 };
2343 
2344 template <class Op>
2345 class BinaryNode : public Node
2346 {
2347  public:
2348  NodePtr l;
2349  NodePtr r;
2350  mutable VResult vresult;
2351 
2352  public:
2353  BinaryNode(NodePtr &a, NodePtr &b) : l(a), r(b) {}
2354 
2355  const VResult &
2356  result() const override
2357  {
2358  Op op;
2359  const VResult &lvec = l->result();
2360  const VResult &rvec = r->result();
2361 
2362  assert(lvec.size() > 0 && rvec.size() > 0);
2363 
2364  if (lvec.size() == 1 && rvec.size() == 1) {
2365  vresult.resize(1);
2366  vresult[0] = op(lvec[0], rvec[0]);
2367  } else if (lvec.size() == 1) {
2368  size_type size = rvec.size();
2369  vresult.resize(size);
2370  for (off_type i = 0; i < size; ++i)
2371  vresult[i] = op(lvec[0], rvec[i]);
2372  } else if (rvec.size() == 1) {
2373  size_type size = lvec.size();
2374  vresult.resize(size);
2375  for (off_type i = 0; i < size; ++i)
2376  vresult[i] = op(lvec[i], rvec[0]);
2377  } else if (rvec.size() == lvec.size()) {
2378  size_type size = rvec.size();
2379  vresult.resize(size);
2380  for (off_type i = 0; i < size; ++i)
2381  vresult[i] = op(lvec[i], rvec[i]);
2382  }
2383 
2384  return vresult;
2385  }
2386 
2387  Result
2388  total() const override
2389  {
2390  const VResult &vec = this->result();
2391  const VResult &lvec = l->result();
2392  const VResult &rvec = r->result();
2393  Result total = 0.0;
2394  Result lsum = 0.0;
2395  Result rsum = 0.0;
2396  Op op;
2397 
2398  assert(lvec.size() > 0 && rvec.size() > 0);
2399  assert(lvec.size() == rvec.size() ||
2400  lvec.size() == 1 || rvec.size() == 1);
2401 
2403  if (lvec.size() == rvec.size() && lvec.size() > 1) {
2404  for (off_type i = 0; i < size(); ++i) {
2405  lsum += lvec[i];
2406  rsum += rvec[i];
2407  }
2408  return op(lsum, rsum);
2409  }
2410 
2412  for (off_type i = 0; i < size(); ++i) {
2413  total += vec[i];
2414  }
2415 
2416  return total;
2417  }
2418 
2419  size_type
2420  size() const override
2421  {
2422  size_type ls = l->size();
2423  size_type rs = r->size();
2424  if (ls == 1) {
2425  return rs;
2426  } else if (rs == 1) {
2427  return ls;
2428  } else {
2429  assert(ls == rs && "Node vector sizes are not equal");
2430  return ls;
2431  }
2432  }
2433 
2434  std::string
2435  str() const override
2436  {
2437  return csprintf("(%s %s %s)", l->str(), OpString<Op>::str(), r->str());
2438  }
2439 };
2440 
2441 template <class Op>
2442 class SumNode : public Node
2443 {
2444  public:
2445  NodePtr l;
2446  mutable VResult vresult;
2447 
2448  public:
2449  SumNode(NodePtr &p) : l(p), vresult(1) {}
2450 
2451  const VResult &
2452  result() const
2453  {
2454  const VResult &lvec = l->result();
2455  size_type size = lvec.size();
2456  assert(size > 0);
2457 
2458  vresult[0] = 0.0;
2459 
2460  Op op;
2461  for (off_type i = 0; i < size; ++i)
2462  vresult[0] = op(vresult[0], lvec[i]);
2463 
2464  return vresult;
2465  }
2466 
2467  Result
2468  total() const
2469  {
2470  const VResult &lvec = l->result();
2471  size_type size = lvec.size();
2472  assert(size > 0);
2473 
2474  Result result = 0.0;
2475 
2476  Op op;
2477  for (off_type i = 0; i < size; ++i)
2478  result = op(result, lvec[i]);
2479 
2480  return result;
2481  }
2482 
2483  size_type size() const { return 1; }
2484 
2485  std::string
2486  str() const
2487  {
2488  return csprintf("total(%s)", l->str());
2489  }
2490 };
2491 
2492 
2494 //
2495 // Visible Statistics Types
2496 //
2498 
2508 class Scalar : public ScalarBase<Scalar, StatStor>
2509 {
2510  public:
2512 
2513  Scalar(Group *parent = nullptr, const char *name = nullptr,
2514  const char *desc = nullptr)
2515  : ScalarBase<Scalar, StatStor>(parent, name, desc)
2516  {
2517  }
2518 };
2519 
2524 class Average : public ScalarBase<Average, AvgStor>
2525 {
2526  public:
2528 
2529  Average(Group *parent = nullptr, const char *name = nullptr,
2530  const char *desc = nullptr)
2531  : ScalarBase<Average, AvgStor>(parent, name, desc)
2532  {
2533  }
2534 };
2535 
2536 class Value : public ValueBase<Value>
2537 {
2538  public:
2539  Value(Group *parent = nullptr, const char *name = nullptr,
2540  const char *desc = nullptr)
2541  : ValueBase<Value>(parent, name, desc)
2542  {
2543  }
2544 };
2545 
2550 class Vector : public VectorBase<Vector, StatStor>
2551 {
2552  public:
2553  Vector(Group *parent = nullptr, const char *name = nullptr,
2554  const char *desc = nullptr)
2555  : VectorBase<Vector, StatStor>(parent, name, desc)
2556  {
2557  }
2558 };
2559 
2564 class AverageVector : public VectorBase<AverageVector, AvgStor>
2565 {
2566  public:
2567  AverageVector(Group *parent = nullptr, const char *name = nullptr,
2568  const char *desc = nullptr)
2569  : VectorBase<AverageVector, AvgStor>(parent, name, desc)
2570  {
2571  }
2572 };
2573 
2578 class Vector2d : public Vector2dBase<Vector2d, StatStor>
2579 {
2580  public:
2581  Vector2d(Group *parent = nullptr, const char *name = nullptr,
2582  const char *desc = nullptr)
2583  : Vector2dBase<Vector2d, StatStor>(parent, name, desc)
2584  {
2585  }
2586 };
2587 
2592 class Distribution : public DistBase<Distribution, DistStor>
2593 {
2594  public:
2595  Distribution(Group *parent = nullptr, const char *name = nullptr,
2596  const char *desc = nullptr)
2597  : DistBase<Distribution, DistStor>(parent, name, desc)
2598  {
2599  }
2600 
2608  Distribution &
2609  init(Counter min, Counter max, Counter bkt)
2610  {
2611  DistStor::Params *params = new DistStor::Params;
2612  params->min = min;
2613  params->max = max;
2614  params->bucket_size = bkt;
2615  // Division by zero is especially serious in an Aarch64 host,
2616  // where it gets rounded to allocate 32GiB RAM.
2617  assert(bkt > 0);
2618  params->buckets = (size_type)ceil((max - min + 1.0) / bkt);
2619  this->setParams(params);
2620  this->doInit();
2621  return this->self();
2622  }
2623 };
2624 
2629 class Histogram : public DistBase<Histogram, HistStor>
2630 {
2631  public:
2632  Histogram(Group *parent = nullptr, const char *name = nullptr,
2633  const char *desc = nullptr)
2634  : DistBase<Histogram, HistStor>(parent, name, desc)
2635  {
2636  }
2637 
2643  Histogram &
2645  {
2646  HistStor::Params *params = new HistStor::Params;
2647  params->buckets = size;
2648  this->setParams(params);
2649  this->doInit();
2650  return this->self();
2651  }
2652 };
2653 
2658 class StandardDeviation : public DistBase<StandardDeviation, SampleStor>
2659 {
2660  public:
2664  StandardDeviation(Group *parent = nullptr, const char *name = nullptr,
2665  const char *desc = nullptr)
2666  : DistBase<StandardDeviation, SampleStor>(parent, name, desc)
2667  {
2668  SampleStor::Params *params = new SampleStor::Params;
2669  this->doInit();
2670  this->setParams(params);
2671  }
2672 };
2673 
2678 class AverageDeviation : public DistBase<AverageDeviation, AvgSampleStor>
2679 {
2680  public:
2684  AverageDeviation(Group *parent = nullptr, const char *name = nullptr,
2685  const char *desc = nullptr)
2686  : DistBase<AverageDeviation, AvgSampleStor>(parent, name, desc)
2687  {
2689  this->doInit();
2690  this->setParams(params);
2691  }
2692 };
2693 
2698 class VectorDistribution : public VectorDistBase<VectorDistribution, DistStor>
2699 {
2700  public:
2701  VectorDistribution(Group *parent = nullptr, const char *name = nullptr,
2702  const char *desc = nullptr)
2703  : VectorDistBase<VectorDistribution, DistStor>(parent, name, desc)
2704  {
2705  }
2706 
2716  init(size_type size, Counter min, Counter max, Counter bkt)
2717  {
2718  DistStor::Params *params = new DistStor::Params;
2719  params->min = min;
2720  params->max = max;
2721  params->bucket_size = bkt;
2722  params->buckets = (size_type)ceil((max - min + 1.0) / bkt);
2723  this->setParams(params);
2724  this->doInit(size);
2725  return this->self();
2726  }
2727 };
2728 
2734  : public VectorDistBase<VectorStandardDeviation, SampleStor>
2735 {
2736  public:
2737  VectorStandardDeviation(Group *parent = nullptr, const char *name = nullptr,
2738  const char *desc = nullptr)
2740  desc)
2741  {
2742  }
2743 
2751  {
2752  SampleStor::Params *params = new SampleStor::Params;
2753  this->doInit(size);
2754  this->setParams(params);
2755  return this->self();
2756  }
2757 };
2758 
2764  : public VectorDistBase<VectorAverageDeviation, AvgSampleStor>
2765 {
2766  public:
2767  VectorAverageDeviation(Group *parent = nullptr, const char *name = nullptr,
2768  const char *desc = nullptr)
2770  desc)
2771  {
2772  }
2773 
2781  {
2783  this->doInit(size);
2784  this->setParams(params);
2785  return this->self();
2786  }
2787 };
2788 
2789 template <class Stat>
2790 class FormulaInfoProxy : public InfoProxy<Stat, FormulaInfo>
2791 {
2792  protected:
2793  mutable VResult vec;
2794  mutable VCounter cvec;
2795 
2796  public:
2797  FormulaInfoProxy(Stat &stat) : InfoProxy<Stat, FormulaInfo>(stat) {}
2798 
2799  size_type size() const { return this->s.size(); }
2800 
2801  const VResult &
2802  result() const
2803  {
2804  this->s.result(vec);
2805  return vec;
2806  }
2807  Result total() const { return this->s.total(); }
2808  VCounter &value() const { return cvec; }
2809 
2810  std::string str() const { return this->s.str(); }
2811 };
2812 
2813 template <class Stat>
2814 class SparseHistInfoProxy : public InfoProxy<Stat, SparseHistInfo>
2815 {
2816  public:
2817  SparseHistInfoProxy(Stat &stat) : InfoProxy<Stat, SparseHistInfo>(stat) {}
2818 };
2819 
2824 template <class Derived, class Stor>
2825 class SparseHistBase : public DataWrap<Derived, SparseHistInfoProxy>
2826 {
2827  public:
2829  typedef Stor Storage;
2830  typedef typename Stor::Params Params;
2831 
2832  protected:
2834  char storage[sizeof(Storage)];
2835 
2836  protected:
2841  Storage *
2843  {
2844  return reinterpret_cast<Storage *>(storage);
2845  }
2846 
2851  const Storage *
2852  data() const
2853  {
2854  return reinterpret_cast<const Storage *>(storage);
2855  }
2856 
2857  void
2859  {
2860  new (storage) Storage(this->info());
2861  this->setInit();
2862  }
2863 
2864  public:
2865  SparseHistBase(Group *parent, const char *name, const char *desc)
2866  : DataWrap<Derived, SparseHistInfoProxy>(parent, name, desc)
2867  {
2868  }
2869 
2876  template <typename U>
2877  void sample(const U &v, int n = 1) { data()->sample(v, n); }
2878 
2883  size_type size() const { return data()->size(); }
2888  bool zero() const { return data()->zero(); }
2889 
2890  void
2892  {
2893  Info *info = this->info();
2894  data()->prepare(info, info->data);
2895  }
2896 
2900  void
2902  {
2903  data()->reset(this->info());
2904  }
2905 };
2906 
2911 {
2912  public:
2914  struct Params : public DistParams
2915  {
2917  };
2918 
2919  private:
2924 
2925  public:
2926  SparseHistStor(Info *info)
2927  {
2928  reset(info);
2929  }
2930 
2936  void
2937  sample(Counter val, int number)
2938  {
2939  cmap[val] += number;
2940  samples += number;
2941  }
2942 
2947  size_type size() const { return cmap.size(); }
2948 
2953  bool
2954  zero() const
2955  {
2956  return samples == Counter();
2957  }
2958 
2959  void
2961  {
2962  MCounter::iterator it;
2963  data.cmap.clear();
2964  for (it = cmap.begin(); it != cmap.end(); it++) {
2965  data.cmap[(*it).first] = (*it).second;
2966  }
2967 
2968  data.samples = samples;
2969  }
2970 
2974  void
2975  reset(Info *info)
2976  {
2977  cmap.clear();
2978  samples = 0;
2979  }
2980 };
2981 
2982 class SparseHistogram : public SparseHistBase<SparseHistogram, SparseHistStor>
2983 {
2984  public:
2985  SparseHistogram(Group *parent = nullptr, const char *name = nullptr,
2986  const char *desc = nullptr)
2988  {
2989  }
2990 
2996  SparseHistogram &
2998  {
3000  this->setParams(params);
3001  this->doInit();
3002  return this->self();
3003  }
3004 };
3005 
3006 class Temp;
3012 class Formula : public DataWrapVec<Formula, FormulaInfoProxy>
3013 {
3014  protected:
3016  NodePtr root;
3017  friend class Temp;
3018 
3019  public:
3023  Formula(Group *parent = nullptr, const char *name = nullptr,
3024  const char *desc = nullptr);
3025 
3026  Formula(Group *parent, const char *name, const char *desc,
3027  const Temp &r);
3028 
3034  const Formula &operator=(const Temp &r);
3035 
3036  template<typename T>
3037  const Formula &operator=(const T &v)
3038  {
3039  *this = Temp(v);
3040  return *this;
3041  }
3042 
3048  const Formula &operator+=(Temp r);
3049 
3055  const Formula &operator/=(Temp r);
3056 
3064  void result(VResult &vec) const;
3065 
3076  Result total() const;
3077 
3081  size_type size() const;
3082 
3083  void prepare() { }
3084 
3088  void reset();
3089 
3093  bool zero() const;
3094 
3095  std::string str() const;
3096 };
3097 
3098 class FormulaNode : public Node
3099 {
3100  private:
3102  mutable VResult vec;
3103 
3104  public:
3105  FormulaNode(const Formula &f) : formula(f) {}
3106 
3107  size_type size() const { return formula.size(); }
3108  const VResult &result() const { formula.result(vec); return vec; }
3109  Result total() const { return formula.total(); }
3110 
3111  std::string str() const { return formula.str(); }
3112 };
3113 
3117 class Temp
3118 {
3119  protected:
3123  NodePtr node;
3124 
3125  public:
3130  Temp(const NodePtr &n) : node(n) { }
3131 
3132  Temp(NodePtr &&n) : node(std::move(n)) { }
3133 
3138  operator NodePtr&() { return node; }
3139 
3143  NodePtr getNodePtr() const { return node; }
3144 
3145  public:
3150  Temp(const Scalar &s)
3151  : node(new ScalarStatNode(s.info()))
3152  { }
3153 
3158  Temp(const Value &s)
3159  : node(new ScalarStatNode(s.info()))
3160  { }
3161 
3166  Temp(const Average &s)
3167  : node(new ScalarStatNode(s.info()))
3168  { }
3169 
3174  Temp(const Vector &s)
3175  : node(new VectorStatNode(s.info()))
3176  { }
3177 
3179  : node(new VectorStatNode(s.info()))
3180  { }
3181 
3185  Temp(const Formula &f)
3186  : node(new FormulaNode(f))
3187  { }
3188 
3193  template <class Stat>
3195  : node(new ScalarProxyNode<Stat>(p))
3196  { }
3197 
3202  Temp(signed char value)
3203  : node(new ConstNode<signed char>(value))
3204  { }
3205 
3210  Temp(unsigned char value)
3211  : node(new ConstNode<unsigned char>(value))
3212  { }
3213 
3218  Temp(signed short value)
3219  : node(new ConstNode<signed short>(value))
3220  { }
3221 
3226  Temp(unsigned short value)
3227  : node(new ConstNode<unsigned short>(value))
3228  { }
3229 
3234  Temp(signed int value)
3235  : node(new ConstNode<signed int>(value))
3236  { }
3237 
3242  Temp(unsigned int value)
3243  : node(new ConstNode<unsigned int>(value))
3244  { }
3245 
3250  Temp(signed long value)
3251  : node(new ConstNode<signed long>(value))
3252  { }
3253 
3258  Temp(unsigned long value)
3259  : node(new ConstNode<unsigned long>(value))
3260  { }
3261 
3266  Temp(signed long long value)
3267  : node(new ConstNode<signed long long>(value))
3268  { }
3269 
3274  Temp(unsigned long long value)
3275  : node(new ConstNode<unsigned long long>(value))
3276  { }
3277 
3282  Temp(float value)
3283  : node(new ConstNode<float>(value))
3284  { }
3285 
3290  Temp(double value)
3291  : node(new ConstNode<double>(value))
3292  { }
3293 };
3294 
3295 
3300 inline Temp
3302 {
3303  return Temp(std::make_shared<BinaryNode<std::plus<Result> > >(l, r));
3304 }
3305 
3306 inline Temp
3308 {
3309  return Temp(std::make_shared<BinaryNode<std::minus<Result> > >(l, r));
3310 }
3311 
3312 inline Temp
3314 {
3315  return Temp(std::make_shared<BinaryNode<std::multiplies<Result> > >(l, r));
3316 }
3317 
3318 inline Temp
3320 {
3321  return Temp(std::make_shared<BinaryNode<std::divides<Result> > >(l, r));
3322 }
3323 
3324 inline Temp
3326 {
3327  return Temp(std::make_shared<UnaryNode<std::negate<Result> > >(l));
3328 }
3329 
3330 template <typename T>
3331 inline Temp
3333 {
3334  return Temp(std::make_shared<ConstNode<T> >(val));
3335 }
3336 
3337 template <typename T>
3338 inline Temp
3340 {
3341  return Temp(std::make_shared<ConstVectorNode<T> >(val));
3342 }
3343 
3344 inline Temp
3346 {
3347  return Temp(std::make_shared<SumNode<std::plus<Result> > >(val));
3348 }
3349 
3351 void dump();
3352 void reset();
3353 void enable();
3354 bool enabled();
3355 
3361 typedef void (*Handler)();
3362 
3363 void registerHandlers(Handler reset_handler, Handler dump_handler);
3364 
3370 
3375 void registerDumpCallback(Callback *cb);
3376 
3380 void processResetQueue();
3381 
3385 void processDumpQueue();
3386 
3388 
3389 typedef std::map<const void *, Info *> MapType;
3390 MapType &statsMap();
3391 
3392 typedef std::map<std::string, Info *> NameMapType;
3393 NameMapType &nameMap();
3394 
3395 bool validateStatName(const std::string &name);
3396 
3397 } // namespace Stats
3398 
3399 void debugDumpStats();
3400 
3401 #endif // __BASE_STATISTICS_HH__
size_type size() const
Definition: statistics.hh:137
ProxyInfo * proxy
Definition: statistics.hh:835
double Result
All results are doubles.
Definition: types.hh:52
Storage * data(off_type index)
Retrieve the storage.
Definition: statistics.hh:1051
std::map< Counter, int > MCounter
map of counters
Definition: types.hh:47
DistProxy(const DistProxy &sp)
Definition: statistics.hh:2053
std::string str() const
Definition: statistics.hh:2249
UnaryNode(NodePtr &p)
Definition: statistics.hh:2307
DistProxy< Derived > Proxy
Definition: statistics.hh:1945
Storage * storage
The storage of this stat.
Definition: statistics.hh:1042
Templatized storage and interface for a sparse histogram stat.
Definition: statistics.hh:2910
DataWrap(Group *parent, const char *name, const char *desc)
Definition: statistics.hh:256
Counter samples
The number of samples.
Definition: statistics.hh:1573
std::string name
The name of the stat.
Definition: info.hh:75
Bitfield< 30, 0 > index
Temp(unsigned long long value)
Create a ConstNode.
Definition: statistics.hh:3274
ScalarBase(Group *parent=nullptr, const char *name=nullptr, const char *desc=nullptr)
Definition: statistics.hh:706
VectorStandardDeviation(Group *parent=nullptr, const char *name=nullptr, const char *desc=nullptr)
Definition: statistics.hh:2737
void sample(const U &v, int n=1)
Definition: statistics.hh:2068
Scalar(Group *parent=nullptr, const char *name=nullptr, const char *desc=nullptr)
Definition: statistics.hh:2513
Derived & method(T *obj, V(T::*method)() const)
Extended functor that calls the specified method of the provided object.
Definition: statistics.hh:873
size_type size() const
Return the number of nodes in the subtree starting at this node.
Definition: statistics.hh:2208
Stor::Params Params
Definition: statistics.hh:661
Derived & init(size_type _x, size_type _y)
Definition: statistics.hh:1288
Bitfield< 28 > v
void processDumpQueue()
Process all the callbacks in the dump callbacks queue.
Definition: statistics.cc:532
Derived & subname(off_type index, const std::string &name)
Set the subfield name for the given index, and marks this stat to print at the end of simulation...
Definition: statistics.hh:379
const VectorProxy & operator=(const VectorProxy &sp)
Definition: statistics.hh:1230
Counter sum
The current sum.
Definition: statistics.hh:1703
Result total() const
Return the total of the result vector.
Definition: statistics.hh:2238
size_type size() const
Return the number of entries in this stat.
Definition: statistics.hh:2883
std::vector< std::string > subdescs
Definition: info.hh:209
bool check() const
Definition: statistics.hh:887
Result total() const
Return the total of the result vector.
Definition: statistics.hh:2206
Generic callback class.
Definition: callback.hh:41
The parameters for a distribution stat.
Definition: statistics.hh:1386
const VResult & result() const
Return the result vector of this subtree.
Definition: statistics.hh:2452
const std::string & name()
Definition: trace.cc:54
void operator++()
Increment the stat by 1.
Definition: statistics.hh:719
Base class for formula statistic node.
Definition: statistics.hh:2101
Counter bucket_size
The number of entries in each bucket.
Definition: statistics.hh:1406
Result total() const
Return the total of the result vector.
Definition: statistics.hh:2177
void reset(Info *info)
Reset stat value to default.
Definition: statistics.hh:1671
Vector2dBase(Group *parent, const char *name, const char *desc)
Definition: statistics.hh:1272
Bitfield< 7 > i
A stat that calculates the per tick average of a value.
Definition: statistics.hh:2524
Result result() const
Definition: statistics.hh:827
MethodProxy(T *obj, MethodPointer meth)
Definition: statistics.hh:825
SampleStor(Info *info)
Create and initialize this storage.
Definition: statistics.hh:1713
std::string str() const
Definition: statistics.hh:2224
std::string str() const
Definition: statistics.hh:3111
Counter min
The minimum value to track.
Definition: statistics.hh:1402
void doInit(size_type s)
Definition: statistics.hh:1061
Counter min_val
The smallest value sampled.
Definition: statistics.hh:1423
NodePtr getNodePtr() const
Makde gcc < 4.6.3 happy and explicitly get the underlying node.
Definition: statistics.hh:3143
VectorProxy(const VectorProxy &sp)
Definition: statistics.hh:1224
Temp(signed int value)
Create a ConstNode.
Definition: statistics.hh:3234
Counter value() const
Definition: statistics.hh:807
Counter current
The current count.
Definition: statistics.hh:563
void operator--(int)
Decrement the stat by 1.
Definition: statistics.hh:972
Temp(const AverageVector &s)
Definition: statistics.hh:3178
std::string str() const override
Definition: statistics.hh:2435
Storage * data(off_type index)
Definition: statistics.hh:1955
ValueBase(Group *parent, const char *name, const char *desc)
Definition: statistics.hh:838
const char * __attribute__((weak)) m5MainCommands[]
Counter max_bucket
The maximum value to track.
Definition: statistics.hh:1562
Temp(unsigned char value)
Create a ConstNode.
Definition: statistics.hh:3210
virtual size_type size() const =0
DataWrapVec(Group *parent=nullptr, const char *name=nullptr, const char *desc=nullptr)
Definition: statistics.hh:363
Result total() const
Return the total of the result vector.
Definition: statistics.hh:2222
Counter overflow
The number of values sampled more than max.
Definition: statistics.hh:1429
void operator+=(const U &v)
Increment the stat by the given value.
Definition: statistics.hh:745
VCounter cvec
Counter for each bucket.
Definition: statistics.hh:1575
const DistType type
Definition: statistics.hh:1388
Bitfield< 8 > a
InfoProxyType< Derived > Info
Definition: statistics.hh:231
size_type buckets
The number of buckets.
Definition: statistics.hh:1553
Result total() const
Return the total of the result vector.
Definition: statistics.hh:2326
Proxy operator[](off_type index)
Definition: statistics.hh:1999
void inc(Counter val)
Increment the current count by the provided value, calls set.
Definition: statistics.hh:599
static void overflow(double &c, const scfx_params &params, bool &o_flag)
Definition: sc_fxnum.cc:428
Counter min_val
Definition: info.hh:184
Implementation of a distribution stat.
Definition: statistics.hh:1847
void(* Handler)()
Register reset and dump handlers.
Definition: statistics.hh:3361
VectorInfoProxy(Stat &stat)
Definition: statistics.hh:135
std::string str() const
Definition: statistics.hh:2486
void operator--()
Decrement the stat by 1.
Definition: statistics.hh:724
VectorAverageDeviation & init(size_type size)
Initialize storage for this distribution.
Definition: statistics.hh:2780
virtual Result total() const =0
Result total() const
Return a total of all entries in this vector.
Definition: statistics.hh:1102
DistType type
Definition: info.hh:179
DistBase(Group *parent, const char *name, const char *desc)
Definition: statistics.hh:1887
void prepare(Info *info, DistData &data)
Definition: statistics.hh:1820
Temp operator/(Temp l, Temp r)
Definition: statistics.hh:3319
ScalarProxy< Derived > Proxy
Proxy type.
Definition: statistics.hh:1036
Bitfield< 0 > sp
std::string ysubname(off_type i) const
Definition: statistics.hh:478
size_type size() const
Return the number of buckets in this distribution.
Definition: statistics.hh:1480
Counter samples
Counter for number of samples.
Definition: statistics.hh:2921
const VResult & result() const
Return the result vector of this subtree.
Definition: statistics.hh:2235
Counter value() const
Definition: statistics.hh:826
Result total() const
Definition: statistics.hh:153
const Storage * data() const
Retrieve a const pointer to the storage.
Definition: statistics.hh:1874
std::string str() const
Definition: statistics.hh:885
Result total
The total count for all tick.
Definition: statistics.hh:567
Counter min_track
The minimum value to track.
Definition: statistics.hh:1416
Result result() const
Definition: statistics.hh:808
Templatized storage and interface for a simple scalar stat.
Definition: statistics.hh:494
Derived & subdesc(off_type index, const std::string &desc)
Set the subfield description for the given index and marks this stat to print at the end of simulatio...
Definition: statistics.hh:403
void value(VCounter &vec) const
Definition: statistics.hh:1078
A vector of scalar stats.
Definition: statistics.hh:2550
Bitfield< 23, 0 > offset
Definition: types.hh:154
Value(Group *parent=nullptr, const char *name=nullptr, const char *desc=nullptr)
Definition: statistics.hh:2539
Histogram & init(size_type size)
Set the parameters of this histogram.
Definition: statistics.hh:2644
MethodPointer method
Definition: statistics.hh:822
Overload hash function for BasicBlockRange type.
Definition: vec_reg.hh:586
size_type buckets
The number of buckets.
Definition: statistics.hh:1408
VectorDistribution & init(size_type size, Counter min, Counter max, Counter bkt)
Initialize storage and parameters for this distribution.
Definition: statistics.hh:2716
size_type size() const
Return the number of nodes in the subtree starting at this node.
Definition: statistics.hh:2483
list< Info * > & statsList()
Definition: statistics.cc:68
A vector of distributions.
Definition: statistics.hh:2698
size_type size() const
Return the number of entries, in this case 1.
Definition: statistics.hh:1811
Counter squares
Current sum of squares.
Definition: statistics.hh:1784
size_type size() const
Definition: statistics.hh:777
MCounter cmap
Counter for each bucket.
Definition: statistics.hh:2923
std::vector< std::string > y_subnames
Definition: info.hh:226
virtual Result result() const =0
AverageDeviation(Group *parent=nullptr, const char *name=nullptr, const char *desc=nullptr)
Construct and initialize this distribution.
Definition: statistics.hh:2684
size_type size() const
Definition: statistics.hh:169
Counter logs
The sum of logarithm of each sample, used to compute geometric mean.
Definition: statistics.hh:1569
Storage * data()
Retrieve the storage.
Definition: statistics.hh:1864
Temp(signed char value)
Create a ConstNode.
Definition: statistics.hh:3202
DataWrapVec2d(Group *parent, const char *name, const char *desc)
Definition: statistics.hh:444
Counter max
Definition: info.hh:181
void operator--(int)
Decrement the stat by 1.
Definition: statistics.hh:729
ScalarProxy(Stat &s, off_type i)
Create and initialize this proxy, do not register it with the database.
Definition: statistics.hh:930
bool zero() const
Definition: statistics.hh:549
The parameters for a distribution stat.
Definition: statistics.hh:1550
Counter squares
The sum of squares.
Definition: statistics.hh:1571
Derived & scalar(T &value)
Definition: statistics.hh:848
void operator++()
Increment the stat by 1.
Definition: statistics.hh:962
Derived & flags(Flags _flags)
Set the flags and marks this stat to print at the end of simulation.
Definition: statistics.hh:336
Vector(Group *parent=nullptr, const char *name=nullptr, const char *desc=nullptr)
Definition: statistics.hh:2553
Counter min_bucket
The minimum value to track.
Definition: statistics.hh:1560
unsigned int size_type
Definition: types.hh:56
const Formula & formula
Definition: statistics.hh:3101
Proxy operator[](off_type index)
Return a reference (ScalarProxy) to the stat at the given index.
Definition: statistics.hh:1165
bool zero() const
Return true if no samples have been added.
Definition: statistics.hh:1817
Counter overflow
Definition: info.hh:187
VectorDistInfoProxy< Derived > Info
Definition: statistics.hh:1942
virtual void visit(const ScalarInfo &info)=0
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2508
This is a vector of AverageDeviation stats.
Definition: statistics.hh:2763
Result total() const
Return the total of the result vector.
Definition: statistics.hh:2468
Derived & init(size_type size)
Set this vector to have the given size.
Definition: statistics.hh:1152
VectorStatNode(const VectorInfo *d)
Definition: statistics.hh:2204
size_type size() const override
Return the number of nodes in the subtree starting at this node.
Definition: statistics.hh:2420
Calculates the mean and variance of all the samples.
Definition: statistics.hh:2658
Distribution(Group *parent=nullptr, const char *name=nullptr, const char *desc=nullptr)
Definition: statistics.hh:2595
void addStat(Stats::Info *info)
Register a stat with this group.
Definition: group.cc:107
void doInit(size_type s)
Definition: statistics.hh:1967
Bitfield< 63 > val
Definition: misc.hh:771
std::string str() const
Definition: statistics.hh:1018
void result(VResult &vec) const
Copy the values to a local vector and return a reference to it.
Definition: statistics.hh:1090
Result total() const
Definition: statistics.hh:828
Bitfield< 31 > n
Bitfield< 6 > f
double Counter
All counters are of 64-bit values.
Definition: types.hh:43
bool zero() const
Definition: statistics.hh:1329
void sample(Counter val, int number)
Add a value to the distribution for the given number of times.
Definition: statistics.hh:1801
bool zero() const
Definition: statistics.hh:886
ScalarProxy(const ScalarProxy &sp)
Create a copy of the provided ScalarProxy.
Definition: statistics.hh:939
Temp(signed long long value)
Create a ConstNode.
Definition: statistics.hh:3266
bool zero() const
Return true if no samples have been added.
Definition: statistics.hh:2888
Data structure of sparse histogram.
Definition: info.hh:246
DistParams(DistType t)
Definition: statistics.hh:1389
Bitfield< 7 > b
void visit(Output &visitor)
Visitor entry for outputing statistics data.
Definition: statistics.hh:783
const VResult & result() const
Return the result vector of this subtree.
Definition: statistics.hh:2310
size_type size() const
Return the number of entries in this stat.
Definition: statistics.hh:1905
bool zero() const
Definition: statistics.hh:217
void operator++(int)
Increment the stat by 1.
Definition: statistics.hh:727
void prepare(Info *info, DistData &data)
Definition: statistics.hh:1493
Counter samples
The number of samples.
Definition: statistics.hh:1435
AverageVector(Group *parent=nullptr, const char *name=nullptr, const char *desc=nullptr)
Definition: statistics.hh:2567
HistStor(Info *info)
Definition: statistics.hh:1578
void enable()
Definition: statistics.cc:552
Tick curTick()
The current simulated tick.
Definition: core.hh:47
Counter max
The maximum value to track.
Definition: statistics.hh:1404
Temp(const ScalarProxy< Stat > &p)
Create a new ScalarProxyNode.
Definition: statistics.hh:3194
void prepare(Info *info, DistData &data)
Definition: statistics.hh:1745
Result total() const
Return the total of the result vector.
Definition: statistics.hh:2147
const VResult & result() const override
Return the result vector of this subtree.
Definition: statistics.hh:2356
Counter squares
The sum of squares.
Definition: statistics.hh:1705
VCounter cvec
Counter for each bucket.
Definition: statistics.hh:1437
virtual const VResult & result() const =0
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:162
bool zero() const
Returns true if any calls to sample have been made.
Definition: statistics.hh:1637
const std::string & setSeparator() const
Definition: statistics.hh:300
void operator=(const U &v)
Set the data value to the given value.
Definition: statistics.hh:737
VCounter cvec
Local storage for the entry values, used for printing.
Definition: info.hh:232
const DistProxy & operator=(const DistProxy &sp)
Definition: statistics.hh:2058
Result result() const
Return the current value of this statas a result type.
Definition: statistics.hh:923
Derived & setSeparator(const std::string &_sep)
Set the character(s) used between the name and vector number on vectors, dist, etc.
Definition: statistics.hh:295
Temp operator-(Temp l, Temp r)
Definition: statistics.hh:3307
FormulaInfoProxy(Stat &stat)
Definition: statistics.hh:2797
void reset()
Proxy has no state.
Definition: statistics.hh:2088
Temp(const Average &s)
Create a new ScalarStatNode.
Definition: statistics.hh:3166
Counter min
Definition: info.hh:180
Tick last
The tick that current last changed.
Definition: statistics.hh:569
BinaryNode(NodePtr &a, NodePtr &b)
Definition: statistics.hh:2353
Templatized storage and interface for a histogram stat.
Definition: statistics.hh:1546
Stor::Params Params
Definition: statistics.hh:1254
Counter sum
The current sum.
Definition: statistics.hh:1567
Proxy operator[](off_type index)
Definition: statistics.hh:1314
uint64_t Tick
Tick count type.
Definition: types.hh:63
void result(VResult &vec) const
Return the result of the Fomula in a vector.
Definition: statistics.cc:469
Counter squares
The sum of squares.
Definition: statistics.hh:1433
const VResult & result() const
Return the result vector of this subtree.
Definition: statistics.hh:2221
size_type size() const
Definition: statistics.hh:2799
Counter underflow
Definition: info.hh:186
A simple distribution stat.
Definition: statistics.hh:2592
std::shared_ptr< Node > NodePtr
Shared pointer to a function Node.
Definition: statistics.hh:2129
Result total() const
Definition: statistics.hh:2807
Implementation of a scalar stat.
Definition: statistics.hh:657
virtual Result total() const =0
FormulaNode(const Formula &f)
Definition: statistics.hh:3105
Counter value() const
Definition: statistics.hh:122
void reset()
Reset the stat to the default state.
Definition: statistics.hh:780
The parameters for a distribution stat.
Definition: statistics.hh:1399
Flags flags
The formatting flags.
Definition: info.hh:81
void dec(Counter val)
Decrement the stat by the given value.
Definition: statistics.hh:526
Derived & prereq(const Stat &prereq)
Set the prerequisite stat and marks this stat to print at the end of simulation.
Definition: statistics.hh:350
const VResult & result() const
Definition: statistics.hh:147
void reset(Info *info)
Reset stat value to default.
Definition: statistics.hh:544
ScalarStatNode(const ScalarInfo *d)
Definition: statistics.hh:2138
ScalarProxy< Stat > operator[](off_type index)
Definition: statistics.hh:1239
Bitfield< 9 > d
void registerResetCallback(Callback *cb)
Register a callback that should be called whenever statistics are reset.
Definition: statistics.cc:538
VectorDistInfoProxy(Stat &stat)
Definition: statistics.hh:167
ScalarInfoProxy(Stat &stat)
Definition: statistics.hh:120
void reset()
Reset the stat to the default state.
Definition: statistics.hh:211
InfoProxyType< Derived > Info
Definition: statistics.hh:442
DistType
Definition: info.hh:175
void reset(Info *info)
Reset stat value to default.
Definition: statistics.hh:643
Bitfield< 18, 16 > len
size_type size() const
Definition: statistics.hh:1323
Vector2d(Group *parent=nullptr, const char *name=nullptr, const char *desc=nullptr)
Definition: statistics.hh:2581
Counter bucket_size
The number of entries in each bucket.
Definition: statistics.hh:1420
A simple histogram stat.
Definition: statistics.hh:2629
StatStor(Info *info)
Builds this storage element and calls the base constructor of the datatype.
Definition: statistics.hh:508
size_type size() const
Return the number of elements in the tree.
Definition: statistics.cc:482
Temp constant(T val)
Definition: statistics.hh:3332
void setName(const std::string &name)
Set the name of this statistic.
Temp(const NodePtr &n)
Copy the given pointer to this class.
Definition: statistics.hh:3130
Result total() const
Return a total of all entries in this vector.
Definition: statistics.hh:1339
virtual Counter value() const =0
Temp(signed short value)
Create a ConstNode.
Definition: statistics.hh:3218
std::string str() const
Definition: statistics.hh:2192
ScalarProxyNode(const ScalarProxy< Stat > &p)
Definition: statistics.hh:2165
size_type size() const
Definition: statistics.hh:1245
Storage * data()
Retrieve the storage.
Definition: statistics.hh:2842
void prepare(Info *info)
Prepare stat data for dumping or serialization.
Definition: statistics.hh:633
AvgStor(Info *info)
Build and initializes this stat storage.
Definition: statistics.hh:578
size_type size() const
Return the number of nodes in the subtree starting at this node.
Definition: statistics.hh:3107
Counter sum
Current total.
Definition: statistics.hh:1782
bool zero() const
Definition: statistics.hh:113
void operator-=(const U &v)
Decrement the stat by the given value.
Definition: statistics.hh:753
Distribution & init(Counter min, Counter max, Counter bkt)
Set the parameters of this distribution.
Definition: statistics.hh:2609
Implementation of a sparse histogram stat.
Definition: statistics.hh:2825
Result result() const
Definition: statistics.hh:123
STL list class.
Definition: stl.hh:54
std::vector< DistData > data
Definition: info.hh:205
VectorDistribution(Group *parent=nullptr, const char *name=nullptr, const char *desc=nullptr)
Definition: statistics.hh:2701
const FlagsType display
Print this stat.
Definition: info.hh:49
bool zero() const
Definition: statistics.hh:1116
Result total() const
Definition: statistics.hh:809
Calculates the per tick mean and variance of the samples.
Definition: statistics.hh:2678
bool zero() const
Return true if no samples have been added.
Definition: statistics.hh:1742
void sample(Counter val, int number)
Add a value to the distribution for the given number of times.
Definition: statistics.hh:1452
unsigned int off_type
Definition: types.hh:57
Temp(const Value &s)
Create a new ScalarStatNode.
Definition: statistics.hh:3158
VectorAverageDeviation(Group *parent=nullptr, const char *name=nullptr, const char *desc=nullptr)
Definition: statistics.hh:2767
Histogram(Group *parent=nullptr, const char *name=nullptr, const char *desc=nullptr)
Definition: statistics.hh:2632
Temp(float value)
Create a ConstNode.
Definition: statistics.hh:3282
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
Temp(unsigned int value)
Create a ConstNode.
Definition: statistics.hh:3242
std::map< const void *, Info * > MapType
Definition: statistics.hh:3389
const Stat::Storage * data() const
Definition: statistics.hh:2046
Derived & precision(int _precision)
Set the precision and marks this stat to print at the end of simulation.
Definition: statistics.hh:324
SparseHistBase(Group *parent, const char *name, const char *desc)
Definition: statistics.hh:2865
size_type x
Definition: info.hh:228
void dec(Counter val)
Deccrement the current count by the provided value, calls set.
Definition: statistics.hh:605
T safe_cast(U ptr)
Definition: cast.hh:61
Counter bucket_size
The number of entries in each bucket.
Definition: statistics.hh:1564
const Storage * data(off_type index) const
Retrieve a const pointer to the storage.
Definition: statistics.hh:1058
Counter logs
Definition: info.hh:191
Statistics container.
Definition: group.hh:85
Temp operator+(Temp l, Temp r)
Definition: statistics.hh:3301
virtual ~Node()
Definition: statistics.hh:2125
Templatized storage and interface to a per-tick average stat.
Definition: statistics.hh:559
Helper class to construct formula node trees.
Definition: statistics.hh:3117
bool enabled()
Definition: statistics.cc:546
void reset()
Reset stat value to default.
Definition: statistics.hh:1923
Temp(signed long value)
Create a ConstNode.
Definition: statistics.hh:3250
SparseHistInfoProxy< Derived > Info
Definition: statistics.hh:2828
StandardDeviation(Group *parent=nullptr, const char *name=nullptr, const char *desc=nullptr)
Construct and initialize this distribution.
Definition: statistics.hh:2664
NameMapType & nameMap()
Definition: statistics.cc:150
const VResult & result() const
Definition: statistics.hh:1199
Counter max_track
The maximum value to track.
Definition: statistics.hh:1418
const FlagsType total
Print the total.
Definition: info.hh:51
void registerDumpCallback(Callback *cb)
Register a callback that should be called whenever statistics are about to be dumped.
Definition: statistics.cc:579
Average(Group *parent=nullptr, const char *name=nullptr, const char *desc=nullptr)
Definition: statistics.hh:2529
Templatized storage and interface for a distribution stat.
Definition: statistics.hh:1395
size_type size() const
Return the number of elements, always 1 for a scalar.
Definition: statistics.hh:759
DistStor(Info *info)
Definition: statistics.hh:1440
SparseHistogram(Group *parent=nullptr, const char *name=nullptr, const char *desc=nullptr)
Definition: statistics.hh:2985
const Storage * data(off_type index) const
Definition: statistics.hh:1269
VCounter & value() const
Definition: statistics.hh:140
void debugDumpStats()
Definition: statistics.cc:587
Result result() const
Return the value of this stat as a result type.
Definition: statistics.hh:536
Counter max_val
The largest value sampled.
Definition: statistics.hh:1425
A formula for statistics that is calculated when printed.
Definition: statistics.hh:3012
Result result() const
Definition: statistics.hh:795
Counter samples
Definition: info.hh:192
bool zero() const
Definition: statistics.hh:781
std::string str() const
Definition: statistics.hh:2810
Tick lastReset
The tick of the last reset.
Definition: statistics.hh:565
void sample(Counter val, int number)
Add a value to the distribution for the given number of times.
Definition: statistics.hh:2937
Derived & name(const std::string &name)
Set the name and marks this stat to print at the end of simulation.
Definition: statistics.hh:279
Temp sum(Temp val)
Definition: statistics.hh:3345
Templatized storage for distribution that calculates per tick mean and variance.
Definition: statistics.hh:1772
void reset(Info *info)
Reset stat value to default.
Definition: statistics.hh:1521
const VResult & result() const
Return the result vector of this subtree.
Definition: statistics.hh:2141
void sample(Counter val, int number)
Add a value the given number of times to this running average.
Definition: statistics.hh:1725
SumNode(NodePtr &p)
Definition: statistics.hh:2449
Result result() const
Return the current average.
Definition: statistics.hh:618
void prepare()
Prepare the stat for dumping.
Definition: statistics.hh:779
const Stat::Storage * data(off_type index) const
Definition: statistics.hh:1191
bool zero() const
Definition: statistics.hh:627
size_type size() const
Definition: statistics.hh:883
const Storage * data() const
Retrieve a const pointer to the storage.
Definition: statistics.hh:2852
InfoProxy(Stat &stat)
Definition: statistics.hh:103
const Storage * data() const
Retrieve a const pointer to the storage.
Definition: statistics.hh:686
bool check() const
Definition: statistics.hh:1125
Temp constantVector(T val)
Definition: statistics.hh:3339
const Info * info() const
Definition: statistics.hh:245
VCounter cvec
Definition: info.hh:188
Result result() const
Definition: statistics.hh:881
const VResult & result() const
Definition: statistics.hh:2802
The parameters for a sparse histogram stat.
Definition: statistics.hh:2914
Result total() const
Return the total Formula result.
Definition: statistics.cc:476
Counter underflow
The number of values sampled less than min.
Definition: statistics.hh:1427
size_type y
Definition: info.hh:229
void processResetQueue()
Process all the callbacks in the reset callbacks queue.
Definition: statistics.cc:526
Storage * data()
Retrieve the storage.
Definition: statistics.hh:674
Stor::Params Params
Definition: statistics.hh:1852
const StorageParams * storageParams
Definition: info.hh:94
const ScalarProxy & operator=(const ScalarProxy &sp)
Set this proxy equal to the provided one.
Definition: statistics.hh:949
size_type size() const
Return the number of buckets in this distribution.
Definition: statistics.hh:2947
size_type size() const
Definition: statistics.hh:1113
Counter squares
Definition: info.hh:190
VCounter & value() const
Definition: statistics.hh:2808
void operator-=(const U &v)
Decrement the stat by the given value.
Definition: statistics.hh:1005
Counter value() const
Return the current value of this stat as its base type.
Definition: statistics.hh:917
void add(DistBase &d)
Add the argument distribution to the this distribution.
Definition: statistics.hh:1931
SparseHistData data
Local storage for the entry values, used for printing.
Definition: info.hh:257
std::string str() const
Definition: statistics.hh:2210
std::string str() const
Definition: statistics.hh:2154
void prepare(Info *info, SparseHistData &data)
Definition: statistics.hh:2960
Derived & ysubname(off_type index, const std::string &subname)
Definition: statistics.hh:466
Temp(const Scalar &s)
Create a new ScalarStatNode.
Definition: statistics.hh:3150
size_type size() const
Definition: statistics.hh:2074
Vector2dInfoProxy< Derived > Info
Definition: statistics.hh:1252
bool validateStatName(const string &name)
Definition: statistics.cc:173
Counter data
The statistic value.
Definition: statistics.hh:498
void sample(Counter val, int number)
Add a value to the distribution for the given number of times.
Definition: statistics.hh:1595
Counter max_val
Definition: info.hh:185
std::string str() const
Definition: statistics.cc:507
Counter sum
Definition: info.hh:189
Result total() const override
Return the total of the result vector.
Definition: statistics.hh:2388
Result total() const
Definition: statistics.hh:178
size_type size() const
Return the number of nodes in the subtree starting at this node.
Definition: statistics.hh:2149
std::string str() const
Definition: statistics.hh:2338
const Storage * data(off_type index) const
Definition: statistics.hh:1961
DistInfoProxy(Stat &stat)
Definition: statistics.hh:160
size_type size() const
Return the number of elements, always 1 for a scalar.
Definition: statistics.hh:1014
SparseHistogram & init(size_type size)
Set the parameters of this histogram.
Definition: statistics.hh:2997
Counter bucket_size
Definition: info.hh:182
SparseHistStor(Info *info)
Definition: statistics.hh:2926
Temp operator*(Temp l, Temp r)
Definition: statistics.hh:3313
off_type index
The index to access in the parent VectorBase.
Definition: statistics.hh:910
size_type size() const
Return the number of buckets in this distribution.
Definition: statistics.hh:1630
Counter value() const
Definition: statistics.hh:794
VectorProxy< Derived > Proxy
Definition: statistics.hh:1255
A vector of Average stats.
Definition: statistics.hh:2564
Result total() const
Definition: statistics.hh:796
Counter value() const
Return the current count.
Definition: statistics.hh:611
VectorProxy(Stat &s, off_type o, size_type l)
Definition: statistics.hh:1219
void reset()
Reset stat value to default.
Definition: statistics.hh:1365
ConstVectorNode(const T &s)
Definition: statistics.hh:2234
NodePtr root
The root of the tree which represents the Formula.
Definition: statistics.hh:3016
Stat::Storage * data(off_type index)
Definition: statistics.hh:1184
const VResult & result() const
Return the result vector of this subtree.
Definition: statistics.hh:2170
size_type size() const
Return the number of nodes in the subtree starting at this node.
Definition: statistics.hh:2247
const VResult & result() const
Return the result vector of this subtree.
Definition: statistics.hh:3108
void inc(Counter val)
Increment the stat by the given value.
Definition: statistics.hh:521
std::string str() const
Definition: statistics.hh:776
void reset(Info *info)
Reset stat value to default.
Definition: statistics.hh:1760
size_type size() const
Return the number of nodes in the subtree starting at this node.
Definition: statistics.hh:2183
Temp(unsigned short value)
Create a ConstNode.
Definition: statistics.hh:3226
void sample(const U &v, int n=1)
Add a value to the distribtion n times.
Definition: statistics.hh:2877
Derived & desc(const std::string &_desc)
Set the description and marks this stat to print at the end of simulation.
Definition: statistics.hh:312
size_type size() const
Return the number of nodes in the subtree starting at this node.
Definition: statistics.hh:2223
void prepare(Info *info, DistData &data)
Definition: statistics.hh:1643
Result total() const
Definition: statistics.hh:1210
bool zero() const
Returns true if any calls to sample have been made.
Definition: statistics.hh:1487
const VResult & result() const
Return the result vector of this subtree.
Definition: statistics.hh:2205
void operator--()
Decrement the stat by 1.
Definition: statistics.hh:967
const ScalarProxy< Stat > proxy
Definition: statistics.hh:2161
size_type size() const
Return the number of entries in this stat, 1.
Definition: statistics.hh:1736
void operator=(const U &v)
Set the data value to the given value.
Definition: statistics.hh:981
void dump()
Dump all statistics data to the registered outputs.
Definition: statistics.cc:561
size_type size() const
Definition: statistics.hh:2006
Vector2dInfoProxy(Stat &stat)
Definition: statistics.hh:176
A 2-Dimensional vecto of scalar stats.
Definition: statistics.hh:2578
Counter value()
Definition: statistics.hh:880
bool check() const
Check that this stat has been set up properly and is ready for use.
Definition: statistics.hh:778
Bitfield< 5 > t
std::map< std::string, Info * > NameMapType
Definition: statistics.hh:3392
Bitfield< 4 > op
Definition: types.hh:80
Storage * data(off_type index)
Definition: statistics.hh:1268
DistInfoProxy< Derived > Info
Definition: statistics.hh:1850
VectorStandardDeviation & init(size_type size)
Initialize storage for this distribution.
Definition: statistics.hh:2750
void reset(Info *info)
Reset stat value to default.
Definition: statistics.hh:2975
VectorBase(Group *parent, const char *name, const char *desc)
Definition: statistics.hh:1131
InfoProxyType< Derived > Info
Definition: statistics.hh:361
bool zero() const
Returns true if any calls to sample have been made.
Definition: statistics.hh:2954
bool check() const
Definition: statistics.hh:1374
This is a vector of StandardDeviation stats.
Definition: statistics.hh:2733
Derived & ysubnames(const char **names)
Definition: statistics.hh:454
const Formula & operator=(const T &v)
Definition: statistics.hh:3037
Temp(double value)
Create a ConstNode.
Definition: statistics.hh:3290
void registerHandlers(Handler reset_handler, Handler dump_handler)
Definition: statistics.cc:516
const ScalarInfo * data
Definition: statistics.hh:2134
Temp(unsigned long value)
Create a ConstNode.
Definition: statistics.hh:3258
Bitfield< 0 > p
Result total() const
Definition: statistics.hh:124
Bitfield< 9, 8 > rs
NodePtr node
Pointer to a Node object.
Definition: statistics.hh:3123
void prepare(Info *info)
Prepare stat data for dumping or serialization.
Definition: statistics.hh:540
Derived & functor(T &func)
Definition: statistics.hh:857
void visit(Output &visitor)
Definition: statistics.hh:109
const char data[]
Info * info()
Grab the information class for this statistic.
Definition: statistics.cc:118
size_type size() const
Return the number of nodes in the subtree starting at this node.
Definition: statistics.hh:2335
void operator++(int)
Increment the stat by 1.
Definition: statistics.hh:970
void set(Type flags)
Definition: flags.hh:70
Bitfield< 5 > l
A proxy similar to the FunctorProxy, but allows calling a method of a bound object, instead of a global free-standing function.
Definition: statistics.hh:817
Counter value() const
Return the value of this stat as its base type.
Definition: statistics.hh:531
Counter value() const
Return the current value of this stat as its base type.
Definition: statistics.hh:703
Counter samples
The number of samples.
Definition: statistics.hh:1707
const VectorInfo * data
Definition: statistics.hh:2201
Temp(const Formula &f)
Definition: statistics.hh:3185
Temp(const Vector &s)
Create a new VectorStatNode.
Definition: statistics.hh:3174
Counter sum
The current sum.
Definition: statistics.hh:1431
Implementation of a vector of stats.
Definition: statistics.hh:1029
void operator+=(const U &v)
Increment the stat by the given value.
Definition: statistics.hh:993
DistData data
Local storage for the entry values, used for printing.
Definition: info.hh:199
bool check() const
Check that this stat has been set up properly and is ready for use.
Definition: statistics.hh:224
void sample(const U &v, int n=1)
Add a value to the distribtion n times.
Definition: statistics.hh:1899
Stor::Params Params
Definition: statistics.hh:1033
Stat::Storage * data()
Definition: statistics.hh:2045
const std::string & name() const
Definition: statistics.hh:286
std::vector< std::string > subnames
Names and descriptions of subfields.
Definition: info.hh:208
VectorDistBase(Group *parent, const char *name, const char *desc)
Definition: statistics.hh:1984
const std::string to_string(sc_enc enc)
Definition: sc_fxdefs.cc:60
void reset()
Reset stat value to default.
Definition: statistics.hh:2901
Templatized storage and interface for a distribution that calculates mean and variance.
Definition: statistics.hh:1693
DistProxy(Stat &s, off_type i)
Definition: statistics.hh:2049
bool zero() const
Return true if no samples have been added.
Definition: statistics.hh:1910
Result total() const
Return the total of the result vector.
Definition: statistics.hh:3109
Stat & stat
Pointer to the parent Vector.
Definition: statistics.hh:907
MapType & statsMap()
Definition: statistics.cc:75
bool check() const
Definition: statistics.hh:105
A proxy class to access the stat at a given index in a VectorBase stat.
Definition: statistics.hh:903
bool zero() const
Definition: statistics.hh:2080
AvgSampleStor(Info *info)
Create and initialize this storage.
Definition: statistics.hh:1790
void reset(Info *info)
Reset stat value to default.
Definition: statistics.hh:1835
Temp(NodePtr &&n)
Definition: statistics.hh:3132
Result total() const
Definition: statistics.hh:882

Generated on Fri Feb 28 2020 16:26:58 for gem5 by doxygen 1.8.13