43 #include "debug/Stats.hh"
54 for (
const auto &
s : labels) {
67 bool desc,
bool formulas)
68 : fname(file), timeChunk(chunking),
69 enableDescriptions(desc), enableFormula(formulas),
75 H5::Exception::dontPrint();
88 dumpCount > 0 ? H5F_ACC_RDWR : H5F_ACC_TRUNC);
117 }
catch (
const H5::FileIException&
e) {
119 }
catch (
const H5::GroupIException&
e) {
129 assert(!
path.empty());
139 hsize_t fdims[1] = { 0, };
154 warn_once(
"HDF5 stat files don't support distributions.\n");
160 warn_once(
"HDF5 stat files don't support vector distributions.\n");
169 hsize_t fdims[3] = { 0, info.
x, info.
y };
170 H5::DataSet data_set =
appendStat(info, 3, fdims, info.
cvec.data());
199 warn_once(
"HDF5 stat files don't support sparse histograms.\n");
209 hsize_t fdims[2] = { 0, vr.size() };
210 H5::DataSet data_set =
appendStat(info, 2, fdims, vr.data());
226 H5::Group group =
path.top();
227 H5::DataSet data_set;
228 H5::DataSpace fspace;
235 data_set = group.openDataSet(info.
name);
236 data_set.extend(dims);
237 fspace = data_set.getSpace();
241 H5::DSetCreatPropList props;
245 std::copy(dims, dims + rank, max_dims.begin());
246 max_dims[0] = H5S_UNLIMITED;
250 std::copy(dims, dims + rank, chunk_dims.begin());
252 props.setChunk(rank, chunk_dims.data());
257 fspace = H5::DataSpace(rank, dims, max_dims.data());
259 DPRINTF(Stats,
"Creating dataset %s in group %s\n",
260 info.
name, group.getObjnameByIdx(group.getId()));
261 data_set = group.createDataSet(info.
name,
262 H5::PredType::NATIVE_DOUBLE, fspace, props);
263 }
catch (
const H5::Exception &
e) {
264 std::string
err =
"Failed creating H5::DataSet " + info.
name +
"; ";
265 err +=
e.getDetailMsg() +
" in " +
e.getFuncName();
267 throw std::runtime_error(
err);
277 H5::DataSpace mspace(rank, dims);
281 fspace.selectHyperslab(H5S_SELECT_SET, dims, foffset.data());
282 data_set.write(
data, H5::PredType::NATIVE_DOUBLE, mspace, fspace);
291 H5::StrType
type(H5::PredType::C_S1, H5T_VARIABLE);
292 hsize_t dims[1] = { values.size(), };
293 H5::DataSpace space(1, dims);
294 H5::Attribute attribute = loc.createAttribute(
name,
type, space);
295 attribute.write(
type, values.data());
303 for (
int i = 0;
i < values.size(); ++
i)
304 cstrs[
i] = values[
i].c_str();
311 const std::string &value)
313 H5::StrType
type(H5::PredType::C_S1, value.length() + 1);
314 hsize_t dims[1] = { 1, };
315 H5::DataSpace space(1, dims);
316 H5::Attribute attribute = loc.createAttribute(
name,
type, space);
317 attribute.write(
type, value.c_str());
323 hsize_t dims[1] = { 1, };
324 H5::DataSpace space(1, dims);
325 H5::Attribute attribute = loc.createAttribute(
326 name, H5::PredType::NATIVE_DOUBLE, space);
327 attribute.write(H5::PredType::NATIVE_DOUBLE, &value);
331 std::unique_ptr<Output>
332 initHDF5(
const std::string &filename,
unsigned chunking,
333 bool desc,
bool formulas)
335 return std::unique_ptr<Output>(
std::string resolve(const std::string &name) const
Returns relative file names prepended with name of this directory.
H5::DataSet appendStat(const Info &info, int rank, hsize_t *dims, const double *data)
Helper function to append an n-dimensional double stat to the file.
bool valid() const override
const bool enableDescriptions
void addMetaData(H5::DataSet &loc, const char *name, const std::vector< const char * > &values)
Helper function to add a string vector attribute to a stat.
std::stack< H5::Group > path
H5::DataSet appendVectorInfo(const VectorInfo &info)
Helper function to append vector stats and set their metadata.
void visit(const ScalarInfo &info) override
void beginGroup(const char *name) override
std::string name
The name of the stat.
std::string desc
The description of the stat.
virtual Result result() const =0
std::vector< std::string > subdescs
std::vector< std::string > y_subnames
std::vector< std::string > subnames
Names and descriptions of subfields.
VCounter cvec
Local storage for the entry values, used for printing.
virtual const VResult & result() const =0
std::vector< std::string > subdescs
std::vector< std::string > subnames
Names and descriptions of subfields.
std::unique_ptr< Output > initHDF5(const std::string &filename, unsigned chunking, bool desc, bool formulas)
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
bool emptyStrings(const T &labels)
Check if all strings in a container are empty.
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
const std::string & name()