ruby: network: correct naming of routers

The routers are created before the network class. This results in the routers
becoming children of the first link they are connected to and they get generic
names like int_node and node_b. This patch creates the network object first
and passes it to the topology creation function. Now the routers are children
of the network object and names are much more sensible.
This commit is contained in:
Nilay Vaish 2013-09-06 16:21:33 -05:00
parent 24dc914d87
commit e9ae8b7d29
8 changed files with 47 additions and 43 deletions

View file

@ -145,17 +145,12 @@ def create_system(options, system, piobus = None, dma_ports = []):
class ExtLinkClass(SimpleExtLink): pass class ExtLinkClass(SimpleExtLink): pass
class RouterClass(Switch): pass class RouterClass(Switch): pass
#
# Important: the topology must be instantiated before the network and after
# the controllers. Hence the separation between topology definition and
# instantiation.
#
routers, int_links, ext_links = topology.makeTopology(options, # Create the network topology
IntLinkClass, ExtLinkClass, RouterClass) network = NetworkClass(ruby_system = ruby, topology = topology.description,
network = NetworkClass(ruby_system = ruby, routers = routers, routers = [], ext_links = [], int_links = [])
int_links = int_links, ext_links = ext_links, topology.makeTopology(options, network, IntLinkClass, ExtLinkClass,
topology = topology.description) RouterClass)
if options.network_fault_model: if options.network_fault_model:
assert(options.garnet_network == "fixed") assert(options.garnet_network == "fixed")

View file

@ -38,7 +38,7 @@ class BaseTopology(object):
all of the controllers created in the above file. all of the controllers created in the above file.
""" """
def makeTopology(self, options, IntLink, ExtLink, Router): def makeTopology(self, options, network, IntLink, ExtLink, Router):
""" Called from configs/ruby/Ruby.py """ Called from configs/ruby/Ruby.py
The return value is ( list(Router), list(IntLink), list(ExtLink)) The return value is ( list(Router), list(IntLink), list(ExtLink))
The API of this function cannot change when subclassing!! The API of this function cannot change when subclassing!!

View file

@ -73,22 +73,17 @@ class Cluster(BaseTopology):
def add(self, node): def add(self, node):
self.nodes.append(node) self.nodes.append(node)
def makeTopology(self, options, IntLink, ExtLink, Router): def makeTopology(self, options, network, IntLink, ExtLink, Router):
""" Recursively make all of the links and routers """ Recursively make all of the links and routers
""" """
routers = []
int_links = []
ext_links = []
# make a router to connect all of the nodes # make a router to connect all of the nodes
self.router = Router(router_id=self.num_routers()) self.router = Router(router_id=self.num_routers())
routers.append(self.router) network.routers.append(self.router)
for node in self.nodes: for node in self.nodes:
if type(node) == Cluster: if type(node) == Cluster:
subRouters, subIntLinks, subExtLinks = node.makeTopology(options, IntLink, ExtLink, Router) node.makeTopology(options, network, IntLink, ExtLink, Router)
routers += subRouters
int_links += subIntLinks
ext_links += subExtLinks
# connect this cluster to the router # connect this cluster to the router
link = IntLink(link_id=self.num_int_links(), node_a=self.router, node_b=node.router) link = IntLink(link_id=self.num_int_links(), node_a=self.router, node_b=node.router)
@ -102,7 +97,7 @@ class Cluster(BaseTopology):
elif self.intLatency: elif self.intLatency:
link.latency = self.intLatency link.latency = self.intLatency
int_links.append(link) network.int_links.append(link)
else: else:
# node is just a controller connect it to the router via a ext_link # node is just a controller connect it to the router via a ext_link
link = ExtLink(link_id=self.num_ext_links(), ext_node=node, int_node=self.router) link = ExtLink(link_id=self.num_ext_links(), ext_node=node, int_node=self.router)
@ -111,9 +106,7 @@ class Cluster(BaseTopology):
if self.intLatency: if self.intLatency:
link.latency = self.intLatency link.latency = self.intLatency
ext_links.append(link) network.ext_links.append(link)
return routers, int_links, ext_links
def __len__(self): def __len__(self):
return len([i for i in self.nodes if type(i) != Cluster]) + \ return len([i for i in self.nodes if type(i) != Cluster]) + \

View file

@ -34,19 +34,22 @@ from BaseTopology import SimpleTopology
class Crossbar(SimpleTopology): class Crossbar(SimpleTopology):
description='Crossbar' description='Crossbar'
def makeTopology(self, options, IntLink, ExtLink, Router): def makeTopology(self, options, network, IntLink, ExtLink, Router):
# Create an individual router for each controller plus one more for the # Create an individual router for each controller plus one more for
# centralized crossbar. The large numbers of routers are needed because # the centralized crossbar. The large numbers of routers are needed
# external links do not model outgoing bandwidth in the simple network, but # because external links do not model outgoing bandwidth in the
# internal links do. # simple network, but internal links do.
routers = [Router(router_id=i) for i in range(len(self.nodes)+1)] routers = [Router(router_id=i) for i in range(len(self.nodes)+1)]
xbar = routers[len(self.nodes)] # the crossbar router is the last router created
network.routers = routers
ext_links = [ExtLink(link_id=i, ext_node=n, int_node=routers[i]) ext_links = [ExtLink(link_id=i, ext_node=n, int_node=routers[i])
for (i, n) in enumerate(self.nodes)] for (i, n) in enumerate(self.nodes)]
network.ext_links = ext_links
link_count = len(self.nodes) link_count = len(self.nodes)
xbar = routers[len(self.nodes)] # the crossbar router is the last router created
int_links = [IntLink(link_id=(link_count+i), int_links = [IntLink(link_id=(link_count+i),
node_a=routers[i], node_b=xbar) node_a=routers[i], node_b=xbar)
for i in range(len(self.nodes))] for i in range(len(self.nodes))]
network.int_links = int_links
return routers, int_links, ext_links

View file

@ -39,7 +39,7 @@ class Mesh(SimpleTopology):
# Makes a generic mesh assuming an equal number of cache and directory cntrls # Makes a generic mesh assuming an equal number of cache and directory cntrls
def makeTopology(self, options, IntLink, ExtLink, Router): def makeTopology(self, options, network, IntLink, ExtLink, Router):
nodes = self.nodes nodes = self.nodes
num_routers = options.num_cpus num_routers = options.num_cpus
@ -54,6 +54,7 @@ class Mesh(SimpleTopology):
# Create the routers in the mesh # Create the routers in the mesh
routers = [Router(router_id=i) for i in range(num_routers)] routers = [Router(router_id=i) for i in range(num_routers)]
network.routers = routers
# link counter to set unique link ids # link counter to set unique link ids
link_count = 0 link_count = 0
@ -86,6 +87,8 @@ class Mesh(SimpleTopology):
int_node=routers[0])) int_node=routers[0]))
link_count += 1 link_count += 1
network.ext_links = ext_links
# Create the mesh links. First row (east-west) links then column # Create the mesh links. First row (east-west) links then column
# (north-south) links # (north-south) links
int_links = [] int_links = []
@ -111,4 +114,4 @@ class Mesh(SimpleTopology):
weight=2)) weight=2))
link_count += 1 link_count += 1
return routers, int_links, ext_links network.int_links = int_links

View file

@ -42,7 +42,7 @@ class MeshDirCorners(SimpleTopology):
# configurations. The network specified is similar to GEMS old file # configurations. The network specified is similar to GEMS old file
# specified network. # specified network.
def makeTopology(self, options, IntLink, ExtLink, Router): def makeTopology(self, options, network, IntLink, ExtLink, Router):
nodes = self.nodes nodes = self.nodes
num_routers = options.num_cpus num_routers = options.num_cpus
@ -74,6 +74,7 @@ class MeshDirCorners(SimpleTopology):
# Create the routers in the mesh # Create the routers in the mesh
routers = [Router(router_id=i) for i in range(num_routers)] routers = [Router(router_id=i) for i in range(num_routers)]
network.routers = routers
# link counter to set unique link ids # link counter to set unique link ids
link_count = 0 link_count = 0
@ -104,7 +105,10 @@ class MeshDirCorners(SimpleTopology):
# Connect the dma nodes to router 0. These should only be DMA nodes. # Connect the dma nodes to router 0. These should only be DMA nodes.
for (i, node) in enumerate(dma_nodes): for (i, node) in enumerate(dma_nodes):
assert(node.type == 'DMA_Controller') assert(node.type == 'DMA_Controller')
ext_links.append(ExtLink(link_id=link_count, ext_node=node, int_node=routers[0])) ext_links.append(ExtLink(link_id=link_count, ext_node=node,
int_node=routers[0]))
network.ext_links = ext_links
# Create the mesh links. First row (east-west) links then column # Create the mesh links. First row (east-west) links then column
# (north-south) links # (north-south) links
@ -131,4 +135,4 @@ class MeshDirCorners(SimpleTopology):
weight=2)) weight=2))
link_count += 1 link_count += 1
return routers, int_links, ext_links network.int_links = int_links

View file

@ -39,15 +39,18 @@ class Pt2Pt(SimpleTopology):
def __init__(self, controllers): def __init__(self, controllers):
self.nodes = controllers self.nodes = controllers
def makeTopology(self, options, IntLink, ExtLink, Router): def makeTopology(self, options, network, IntLink, ExtLink, Router):
nodes = self.nodes nodes = self.nodes
# Create an individual router for each controller, and connect all to all.
# Create an individual router for each controller, and connect all to all.
routers = [Router(router_id=i) for i in range(len(nodes))] routers = [Router(router_id=i) for i in range(len(nodes))]
network.routers = routers
ext_links = [ExtLink(link_id=i, ext_node=n, int_node=routers[i]) ext_links = [ExtLink(link_id=i, ext_node=n, int_node=routers[i])
for (i, n) in enumerate(nodes)] for (i, n) in enumerate(nodes)]
link_count = len(nodes) network.ext_links = ext_links
link_count = len(nodes)
int_links = [] int_links = []
for i in xrange(len(nodes)): for i in xrange(len(nodes)):
for j in xrange(len(nodes)): for j in xrange(len(nodes)):
@ -57,4 +60,4 @@ class Pt2Pt(SimpleTopology):
node_a=routers[i], node_a=routers[i],
node_b=routers[j])) node_b=routers[j]))
return routers, int_links, ext_links network.int_links = int_links

View file

@ -44,7 +44,7 @@ class Torus(SimpleTopology):
# All links (including the wrap-around ones) are of equal length, double that # All links (including the wrap-around ones) are of equal length, double that
# of a mesh. Thus, each link is assigned a latency of 2 cycles. # of a mesh. Thus, each link is assigned a latency of 2 cycles.
def makeTopology(self, options, IntLink, ExtLink, Router): def makeTopology(self, options, network, IntLink, ExtLink, Router):
nodes = self.nodes nodes = self.nodes
num_routers = options.num_cpus num_routers = options.num_cpus
@ -59,6 +59,7 @@ class Torus(SimpleTopology):
# Create the routers in the torus # Create the routers in the torus
routers = [Router(router_id=i) for i in range(num_routers)] routers = [Router(router_id=i) for i in range(num_routers)]
network.routers = routers
# link counter to set unique link ids # link counter to set unique link ids
link_count = 0 link_count = 0
@ -91,6 +92,8 @@ class Torus(SimpleTopology):
int_node=routers[0])) int_node=routers[0]))
link_count += 1 link_count += 1
network.ext_links = ext_links
# Create the torus links. First row (east-west) links then column # Create the torus links. First row (east-west) links then column
# (north-south) links # (north-south) links
# column links are given higher weights to implement XY routing # column links are given higher weights to implement XY routing
@ -123,4 +126,4 @@ class Torus(SimpleTopology):
weight=2)) weight=2))
link_count += 1 link_count += 1
return routers, int_links, ext_links network.int_links = int_links