diff options
author | Brad Beckmann <Brad.Beckmann@amd.com> | 2010-01-29 20:29:27 -0800 |
---|---|---|
committer | Brad Beckmann <Brad.Beckmann@amd.com> | 2010-01-29 20:29:27 -0800 |
commit | 6c867f82632fa8d635cd617dd933332f596d0bc4 (patch) | |
tree | bb38abc37afa73f3cadb989a3d7093a00bf79a57 /src | |
parent | faa76fc248ec7647f766ea14335d86036a5d2b9b (diff) | |
download | gem5-6c867f82632fa8d635cd617dd933332f596d0bc4.tar.xz |
ruby: Added a mesh topology
Diffstat (limited to 'src')
-rw-r--r-- | src/mem/ruby/network/Network.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/mem/ruby/network/Network.py b/src/mem/ruby/network/Network.py index 8079032c6..01ebfff70 100644 --- a/src/mem/ruby/network/Network.py +++ b/src/mem/ruby/network/Network.py @@ -64,6 +64,52 @@ def makeCrossbar(nodes): 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' |