SST::Statistic(Fields)Output
StatisticOutput objects generate output for all Statistics that are registered to them. There are several built-in StatisticOutput objects in SST and custom ones can also be registered from an element library to provide additional options. The SST configuration file determines which output(s) are used and specifies their parameters, such as output frequency.
StatisticOutput and StatisticFieldsOutput
Statistics (the data object itself, not the output), are typically implemented as a derivative of the Statistic<T>
class. This class implements statistics that track data fields of type T
(e.g., histogram of int
s, accumulator of double
s, etc.). However, custom statistics can be created from a base class of Statistic<T>
called StatisticBase
. In the same way, the StatisticOutput
class is designed to handle arbitrary statistics derived from StatisticBase
while the StatisticFieldsOutput
is a derivative class designed for statistics of type Statistic<T>
. All built in statistics in SST derive from Statistic<T>
and all built-in statistic output objects derive from StatisticFieldsOutput
. This section documents the StatisticFieldsOutput
API, not the underlying StatisticOutput
API.
Creating a new StatisticFieldsOutput element
SST's StatisticEngine constructs statistic outputs, registers statistics with outputs, and triggers output according to parameters given in the SST input file. From the perspective of a StatisticFieldsOutput object, the following will happen throughout simulation.
Construction
- When SST begins, the output objects are constructed (one per rank).
- SST calls
checkOutputParameters
to ensure that the statistic output object's parameters are valid and the OutputObject constructed correctly. For example, if the output requires a filename and none was given, the output can flag that error here.- If
checkoutOutputParameters()
fails, SST will callprintUsage
.
- If
- SST calls
startOfSimulation
when the simulation is fully constructed and ready to start. Any pre-simulation preparation such as opening files can be done here.
Output generation
When output needs to be generated, the following calls to the output object will be made for each statistic registered to the output.
implStartOutputEntries
- Some number of
outputFields
- these are called by the statistic itself to generate output each of its fields in the desired format. implStopOutputEntries
End of simulation
When simulation ends, the following functions are called on each statistic output object.
endOfSimulation
- Destructor
Implementation
To implement a new StatisticFieldsOutput, create a class that inherits from SST::StatisticFieldsOutput
and uses the SST_ELI_REGISTER_DERIVED
macro to declare itself a derivative from the element type StatisticOutput
as shown below.
#include <sst/core/statapi/statoutput.h>
class ExampleStatOutput : public StatisticFieldsOutput
{
public:
SST_ELI_REGISTER_DERIVED(
StatisticOutput, // Base class name (element type)
ExampleStatOutput, // Class name
"example", // Library
"outputexample", // ELI name
SST_ELI_ELEMENT_VERSION(1,0,0), // ELI version
"Example StatisticOutput" // Description
)
// ... rest of class
};
StatisticOutput types derived from StatisticFieldOutput
should implement the following functions.
- Constructor
- Destructor
- implStartOutputEntries
- implStopOutputEntries
- checkOutputParameters
- printUsage
- startOfSimulation()
- endOfSimulation()
- outputField()
- serialize_order
Outputs may also need to implement these.
These additional functions are available for use by StatisticFieldsOutput objects.
- getAbsolutePathForOutputFile
- getCurrentSimCycle
- getFieldInfoArray
- getFieldTypeShortName
- getNumRanks
- getOutputParameters
- getRank
- getRegisteredField
- getSimulationOutput
- getStatisticOutputName
- setStatisticOutputName
- lock/unlock
Parallel considerations
In parallel SST executions, each rank has its own instance of a StatisticOutput object while threads on a rank share the same instance. Be aware of this when creating an output object that creates files. The StatisticFieldsOutput
class ensures statistics are generated serially but if an output object inherits from StatisticOutput
directly or overrides certain API functions from StatisticOutput
that StatisticFieldsOutput
provides an implementation for, the object will need to manage threading itself. Those specific functions are not documented here as they are part of the StatisticOutput
API but not part of StatisticFieldsOutput
.
Header
#include <sst/core/statapi/statoutput.h>