12 #ifndef SST_CORE_STATAPI_STATOUTPUTHDF5_H
13 #define SST_CORE_STATAPI_STATOUTPUTHDF5_H
15 #include "sst/core/sst_types.h"
16 #include "sst/core/statapi/statoutput.h"
17 #include "sst/core/warnmacros.h"
19 DISABLE_WARN_MISSING_OVERRIDE
27 namespace Statistics {
42 SST_ELI_ELEMENT_VERSION(1,0,0),
43 "Output to an HDF5 file")
56 bool checkOutputParameters()
override;
59 void printUsage()
override;
62 void implRegisteredField(fieldHandle_t fieldHandle)
override;
63 void stopRegisterFields()
override;
66 void stopRegisterGroup()
override;
71 void startOfSimulation()
override;
76 void endOfSimulation()
override;
84 void implStartOutputEntries(
StatisticBase* statistic)
override;
91 void implStopOutputEntries()
override;
94 void stopOutputGroup()
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;
125 DataSet(H5::H5File* file) : file(file) {}
126 virtual ~DataSet() {}
127 H5::H5File* getFile() {
return file; }
128 virtual bool isGroup()
const = 0;
130 virtual void setCurrentStatistic(StatisticBase* UNUSED(stat)) {}
132 virtual void finalizeCurrentStatistic() = 0;
134 virtual void beginGroupRegistration(StatisticGroup* UNUSED(group)) {}
135 virtual void finalizeGroupRegistration() {}
137 virtual void startNewGroupEntry() {}
138 virtual void finishGroupEntry() {}
140 virtual void startNewEntry(StatisticBase* stat) = 0;
141 virtual StatData_u& getFieldLoc(fieldHandle_t fieldHandle) = 0;
142 virtual void finishEntry() = 0;
148 class StatisticInfo :
public DataSet
150 StatisticBase* statistic;
151 std::vector<fieldHandle_t> indexMap;
152 std::vector<StatData_u> currentData;
153 std::vector<fieldType_t> typeList;
154 std::vector<std::string> fieldNames;
156 H5::DataSet* dataset;
157 H5::CompType* memType;
162 StatisticInfo(StatisticBase* stat, H5::H5File* file) : DataSet(file), statistic(stat), nEntries(0)
164 typeList.push_back(StatisticFieldType<uint64_t>::id());
165 indexMap.push_back(-1);
166 fieldNames.push_back(
"SimTime");
170 if ( dataset )
delete dataset;
171 if ( memType )
delete memType;
174 void finalizeCurrentStatistic()
override;
176 bool isGroup()
const override {
return false; }
177 void startNewEntry(StatisticBase* stat)
override;
178 StatData_u& getFieldLoc(fieldHandle_t fieldHandle)
override;
179 void finishEntry()
override;
182 class GroupInfo :
public DataSet
187 std::string statPath;
189 H5::DataSet* dataset;
190 H5::CompType* memType;
194 std::vector<std::string> registeredFields;
195 std::vector<fieldType_t> typeList;
196 std::map<fieldHandle_t, size_t> handleIndexMap;
198 std::vector<StatData_u> currentData;
199 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();
215 std::map<std::string, GroupStat> m_statGroups;
216 GroupStat* m_currentStat;
217 StatisticGroup* m_statGroup;
218 std::vector<BaseComponent*> m_components;
219 H5::DataSet* timeDataSet;
222 GroupInfo(StatisticGroup* group, H5::H5File* file);
223 void beginGroupRegistration(StatisticGroup* UNUSED(group))
override {}
224 void setCurrentStatistic(StatisticBase* stat)
override;
226 void finalizeCurrentStatistic()
override;
227 void finalizeGroupRegistration()
override;
229 bool isGroup()
const override {
return true; }
230 void startNewEntry(StatisticBase* stat)
override;
231 StatData_u& getFieldLoc(fieldHandle_t fieldHandle)
override {
return m_currentStat->getFieldLoc(fieldHandle); }
232 void finishEntry()
override;
234 void startNewGroupEntry()
override;
235 void finishGroupEntry()
override;
236 size_t getNumComponents()
const {
return m_components.size(); }
238 const std::string& getName()
const;
242 DataSet* m_currentDataSet;
243 std::map<StatisticBase*, StatisticInfo*> m_statistics;
244 std::map<std::string, GroupInfo> m_statGroups;
246 StatisticInfo* initStatistic(StatisticBase* statistic);
247 StatisticInfo* getStatisticInfo(StatisticBase* statistic);
253 #endif // SST_CORE_STATAPI_STATOUTPUTHDF5_H
Forms the base class for statistics output generation within the SST core.
Definition: statoutput.h:49
Forms the base class for statistics gathering within SST.
Definition: statbase.h:63
fieldHandle_t registerField(const char *fieldName)
Register a field to be output (templated function)
Definition: statoutput.h:239
bool acceptsGroups() const override
True if this StatOutput can handle StatisticGroups.
Definition: statoutputhdf5.h:50
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.
Definition: statoutput.h:142
The class for statistics output to a comma separated file.
Definition: statoutputhdf5.h:34
Parameter store.
Definition: params.h:55
Definition: statgroup.h:27