sw.py revision 11682
112855Sgabeblack@google.com# Copyright (c) 2015 The University of Illinois Urbana Champaign 212855Sgabeblack@google.com# All rights reserved 312855Sgabeblack@google.com# 412855Sgabeblack@google.com# Redistribution and use in source and binary forms, with or without 512855Sgabeblack@google.com# modification, are permitted provided that the following conditions are 612855Sgabeblack@google.com# met: redistributions of source code must retain the above copyright 712855Sgabeblack@google.com# notice, this list of conditions and the following disclaimer; 812855Sgabeblack@google.com# redistributions in binary form must reproduce the above copyright 912855Sgabeblack@google.com# notice, this list of conditions and the following disclaimer in the 1012855Sgabeblack@google.com# documentation and/or other materials provided with the distribution; 1112855Sgabeblack@google.com# neither the name of the copyright holders nor the names of its 1212855Sgabeblack@google.com# contributors may be used to endorse or promote products derived from 1312855Sgabeblack@google.com# this software without specific prior written permission. 1412855Sgabeblack@google.com# 1512855Sgabeblack@google.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1612855Sgabeblack@google.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1712855Sgabeblack@google.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1812855Sgabeblack@google.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1912855Sgabeblack@google.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2012855Sgabeblack@google.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2112855Sgabeblack@google.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2212855Sgabeblack@google.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2312855Sgabeblack@google.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2412855Sgabeblack@google.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2512855Sgabeblack@google.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2612855Sgabeblack@google.com# 2712855Sgabeblack@google.com# Authors: Mohammad Alian 2812855Sgabeblack@google.com 2912855Sgabeblack@google.com# This is an example of an n port network switch to work in dist-gem5. 3012855Sgabeblack@google.com# Users can extend this to have different different topologies 3112855Sgabeblack@google.com 3212855Sgabeblack@google.comimport optparse 3312855Sgabeblack@google.comimport sys 3412855Sgabeblack@google.com 3512855Sgabeblack@google.comimport m5 3612855Sgabeblack@google.comfrom m5.defines import buildEnv 3712855Sgabeblack@google.comfrom m5.objects import * 3812855Sgabeblack@google.comfrom m5.util import addToPath, fatal 3912855Sgabeblack@google.com 4012855Sgabeblack@google.comaddToPath('../') 4112855Sgabeblack@google.com 4212855Sgabeblack@google.comfrom common import Simulation 4312855Sgabeblack@google.comfrom common import Options 4412855Sgabeblack@google.com 4512855Sgabeblack@google.comdef build_switch(options): 4612855Sgabeblack@google.com # instantiate an EtherSwitch 4712855Sgabeblack@google.com switch = EtherSwitch() 4812855Sgabeblack@google.com # instantiate distEtherLinks to connect switch ports 4912855Sgabeblack@google.com # to other gem5 instances 5012855Sgabeblack@google.com switch.portlink = [DistEtherLink(speed = options.ethernet_linkspeed, 5112855Sgabeblack@google.com delay = options.ethernet_linkdelay, 5212855Sgabeblack@google.com dist_rank = options.dist_rank, 5312855Sgabeblack@google.com dist_size = options.dist_size, 5412855Sgabeblack@google.com server_name = options.dist_server_name, 5512855Sgabeblack@google.com server_port = options.dist_server_port, 5612855Sgabeblack@google.com sync_start = options.dist_sync_start, 5712855Sgabeblack@google.com sync_repeat = options.dist_sync_repeat, 5812855Sgabeblack@google.com is_switch = True, 5912855Sgabeblack@google.com num_nodes = options.dist_size) 6012855Sgabeblack@google.com for i in xrange(options.dist_size)] 6112855Sgabeblack@google.com 6212855Sgabeblack@google.com for (i, link) in enumerate(switch.portlink): 6312855Sgabeblack@google.com link.int0 = switch.interface[i] 6412855Sgabeblack@google.com 6512855Sgabeblack@google.com return switch 6612855Sgabeblack@google.com# Add options 6712855Sgabeblack@google.comparser = optparse.OptionParser() 6812855Sgabeblack@google.comOptions.addCommonOptions(parser) 6912855Sgabeblack@google.comOptions.addFSOptions(parser) 70(options, args) = parser.parse_args() 71 72system = build_switch(options) 73root = Root(full_system = True, system = system) 74Simulation.run(options, root, None, None) 75 76