# HG changeset patch
# User Brad Beckmann <brad.beckm...@amd.com>
# Date 1263536250 28800
# Node ID 69a46a488db7cd4dbcc6ec681c3dcd2ed549c225
# Parent  c5104360b4a1dc8404138adbad93bb9d78b4bae5
ruby: Added a mesh topology

diff -r c5104360b4a1 -r 69a46a488db7 configs/common/Options.py
--- a/configs/common/Options.py Thu Jan 14 22:17:30 2010 -0800
+++ b/configs/common/Options.py Thu Jan 14 22:17:30 2010 -0800
@@ -37,6 +37,10 @@
 parser.add_option("--clock", action="store", type="string", default='1GHz')
 parser.add_option("--num-dirs", type="int", default=1)
 parser.add_option("--num-l2caches", type="int", default=1)
+parser.add_option("--topology", type="string", default="crossbar",
+                  help="'crossbar'|'mesh'")
+parser.add_option("--mesh-rows", type="int", default=1,
+                  help="the number of rows in the mesh topology")
 parser.add_option("--garnet-network", type="string", default=none,
                   help="'fixed'|'flexible'")
 
diff -r c5104360b4a1 -r 69a46a488db7 configs/ruby/Ruby.py
--- a/configs/ruby/Ruby.py      Thu Jan 14 22:17:30 2010 -0800
+++ b/configs/ruby/Ruby.py      Thu Jan 14 22:17:30 2010 -0800
@@ -80,12 +80,22 @@
     # Important: the topology constructor must be called before the network
     # constructor.
     #
+    if options.topology == "crossbar":
+        net_topology = makeCrossbar(all_cntrls)
+    elif options.topology == "mesh":
+        #
+        # The uniform mesh topology assumes one router per cpu
+        #
+        net_topology = makeMesh(all_cntrls,
+                                len(cpu_sequencers),
+                                options.mesh_rows)
+
     if options.garnet_network == "fixed":
-        network = GarnetNetwork_d(topology = makeCrossbar(all_cntrls))
+        network = GarnetNetwork_d(topology = net_topology)
     elif options.garnet_network == "flexible":
-        network = GarnetNetwork(topology = makeCrossbar(all_cntrls))
+        network = GarnetNetwork(topology = net_topology)
     else:
-        network = SimpleNetwork(topology = makeCrossbar(all_cntrls))
+        network = SimpleNetwork(topology = net_topology)
 
     #
     # determine the total memory size of the ruby system and verify it is equal
diff -r c5104360b4a1 -r 69a46a488db7 src/mem/ruby/network/Network.py
--- a/src/mem/ruby/network/Network.py   Thu Jan 14 22:17:30 2010 -0800
+++ b/src/mem/ruby/network/Network.py   Thu Jan 14 22:17:30 2010 -0800
@@ -35,6 +35,52 @@
     return Topology(ext_links=ext_links, int_links=int_links,
                     num_int_nodes=len(nodes)+1)
 
+def makeMesh(nodes, num_routers, num_rows):
+    #
+    # There must be an evenly divisible number of cntrls to routers
+    # Also, obviously the number or rows must be <= the number of routers
+    #
+    cntrls_per_router, remainder = divmod(len(nodes), num_routers)
+    assert(remainder == 0)
+    assert(num_rows <= num_routers)
+    num_columns = int(num_routers / num_rows)
+    assert(num_columns * num_rows == num_routers)
+
+    #
+    # Connect each node to the appropriate router
+    #
+    ext_links = []
+    for (i, n) in enumerate(nodes):
+        cntrl_level, router_id = divmod(i, num_routers)
+        assert(cntrl_level < cntrls_per_router)
+        ext_links.append(ExtLink(ext_node=n, int_node=router_id))
+
+    #
+    # Create the mesh links.  First row (east-west) links then column
+    # (north-south) links
+    #
+    int_links = []
+    for row in xrange(num_rows):
+        for col in xrange(num_columns):
+            if (col + 1 < num_columns):
+                east_id = col + (row * num_columns)
+                west_id = (col + 1) + (row * num_columns)
+                int_links.append(IntLink(node_a=east_id,
+                                         node_b=west_id,
+                                         weight=1))
+    for col in xrange(num_columns):
+        for row in xrange(num_rows):
+            if (row + 1 < num_rows):
+                north_id = col + (row * num_columns)
+                south_id = col + ((row + 1) * num_columns)
+                int_links.append(IntLink(node_a=north_id,
+                                         node_b=south_id,
+                                         weight=2))
+
+    return Topology(ext_links=ext_links,
+                    int_links=int_links,
+                    num_int_nodes=num_routers)
+
 class RubyNetwork(SimObject):
     type = 'RubyNetwork'
     cxx_class = 'Network'

_______________________________________________
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to