41 #include "pybind11/pybind11.h"
42 #include "pybind11/stl.h"
46 #include "config/have_hdf5.hh"
55 namespace py = pybind11;
60 static 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);
93 py::module_
m = py::module_::import(
"m5.stats");
100 py::module_
m = py::module_::import(
"m5.stats");
109 py::module_
m = m_native.def_submodule(
"stats");
114 py::return_value_policy::reference)
118 .def(
"registerPythonStatsHandlers",
130 py::class_<statistics::Output>(
m,
"Output")
139 std::unique_ptr<statistics::Info, py::nodelete>>(
m,
"Info")
159 std::unique_ptr<statistics::ScalarInfo, py::nodelete>>(
161 .def_property_readonly(
"value",
163 .def_property_readonly(
"result",
165 .def_property_readonly(
"total",
170 std::unique_ptr<statistics::VectorInfo, py::nodelete>>(
174 .def_property_readonly(
"size",
176 .def_property_readonly(
"value",
178 .def_property_readonly(
"result",
180 .def_property_readonly(
"total",
185 std::unique_ptr<statistics::FormulaInfo, py::nodelete>>(
187 .def_property_readonly(
"str",
192 std::unique_ptr<statistics::DistInfo, py::nodelete>>(
194 .def_property_readonly(
"min_val",
196 .def_property_readonly(
"max_val",
198 .def_property_readonly(
"bucket_size",
202 .def_property_readonly(
"values",
204 .def_property_readonly(
"overflow",
208 .def_property_readonly(
"underflow",
212 .def_property_readonly(
"sum",
214 .def_property_readonly(
"logs",
216 .def_property_readonly(
"squares",
221 std::unique_ptr<statistics::Group, py::nodelete>>(
m,
"Group")
228 auto stats =
self.getStats();
230 py_stats.reserve(stats.size());
231 std::transform(stats.begin(), stats.end(),
232 std::back_inserter(py_stats),
239 const std::string &
name) -> py::object {
242 throw pybind11::key_error(
"Unknown stat name");
DistData data
Local storage for the entry values, used for printing.
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.
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_...
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)
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
Declaration of Statistics objects.
virtual bool valid() const =0
virtual void beginGroup(const char *name)=0
virtual void endGroup()=0
const std::string & name()