SST  14.1.0
StructuralSimulationToolkit
coreTest_StatisticsComponent.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_CORETEST_STATISTICSCOMPONENT_H
13 #define SST_CORE_CORETEST_STATISTICSCOMPONENT_H
14 
15 #include "sst/core/component.h"
16 #include "sst/core/rng/rng.h"
17 
18 using namespace SST;
19 using namespace SST::RNG;
20 using namespace SST::Statistics;
21 
22 namespace SST {
23 namespace CoreTestStatisticsComponent {
24 
26 {
27 public:
28  // REGISTER THIS COMPONENT INTO THE ELEMENT LIBRARY
29  SST_ELI_REGISTER_COMPONENT(
31  "coreTestElement",
32  "StatisticsComponent.int",
33  SST_ELI_ELEMENT_VERSION(1,0,0),
34  "Statistics test component with ints",
35  COMPONENT_CATEGORY_UNCATEGORIZED
36  )
37 
38  SST_ELI_DOCUMENT_PARAMS(
39  { "seed_w", "The seed to use for the random number generator", "7" },
40  { "seed_z", "The seed to use for the random number generator", "5" },
41  { "seed", "The seed to use for the random number generator.", "11" },
42  { "rng", "The random number generator to use (Marsaglia or Mersenne), default is Mersenne", "Mersenne"},
43  { "count", "The number of random numbers to generate, default is 1000", "1000" }
44  )
45 
46  SST_ELI_DOCUMENT_STATISTICS(
47  { "stat1_U32", "Test Statistic 1 - Collecting U32 Data", "units", 1},
48  { "stat2_U64", "Test Statistic 2 - Collecting U64 Data", "units", 2},
49  { "stat3_I32", "Test Statistic 3 - Collecting I32 Data", "units", 3},
50  { "stat4_I64", "Test Statistic 4 - Collecting I64 Data", "units", 4},
51  { "stat5_U32", "Test Statistic 5 - Collecting U32 Data", "units", 5},
52  { "stat6_U64", "Test Statistic 6 - Collecting U64 Data", "units", 6}
53  )
54 
55  // Optional since there is nothing to document
56  SST_ELI_DOCUMENT_PORTS(
57  )
58 
59  // Optional since there is nothing to document
60  SST_ELI_DOCUMENT_SUBCOMPONENT_SLOTS(
61  )
62 
63  StatisticsComponentInt(ComponentId_t id, Params& params);
64  void setup() {}
65  void finish() {}
66 
67 private:
69  StatisticsComponentInt(const StatisticsComponentInt&); // do not implement
70  void operator=(const StatisticsComponentInt&); // do not implement
71 
72  virtual bool Clock1Tick(SST::Cycle_t);
73 
74  Random* rng;
75  std::string rng_type;
76  int rng_max_count;
77  int rng_count;
78  Output& output;
79 
80  // Statistics
81  Statistic<uint32_t>* stat1_U32;
82  Statistic<uint64_t>* stat2_U64;
83  Statistic<int32_t>* stat3_I32;
84  Statistic<int64_t>* stat4_I64;
85 };
86 
88 {
89 public:
90  // REGISTER THIS COMPONENT INTO THE ELEMENT LIBRARY
91  SST_ELI_REGISTER_COMPONENT(
93  "coreTestElement",
94  "StatisticsComponent.float",
95  SST_ELI_ELEMENT_VERSION(1,0,0),
96  "Statistics test component with floats",
97  COMPONENT_CATEGORY_UNCATEGORIZED
98  )
99 
100  SST_ELI_DOCUMENT_PARAMS(
101  { "seed_w", "The seed to use for the random number generator", "7" },
102  { "seed_z", "The seed to use for the random number generator", "5" },
103  { "seed", "The seed to use for the random number generator.", "11" },
104  { "rng", "The random number generator to use (Marsaglia or Mersenne), default is Mersenne", "Mersenne"},
105  { "count", "The number of random numbers to generate, default is 1000", "1000" }
106  )
107 
108  SST_ELI_DOCUMENT_STATISTICS(
109  { "stat1_F32", "Test Statistic 1 - Collecting F32 Data", "units", 1},
110  { "stat2_F64", "Test Statistic 2 - Collecting F64 Data", "units", 2},
111  { "stat3_F64", "Test Statistic 2 - Collecting F64 Data", "units", 9},
112  )
113 
114  // Optional since there is nothing to document
115  SST_ELI_DOCUMENT_PORTS(
116  )
117 
118  // Optional since there is nothing to document
119  SST_ELI_DOCUMENT_SUBCOMPONENT_SLOTS(
120  )
121 
122  StatisticsComponentFloat(ComponentId_t id, Params& params);
123  void setup() {}
124  void finish() {}
125 
126 private:
128  StatisticsComponentFloat(const StatisticsComponentFloat&); // do not implement
129  void operator=(const StatisticsComponentFloat&); // do not implement
130 
131  virtual bool Clock1Tick(SST::Cycle_t);
132 
133  Random* rng;
134  std::string rng_type;
135  int rng_max_count;
136  int rng_count;
137  Output& output;
138 
139  // Statistics
140  Statistic<float>* stat1_F32;
141  Statistic<double>* stat2_F64;
142  Statistic<double>* stat3_F64; // For testing stat sharing
143 };
144 
145 } // namespace CoreTestStatisticsComponent
146 } // namespace SST
147 
148 #endif // SST_CORE_CORETEST_STATISTICSCOMPONENT_H
Output object provides consistent method for outputting data to stdout, stderr and/or sst debug file...
Definition: output.h:53
Implements the base class for random number generators for the SST core.
Definition: rng.h:29
Definition: constant.h:21
void setup()
Called after all components have been constructed and initialization has completed, but before simulation time has begun.
Definition: coreTest_StatisticsComponent.h:64
void setup()
Called after all components have been constructed and initialization has completed, but before simulation time has begun.
Definition: coreTest_StatisticsComponent.h:123
Main component object for the simulation.
Definition: component.h:30
void finish()
Called after complete phase, but before objects are destroyed.
Definition: coreTest_StatisticsComponent.h:124
Definition: action.cc:18
void finish()
Called after complete phase, but before objects are destroyed.
Definition: coreTest_StatisticsComponent.h:65
Parameter store.
Definition: params.h:55
Definition: coreTest_StatisticsComponent.h:87
Definition: coreTest_StatisticsComponent.h:25
Definition: elementinfo.h:43