class ExtLinkClass(SimpleExtLink): 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,
- IntLinkClass, ExtLinkClass, RouterClass)
- network = NetworkClass(ruby_system = ruby, routers = routers,
- int_links = int_links, ext_links = ext_links,
- topology = topology.description)
+ # Create the network topology
+ network = NetworkClass(ruby_system = ruby, topology = topology.description,
+ routers = [], ext_links = [], int_links = [])
+ topology.makeTopology(options, network, IntLinkClass, ExtLinkClass,
+ RouterClass)
if options.network_fault_model:
assert(options.garnet_network == "fixed")
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
The return value is ( list(Router), list(IntLink), list(ExtLink))
The API of this function cannot change when subclassing!!
def add(self, 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
"""
- routers = []
- int_links = []
- ext_links = []
# make a router to connect all of the nodes
self.router = Router(router_id=self.num_routers())
- routers.append(self.router)
+ network.routers.append(self.router)
+
for node in self.nodes:
if type(node) == Cluster:
- subRouters, subIntLinks, subExtLinks = node.makeTopology(options, IntLink, ExtLink, Router)
- routers += subRouters
- int_links += subIntLinks
- ext_links += subExtLinks
+ node.makeTopology(options, network, IntLink, ExtLink, Router)
# connect this cluster to the router
link = IntLink(link_id=self.num_int_links(), node_a=self.router, node_b=node.router)
elif self.intLatency:
link.latency = self.intLatency
- int_links.append(link)
+ network.int_links.append(link)
else:
# 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)
if self.intLatency:
link.latency = self.intLatency
- ext_links.append(link)
-
- return routers, int_links, ext_links
+ network.ext_links.append(link)
def __len__(self):
return len([i for i in self.nodes if type(i) != Cluster]) + \
class Crossbar(SimpleTopology):
description='Crossbar'
- def makeTopology(self, options, IntLink, ExtLink, Router):
- # Create an individual router for each controller plus one more for the
- # centralized crossbar. The large numbers of routers are needed because
- # external links do not model outgoing bandwidth in the simple network, but
- # internal links do.
+ def makeTopology(self, options, network, IntLink, ExtLink, Router):
+ # Create an individual router for each controller plus one more for
+ # the centralized crossbar. The large numbers of routers are needed
+ # because external links do not model outgoing bandwidth in the
+ # simple network, but internal links do.
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])
for (i, n) in enumerate(self.nodes)]
+ network.ext_links = ext_links
+
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),
node_a=routers[i], node_b=xbar)
for i in range(len(self.nodes))]
-
- return routers, int_links, ext_links
+ network.int_links = int_links
# 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
num_routers = options.num_cpus
# Create the routers in the mesh
routers = [Router(router_id=i) for i in range(num_routers)]
+ network.routers = routers
# link counter to set unique link ids
link_count = 0
int_node=routers[0]))
link_count += 1
+ network.ext_links = ext_links
+
# Create the mesh links. First row (east-west) links then column
# (north-south) links
int_links = []
weight=2))
link_count += 1
- return routers, int_links, ext_links
+ network.int_links = int_links
# configurations. The network specified is similar to GEMS old file
# specified network.
- def makeTopology(self, options, IntLink, ExtLink, Router):
+ def makeTopology(self, options, network, IntLink, ExtLink, Router):
nodes = self.nodes
num_routers = options.num_cpus
# Create the routers in the mesh
routers = [Router(router_id=i) for i in range(num_routers)]
+ network.routers = routers
# link counter to set unique link ids
link_count = 0
# Connect the dma nodes to router 0. These should only be DMA nodes.
for (i, node) in enumerate(dma_nodes):
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
# (north-south) links
weight=2))
link_count += 1
- return routers, int_links, ext_links
+ network.int_links = int_links
def __init__(self, controllers):
self.nodes = controllers
- def makeTopology(self, options, IntLink, ExtLink, Router):
+ def makeTopology(self, options, network, IntLink, ExtLink, Router):
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))]
+ network.routers = routers
+
ext_links = [ExtLink(link_id=i, ext_node=n, int_node=routers[i])
for (i, n) in enumerate(nodes)]
- link_count = len(nodes)
+ network.ext_links = ext_links
+ link_count = len(nodes)
int_links = []
for i in xrange(len(nodes)):
for j in xrange(len(nodes)):
node_a=routers[i],
node_b=routers[j]))
- return routers, int_links, ext_links
+ network.int_links = int_links
# 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.
- def makeTopology(self, options, IntLink, ExtLink, Router):
+ def makeTopology(self, options, network, IntLink, ExtLink, Router):
nodes = self.nodes
num_routers = options.num_cpus
# Create the routers in the torus
routers = [Router(router_id=i) for i in range(num_routers)]
+ network.routers = routers
# link counter to set unique link ids
link_count = 0
int_node=routers[0]))
link_count += 1
+ network.ext_links = ext_links
+
# Create the torus links. First row (east-west) links then column
# (north-south) links
# column links are given higher weights to implement XY routing
weight=2))
link_count += 1
- return routers, int_links, ext_links
+ network.int_links = int_links