Commit Graph

12 Commits

Author SHA1 Message Date
Bobby R. Bruce
3c86175d08 stdlib: Rename BaseScalarVector -> Vector
This isn't a true Base class, it's just a Vector. In gem5 all Vectors
are Scalar Vectors. This change simplfies the naming.

Change-Id: Ib8881d854ab18de6acbf0fb200db2de6a43621a7
2024-05-23 14:54:58 -07:00
Bobby R. Bruce
8d7e3fb16b stdlib: Move SimStat 'unit' and 'datatype' field to Scalar (#970)
These are not general statistic properties and better put as a property
of a Scalar value.
2024-04-04 10:02:22 -07:00
Bobby R. Bruce
213b418391 stdlib: Specify typing for SimStat Scalar value (#971) 2024-04-04 08:34:20 -07:00
Ivana Mitrovic
d96b6cdae7 misc, stdlib: Update documentation to adhere to RST formatting. (#631)
This PR updates files in `src/python` to adhere to reStructuredText
formatting.
2023-12-01 11:43:49 -08:00
Bobby R. Bruce
d11c40dcac misc: Run pre-commit run --all-files
This ensures `isort` is applied to all files in the repo.

Change-Id: Ib7ced1c924ef1639542bf0d1a01c5737f6ba43e9
2023-11-29 22:06:41 -08:00
Bobby R. Bruce
b65fa9e0d8 python: Add AbstractStat for PyStats
Previously all PyStats inheritted from JsonSerializable. The
AbstractStat class has been added to give a cleaner, clearer Base class
for PyStats.

Change-Id: I7e1808c4b4dcd6110fd524ad3553a9dc19f72e24
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/63691
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-11-03 22:32:36 +00:00
Bobby R. Bruce
4a06375212 stdlib: Add __repr__ to pystats
For Statistics the value is returned. E.g.:

```
print(simstats.board.core.some_integer)
> 5
```

For Groups the names of the stats in that group are listed.
E.g.:

```
print(stats.board.core)
> [Group: [some_integer, another_stat, another_group]]
```

Change-Id: I94cea907608fba622f4fc141d5b22ac95d8cde40
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/63271
Tested-by: kokoro <noreply+kokoro@google.com>
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
2022-11-03 22:32:36 +00:00
Bobby R. Bruce
5204b58e19 stdlib: Rename JsonSerializable to SerializableStat
As this abstract class now allows the output of text stats, it's more
appropriate to rename it. It no longer handles processing just for JSON
output

Change-Id: Ia9a1e3ef4029de45a11ac261fb14c9bdfa412cdd
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/59273
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
2022-11-03 22:32:36 +00:00
Bobby R. Bruce
787204c92d python: Apply Black formatter to Python files
The command executed was `black src configs tests util`.

Change-Id: I8dfaa6ab04658fea37618127d6ac19270028d771
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/47024
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-08-03 09:10:41 +00:00
Gabe Black
ba5f68db3d misc: Use python 3's argumentless super().
When calling a method in a superclass, you can/should use the super()
method to get a reference to that class. The python 2 version of that
method takes two parameters, the current class name, and the "self"
instance. The python 3 version takes no arguments. This is better for a
at least three reasons.

First, this version is less verbose because you don't have to specify
any arguments.

Second, you don't have to remember which argument goes where (I always
have to look it up), and you can't accidentally use the wrong class
name, or forget to update it if you copy code from a different class.

Third, this version will work correctly if you use a class decorator.
I don't know exactly how the mechanics of this work, but it is referred
to in a comment on this stackoverflow question:

https://stackoverflow.com/questions/681953/how-to-decorate-a-class

Change-Id: I427737c8f767e80da86cd245642e3b057121bc3b
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/52224
Reviewed-by: Gabe Black <gabe.black@gmail.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-11-09 13:04:44 +00:00
Jason Lowe-Power
91f4ea6683 python: Improve type annotations in pystats
This fixes some errors and warning when running mypy.

`gem5/src/python/m5/ext> mypy pystats`

There is one error that is ignored, which is a bug in mypy. See
https://github.com/python/mypy/issues/6040

Change-Id: I18b648c059da12bd30d612f0e265930b976f22b4
Signed-off-by: Jason Lowe-Power <jason@lowepower.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/42644
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-04-02 20:47:35 +00:00
Bobby R. Bruce
f11617736e base-stats,python: Add Python Stats
This model is used to store and represent the "new" hierarchical stats
at the Python level. Over time these classes may be extended with
functions to ease in the analysis of gem5 stats. Though, for this
commit, such functions have been kept to a minimum.

`m5/pystats/loader.py` contains functions for translating the gem5  `_m5.stats`
statistics exposed via Pybind11 to the Python Stats model. For example:

```
import m5.pystats.gem5stats as gem5stats

simstat = gem5stats.get_simstat(root)
```

All the python Stats model classes inherit from JsonSerializable meaning
they can be translated to JSON. For example:

```
import m5.pystats.gem5stats as gem5stats

simstat = gem5stats.get_simstat(root)
with open('test.json', 'w') as f:
    simstat.dump(f)
```

The stats have also been exposed via the python statistics API. Via
command line, a JSON output may be specified with the argument
`--stats-file json://<file path>`.

Change-Id: I253a869f6b6d8c0de4dbed708892ee0cc33c5665
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/38615
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-02-26 20:44:47 +00:00