gem5  v21.1.0.2
hdf5.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2019 Arm Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #ifndef __BASE_STATS_HDF5_HH__
39 #define __BASE_STATS_HDF5_HH__
40 
41 #include <H5Cpp.h>
42 
43 #include <memory>
44 #include <stack>
45 #include <string>
46 #include <vector>
47 
48 #include "base/compiler.hh"
49 #include "base/output.hh"
50 #include "base/stats/output.hh"
51 #include "base/stats/types.hh"
52 
53 namespace gem5
54 {
55 
56 GEM5_DEPRECATED_NAMESPACE(Stats, statistics);
57 namespace statistics
58 {
59 
60 class Hdf5 : public Output
61 {
62  public:
63  Hdf5(const std::string &file, unsigned chunking, bool desc, bool formulas);
64 
65  ~Hdf5();
66 
67  Hdf5() = delete;
68  Hdf5(const Hdf5 &other) = delete;
69 
70  public: // Output interface
71  void begin() override;
72  void end() override;
73  bool valid() const override;
74 
75  void beginGroup(const char *name) override;
76  void endGroup() override;
77 
78  void visit(const ScalarInfo &info) override;
79  void visit(const VectorInfo &info) override;
80  void visit(const DistInfo &info) override;
81  void visit(const VectorDistInfo &info) override;
82  void visit(const Vector2dInfo &info) override;
83  void visit(const FormulaInfo &info) override;
84  void visit(const SparseHistInfo &info) override;
85 
86  protected:
90  H5::DataSet appendVectorInfo(const VectorInfo &info);
91 
103  H5::DataSet appendStat(const Info &info, int rank, hsize_t *dims,
104  const double *data);
105 
113  void addMetaData(H5::DataSet &loc, const char *name,
114  const std::vector<const char *> &values);
115 
123  void addMetaData(H5::DataSet &loc, const char *name,
124  const std::vector<std::string> &values);
125 
133  void addMetaData(H5::DataSet &loc, const char *name,
134  const std::string &value);
135 
143  void addMetaData(H5::DataSet &loc, const char *name, double value);
144 
145  protected:
146  const std::string fname;
147  const hsize_t timeChunk;
148  const bool enableDescriptions;
149  const bool enableFormula;
150 
151  std::stack<H5::Group> path;
152 
153  unsigned dumpCount;
154  H5::H5File h5File;
155 };
156 
157 std::unique_ptr<Output> initHDF5(
158  const std::string &filename,unsigned chunking = 10,
159  bool desc = true, bool formulas = true);
160 
161 } // namespace statistics
162 } // namespace gem5
163 
164 #endif // __BASE_STATS_HDF5_HH__
types.hh
gem5::statistics::DistInfo
Definition: info.hh:201
gem5::statistics::Hdf5::visit
void visit(const ScalarInfo &info) override
Definition: hdf5.cc:132
data
const char data[]
Definition: circlebuf.test.cc:48
gem5::statistics::VectorInfo
Definition: info.hh:184
gem5::statistics::Hdf5::~Hdf5
~Hdf5()
Definition: hdf5.cc:76
gem5::statistics::Hdf5::endGroup
void endGroup() override
Definition: hdf5.cc:125
gem5::statistics::Hdf5::enableDescriptions
const bool enableDescriptions
Definition: hdf5.hh:148
gem5::statistics::ScalarInfo
Definition: info.hh:176
std::vector< const char * >
gem5::statistics::Hdf5::dumpCount
unsigned dumpCount
Definition: hdf5.hh:153
gem5::statistics::Hdf5::end
void end() override
Definition: hdf5.cc:91
output.hh
gem5::statistics::Hdf5::enableFormula
const bool enableFormula
Definition: hdf5.hh:149
gem5::statistics::Hdf5::appendVectorInfo
H5::DataSet appendVectorInfo(const VectorInfo &info)
Helper function to append vector stats and set their metadata.
Definition: hdf5.cc:201
gem5::statistics::Hdf5::begin
void begin() override
Definition: hdf5.cc:82
gem5::statistics::Hdf5::fname
const std::string fname
Definition: hdf5.hh:146
gem5::statistics::Hdf5::appendStat
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.
Definition: hdf5.cc:222
gem5::statistics::Hdf5::path
std::stack< H5::Group > path
Definition: hdf5.hh:151
gem5::statistics::Output
Definition: output.hh:65
gem5::statistics::Hdf5::Hdf5
Hdf5()=delete
gem5::statistics::SparseHistInfo
Definition: info.hh:251
gem5::statistics::Hdf5::h5File
H5::H5File h5File
Definition: hdf5.hh:154
compiler.hh
gem5::statistics::initHDF5
std::unique_ptr< Output > initHDF5(const std::string &filename, unsigned chunking, bool desc, bool formulas)
Definition: hdf5.cc:328
gem5::statistics::Hdf5::addMetaData
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.
Definition: hdf5.cc:284
gem5::GEM5_DEPRECATED_NAMESPACE
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
name
const std::string & name()
Definition: trace.cc:49
gem5::statistics::Hdf5
Definition: hdf5.hh:60
gem5::statistics::VectorDistInfo
Definition: info.hh:208
gem5::statistics::Hdf5::valid
bool valid() const override
Definition: hdf5.cc:99
output.hh
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::statistics::Hdf5::timeChunk
const hsize_t timeChunk
Definition: hdf5.hh:147
gem5::statistics::FormulaInfo
Definition: info.hh:245
gem5::statistics::Vector2dInfo
Definition: info.hh:226
gem5::statistics::Hdf5::beginGroup
void beginGroup(const char *name) override
Definition: hdf5.cc:106
gem5::statistics::Info
Definition: info.hh:80

Generated on Tue Sep 21 2021 12:24:58 for gem5 by doxygen 1.8.17