12 #ifndef SST_CORE_STATAPI_STATACCUMULATOR_H 13 #define SST_CORE_STATAPI_STATACCUMULATOR_H 15 #include "sst/core/sst_types.h" 16 #include "sst/core/statapi/statbase.h" 17 #include "sst/core/statapi/statoutput.h" 18 #include "sst/core/warnmacros.h" 24 namespace Statistics {
44 template <
typename NumberBase>
48 SST_ELI_DECLARE_STATISTIC_TEMPLATE(
51 "AccumulatorStatistic",
52 SST_ELI_ELEMENT_VERSION(1,0,0),
53 "Accumulate all contributions to a statistic",
57 BaseComponent* comp,
const std::string& statName,
const std::string& statSubId,
Params& statParams) :
60 m_sum =
static_cast<NumberBase
>(0);
61 m_sum_sq =
static_cast<NumberBase
>(0);
62 m_min = std::numeric_limits<NumberBase>::max();
63 m_max = std::numeric_limits<NumberBase>::min();
66 this->setStatisticTypeName(
"Accumulator");
91 m_sum_sq += (value * value);
92 m_min = (value < m_min) ? value : m_min;
93 m_max = (value > m_max) ? value : m_max;
96 void addData_impl_Ntimes(uint64_t N, NumberBase value)
override 99 m_sum_sq += N * value * value;
100 m_min = (value < m_min) ? value : m_min;
101 m_max = (value > m_max) ? value : m_max;
136 return (count > 0) ? (m_sum / (NumberBase)count) : 0;
146 return (count > 0) ? (m_sum_sq * count) - (m_sum * m_sum) : 0;
165 m_min = std::numeric_limits<NumberBase>::max();
166 m_max = std::numeric_limits<NumberBase>::min();
198 case StatisticBase::STAT_MODE_COUNT:
199 case StatisticBase::STAT_MODE_PERIODIC:
200 case StatisticBase::STAT_MODE_DUMP_AT_END:
214 StatisticOutput::fieldHandle_t h_sum;
215 StatisticOutput::fieldHandle_t h_sumsq;
216 StatisticOutput::fieldHandle_t h_count;
217 StatisticOutput::fieldHandle_t h_max;
218 StatisticOutput::fieldHandle_t h_min;
224 #endif // SST_CORE_STATAPI_STATACCUMULATOR_H void addData_impl(NumberBase value) override
Present a new value to the class to be included in the statistics.
Definition: stataccumulator.h:88
void registerOutputFields(StatisticFieldsOutput *statOutput) override
Called by the system to tell the Statistic to register its output fields.
Definition: stataccumulator.h:170
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:43
NumberBase getMin()
Provides the minimum value presented so far.
Definition: stataccumulator.h:121
Allows the online gathering of statistical information about a single quantity.
Definition: stataccumulator.h:45
void clearStatisticData() override
Inform the Statistic to clear its data.
Definition: stataccumulator.h:161
Forms the template defined base class for statistics gathering within SST.
Definition: elementinfo.h:45
NumberBase getMax()
Provides the maxmimum value presented so far.
Definition: stataccumulator.h:115
NumberBase getVariance()
Get the variance of the values presented so far.
Definition: stataccumulator.h:143
fieldHandle_t registerField(const char *fieldName)
Register a field to be output (templated function)
Definition: statoutput.h:259
virtual void outputField(fieldHandle_t fieldHandle, int32_t data)
Output field data.
NumberBase getSumSquared()
Provides the sum of each value squared presented to the class so far.
Definition: stataccumulator.h:127
Definition: statoutput.h:162
Main component object for the simulation.
Definition: baseComponent.h:62
StatMode_t
Statistic collection mode.
Definition: statbase.h:49
Parameter store.
Definition: params.h:55
NumberBase getSum()
Provides the sum of the values presented so far.
Definition: stataccumulator.h:109
uint64_t getCount()
Get a count of the number of elements presented to the statistics collection so far.
Definition: stataccumulator.h:159
virtual void setCollectionCount(uint64_t newCount)
Set the current collection count to a defined value.
Definition: statbase.cc:94
NumberBase getArithmeticMean()
Get the arithmetic mean of the values presented so far.
Definition: stataccumulator.h:133
virtual void serialize_order(SST::Core::Serialization::serializer &ser) override
Serialization.
Definition: statbase.h:389
NumberBase getStandardDeviation()
Get the standard deviation of the values presented so far.
Definition: stataccumulator.h:153
uint64_t getCollectionCount() const
Return the current collection count.
Definition: statbase.h:137
void serialize_order(SST::Core::Serialization::serializer &ser) override
Serialization.
Definition: stataccumulator.h:73