Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stdlib: Improve gem5 PyStats #996

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from

Conversation

BobbyRBruce
Copy link
Member

@BobbyRBruce BobbyRBruce commented Apr 5, 2024

This PR incorporates numerous improvements and fixes to the gem5 PyStats. This includes:

  • PyStats now support SimObject Vectors. The PyStats representing them are subscribable and therefore acceptable by accessing an index: e.g.,: simobjectvec[0]. (This replaces the Vector group PyStat)
  • Adds the SparseHist PyStats.
  • Adds the Vector2d to PyStats.
  • The Distribution PyStats is fixed to be a vector of Scalars.
  • Tests added for the PyStat's Vector and bugs fixed.

@BobbyRBruce BobbyRBruce added stats The gem5 statistics code and related infrastructure stdlib The gem5 standard library. Code typically found under "src/pythongem5" labels Apr 5, 2024
@BobbyRBruce BobbyRBruce force-pushed the vector-fixes-and-improvements branch 4 times, most recently from a9665f0 to d842e35 Compare April 5, 2024 21:15
@powerjg powerjg added this to the v24.0 milestone Apr 11, 2024
@BobbyRBruce BobbyRBruce force-pushed the vector-fixes-and-improvements branch 7 times, most recently from fd4a537 to 261c501 Compare April 29, 2024 14:23
@BobbyRBruce BobbyRBruce force-pushed the vector-fixes-and-improvements branch 4 times, most recently from ee2d4f0 to 7fa7584 Compare May 2, 2024 12:19
@BobbyRBruce BobbyRBruce force-pushed the vector-fixes-and-improvements branch 7 times, most recently from e893be9 to a1c6b37 Compare May 20, 2024 11:50
@BobbyRBruce BobbyRBruce marked this pull request as ready for review May 20, 2024 11:51
@BobbyRBruce BobbyRBruce force-pushed the vector-fixes-and-improvements branch 2 times, most recently from 7dd21a7 to 515dac4 Compare May 20, 2024 13:59
@Harshil2107 Harshil2107 force-pushed the vector-fixes-and-improvements branch from 515dac4 to 350ef31 Compare May 21, 2024 19:47
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
The big thing missing from the Vector stats was that each position in
the vector could have it's own unique id (a str, float, or int) and each
position in the vector can have its own description. Therefore, to add
this the Vector is represented as a dictionary mapping the unique ID to
a Pystat Scaler (whcih can have it's own unique description.

Change-Id: I3a8634f43298f6491300cf5a4f9d25dee8101808
As Distribution inherits from Vector, it should be constructed with
a Dictionary of scalars (in our implementation, a dictionary mapping the
vector position's unique id for each bin and the value of that bin).

Change-Id: Ie603c248e5db4b6dd7f71cc453eebd78793f69a3
This appears to have no equivalent type in the CPP stats and was never
utilized in PyStats.

Change-Id: Ia9afc83b4159eb1ab2c6f44ec0ad86cd73f2a4f8
Change-Id: Icb2f691abf88ef4bac8d277e421329edb000209b
This was not used and easily confused with the other 'Vector' in
PyStats.

Change-Id: I9294bb0ae04db0537c87a5f50ce023fc83d587b8
This is inclusive of tests to ensure they have implemented correctly.

Change-Id: I5c84d5ffdb7b914936cfd86ca012a7b141eeaf42
Change-Id: Iba0c93ffa5c4b18acf75af82965c63a8881df189
1. Thests here for the Scalar tasks are named appropriately. Not just
   generic "SimStats tess".
2. We remove 'simstat' terminology. The correct word is "Pystats".

Change-Id: Idebc4e750f4be7f140ad6bff9c6772f580a24861
Change-Id: I1d93453072d12aa2dd40066f364723de1225b4e0
Change-Id: Iae12a0ac88f9646acb00e73d70f83b1e2ff94ac9
@BobbyRBruce BobbyRBruce force-pushed the vector-fixes-and-improvements branch from 350ef31 to 0f6bd24 Compare May 23, 2024 21:55
@BobbyRBruce
Copy link
Member Author

I believe I've fixed the failing tests. This should be ready for review.

Copy link
Contributor

@powerjg powerjg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small things, but overall it looks great! Thanks for the hard work!!

src/python/m5/ext/pystats/group.py Outdated Show resolved Hide resolved
src/python/m5/stats/gem5stats.py Outdated Show resolved Hide resolved
This commit addresses Jason's comment
(gem5#996 (comment)) which
highlighted putting the `_m5.stats.processDumpQueue` call in the
iteration through the `root` object in `get_simstat` caused this
function be potentially called many times when it only needs to be
called once. This chance moved this call to just before this iteration
and will tehrefore only be called once (if required) per `get_simstat`
execution.

Change-Id: I16908b6dee063a0df7877a19e215883963bfb081
src/python/m5/stats/gem5stats.py Outdated Show resolved Hide resolved
src/python/m5/ext/pystats/group.py Outdated Show resolved Hide resolved
Change-Id: Ifd3d88deebd4e72bdb8792405966d2e158e6366d
1. Adds newly added PyStat classes to "__init__.py", ensuring they can
   all be accessed via a `m5.ext.pystats` import.
2. Simplifies the layout out "__init__.py" to just import all classes
   from all files.

Change-Id: I43bfc5e7ff1aec837e661905304c6fb10b00c90e
The SimStat Object is nothing more than a group of other SimStats and is
therefore logically a group. With this, functionality can be shared more
easily.

Change-Id: I5dce23a02d5871e640b422654ca063e590b1429a
@BobbyRBruce BobbyRBruce force-pushed the vector-fixes-and-improvements branch from 2f6a0df to 92900ab Compare May 30, 2024 09:56
Bigs fixed of note:

1. The 'find' method has been fixed to work. This involved making
   'children' a class implemented per-subclass as required.
2. The 'get_all_stats_of_name' method has been removed. This was not
   working at all correctly and is largely doing what 'find' does.
2. The functionality to get an element in a vector via an attribute call
   (i.e., self.vector1 == self.vector[1]) has been implemented this
   maintaining backwards compatibility with the regular Python stats.

Change-Id: I31a4ccc723937018a3038dcdf491c82629ddbbb2
Change-Id: I6e1f4c01a52ae904e9a6c6582b5b413f94c1cb05
@BobbyRBruce BobbyRBruce force-pushed the vector-fixes-and-improvements branch from 3be5ce3 to c0a64c4 Compare May 30, 2024 10:03
Comment on lines +27 to +34
from .abstract_stat import *
from .group import *
from .jsonloader import *
from .serializable_stat import *
from .simstat import *
from .statistic import *
from .storagetype import *
from .timeconversion import *
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't like this. From PEP008

Wildcard imports (from import *) should be avoided, as they make it unclear which names are present in the namespace, confusing both readers and many automated tools.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stats The gem5 statistics code and related infrastructure stdlib The gem5 standard library. Code typically found under "src/pythongem5"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants