41#include "pybind11/pybind11.h"
42#include "pybind11/stl.h"
46#include "config/have_hdf5.hh"
55namespace py = pybind11;
60static const py::object
66#define TRY_CAST(T) do { \
67 auto _stat = dynamic_cast<const T *>(info); \
69 return py::cast(_stat); \
81 return py::cast(info);
92 py::module_
m = py::module_::import(
"m5.stats");
99 py::module_
m = py::module_::import(
"m5.stats");
108 py::module_
m = m_native.def_submodule(
"stats");
113 py::return_value_policy::reference)
117 .def(
"registerPythonStatsHandlers",
129 py::class_<statistics::Output>(
m,
"Output")
138 std::unique_ptr<statistics::Info, py::nodelete>>(
m,
"Info")
158 std::unique_ptr<statistics::ScalarInfo, py::nodelete>>(
160 .def_property_readonly(
"value",
162 .def_property_readonly(
"result",
164 .def_property_readonly(
"total",
169 std::unique_ptr<statistics::VectorInfo, py::nodelete>>(
173 .def_property_readonly(
"size",
175 .def_property_readonly(
"value",
177 .def_property_readonly(
"result",
179 .def_property_readonly(
"total",
184 std::unique_ptr<statistics::FormulaInfo, py::nodelete>>(
186 .def_property_readonly(
"str",
191 std::unique_ptr<statistics::DistInfo, py::nodelete>>(
193 .def_property_readonly(
"min_val",
195 .def_property_readonly(
"max_val",
197 .def_property_readonly(
"bucket_size",
201 .def_property_readonly(
"values",
203 .def_property_readonly(
"overflow",
207 .def_property_readonly(
"underflow",
211 .def_property_readonly(
"sum",
213 .def_property_readonly(
"logs",
215 .def_property_readonly(
"squares",
220 std::unique_ptr<statistics::Group, py::nodelete>>(
m,
"Group")
229 py_stats.reserve(stats.size());
230 std::transform(stats.begin(), stats.end(),
231 std::back_inserter(py_stats),
238 const std::string &
name) -> py::object {
241 throw pybind11::key_error(
"Unknown stat name");
DistData data
Local storage for the entry values, used for printing.
const Info * resolveStat(std::string name) const
Resolve a stat by its name within this group.
Flags flags
The formatting flags.
const units::Base * unit
The unit of the stat.
virtual void enable()
Enable the stat for use.
std::string name
The name of the stat.
std::string desc
The description of the stat.
virtual bool zero() const =0
virtual void prepare()=0
Prepare the stat for dumping.
virtual void reset()=0
Reset the stat to the default state.
virtual void visit(Output &visitor)=0
Visitor entry for outputing statistics data.
virtual bool check() const =0
Check that this stat has been set up properly and is ready for use.
virtual Result total() const =0
virtual Result result() const =0
virtual Counter value() const =0
std::vector< std::string > subdescs
std::vector< std::string > subnames
Names and descriptions of subfields.
virtual std::string getUnitString() const =0
const std::map< std::string, Group * > & getStatGroups() const
Get all child groups associated with this object.
const std::vector< Info * > & getStats() const
Get all stats associated with this object.
virtual void regStats()
Callback to set stat parameters.
void addStatGroup(const char *name, Group *block)
Add a stat block as a child of this block.
virtual void preDumpStats()
Callback before stats are dumped.
virtual void resetStats()
Callback to reset stats.
void schedStatEvent(bool dump, bool reset, Tick when, Tick repeat)
Schedule statistics dumping.
void processResetQueue()
Process all the callbacks in the reset callbacks queue.
std::unique_ptr< Output > initHDF5(const std::string &filename, unsigned chunking, bool desc, bool formulas)
void periodicStatDump(Tick period)
Schedule periodic statistics dumping.
void updateEvents()
Update the events after resuming from a checkpoint.
void registerPythonStatsHandlers()
Register py_... functions as the statistics handlers.
std::list< Info * > & statsList()
void processDumpQueue()
Process all the callbacks in the dump callbacks queue.
Output * initText(const std::string &filename, bool desc, bool spaces)
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
void pybind_init_stats(pybind11::module_ &m_native)
static const py::object cast_stat_info(const statistics::Info *info)
Declaration of Statistics objects.
virtual bool valid() const =0
virtual void beginGroup(const char *name)=0
virtual void endGroup()=0
const std::string & name()