summaryrefslogtreecommitdiff
path: root/src/python/m5/SimObject.py
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2014-11-12 09:05:21 -0500
committerAndreas Hansson <andreas.hansson@arm.com>2014-11-12 09:05:21 -0500
commit7d0589512089402cf7bbf585c0e2b4878dc1dd6a (patch)
tree84f594bfeee7c270af3727672fce64d5872d70d8 /src/python/m5/SimObject.py
parentcc336ecb5e36a7547cecab305692a93271e0e5b8 (diff)
downloadgem5-7d0589512089402cf7bbf585c0e2b4878dc1dd6a.tar.xz
sim: Sort SimObject descendants and ports
This patch fixes a number of occurences where the sorting order of the objects was implementation defined.
Diffstat (limited to 'src/python/m5/SimObject.py')
-rw-r--r--src/python/m5/SimObject.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/python/m5/SimObject.py b/src/python/m5/SimObject.py
index 40203a307..71091ce6c 100644
--- a/src/python/m5/SimObject.py
+++ b/src/python/m5/SimObject.py
@@ -1289,7 +1289,9 @@ class SimObject(object):
match_obj = self._values[pname]
if not isproxy(match_obj) and not isNullPointer(match_obj):
all[match_obj] = True
- return all.keys(), True
+ # Also make sure to sort the keys based on the objects' path to
+ # ensure that the order is the same on all hosts
+ return sorted(all.keys(), key = lambda o: o.path()), True
def unproxy(self, base):
return self
@@ -1437,7 +1439,10 @@ class SimObject(object):
def descendants(self):
yield self
- for child in self._children.itervalues():
+ # The order of the dict is implementation dependent, so sort
+ # it based on the key (name) to ensure the order is the same
+ # on all hosts
+ for (name, child) in sorted(self._children.iteritems()):
for obj in child.descendants():
yield obj
@@ -1452,7 +1457,9 @@ class SimObject(object):
# Create C++ port connections corresponding to the connections in
# _port_refs
def connectPorts(self):
- for portRef in self._port_refs.itervalues():
+ # Sort the ports based on their attribute name to ensure the
+ # order is the same on all hosts
+ for (attr, portRef) in sorted(self._port_refs.iteritems()):
portRef.ccConnect()
# Function to provide to C++ so it can look up instances based on paths