12 #ifndef _H_SST_CORE_STATISTICS_OUTPUTHDF5
13 #define _H_SST_CORE_STATISTICS_OUTPUTHDF5
15 #include "sst/core/sst_types.h"
17 #include <sst/core/statapi/statoutput.h>
18 #include <sst/core/warnmacros.h>
20 DISABLE_WARN_MISSING_OVERRIDE
28 namespace Statistics {
43 SST_ELI_ELEMENT_VERSION(1,0,0),
44 "Output to an HDF5 file")
62 void implRegisteredField(fieldHandle_t fieldHandle)
override;
63 void implStopRegisterFields()
override;
66 void implStopRegisterGroup()
override;
94 void implStopOutputGroup()
override;
102 void outputField(fieldHandle_t fieldHandle, int32_t data)
override;
103 void outputField(fieldHandle_t fieldHandle, uint32_t data)
override;
104 void outputField(fieldHandle_t fieldHandle, int64_t data)
override;
105 void outputField(fieldHandle_t fieldHandle, uint64_t data)
override;
106 void outputField(fieldHandle_t fieldHandle,
float data)
override;
107 void outputField(fieldHandle_t fieldHandle,
double data)
override;
126 DataSet(H5::H5File *file) : file(file) { }
127 virtual ~DataSet() { }
128 H5::H5File* getFile() {
return file; }
129 virtual bool isGroup()
const = 0;
131 virtual void setCurrentStatistic(StatisticBase *UNUSED(stat)) { }
133 virtual void finalizeCurrentStatistic() = 0;
135 virtual void beginGroupRegistration(StatisticGroup *UNUSED(group)) { }
136 virtual void finalizeGroupRegistration() { }
139 virtual void startNewGroupEntry() {}
140 virtual void finishGroupEntry() {}
142 virtual void startNewEntry(StatisticBase *stat) = 0;
143 virtual StatData_u& getFieldLoc(fieldHandle_t fieldHandle) = 0;
144 virtual void finishEntry() = 0;
150 class StatisticInfo :
public DataSet {
151 StatisticBase *statistic;
152 std::vector<fieldHandle_t> indexMap;
153 std::vector<StatData_u> currentData;
154 std::vector<fieldType_t> typeList;
155 std::vector<std::string> fieldNames;
157 H5::DataSet *dataset;
158 H5::CompType *memType;
163 StatisticInfo(StatisticBase *stat, H5::H5File *file) :
164 DataSet(file), statistic(stat), nEntries(0)
166 typeList.push_back(StatisticFieldType<uint64_t>::id());
167 indexMap.push_back(-1);
168 fieldNames.push_back(
"SimTime");
171 if ( dataset )
delete dataset;
172 if ( memType )
delete memType;
175 void finalizeCurrentStatistic()
override;
177 bool isGroup()
const override {
return false; }
178 void startNewEntry(StatisticBase *stat)
override;
179 StatData_u& getFieldLoc(fieldHandle_t fieldHandle)
override;
180 void finishEntry()
override;
183 class GroupInfo :
public DataSet {
186 std::string statPath;
188 H5::DataSet *dataset;
189 H5::CompType *memType;
193 std::vector<std::string> registeredFields;
194 std::vector<fieldType_t> typeList;
195 std::map<fieldHandle_t, size_t> handleIndexMap;
197 std::vector<StatData_u> currentData;
198 size_t currentCompOffset;
201 GroupStat(GroupInfo *group, StatisticBase *stat);
202 void finalizeRegistration();
203 static std::string getStatName(StatisticBase* stat);
205 void startNewGroupEntry();
207 void startNewEntry(
size_t componentIndex, StatisticBase *stat);
208 StatData_u& getFieldLoc(fieldHandle_t fieldHandle);
211 void finishGroupEntry();
217 std::map<std::string, GroupStat> m_statGroups;
218 GroupStat *m_currentStat;
219 StatisticGroup *m_statGroup;
220 std::vector<BaseComponent*> m_components;
221 H5::DataSet *timeDataSet;
224 GroupInfo(StatisticGroup *group, H5::H5File *file);
225 void beginGroupRegistration(StatisticGroup *UNUSED(group))
override { }
226 void setCurrentStatistic(StatisticBase *stat)
override;
228 void finalizeCurrentStatistic()
override;
229 void finalizeGroupRegistration()
override;
231 bool isGroup()
const override {
return true; }
232 void startNewEntry(StatisticBase *stat)
override;
233 StatData_u& getFieldLoc(fieldHandle_t fieldHandle)
override {
return m_currentStat->getFieldLoc(fieldHandle); }
234 void finishEntry()
override;
236 void startNewGroupEntry()
override;
237 void finishGroupEntry()
override;
238 size_t getNumComponents()
const {
return m_components.size(); }
240 const std::string& getName()
const {
return m_statGroup->name; }
245 DataSet* m_currentDataSet;
246 std::map<StatisticBase*, StatisticInfo*> m_statistics;
247 std::map<std::string, GroupInfo> m_statGroups;
250 StatisticInfo* initStatistic(StatisticBase* statistic);
251 StatisticInfo* getStatisticInfo(StatisticBase* statistic);
void outputField(fieldHandle_t fieldHandle, int32_t data) override
Implementation functions for output.
Definition: statoutputhdf5.cc:166
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
Forms the base class for statistics gathering within SST.
Definition: statbase.h:63
void implStartOutputEntries(StatisticBase *statistic) override
Implementation function for the start of output.
Definition: statoutputhdf5.cc:133
bool acceptsGroups() const override
True if this StatOutput can handle StatisticGroups.
Definition: statoutputhdf5.h:51
SST_ELI_REGISTER_DERIVED(StatisticOutput, StatisticOutputHDF5,"sst","statoutputhdf5", SST_ELI_ELEMENT_VERSION(1, 0, 0),"Output to an HDF5 file") StatisticOutputHDF5(Params &outputParameters)
Construct a StatOutputHDF5.
void implStopOutputEntries() override
Implementation function for the end of output.
Definition: statoutputhdf5.cc:140
The class for statistics output to a comma separated file.
Definition: statoutputhdf5.h:35
void startOfSimulation() override
Indicate to Statistic Output that simulation started.
Definition: statoutputhdf5.cc:117
Parameter store.
Definition: params.h:45
void printUsage() override
Print out usage for this Statistic Output.
Definition: statoutputhdf5.cc:65
void endOfSimulation() override
Indicate to Statistic Output that simulation ended.
Definition: statoutputhdf5.cc:122
bool checkOutputParameters() override
Perform a check of provided parameters.
Definition: statoutputhdf5.cc:37
Definition: statgroup.h:29