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