changeset 3caf131d7a95 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=3caf131d7a95
description:
ruby: changes how Topologies are created
Instead of just passing a list of controllers to the makeTopology
function
in src/mem/ruby/network/topologies/<Topo>.py we pass in a function
pointer
which knows how to make the topology, possibly with some extra state set
in the configs/ruby/<protocol>.py file. Thus, we can move all of the
files
from network/topologies to configs/topologies. A new class BaseTopology
is added which all topologies in configs/topologies must inheirit from
and
follow its API.
diffstat:
configs/example/ruby_direct_test.py | 1 +
configs/example/ruby_fs.py | 1 +
configs/example/ruby_mem_test.py | 1 +
configs/example/ruby_network_test.py | 1 +
configs/example/ruby_random_test.py | 1 +
configs/example/se.py | 1 +
configs/ruby/MESI_CMP_directory.py | 5 +-
configs/ruby/MI_example.py | 5 +-
configs/ruby/MOESI_CMP_directory.py | 5 +-
configs/ruby/MOESI_CMP_token.py | 5 +-
configs/ruby/MOESI_hammer.py | 5 +-
configs/ruby/Network_test.py | 5 +-
configs/ruby/Ruby.py | 28 ++-
configs/topologies/BaseTopology.py | 51 +++++++
configs/topologies/Cluster.py | 117 ++++++++++++++++++
configs/topologies/Crossbar.py | 56 ++++++++
configs/topologies/Mesh.py | 114 +++++++++++++++++
configs/topologies/MeshDirCorners.py | 134 +++++++++++++++++++++
configs/topologies/Pt2Pt.py | 60 +++++++++
configs/topologies/Torus.py | 126 +++++++++++++++++++
src/mem/ruby/network/topologies/Crossbar.py | 51 -------
src/mem/ruby/network/topologies/Mesh.py | 114 -----------------
src/mem/ruby/network/topologies/MeshDirCorners.py | 132 --------------------
src/mem/ruby/network/topologies/Pt2Pt.py | 57 --------
src/mem/ruby/network/topologies/SConscript | 6 +-
src/mem/ruby/network/topologies/TopologyCreator.py | 19 ++
src/mem/ruby/network/topologies/Torus.py | 126 -------------------
src/python/m5/SimObject.py | 13 +-
28 files changed, 736 insertions(+), 504 deletions(-)
diffs (truncated from 1480 to 300 lines):
diff -r 7dee77da691b -r 3caf131d7a95 configs/example/ruby_direct_test.py
--- a/configs/example/ruby_direct_test.py Mon Jul 09 12:35:46 2012 -0400
+++ b/configs/example/ruby_direct_test.py Tue Jul 10 22:51:53 2012 -0700
@@ -35,6 +35,7 @@
import os, optparse, sys
addToPath('../common')
addToPath('../ruby')
+addToPath('../topologies')
import Options
import Ruby
diff -r 7dee77da691b -r 3caf131d7a95 configs/example/ruby_fs.py
--- a/configs/example/ruby_fs.py Mon Jul 09 12:35:46 2012 -0400
+++ b/configs/example/ruby_fs.py Tue Jul 10 22:51:53 2012 -0700
@@ -40,6 +40,7 @@
addToPath('../common')
addToPath('../ruby')
+addToPath('../topologies')
import Ruby
diff -r 7dee77da691b -r 3caf131d7a95 configs/example/ruby_mem_test.py
--- a/configs/example/ruby_mem_test.py Mon Jul 09 12:35:46 2012 -0400
+++ b/configs/example/ruby_mem_test.py Tue Jul 10 22:51:53 2012 -0700
@@ -35,6 +35,7 @@
import os, optparse, sys
addToPath('../common')
addToPath('../ruby')
+addToPath('../topologies')
import Options
import Ruby
diff -r 7dee77da691b -r 3caf131d7a95 configs/example/ruby_network_test.py
--- a/configs/example/ruby_network_test.py Mon Jul 09 12:35:46 2012 -0400
+++ b/configs/example/ruby_network_test.py Tue Jul 10 22:51:53 2012 -0700
@@ -35,6 +35,7 @@
import os, optparse, sys
addToPath('../common')
addToPath('../ruby')
+addToPath('../topologies')
import Options
import Ruby
diff -r 7dee77da691b -r 3caf131d7a95 configs/example/ruby_random_test.py
--- a/configs/example/ruby_random_test.py Mon Jul 09 12:35:46 2012 -0400
+++ b/configs/example/ruby_random_test.py Tue Jul 10 22:51:53 2012 -0700
@@ -35,6 +35,7 @@
import os, optparse, sys
addToPath('../common')
addToPath('../ruby')
+addToPath('../topologies')
import Options
import Ruby
diff -r 7dee77da691b -r 3caf131d7a95 configs/example/se.py
--- a/configs/example/se.py Mon Jul 09 12:35:46 2012 -0400
+++ b/configs/example/se.py Tue Jul 10 22:51:53 2012 -0700
@@ -52,6 +52,7 @@
addToPath('../common')
addToPath('../ruby')
+addToPath('../topologies')
import Options
import Ruby
diff -r 7dee77da691b -r 3caf131d7a95 configs/ruby/MESI_CMP_directory.py
--- a/configs/ruby/MESI_CMP_directory.py Mon Jul 09 12:35:46 2012 -0400
+++ b/configs/ruby/MESI_CMP_directory.py Tue Jul 10 22:51:53 2012 -0700
@@ -31,6 +31,7 @@
import m5
from m5.objects import *
from m5.defines import buildEnv
+from Ruby import create_topology
#
# Note: the L1 Cache latency is only used by the sequencer on fast path hits
@@ -185,4 +186,6 @@
dir_cntrl_nodes + \
dma_cntrl_nodes
- return (cpu_sequencers, dir_cntrl_nodes, all_cntrls)
+ topology = create_topology(all_cntrls, options)
+
+ return (cpu_sequencers, dir_cntrl_nodes, topology)
diff -r 7dee77da691b -r 3caf131d7a95 configs/ruby/MI_example.py
--- a/configs/ruby/MI_example.py Mon Jul 09 12:35:46 2012 -0400
+++ b/configs/ruby/MI_example.py Tue Jul 10 22:51:53 2012 -0700
@@ -31,6 +31,7 @@
import m5
from m5.objects import *
from m5.defines import buildEnv
+from Ruby import create_topology
#
# Note: the cache latency is only used by the sequencer on fast path hits
@@ -155,4 +156,6 @@
all_cntrls = l1_cntrl_nodes + dir_cntrl_nodes + dma_cntrl_nodes
- return (cpu_sequencers, dir_cntrl_nodes, all_cntrls)
+ topology = create_topology(all_cntrls, options)
+
+ return (cpu_sequencers, dir_cntrl_nodes, topology)
diff -r 7dee77da691b -r 3caf131d7a95 configs/ruby/MOESI_CMP_directory.py
--- a/configs/ruby/MOESI_CMP_directory.py Mon Jul 09 12:35:46 2012 -0400
+++ b/configs/ruby/MOESI_CMP_directory.py Tue Jul 10 22:51:53 2012 -0700
@@ -31,6 +31,7 @@
import m5
from m5.objects import *
from m5.defines import buildEnv
+from Ruby import create_topology
#
# Note: the L1 Cache latency is only used by the sequencer on fast path hits
@@ -182,4 +183,6 @@
dir_cntrl_nodes + \
dma_cntrl_nodes
- return (cpu_sequencers, dir_cntrl_nodes, all_cntrls)
+ topology = create_topology(all_cntrls, options)
+
+ return (cpu_sequencers, dir_cntrl_nodes, topology)
diff -r 7dee77da691b -r 3caf131d7a95 configs/ruby/MOESI_CMP_token.py
--- a/configs/ruby/MOESI_CMP_token.py Mon Jul 09 12:35:46 2012 -0400
+++ b/configs/ruby/MOESI_CMP_token.py Tue Jul 10 22:51:53 2012 -0700
@@ -31,6 +31,7 @@
import m5
from m5.objects import *
from m5.defines import buildEnv
+from Ruby import create_topology
#
# Note: the L1 Cache latency is only used by the sequencer on fast path hits
@@ -206,4 +207,6 @@
dir_cntrl_nodes + \
dma_cntrl_nodes
- return (cpu_sequencers, dir_cntrl_nodes, all_cntrls)
+ topology = create_topology(all_cntrls, options)
+
+ return (cpu_sequencers, dir_cntrl_nodes, topology)
diff -r 7dee77da691b -r 3caf131d7a95 configs/ruby/MOESI_hammer.py
--- a/configs/ruby/MOESI_hammer.py Mon Jul 09 12:35:46 2012 -0400
+++ b/configs/ruby/MOESI_hammer.py Tue Jul 10 22:51:53 2012 -0700
@@ -31,6 +31,7 @@
import m5
from m5.objects import *
from m5.defines import buildEnv
+from Ruby import create_topology
#
# Note: the L1 Cache latency is only used by the sequencer on fast path hits
@@ -219,4 +220,6 @@
all_cntrls = l1_cntrl_nodes + dir_cntrl_nodes + dma_cntrl_nodes
- return (cpu_sequencers, dir_cntrl_nodes, all_cntrls)
+ topology = create_topology(all_cntrls, options)
+
+ return (cpu_sequencers, dir_cntrl_nodes, topology)
diff -r 7dee77da691b -r 3caf131d7a95 configs/ruby/Network_test.py
--- a/configs/ruby/Network_test.py Mon Jul 09 12:35:46 2012 -0400
+++ b/configs/ruby/Network_test.py Tue Jul 10 22:51:53 2012 -0700
@@ -31,6 +31,7 @@
from m5.objects import *
from m5.defines import buildEnv
from m5.util import addToPath
+from Ruby import create_topology
#
# Note: the cache latency is only used by the sequencer on fast path hits
@@ -135,4 +136,6 @@
all_cntrls = l1_cntrl_nodes + dir_cntrl_nodes
- return (cpu_sequencers, dir_cntrl_nodes, all_cntrls)
+ topology = create_topology(all_cntrls, options)
+
+ return (cpu_sequencers, dir_cntrl_nodes, topology)
diff -r 7dee77da691b -r 3caf131d7a95 configs/ruby/Ruby.py
--- a/configs/ruby/Ruby.py Mon Jul 09 12:35:46 2012 -0400
+++ b/configs/ruby/Ruby.py Tue Jul 10 22:51:53 2012 -0700
@@ -79,6 +79,16 @@
exec "import %s" % protocol
eval("%s.define_options(parser)" % protocol)
+def create_topology(controllers, options):
+ """ Called from create_system in configs/ruby/<protocol>.py
+ Must return an object which is a subclass of BaseTopology
+ found in configs/topologies/BaseTopology.py
+ This is a wrapper for the legacy topologies.
+ """
+ exec "import %s as Topo" % options.topology
+ topology = eval("Topo.%s(controllers)" % options.topology)
+ return topology
+
def create_system(options, system, piobus = None, dma_ports = []):
system.ruby = RubySystem(clock = options.clock,
@@ -89,7 +99,7 @@
protocol = buildEnv['PROTOCOL']
exec "import %s" % protocol
try:
- (cpu_sequencers, dir_cntrls, all_cntrls) = \
+ (cpu_sequencers, dir_cntrls, topology) = \
eval("%s.create_system(options, system, piobus, dma_ports, ruby)"
% protocol)
except:
@@ -128,17 +138,17 @@
class RouterClass(BasicRouter): pass
#
- # Important: the topology must be created before the network and after the
- # controllers.
+ # Important: the topology must be instantiated before the network and after
+ # the controllers. Hence the separation between topology definition and
+ # instantiation. TopologyCreator is in src/mem/ruby/network/topologies/.
#
- exec "import %s" % options.topology
+ from TopologyCreator import instantiateTopology
try:
- net_topology = eval("%s.makeTopology(all_cntrls, options, \
- IntLinkClass, ExtLinkClass, \
- RouterClass)" \
- % options.topology)
+ net_topology = instantiateTopology(topology, options, \
+ IntLinkClass, ExtLinkClass, \
+ RouterClass)
except:
- print "Error: could not create topology %s" % options.topology
+ print "Error: could not make topology %s" % options.topology
raise
if options.network_fault_model:
diff -r 7dee77da691b -r 3caf131d7a95 configs/topologies/BaseTopology.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/configs/topologies/BaseTopology.py Tue Jul 10 22:51:53 2012 -0700
@@ -0,0 +1,51 @@
+# Copyright (c) 2012 Advanced Micro Devices, Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met: redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer;
+# redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution;
+# neither the name of the copyright holders nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# Authors: Jason Power
+
+
+class BaseTopology(object):
+ description = "BaseTopology"
+
+ def __init__(self):
+ """ When overriding place any objects created in
+ configs/ruby/<protocol>.py that are needed in
+ makeTopology (below) here. The minimum is usually
+ all of the controllers created in the above file.
+ """
+
+ def makeTopology(self, options, IntLink, ExtLink, Router):
+ """ Called from src/mem/ruby/network/topologies/TopologyCreatory.py
+ The return value is ( list(Router), list(IntLink), list(ExtLink))
+ The API of this function cannot change when subclassing!!
+ Any additional information needed to create this topology should
+ be passed into the constructor when it's instantiated in
+ configs/ruby/<protocol>.py
+ """
+ print "BaseTopology should have been overridden in a sub class!!"
+ import sys
+ sys.exit(1)
+
diff -r 7dee77da691b -r 3caf131d7a95 configs/topologies/Cluster.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/configs/topologies/Cluster.py Tue Jul 10 22:51:53 2012 -0700
@@ -0,0 +1,117 @@
+# Copyright (c) 2012 Advanced Micro Devices, Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met: redistributions of source code must retain the above copyright
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev