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"
44template <
typename NumberBase>
45class AccumulatorStatistic :
public Statistic<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 ~AccumulatorStatistic() {}
68 AccumulatorStatistic() :
72 virtual const std::string&
getStatTypeName()
const override {
return stat_type_; }
93 m_sum_sq += (value * value);
94 m_min = (value < m_min) ? value : m_min;
95 m_max = (value > m_max) ? value : m_max;
98 void addData_impl_Ntimes(uint64_t N, NumberBase value)
override
101 m_sum_sq += N * value * value;
102 m_min = (value < m_min) ? value : m_min;
103 m_max = (value > m_max) ? value : m_max;
138 return (count > 0) ? (m_sum / (NumberBase)count) : 0;
148 return (count > 0) ? (m_sum_sq * count) - (m_sum * m_sum) : 0;
167 m_min = std::numeric_limits<NumberBase>::max();
168 m_max = std::numeric_limits<NumberBase>::min();
200 case StatisticBase::STAT_MODE_COUNT:
201 case StatisticBase::STAT_MODE_PERIODIC:
202 case StatisticBase::STAT_MODE_DUMP_AT_END:
216 StatisticOutput::fieldHandle_t h_sum;
217 StatisticOutput::fieldHandle_t h_sumsq;
218 StatisticOutput::fieldHandle_t h_count;
219 StatisticOutput::fieldHandle_t h_max;
220 StatisticOutput::fieldHandle_t h_min;
222 inline static const std::string stat_type_ =
"Accumulator";
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition serializer.h:45
Parameter store.
Definition params.h:58
void addData_impl(NumberBase value) override
Present a new value to the class to be included in the statistics.
Definition stataccumulator.h:90
NumberBase getVariance()
Get the variance of the values presented so far.
Definition stataccumulator.h:145
NumberBase getMax()
Provides the maxmimum value presented so far.
Definition stataccumulator.h:117
NumberBase getStandardDeviation()
Get the standard deviation of the values presented so far.
Definition stataccumulator.h:155
NumberBase getArithmeticMean()
Get the arithmetic mean of the values presented so far.
Definition stataccumulator.h:135
NumberBase getSum()
Provides the sum of the values presented so far.
Definition stataccumulator.h:111
void registerOutputFields(StatisticFieldsOutput *statOutput) override
Called by the system to tell the Statistic to register its output fields.
Definition stataccumulator.h:172
NumberBase getSumSquared()
Provides the sum of each value squared presented to the class so far.
Definition stataccumulator.h:129
void serialize_order(SST::Core::Serialization::serializer &ser) override
Serialization.
Definition stataccumulator.h:75
void clearStatisticData() override
Inform the Statistic to clear its data.
Definition stataccumulator.h:163
virtual const std::string & getStatTypeName() const override
Return the Statistic type name.
Definition stataccumulator.h:72
uint64_t getCount()
Get a count of the number of elements presented to the statistics collection so far.
Definition stataccumulator.h:161
NumberBase getMin()
Provides the minimum value presented so far.
Definition stataccumulator.h:123
virtual void setCollectionCount(uint64_t new_count)
Set the current collection count to a defined value.
Definition statbase.cc:142
StatMode_t
Statistic collection mode STAT_MODE_UNDEFINED - unknown mode STAT_MODE_COUNT - generating statistic o...
Definition statbase.h:57
uint64_t getCollectionCount() const
Return the current collection count.
Definition statbase.h:162
Definition statoutput.h:170
fieldHandle_t registerField(const char *fieldName)
Register a field to be output (templated function)
Definition statoutput.h:266
virtual void outputField(fieldHandle_t fieldHandle, int32_t data)
Output field data.
Statistic(BaseComponent *comp, const std::string &stat_name, const std::string &stat_sub_id, Params &stat_params, bool null_stat=false)
Definition statbase.h:437
virtual void serialize_order(SST::Core::Serialization::serializer &ser) override
Serialization.
Definition statbase.h:420