Ruby: Clean up topology changes
This patch moves instantiateTopology into Ruby.py and removes the mem/ruby/network/topologies directory. It also adds some extra inheritance to the topologies to clean up some issues in the existing topologies.
This commit is contained in:
parent
706e84f2b8
commit
11411cc9c7
10 changed files with 48 additions and 86 deletions
|
@ -140,16 +140,19 @@ def create_system(options, system, piobus = None, dma_ports = []):
|
||||||
#
|
#
|
||||||
# Important: the topology must be instantiated before the network and after
|
# Important: the topology must be instantiated before the network and after
|
||||||
# the controllers. Hence the separation between topology definition and
|
# the controllers. Hence the separation between topology definition and
|
||||||
# instantiation. TopologyCreator is in src/mem/ruby/network/topologies/.
|
# instantiation.
|
||||||
#
|
#
|
||||||
from TopologyCreator import instantiateTopology
|
# gem5 SimObject defined in src/mem/ruby/network/Network.py
|
||||||
try:
|
net_topology = Topology()
|
||||||
net_topology = instantiateTopology(topology, options, \
|
net_topology.description = topology.description
|
||||||
IntLinkClass, ExtLinkClass, \
|
|
||||||
RouterClass)
|
routers, int_links, ext_links = topology.makeTopology(options,
|
||||||
except:
|
IntLinkClass, ExtLinkClass, RouterClass)
|
||||||
print "Error: could not make topology %s" % options.topology
|
|
||||||
raise
|
net_topology.routers = routers
|
||||||
|
net_topology.int_links = int_links
|
||||||
|
net_topology.ext_links = ext_links
|
||||||
|
|
||||||
|
|
||||||
if options.network_fault_model:
|
if options.network_fault_model:
|
||||||
assert(options.garnet_network == "fixed")
|
assert(options.garnet_network == "fixed")
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#
|
#
|
||||||
# Authors: Jason Power
|
# Authors: Jason Power
|
||||||
|
|
||||||
|
import m5
|
||||||
|
|
||||||
class BaseTopology(object):
|
class BaseTopology(object):
|
||||||
description = "BaseTopology"
|
description = "BaseTopology"
|
||||||
|
@ -38,14 +39,28 @@ class BaseTopology(object):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def makeTopology(self, options, IntLink, ExtLink, Router):
|
def makeTopology(self, options, IntLink, ExtLink, Router):
|
||||||
""" Called from src/mem/ruby/network/topologies/TopologyCreatory.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!!
|
||||||
Any additional information needed to create this topology should
|
Any additional information needed to create this topology should
|
||||||
be passed into the constructor when it's instantiated in
|
be passed into the constructor when it's instantiated in
|
||||||
configs/ruby/<protocol>.py
|
configs/ruby/<protocol>.py
|
||||||
"""
|
"""
|
||||||
print "BaseTopology should have been overridden in a sub class!!"
|
m5.util.fatal("BaseTopology should have been overridden!!")
|
||||||
import sys
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
|
class SimpleTopology(BaseTopology):
|
||||||
|
""" Provides methods needed for the topologies included in Ruby before
|
||||||
|
topology changes.
|
||||||
|
These topologies are "simple" in the sense that they only use a flat
|
||||||
|
list of controllers to construct the topology.
|
||||||
|
"""
|
||||||
|
description = "SimpleTopology"
|
||||||
|
|
||||||
|
def __init__(self, controllers):
|
||||||
|
self.nodes = controllers
|
||||||
|
|
||||||
|
def addController(self, controller):
|
||||||
|
self.nodes.append(controller)
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
return len(self.nodes)
|
||||||
|
|
|
@ -115,3 +115,6 @@ class Cluster(BaseTopology):
|
||||||
|
|
||||||
return routers, int_links, ext_links
|
return routers, int_links, ext_links
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
return len([i for i in self.nodes if type(i) != Cluster]) + \
|
||||||
|
sum([len(i) for i in self.nodes if type(i) == Cluster])
|
||||||
|
|
|
@ -29,14 +29,11 @@
|
||||||
from m5.params import *
|
from m5.params import *
|
||||||
from m5.objects import *
|
from m5.objects import *
|
||||||
|
|
||||||
from BaseTopology import BaseTopology
|
from BaseTopology import SimpleTopology
|
||||||
|
|
||||||
class Crossbar(BaseTopology):
|
class Crossbar(SimpleTopology):
|
||||||
description='Crossbar'
|
description='Crossbar'
|
||||||
|
|
||||||
def __init__(self, controllers):
|
|
||||||
self.nodes = controllers
|
|
||||||
|
|
||||||
def makeTopology(self, options, IntLink, ExtLink, Router):
|
def makeTopology(self, options, 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 the
|
||||||
# centralized crossbar. The large numbers of routers are needed because
|
# centralized crossbar. The large numbers of routers are needed because
|
||||||
|
@ -53,4 +50,3 @@ class Crossbar(BaseTopology):
|
||||||
for i in range(len(self.nodes))]
|
for i in range(len(self.nodes))]
|
||||||
|
|
||||||
return routers, int_links, ext_links
|
return routers, int_links, ext_links
|
||||||
|
|
||||||
|
|
|
@ -29,9 +29,9 @@
|
||||||
from m5.params import *
|
from m5.params import *
|
||||||
from m5.objects import *
|
from m5.objects import *
|
||||||
|
|
||||||
from BaseTopology import BaseTopology
|
from BaseTopology import SimpleTopology
|
||||||
|
|
||||||
class Mesh(BaseTopology):
|
class Mesh(SimpleTopology):
|
||||||
description='Mesh'
|
description='Mesh'
|
||||||
|
|
||||||
def __init__(self, controllers):
|
def __init__(self, controllers):
|
||||||
|
|
|
@ -29,9 +29,9 @@
|
||||||
from m5.params import *
|
from m5.params import *
|
||||||
from m5.objects import *
|
from m5.objects import *
|
||||||
|
|
||||||
from BaseTopology import BaseTopology
|
from BaseTopology import SimpleTopology
|
||||||
|
|
||||||
class MeshDirCorners(BaseTopology):
|
class MeshDirCorners(SimpleTopology):
|
||||||
description='MeshDirCorners'
|
description='MeshDirCorners'
|
||||||
|
|
||||||
def __init__(self, controllers):
|
def __init__(self, controllers):
|
||||||
|
|
|
@ -31,9 +31,9 @@
|
||||||
from m5.params import *
|
from m5.params import *
|
||||||
from m5.objects import *
|
from m5.objects import *
|
||||||
|
|
||||||
from BaseTopology import BaseTopology
|
from BaseTopology import SimpleTopology
|
||||||
|
|
||||||
class Pt2Pt(BaseTopology):
|
class Pt2Pt(SimpleTopology):
|
||||||
description='Pt2Pt'
|
description='Pt2Pt'
|
||||||
|
|
||||||
def __init__(self, controllers):
|
def __init__(self, controllers):
|
||||||
|
|
|
@ -31,9 +31,9 @@
|
||||||
from m5.params import *
|
from m5.params import *
|
||||||
from m5.objects import *
|
from m5.objects import *
|
||||||
|
|
||||||
from BaseTopology import BaseTopology
|
from BaseTopology import SimpleTopology
|
||||||
|
|
||||||
class Torus(BaseTopology):
|
class Torus(SimpleTopology):
|
||||||
description='Torus'
|
description='Torus'
|
||||||
|
|
||||||
def __init__(self, controllers):
|
def __init__(self, controllers):
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
# -*- mode:python -*-
|
|
||||||
|
|
||||||
# Copyright (c) 2010 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: Brad Beckmann
|
|
||||||
|
|
||||||
Import('*')
|
|
||||||
|
|
||||||
if env['PROTOCOL'] == 'None':
|
|
||||||
Return()
|
|
||||||
|
|
||||||
PySource('', 'TopologyCreator.py')
|
|
|
@ -1,19 +0,0 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
from m5.params import *
|
|
||||||
from m5.objects import *
|
|
||||||
|
|
||||||
def instantiateTopology(topology, options, IntLink, ExtLink, Router):
|
|
||||||
|
|
||||||
topo = Topology()
|
|
||||||
topo.description = topology.description
|
|
||||||
|
|
||||||
routers, int_links, ext_links = topology.makeTopology(options, IntLink, ExtLink, Router)
|
|
||||||
|
|
||||||
topo.routers = routers
|
|
||||||
topo.int_links = int_links
|
|
||||||
topo.ext_links = ext_links
|
|
||||||
|
|
||||||
return topo
|
|
Loading…
Reference in a new issue