changeset e63c6f279906 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=e63c6f279906
description:
        sim: Reuse the code to change memory mode.

        changeToAtomic and changeToTiming both do essentially the same thing,
        they check the type of their input argument, drain the system, and
        switch to the desired memory mode. This patch moves all of that code
        to a separate method (changeMemoryMode) and calls that from both
        changeToAtomic and changeToTiming.

diffstat:

 src/python/m5/simulate.py |  23 +++++++++++------------
 1 files changed, 11 insertions(+), 12 deletions(-)

diffs (39 lines):

diff -r 6fec8f26e56d -r e63c6f279906 src/python/m5/simulate.py
--- a/src/python/m5/simulate.py Fri Nov 02 11:32:01 2012 -0500
+++ b/src/python/m5/simulate.py Fri Nov 02 11:32:02 2012 -0500
@@ -192,24 +192,23 @@
     internal.core.serializeAll(dir)
     resume(root)
 
-def changeToAtomic(system):
+def changeMemoryMode(system, mode):
     if not isinstance(system, (objects.Root, objects.System)):
         raise TypeError, "Parameter of type '%s'.  Must be type %s or %s." % \
               (type(system), objects.Root, objects.System)
-    if system.getMemoryMode() != objects.params.atomic:
+    if system.getMemoryMode() != mode:
         doDrain(system)
-        print "Changing memory mode to atomic"
-        system.setMemoryMode(objects.params.atomic)
+        system.setMemoryMode(mode)
+    else:
+        print "System already in target mode. Memory mode unchanged."
 
-def changeToTiming(system):
-    if not isinstance(system, (objects.Root, objects.System)):
-        raise TypeError, "Parameter of type '%s'.  Must be type %s or %s." % \
-              (type(system), objects.Root, objects.System)
+def changeToAtomic(system, **kwargs):
+    print "Changing memory mode to atomic"
+    changeMemoryMode(system, objects.params.atomic, **kwargs)
 
-    if system.getMemoryMode() != objects.params.timing:
-        doDrain(system)
-        print "Changing memory mode to timing"
-        system.setMemoryMode(objects.params.timing)
+def changeToTiming(system, **kwargs):
+    print "Changing memory mode to timing"
+    changeMemoryMode(system, objects.params.timing, **kwargs)
 
 def switchCpus(cpuList):
     print "switching cpus"
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to