sw.py revision 13731
111444Sm.alian1369@gmail.com# Copyright (c) 2015 The University of Illinois Urbana Champaign 211444Sm.alian1369@gmail.com# All rights reserved 311444Sm.alian1369@gmail.com# 411444Sm.alian1369@gmail.com# Redistribution and use in source and binary forms, with or without 511444Sm.alian1369@gmail.com# modification, are permitted provided that the following conditions are 611444Sm.alian1369@gmail.com# met: redistributions of source code must retain the above copyright 711444Sm.alian1369@gmail.com# notice, this list of conditions and the following disclaimer; 811444Sm.alian1369@gmail.com# redistributions in binary form must reproduce the above copyright 911444Sm.alian1369@gmail.com# notice, this list of conditions and the following disclaimer in the 1011444Sm.alian1369@gmail.com# documentation and/or other materials provided with the distribution; 1111444Sm.alian1369@gmail.com# neither the name of the copyright holders nor the names of its 1211444Sm.alian1369@gmail.com# contributors may be used to endorse or promote products derived from 1311444Sm.alian1369@gmail.com# this software without specific prior written permission. 1411444Sm.alian1369@gmail.com# 1511444Sm.alian1369@gmail.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1611444Sm.alian1369@gmail.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1711444Sm.alian1369@gmail.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1811444Sm.alian1369@gmail.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1911444Sm.alian1369@gmail.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2011444Sm.alian1369@gmail.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2111444Sm.alian1369@gmail.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2211444Sm.alian1369@gmail.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2311444Sm.alian1369@gmail.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2411444Sm.alian1369@gmail.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2511444Sm.alian1369@gmail.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2611444Sm.alian1369@gmail.com# 2711444Sm.alian1369@gmail.com# Authors: Mohammad Alian 2811444Sm.alian1369@gmail.com 2911444Sm.alian1369@gmail.com# This is an example of an n port network switch to work in dist-gem5. 3011444Sm.alian1369@gmail.com# Users can extend this to have different different topologies 3111444Sm.alian1369@gmail.com 3211444Sm.alian1369@gmail.comimport optparse 3311444Sm.alian1369@gmail.comimport sys 3411444Sm.alian1369@gmail.com 3511444Sm.alian1369@gmail.comimport m5 3611444Sm.alian1369@gmail.comfrom m5.defines import buildEnv 3711444Sm.alian1369@gmail.comfrom m5.objects import * 3811444Sm.alian1369@gmail.comfrom m5.util import addToPath, fatal 3911444Sm.alian1369@gmail.com 4011682Sandreas.hansson@arm.comaddToPath('../') 4111444Sm.alian1369@gmail.com 4211682Sandreas.hansson@arm.comfrom common import Simulation 4311682Sandreas.hansson@arm.comfrom common import Options 4411444Sm.alian1369@gmail.com 4511444Sm.alian1369@gmail.comdef build_switch(options): 4611444Sm.alian1369@gmail.com # instantiate an EtherSwitch 4711444Sm.alian1369@gmail.com switch = EtherSwitch() 4811444Sm.alian1369@gmail.com # instantiate distEtherLinks to connect switch ports 4911444Sm.alian1369@gmail.com # to other gem5 instances 5011444Sm.alian1369@gmail.com switch.portlink = [DistEtherLink(speed = options.ethernet_linkspeed, 5111444Sm.alian1369@gmail.com delay = options.ethernet_linkdelay, 5211444Sm.alian1369@gmail.com dist_rank = options.dist_rank, 5311444Sm.alian1369@gmail.com dist_size = options.dist_size, 5411444Sm.alian1369@gmail.com server_name = options.dist_server_name, 5511444Sm.alian1369@gmail.com server_port = options.dist_server_port, 5611444Sm.alian1369@gmail.com sync_start = options.dist_sync_start, 5711444Sm.alian1369@gmail.com sync_repeat = options.dist_sync_repeat, 5811444Sm.alian1369@gmail.com is_switch = True, 5911444Sm.alian1369@gmail.com num_nodes = options.dist_size) 6013731Sandreas.sandberg@arm.com for i in range(options.dist_size)] 6111444Sm.alian1369@gmail.com 6211444Sm.alian1369@gmail.com for (i, link) in enumerate(switch.portlink): 6311444Sm.alian1369@gmail.com link.int0 = switch.interface[i] 6411444Sm.alian1369@gmail.com 6511444Sm.alian1369@gmail.com return switch 6611444Sm.alian1369@gmail.com 6711844Sgabor.dozsa@arm.comdef main(): 6811844Sgabor.dozsa@arm.com # Add options 6911844Sgabor.dozsa@arm.com parser = optparse.OptionParser() 7011844Sgabor.dozsa@arm.com Options.addCommonOptions(parser) 7111844Sgabor.dozsa@arm.com Options.addFSOptions(parser) 7211844Sgabor.dozsa@arm.com (options, args) = parser.parse_args() 7311444Sm.alian1369@gmail.com 7411844Sgabor.dozsa@arm.com system = build_switch(options) 7511844Sgabor.dozsa@arm.com root = Root(full_system = True, system = system) 7611844Sgabor.dozsa@arm.com Simulation.run(options, root, None, None) 7711844Sgabor.dozsa@arm.com 7811844Sgabor.dozsa@arm.comif __name__ == "__m5_main__": 7911844Sgabor.dozsa@arm.com main() 80