13 #ifndef _H_SST_CORE_ACCUMULATOR_STATISTIC_
14 #define _H_SST_CORE_ACCUMULATOR_STATISTIC_
19 #include <sst/core/sst_types.h>
20 #include <sst/core/warnmacros.h>
22 #include <sst/core/statapi/statbase.h>
23 #include <sst/core/statapi/statoutput.h>
26 namespace Statistics {
46 template <
typename NumberBase>
50 SST_ELI_DECLARE_STATISTIC_TEMPLATE(
53 "AccumulatorStatistic",
54 SST_ELI_ELEMENT_VERSION(1,0,0),
55 "Accumulate all contributions to a statistic",
61 m_sum =
static_cast<NumberBase
>(0);
62 m_sum_sq =
static_cast<NumberBase
>(0);
63 m_min = std::numeric_limits<NumberBase>::max();
64 m_max = std::numeric_limits<NumberBase>::min();
67 this->setStatisticTypeName(
"Accumulator");
80 m_sum_sq += (value * value);
81 m_min = ( value < m_min ) ? value : m_min;
82 m_max = ( value > m_max ) ? value : m_max;
129 return (count > 0) ? (m_sum / (NumberBase) count) : 0;
139 return (count > 0) ? (m_sum_sq * count) - (m_sum * m_sum) : 0;
148 return (NumberBase) std::sqrt( (
double)
getVariance() );
164 m_min = std::numeric_limits<NumberBase>::max();
165 m_max = std::numeric_limits<NumberBase>::min();
178 void outputStatisticData(
StatisticOutput* statOutput,
bool UNUSED(EndOfSimFlag))
override
195 if (mode == StatisticBase::STAT_MODE_COUNT) {
198 if (mode == StatisticBase::STAT_MODE_PERIODIC) {
210 StatisticOutput::fieldHandle_t h_sum;
211 StatisticOutput::fieldHandle_t h_sumsq;
212 StatisticOutput::fieldHandle_t h_count;
213 StatisticOutput::fieldHandle_t h_max;
214 StatisticOutput::fieldHandle_t h_min;
void addData_impl(NumberBase value) override
Present a new value to the class to be included in the statistics.
Definition: stataccumulator.h:77
NumberBase getMin()
Provides the minimum value presented so far.
Definition: stataccumulator.h:108
void registerOutputFields(StatisticOutput *statOutput) override
Called by the system to tell the Statistic to register its output fields.
Definition: stataccumulator.h:169
Forms the base class for statistics output generation within the SST core.
Definition: statoutput.h:48
fieldHandle_t registerField(const char *fieldName)
Register a field to be output (templated function)
Definition: statoutput.h:89
Allows the online gathering of statistical information about a single quantity.
Definition: stataccumulator.h:47
uint64_t getCollectionCount() const
Return the current collection count.
Definition: statbase.h:149
void clearStatisticData() override
Inform the Statistic to clear its data.
Definition: stataccumulator.h:160
Forms the template defined base class for statistics gathering within SST.
Definition: elementinfo.h:43
NumberBase getMax()
Provides the maxmimum value presented so far.
Definition: stataccumulator.h:99
NumberBase getVariance()
Get the variance of the values presented so far.
Definition: stataccumulator.h:136
NumberBase getSumSquared()
Provides the sum of each value squared presented to the class so far.
Definition: stataccumulator.h:117
virtual void outputField(fieldHandle_t fieldHandle, int32_t data)
Output field data.
Main component object for the simulation.
Definition: baseComponent.h:52
StatMode_t
Statistic collection mode.
Definition: statbase.h:67
Parameter store.
Definition: params.h:45
NumberBase getSum()
Provides the sum of the values presented so far.
Definition: stataccumulator.h:90
uint64_t getCount()
Get a count of the number of elements presented to the statistics collection so far.
Definition: stataccumulator.h:155
virtual void setCollectionCount(uint64_t newCount)
Set the current collection count to a defined value.
Definition: statbase.cc:61
NumberBase getArithmeticMean()
Get the arithmetic mean of the values presented so far.
Definition: stataccumulator.h:126
NumberBase getStandardDeviation()
Get the standard deviation of the values presented so far.
Definition: stataccumulator.h:146