SST  14.1.0
StructuralSimulationToolkit
statbase.h
1 // Copyright 2009-2024 NTESS. Under the terms
2 // of Contract DE-NA0003525 with NTESS, the U.S.
3 // Government retains certain rights in this software.
4 //
5 // Copyright (c) 2009-2024, NTESS
6 // All rights reserved.
7 //
8 // This file is part of the SST software package. For license
9 // information, see the LICENSE file in the top level directory of the
10 // distribution.
11 
12 #ifndef SST_CORE_STATAPI_STATBASE_H
13 #define SST_CORE_STATAPI_STATBASE_H
14 
15 #include "sst/core/eli/elementinfo.h"
16 #include "sst/core/factory.h"
17 #include "sst/core/oneshot.h"
18 #include "sst/core/params.h"
19 #include "sst/core/serialization/serialize_impl_fwd.h"
20 #include "sst/core/sst_types.h"
21 #include "sst/core/statapi/statfieldinfo.h"
22 #include "sst/core/warnmacros.h"
23 
24 #include <string>
25 
26 namespace SST {
27 class BaseComponent;
28 class Factory;
29 
30 namespace Statistics {
31 class StatisticOutput;
32 class StatisticFieldsOutput;
33 class StatisticProcessingEngine;
34 class StatisticGroup;
35 
36 /**
37  \class StatisticBase
38 
39  Forms the base class for statistics gathering within SST. Statistics are
40  gathered and processed into various (extensible) output forms. Statistics
41  are expected to be named so that they can be located in the simulation
42  output files.
43 */
44 
46 {
47 public:
48  /** Statistic collection mode */
49  typedef enum { STAT_MODE_UNDEFINED, STAT_MODE_COUNT, STAT_MODE_PERIODIC, STAT_MODE_DUMP_AT_END } StatMode_t;
50 
51  // Enable/Disable of Statistic
52  /** Enable Statistic for collections */
53  void enable() { m_statEnabled = true; }
54 
55  /** Disable Statistic for collections */
56  void disable() { m_statEnabled = false; }
57 
58  // Handling of Collection Counts and Data
59  /** Inform the Statistic to clear its data */
60  virtual void clearStatisticData() {}
61 
62  /** Set the current collection count to 0 */
63  virtual void resetCollectionCount();
64 
65  /** Increment current collection count */
66  virtual void incrementCollectionCount(uint64_t increment);
67 
68  /** Set the current collection count to a defined value */
69  virtual void setCollectionCount(uint64_t newCount);
70 
71  /** Set the collection count limit to a defined value */
72  virtual void setCollectionCountLimit(uint64_t newLimit);
73 
74  // Control Statistic Operation Flags
75  /** Set the Reset Count On Output flag.
76  * If Set, the collection count will be reset when statistic is output.
77  */
78  void setFlagResetCountOnOutput(bool flag) { m_resetCountOnOutput = flag; }
79 
80  static const std::vector<ElementInfoParam>& ELI_getParams();
81 
82  /** Set the Clear Data On Output flag.
83  * If Set, the data in the statistic will be cleared by calling
84  * clearStatisticData().
85  */
86  void setFlagClearDataOnOutput(bool flag) { m_clearDataOnOutput = flag; }
87 
88  /** Set the Output At End Of Sim flag.
89  * If Set, the statistic will perform an output at the end of simulation.
90  */
91  void setFlagOutputAtEndOfSim(bool flag) { m_outputAtEndOfSim = flag; }
92 
93  // Get Data & Information on Statistic
94  /** Return the Component Name */
95  const std::string& getCompName() const;
96 
97  /** Return the Statistic Name */
98  inline const std::string& getStatName() const { return m_statName; }
99 
100  /** Return the Statistic SubId */
101  inline const std::string& getStatSubId() const { return m_statSubId; }
102 
103  /** Return the full Statistic name of Component.StatName.SubId */
104  inline const std::string& getFullStatName() const { return m_statFullName; } // Return compName.statName.subId
105 
106  /** Return the Statistic type name */
107  inline const std::string& getStatTypeName() const { return m_statTypeName; }
108 
109  /** Return the Statistic data type */
110  inline const StatisticFieldInfo::fieldType_t& getStatDataType() const { return m_statDataType; }
111 
112  /** Return the Statistic data type */
113  inline const char* getStatDataTypeShortName() const
114  {
115  return StatisticFieldInfo::getFieldTypeShortName(m_statDataType);
116  }
117 
118  /** Return the Statistic data type */
119  inline const char* getStatDataTypeFullName() const
120  {
121  return StatisticFieldInfo::getFieldTypeFullName(m_statDataType);
122  }
123 
124  /** Return a pointer to the parent Component */
125  BaseComponent* getComponent() const { return m_component; }
126 
127  /** Return the enable status of the Statistic */
128  bool isEnabled() const { return m_statEnabled; }
129 
130  /** Return the enable status of the Statistic's ability to output data */
131  bool isOutputEnabled() const { return m_outputEnabled; }
132 
133  /** Return the collection count limit */
134  uint64_t getCollectionCountLimit() const { return m_collectionCountLimit; }
135 
136  /** Return the current collection count */
137  uint64_t getCollectionCount() const { return m_currentCollectionCount; }
138 
139  /** Return the ResetCountOnOutput flag value */
140  bool getFlagResetCountOnOutput() const { return m_resetCountOnOutput; }
141 
142  /** Return the ClearDataOnOutput flag value */
143  bool getFlagClearDataOnOutput() const { return m_clearDataOnOutput; }
144 
145  /** Return the OutputAtEndOfSim flag value */
146  bool getFlagOutputAtEndOfSim() const { return m_outputAtEndOfSim; }
147 
148  /** Return the collection mode that is registered */
149  StatMode_t getRegisteredCollectionMode() const { return m_registeredCollectionMode; }
150 
151  // Delay Methods (Uses OneShot to disable Statistic or Collection)
152  /** Delay the statistic from outputting data for a specified delay time
153  * @param delayTime - Value in UnitAlgebra format for delay (i.e. 10ns).
154  */
155  void delayOutput(const char* delayTime);
156 
157  /** Delay the statistic from collecting data for a specified delay time.
158  * @param delayTime - Value in UnitAlgebra format for delay (i.e. 10ns).
159  */
160  void delayCollection(const char* delayTime);
161 
162  // Status of Statistic
163  /** Indicate that the Statistic is Ready to be used */
164  virtual bool isReady() const { return true; }
165 
166  /** Indicate if the Statistic is a NullStatistic */
167  virtual bool isNullStatistic() const { return false; }
168 
169  /** Return the Statistic Parameters
170  * NOTE: This must be public so that it is accessible to the serialize_impl
171  * class for statistics.
172  */
173  Params& getParams() { return m_statParams; }
174 
175  /** Serialization */
177 
178 protected:
181  friend class SST::Statistics::StatisticGroup;
183 
184  /** Construct a StatisticBase
185  * @param comp - Pointer to the parent constructor.
186  * @param statName - Name of the statistic to be registered. This name must
187  * match the name in the ElementInfoStatistic.
188  * @param statSubId - Additional name of the statistic
189  * @param statParams - The parameters for this statistic
190  */
191  // Constructors:
192  StatisticBase(BaseComponent* comp, const std::string& statName, const std::string& statSubId, Params& statParams);
193 
194  // Destructor
195  virtual ~StatisticBase() {}
196 
197 protected:
198  /** Set the Statistic Data Type */
199  void setStatisticDataType(const StatisticFieldInfo::fieldType_t dataType) { m_statDataType = dataType; }
200 
201  /** Set an optional Statistic Type Name */
202  void setStatisticTypeName(const char* typeName) { m_statTypeName = typeName; }
203 
204 private:
205  friend class SST::BaseComponent;
206 
207  /** Set the Registered Collection Mode */
208  void setRegisteredCollectionMode(StatMode_t mode) { m_registeredCollectionMode = mode; }
209 
210  /** Construct a full name of the statistic */
211  static std::string buildStatisticFullName(const char* compName, const char* statName, const char* statSubId);
212  static std::string
213  buildStatisticFullName(const std::string& compName, const std::string& statName, const std::string& statSubId);
214 
215  // Required Virtual Methods:
216  /** Called by the system to tell the Statistic to register its output fields.
217  * by calling statOutput->registerField(...)
218  * @param statOutput - Pointer to the statistic output
219  */
220  virtual void registerOutputFields(StatisticFieldsOutput* statOutput) = 0;
221 
222  /** Called by the system to tell the Statistic to send its data to the
223  * StatisticOutput to be output.
224  * @param statOutput - Pointer to the statistic output
225  * @param EndOfSimFlag - Indicates that the output is occurring at the end of simulation.
226  */
227  virtual void outputStatisticFields(StatisticFieldsOutput* statOutput, bool EndOfSimFlag) = 0;
228 
229  /** Indicate if the Statistic Mode is supported.
230  * This allows Statistics to support STAT_MODE_COUNT and STAT_MODE_PERIODIC modes.
231  * by default, both modes are supported.
232  * @param mode - Mode to test
233  */
234  virtual bool isStatModeSupported(StatMode_t UNUSED(mode)) const { return true; } // Default is to accept all modes
235 
236  /** Verify that the statistic names match */
237  bool operator==(StatisticBase& checkStat);
238 
239  // Support Routines
240  void initializeStatName(const char* compName, const char* statName, const char* statSubId);
241  void initializeStatName(const std::string& compName, const std::string& statName, const std::string& statSubId);
242 
243  void initializeProperties();
244  void checkEventForOutput();
245 
246  // OneShot Callbacks:
247  void delayOutputExpiredHandler(); // Enable Output in handler
248  void delayCollectionExpiredHandler(); // Enable Collection in Handler
249 
250  const StatisticGroup* getGroup() const { return m_group; }
251  void setGroup(const StatisticGroup* group) { m_group = group; }
252 
253 protected:
254  StatisticBase(); // For serialization only
255 
256 private:
257  BaseComponent* m_component;
258  std::string m_statName;
259  std::string m_statSubId;
260  std::string m_statFullName;
261  std::string m_statTypeName;
262  Params m_statParams;
263  StatMode_t m_registeredCollectionMode;
264  uint64_t m_currentCollectionCount;
265  uint64_t m_outputCollectionCount;
266  uint64_t m_collectionCountLimit;
267  StatisticFieldInfo::fieldType_t m_statDataType;
268 
269  bool m_statEnabled;
270  bool m_outputEnabled;
271  bool m_resetCountOnOutput;
272  bool m_clearDataOnOutput;
273  bool m_outputAtEndOfSim;
274 
275  bool m_outputDelayed;
276  bool m_collectionDelayed;
277  bool m_savedStatEnabled;
278  bool m_savedOutputEnabled;
279  const StatisticGroup* m_group;
280 };
281 
282 
283 /**
284  \class StatisticCollector
285  * Base type that creates the virtual addData(...) interface
286  * Used for distinguishing fundamental types (collected by value)
287  * and composite struct types (collected by reference)
288  */
289 template <class T, bool F = std::is_fundamental<T>::value>
291 {};
292 
293 template <class T>
294 struct StatisticCollector<T, true>
295 {
296  virtual void addData_impl(T data) = 0;
297 
298  /**
299  * @brief addData_impl_Ntimes Add the same data N times in a row
300  * By default, this just calls the addData function N times
301  * @param N The number of consecutive times
302  * @param args The arguments to pass in
303  */
304  virtual void addData_impl_Ntimes(uint64_t N, T data)
305  {
306  for ( uint64_t i = 0; i < N; ++i ) {
307  addData_impl(data);
308  }
309  }
310 };
311 
312 template <class... Args>
313 struct StatisticCollector<std::tuple<Args...>, false>
314 {
315  virtual void addData_impl(Args... args) = 0;
316 
317  /**
318  * @brief addData_impl_Ntimes Add the same data N times in a row
319  * By default, this just calls the addData function N times
320  * @param N The number of consecutive times
321  * @param args The arguments to pass in
322  */
323  virtual void addData_impl_Ntimes(uint64_t N, Args... args)
324  {
325  for ( uint64_t i = 0; i < N; ++i ) {
326  addData_impl(args...);
327  }
328  }
329 
330  template <class... InArgs>
331  void addData(InArgs&&... args)
332  {
333  addData_impl(std::make_tuple(std::forward<InArgs>(args)...));
334  }
335 };
336 
337 ////////////////////////////////////////////////////////////////////////////////
338 
339 /**
340  \class Statistic
341 
342  Forms the template defined base class for statistics gathering within SST.
343 
344  @tparam T A template for the basic numerical data stored by this Statistic
345 */
346 
347 template <typename T>
348 class Statistic : public StatisticBase, public StatisticCollector<T>
349 {
350 public:
351  SST_ELI_DECLARE_BASE(Statistic)
352  SST_ELI_DECLARE_INFO(
353  ELI::ProvidesInterface,
354  ELI::ProvidesParams)
355  SST_ELI_DECLARE_CTOR(BaseComponent*, const std::string&, const std::string&, SST::Params&)
356 
357  using Datum = T;
358  using StatisticCollector<T>::addData_impl;
359  using StatisticCollector<T>::addData_impl_Ntimes;
360 
361  // The main method to add data to the statistic
362  /** Add data to the Statistic
363  * This will call the addData_impl() routine in the derived Statistic.
364  */
365  template <class... InArgs> // use a universal reference here
366  void addData(InArgs&&... args)
367  {
368  // Call the Derived Statistic's implementation
369  // of addData and increment the count
370  if ( isEnabled() ) {
371  addData_impl(std::forward<InArgs>(args)...);
373  }
374  }
375 
376  template <class... InArgs> // use a universal reference here
377  void addDataNTimes(uint64_t N, InArgs&&... args)
378  {
379  // Call the Derived Statistic's implementation
380  // of addData and increment the count
381  if ( isEnabled() ) {
382  addData_impl_Ntimes(N, std::forward<InArgs>(args)...);
384  }
385  }
386 
387  static fieldType_t fieldId() { return StatisticFieldType<T>::id(); }
388 
390  {
392  }
393 
394 protected:
395  friend class SST::Factory;
396  friend class SST::BaseComponent;
397  /** Construct a Statistic
398  * @param comp - Pointer to the parent constructor.
399  * @param statName - Name of the statistic to be registered. This name must
400  * match the name in the ElementInfoStatistic.
401  * @param statSubId - Additional name of the statistic
402  * @param statParams - The parameters for this statistic
403  */
404 
405  Statistic(BaseComponent* comp, const std::string& statName, const std::string& statSubId, Params& statParams) :
406  StatisticBase(comp, statName, statSubId, statParams)
407  {
408  setStatisticDataType(StatisticFieldInfo::getFieldTypeFromTemplate<T>());
409  }
410 
411  virtual ~Statistic() {}
412 
413 private:
414  Statistic() {} // For serialization only
415 };
416 
417 /**
418  * void Statistic has special meaning in that it does not collect fields
419  * in the usual way through the addData function. It has to use custom functions.
420  */
421 template <>
422 class Statistic<void> : public StatisticBase
423 {
424 public:
425  SST_ELI_DECLARE_BASE(Statistic)
426  SST_ELI_DECLARE_INFO(
429  SST_ELI_DECLARE_CTOR(BaseComponent*, const std::string&, const std::string&, SST::Params&)
430 
431  void registerOutputFields(StatisticFieldsOutput* statOutput) override;
432 
433  void outputStatisticFields(StatisticFieldsOutput* statOutput, bool EndOfSimFlag) override;
434 
435 protected:
436  friend class SST::Factory;
437  friend class SST::BaseComponent;
438  /** Construct a Statistic
439  * @param comp - Pointer to the parent constructor.
440  * @param statName - Name of the statistic to be registered. This name must
441  * match the name in the ElementInfoStatistic.
442  * @param statSubId - Additional name of the statistic
443  * @param statParams - The parameters for this statistic
444  */
445 
446  Statistic(BaseComponent* comp, const std::string& statName, const std::string& statSubId, Params& statParams) :
447  StatisticBase(comp, statName, statSubId, statParams)
448  {}
449 
450  virtual ~Statistic() {}
451 
452 private:
453  Statistic() {} // For serialization only
454 };
455 
456 using CustomStatistic = Statistic<void>;
457 
458 template <class... Args>
459 using MultiStatistic = Statistic<std::tuple<Args...>>;
460 
462 {
463 public:
464  std::string toString() const;
465 
466  Statistics::fieldType_t fieldId() const { return field_; }
467 
468  const char* fieldName() const { return field_name_; }
469 
470  const char* fieldShortName() const { return short_name_; }
471 
472 protected:
473  template <class T>
474  ImplementsStatFields(T* UNUSED(t)) :
475  field_name_(T::ELI_fieldName()),
476  short_name_(T::ELI_fieldShortName()),
477  field_(T::ELI_registerField(T::ELI_fieldName(), T::ELI_fieldShortName()))
478  {}
479 
480 private:
481  const char* field_name_;
482  const char* short_name_;
483  Statistics::fieldType_t field_;
484 };
485 
486 
487 #define SST_ELI_DECLARE_STATISTIC_TEMPLATE(cls, lib, name, version, desc, interface) \
488  SST_ELI_DEFAULT_INFO(lib, name, ELI_FORWARD_AS_ONE(version), desc) \
489  SST_ELI_INTERFACE_INFO(interface)
490 
491 #define SST_ELI_REGISTER_CUSTOM_STATISTIC(cls, lib, name, version, desc) \
492  SST_ELI_REGISTER_DERIVED(SST::Statistics::CustomStatistic,cls,lib,name,ELI_FORWARD_AS_ONE(version),desc) \
493  SST_ELI_INTERFACE_INFO("CustomStatistic")
494 
495 #define SST_ELI_DECLARE_STATISTIC(cls, field, lib, name, version, desc, interface) \
496  static bool ELI_isLoaded() \
497  { \
498  return SST::Statistics::Statistic<field>::template addDerivedInfo<cls>(lib, name) && \
499  SST::Statistics::Statistic<field>::template addDerivedBuilder<cls>(lib, name) && \
500  SST::Statistics::Statistic<field>::template addDerivedInfo<SST::Statistics::NullStatistic<field>>( \
501  lib, name) && \
502  SST::Statistics::Statistic<field>::template addDerivedBuilder<SST::Statistics::NullStatistic<field>>( \
503  lib, name); \
504  } \
505  SST_ELI_DEFAULT_INFO(lib, name, ELI_FORWARD_AS_ONE(version), desc) \
506  SST_ELI_INTERFACE_INFO(interface) \
507  static const char* ELI_fieldName() { return #field; } \
508  static const char* ELI_fieldShortName() { return #field; }
509 
510 #ifdef __INTEL_COMPILER
511 #define SST_ELI_INSTANTIATE_STATISTIC(cls, field) \
512  bool force_instantiate_##cls##_##field = \
513  SST::ELI::InstantiateBuilderInfo<SST::Statistics::Statistic<field>, cls<field>>::isLoaded() && \
514  SST::ELI::InstantiateBuilder<SST::Statistics::Statistic<field>, cls<field>>::isLoaded() && \
515  SST::ELI::InstantiateBuilderInfo< \
516  SST::Statistics::Statistic<field>, SST::Statistics::NullStatistic<field>>::isLoaded() && \
517  SST::ELI::InstantiateBuilder< \
518  SST::Statistics::Statistic<field>, SST::Statistics::NullStatistic<field>>::isLoaded();
519 #else
520 #define SST_ELI_INSTANTIATE_STATISTIC(cls, field) \
521  struct cls##_##field##_##shortName : public cls<field> \
522  { \
523  cls##_##field##_##shortName( \
524  SST::BaseComponent* bc, const std::string& sn, const std::string& si, SST::Params& p) : \
525  cls<field>(bc, sn, si, p) \
526  {} \
527  static bool ELI_isLoaded() \
528  { \
529  return SST::ELI::InstantiateBuilderInfo< \
530  SST::Statistics::Statistic<field>, cls##_##field##_##shortName>::isLoaded() && \
531  SST::ELI::InstantiateBuilder< \
532  SST::Statistics::Statistic<field>, cls##_##field##_##shortName>::isLoaded() && \
533  SST::ELI::InstantiateBuilderInfo< \
534  SST::Statistics::Statistic<field>, SST::Statistics::NullStatistic<field>>::isLoaded() && \
535  SST::ELI::InstantiateBuilder< \
536  SST::Statistics::Statistic<field>, SST::Statistics::NullStatistic<field>>::isLoaded(); \
537  } \
538  };
539 #endif
540 
541 #define PP_NARG(...) PP_NARG_(__VA_ARGS__, PP_NSEQ())
542 #define PP_NARG_(...) PP_ARG_N(__VA_ARGS__)
543 #define PP_ARG_N(_1, _2, _3, _4, _5, N, ...) N
544 #define PP_NSEQ() 5, 4, 3, 2, 1, 0
545 
546 #define PP_GLUE(X, Y) PP_GLUE_I(X, Y)
547 #define PP_GLUE_I(X, Y) X##Y
548 
549 #define STAT_NAME1(base, a) base##a
550 #define STAT_NAME2(base, a, b) base##a##b
551 #define STAT_NAME3(base, a, b, c) base##a##b##c
552 #define STAT_NAME4(base, a, b, c, d) base##a##b##c##d
553 
554 #define STAT_GLUE_NAME(base, ...) PP_GLUE(STAT_NAME, PP_NARG(__VA_ARGS__))(base, __VA_ARGS__)
555 #define STAT_TUPLE(...) std::tuple<__VA_ARGS__>
556 
557 #ifdef __INTEL_COMPILER
558 #define MAKE_MULTI_STATISTIC(cls, name, tuple, ...) \
559  bool force_instantiate_stat_name = \
560  SST::ELI::InstantiateBuilderInfo<SST::Statistics::Statistic<tuple>, cls<__VA_ARGS__>>::isLoaded() && \
561  SST::ELI::InstantiateBuilder<SST::Statistics::Statistic<tuple>, cls<__VA_ARGS__>>::isLoaded() && \
562  SST::ELI::InstantiateBuilderInfo< \
563  SST::Statistics::Statistic<tuple>, SST::Statistics::NullStatistic<tuple>>::isLoaded() && \
564  SST::ELI::InstantiateBuilder< \
565  SST::Statistics::Statistic<tuple>, SST::Statistics::NullStatistic<tuple>>::isLoaded(); \
566  } \
567  } \
568  ;
569 #else
570 #define MAKE_MULTI_STATISTIC(cls, name, tuple, ...) \
571  struct name : public cls<__VA_ARGS__> \
572  { \
573  name(SST::BaseComponent* bc, const std::string& sn, const std::string& si, SST::Params& p) : \
574  cls<__VA_ARGS__>(bc, sn, si, p) \
575  {} \
576  bool ELI_isLoaded() const \
577  { \
578  return SST::ELI::InstantiateBuilderInfo<SST::Statistics::Statistic<tuple>, name>::isLoaded() && \
579  SST::ELI::InstantiateBuilder<SST::Statistics::Statistic<tuple>, name>::isLoaded() && \
580  SST::ELI::InstantiateBuilderInfo< \
581  SST::Statistics::Statistic<tuple>, SST::Statistics::NullStatistic<tuple>>::isLoaded() && \
582  SST::ELI::InstantiateBuilder< \
583  SST::Statistics::Statistic<tuple>, SST::Statistics::NullStatistic<tuple>>::isLoaded(); \
584  } \
585  };
586 #endif
587 
588 #define SST_ELI_INSTANTIATE_MULTI_STATISTIC(cls, ...) \
589  MAKE_MULTI_STATISTIC(cls, STAT_GLUE_NAME(cls, __VA_ARGS__), STAT_TUPLE(__VA_ARGS__), __VA_ARGS__)
590 
591 } // namespace Statistics
592 
593 namespace Stat {
594 namespace pvt {
595 
596 /** Helper function for re-registering statistics during simulation restart */
597 void registerStatWithEngineOnRestart(SST::Statistics::StatisticBase* s);
598 
599 } // namespace pvt
600 } // namespace Stat
601 
602 namespace Core {
603 namespace Serialization {
604 
605 template <class T>
606 class serialize_impl<Statistics::Statistic<T>*>
607 {
608  template <class A>
609  friend class serialize;
610  void operator()(Statistics::Statistic<T>*& s, serializer& ser, const char* UNUSED(name) = nullptr)
611  {
612  // For sizer and pack, need to get the information needed
613  // to create a new statistic of the correct type on unpack.
614  switch ( ser.mode() ) {
615  case serializer::SIZER:
616  case serializer::PACK:
617  {
618  Params params = s->getParams();
619  std::string stattype = s->getStatTypeName();
620  if ( stattype == "NULL" )
621  stattype = "sst.NullStatistic";
622  else
623  stattype = params.find<std::string>("type", "sst.AccumulatorStatistic");
624  BaseComponent* comp = s->getComponent();
625  ser& stattype;
626  ser& comp;
627  ser& params;
628  s->serialize_order(ser);
629  break;
630  }
631  case serializer::UNPACK:
632  {
633  Params params;
634  std::string stattype;
635  BaseComponent* comp;
636  ser& stattype;
637  ser& comp;
638  ser& params;
639  s = Factory::getFactory()->CreateWithParams<Statistics::Statistic<T>>(
640  stattype, params, comp, "", "", params);
641  s->serialize_order(ser);
642  if ( stattype != "sst.NullStatistic" ) { SST::Stat::pvt::registerStatWithEngineOnRestart(s); }
643  break;
644  }
645  case serializer::MAP:
646  // Mapping mode not supported for stats
647  break;
648  }
649  }
650 
651  // void operator()(Statistics::Statistic<T>*& UNUSED(s), serializer& UNUSED(ser), const char* UNUSED(name))
652  // {
653  // // Mapping mode not supported for stats
654  // }
655 };
656 
657 } // namespace Serialization
658 } // namespace Core
659 
660 
661 } // namespace SST
662 
663 // we need to make sure null stats are instantiated for whatever types we use
664 #include "sst/core/statapi/statnull.h"
665 
666 #endif // SST_CORE_STATAPI_STATBASE_H
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:43
void setFlagOutputAtEndOfSim(bool flag)
Set the Output At End Of Sim flag.
Definition: statbase.h:91
virtual void setCollectionCountLimit(uint64_t newLimit)
Set the collection count limit to a defined value.
Definition: statbase.cc:108
bool isOutputEnabled() const
Return the enable status of the Statistic&#39;s ability to output data.
Definition: statbase.h:131
void delayCollection(const char *delayTime)
Delay the statistic from collecting data for a specified delay time.
Definition: statbase.cc:190
void setFlagClearDataOnOutput(bool flag)
Set the Clear Data On Output flag.
Definition: statbase.h:86
Forms the base class for statistics output generation within the SST core.
Definition: statoutput.h:50
void addData(InArgs &&... args)
Add data to the Statistic This will call the addData_impl() routine in the derived Statistic...
Definition: statbase.h:366
const StatisticFieldInfo::fieldType_t & getStatDataType() const
Return the Statistic data type.
Definition: statbase.h:110
Base serialize class.
Definition: serialize.h:45
Forms the base class for statistics gathering within SST.
Definition: statbase.h:45
virtual void addData_impl_Ntimes(uint64_t N, T data)
addData_impl_Ntimes Add the same data N times in a row By default, this just calls the addData functi...
Definition: statbase.h:304
const std::string & getStatName() const
Return the Statistic Name.
Definition: statbase.h:98
void setStatisticTypeName(const char *typeName)
Set an optional Statistic Type Name.
Definition: statbase.h:202
const char * getStatDataTypeFullName() const
Return the Statistic data type.
Definition: statbase.h:119
Definition: action.cc:18
void enable()
Enable Statistic for collections.
Definition: statbase.h:53
bool getFlagResetCountOnOutput() const
Return the ResetCountOnOutput flag value.
Definition: statbase.h:140
void delayOutput(const char *delayTime)
Delay the statistic from outputting data for a specified delay time.
Definition: statbase.cc:172
Forms the template defined base class for statistics gathering within SST.
Definition: elementinfo.h:45
Statistic(BaseComponent *comp, const std::string &statName, const std::string &statSubId, Params &statParams)
Construct a Statistic.
Definition: statbase.h:446
const std::string & getCompName() const
Return the Component Name.
Definition: statbase.cc:64
bool getFlagClearDataOnOutput() const
Return the ClearDataOnOutput flag value.
Definition: statbase.h:143
uint64_t getCollectionCountLimit() const
Return the collection count limit.
Definition: statbase.h:134
BaseComponent * getComponent() const
Return a pointer to the parent Component.
Definition: statbase.h:125
Serialization "gateway" object.
Definition: serialize.h:133
virtual void resetCollectionCount()
Set the current collection count to 0.
Definition: statbase.cc:102
Base type that creates the virtual addData(...) interface Used for distinguishing fundamental types...
Definition: statbase.h:290
bool getFlagOutputAtEndOfSim() const
Return the OutputAtEndOfSim flag value.
Definition: statbase.h:146
Statistic(BaseComponent *comp, const std::string &statName, const std::string &statSubId, Params &statParams)
Construct a Statistic.
Definition: statbase.h:405
Definition: paramsInfo.h:40
const char * getStatDataTypeShortName() const
Return the Statistic data type.
Definition: statbase.h:113
virtual void incrementCollectionCount(uint64_t increment)
Increment current collection count.
Definition: statbase.cc:86
Definition: statoutput.h:162
virtual bool isNullStatistic() const
Indicate if the Statistic is a NullStatistic.
Definition: statbase.h:167
bool isEnabled() const
Return the enable status of the Statistic.
Definition: statbase.h:128
Main component object for the simulation.
Definition: baseComponent.h:62
void disable()
Disable Statistic for collections.
Definition: statbase.h:56
const std::string & getStatTypeName() const
Return the Statistic type name.
Definition: statbase.h:107
Definition: statbase.h:461
StatMode_t
Statistic collection mode.
Definition: statbase.h:49
virtual void clearStatisticData()
Inform the Statistic to clear its data.
Definition: statbase.h:60
virtual void addData_impl_Ntimes(uint64_t N, Args... args)
addData_impl_Ntimes Add the same data N times in a row By default, this just calls the addData functi...
Definition: statbase.h:323
const std::string & getStatSubId() const
Return the Statistic SubId.
Definition: statbase.h:101
std::enable_if< not std::is_same< std::string, T >::value, T >::type find(const std::string &k, T default_value, bool &found) const
Find a Parameter value in the set, and return its value as a type T.
Definition: params.h:321
void setFlagResetCountOnOutput(bool flag)
Set the Reset Count On Output flag.
Definition: statbase.h:78
Parameter store.
Definition: params.h:55
Class for instantiating Components, Links and the like out of element libraries.
Definition: factory.h:43
virtual void setCollectionCount(uint64_t newCount)
Set the current collection count to a defined value.
Definition: statbase.cc:94
void setStatisticDataType(const StatisticFieldInfo::fieldType_t dataType)
Set the Statistic Data Type.
Definition: statbase.h:199
virtual void serialize_order(SST::Core::Serialization::serializer &ser) override
Serialization.
Definition: statbase.h:389
StatMode_t getRegisteredCollectionMode() const
Return the collection mode that is registered.
Definition: statbase.h:149
An SST core component that handles timing and event processing informing all registered Statistics to...
Definition: statengine.h:52
Definition: statgroup.h:29
Params & getParams()
Return the Statistic Parameters NOTE: This must be public so that it is accessible to the serialize_i...
Definition: statbase.h:173
virtual void serialize_order(SST::Core::Serialization::serializer &ser)
Serialization.
Definition: statbase.cc:223
Definition: interfaceInfo.h:18
virtual bool isReady() const
Indicate that the Statistic is Ready to be used.
Definition: statbase.h:164
StatisticBase(BaseComponent *comp, const std::string &statName, const std::string &statSubId, Params &statParams)
Construct a StatisticBase.
Definition: statbase.cc:43
const std::string & getFullStatName() const
Return the full Statistic name of Component.StatName.SubId.
Definition: statbase.h:104
uint64_t getCollectionCount() const
Return the current collection count.
Definition: statbase.h:137