sim: move iterating over SimObjects into Python.
Review Request #27 - Created June 27, 2010 and submitted
| Information | |
|---|---|
| Steve Reinhardt | |
| gem5 | |
| Reviewers | |
| Default | |
sim: move iterating over SimObjects into Python.
Posted (June 28, 2010, 10:41 a.m.)
-
src/python/m5/SimObject.py (Diff revision 2) -
I wonder if Children doesn't quite describe it right since children doesn't obviously imply recursion. iterDescendants? (I don't have strong feelings here.)
-
src/python/m5/SimObject.py (Diff revision 2) -
Not sure if it is worth it, but we could add the following to __getattr__(self, attr): try: return getattr(self._ccObject, attr) except AttributeError: pass There are two failures, _ccObject doesn't exist yet, and attr is not found. I think both are handled by AttributeError. Anyway it's just an idea since the code looks repetitive. Could also do: if attr in ('init', 'regStats' .....): return getattr(self._ccObject, attr) Just less code and I know that you like less code :) -
src/python/m5/stats.py (Diff revision 2) -
Not sure if it matters at all, but you've changed the order of reset. Currently, we reset stats and then reset objects. I hope that nothing depends on this order, but I thought I'd mention it.
-
src/sim/sim_object.cc (Diff revision 2) -
I don't care much, but do we want to create these as DPRINTFs in the Python code? Could help in stats debugging.
Posted (July 29, 2010, 3:04 p.m.)
-
src/python/m5/SimObject.py (Diff revision 3) -
Seems like you could have a lot less code if you had a sorted=False parameter to iterChildren. You could also rely on people just calling (or implement it by doing) sorted(iterChildren(), key=lambda c: c.name)
-
src/python/m5/simulate.py (Diff revision 3) -
Why exactly is this more deterministic? It seems that if unproxying can be non-deterministic, we should flag that as an error, no?
-
src/python/m5/simulate.py (Diff revision 3) -
I'd say for easier diffing.
-
src/python/swig/sim_object.i (Diff revision 3) -
How far are we from just doing a %include of sim_object.hh?
-
src/sim/sim_object.cc (Diff revision 3) -
I like this!
Posted (July 29, 2010, 3:21 p.m.)
-
src/python/m5/SimObject.py (Diff revision 3) -
I'm not sure you'd save that many LOC, but it might be a nicer interface. Also, since you cast some doubt on one of the two places it's used, forcing the caller to use sorted() doesn't seem so bad.
-
src/python/m5/simulate.py (Diff revision 3) -
Good point... I just copied the logic and the comment from SimObject.py line 684. I agree it seems unnecessary.
-
src/python/m5/simulate.py (Diff revision 3) -
Determinism across minor code changes, so basically the same thing... but yeah.
-
src/python/swig/sim_object.i (Diff revision 3) -
Beats me, it didn't cross my mind...
Posted (July 30, 2010, 9:40 a.m.)
I tried unproxying without sorting and the regressions passed, so it looks like you were right that it's unnecessary. I then got rid of iterSortedChildren() and replaced the one remaining use with
for obj in sorted(root.iterChildren(), key=lambda o: o.path()):
obj.print_ini(ini_file)
I can upload a new diff if you want but it seemed like overkill.
As far as the naming, I guess iterChildren has kind of grown on me; the @property thing does seem like going overboard, but calling it descendants() might not be too bad. How much benefit is there in having 'iter' in there so you know it's an iterator? I'd be interested in having people other than Nate weigh in on this, since while I consider his opinions valuable, his perspective is not necessarily typical ;-).
