Review Board 2.0.15


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 (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 ;-).