Ruby.py revision 8638
11689SN/A# Copyright (c) 2006-2007 The Regents of The University of Michigan 210330Smitch.hayenga@arm.com# Copyright (c) 2009 Advanced Micro Devices, Inc. 38842Smrinmoy.ghosh@arm.com# All rights reserved. 48842Smrinmoy.ghosh@arm.com# 58842Smrinmoy.ghosh@arm.com# Redistribution and use in source and binary forms, with or without 68842Smrinmoy.ghosh@arm.com# modification, are permitted provided that the following conditions are 78842Smrinmoy.ghosh@arm.com# met: redistributions of source code must retain the above copyright 88842Smrinmoy.ghosh@arm.com# notice, this list of conditions and the following disclaimer; 98842Smrinmoy.ghosh@arm.com# redistributions in binary form must reproduce the above copyright 108842Smrinmoy.ghosh@arm.com# notice, this list of conditions and the following disclaimer in the 118842Smrinmoy.ghosh@arm.com# documentation and/or other materials provided with the distribution; 128842Smrinmoy.ghosh@arm.com# neither the name of the copyright holders nor the names of its 138842Smrinmoy.ghosh@arm.com# contributors may be used to endorse or promote products derived from 142345SN/A# this software without specific prior written permission. 151689SN/A# 161689SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 171689SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 181689SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 191689SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 201689SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 211689SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 221689SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 231689SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 241689SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 251689SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 261689SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 271689SN/A# 281689SN/A# Authors: Brad Beckmann 291689SN/A 301689SN/Aimport math 311689SN/Aimport m5 321689SN/Afrom m5.objects import * 331689SN/Afrom m5.defines import buildEnv 341689SN/A 351689SN/Adef define_options(parser): 361689SN/A # ruby network options 371689SN/A parser.add_option("--topology", type="string", default="Crossbar", 381689SN/A help="check src/mem/ruby/network/topologies for complete set") 392665SN/A parser.add_option("--mesh-rows", type="int", default=1, 402665SN/A help="the number of rows in the mesh topology") 419480Snilay@cs.wisc.edu parser.add_option("--garnet-network", type="string", default=None, 429480Snilay@cs.wisc.edu help="'fixed'|'flexible'") 431689SN/A parser.add_option("--network-fault-model", action="store_true", default=False, 441689SN/A help="enable network fault model: see src/mem/ruby/network/fault_model/") 459480Snilay@cs.wisc.edu 469480Snilay@cs.wisc.edu # ruby mapping options 471062SN/A parser.add_option("--numa-high-bit", type="int", default=0, 486216SN/A help="high order address bit to use for numa mapping. " \ 496216SN/A "0 = highest bit, not specified = lowest bit") 5013960Sodanrc@yahoo.com.br 516216SN/A # ruby sparse memory options 529480Snilay@cs.wisc.edu parser.add_option("--use-map", action="store_true", default=False) 5310785Sgope@wisc.edu parser.add_option("--map-levels", type="int", default=4) 541062SN/A 552345SN/A parser.add_option("--recycle-latency", type="int", default=10, 562345SN/A help="Recycle latency for ruby controller input buffers") 572345SN/A 582345SN/A parser.add_option("--random_seed", type="int", default=1234, 592345SN/A help="Used for seeding the random number generator") 6011782Sarthur.perais@inria.fr 6111782Sarthur.perais@inria.fr parser.add_option("--ruby_stats", type="string", default="ruby.stats") 622345SN/A 639480Snilay@cs.wisc.edu protocol = buildEnv['PROTOCOL'] 641062SN/A exec "import %s" % protocol 651062SN/A eval("%s.define_options(parser)" % protocol) 661062SN/A 671062SN/Adef create_system(options, system, piobus = None, dma_devices = []): 681062SN/A 6910785Sgope@wisc.edu system.ruby = RubySystem(clock = options.clock, 701062SN/A stats_filename = options.ruby_stats) 711062SN/A ruby = system.ruby 721062SN/A 732345SN/A protocol = buildEnv['PROTOCOL'] 742345SN/A exec "import %s" % protocol 751062SN/A try: 762345SN/A (cpu_sequencers, dir_cntrls, all_cntrls) = \ 771062SN/A eval("%s.create_system(options, system, piobus, \ 781062SN/A dma_devices, ruby)" \ 7911434Smitch.hayenga@arm.com % protocol) 802345SN/A except: 812345SN/A print "Error: could not create sytem for ruby protocol %s" % protocol 822345SN/A raise 832345SN/A 842345SN/A # 852345SN/A # Set the network classes based on the command line options 862345SN/A # 8711434Smitch.hayenga@arm.com if options.garnet_network == "fixed": 888842Smrinmoy.ghosh@arm.com class NetworkClass(GarnetNetwork_d): pass 898842Smrinmoy.ghosh@arm.com class IntLinkClass(GarnetIntLink_d): pass 908842Smrinmoy.ghosh@arm.com class ExtLinkClass(GarnetExtLink_d): pass 918842Smrinmoy.ghosh@arm.com class RouterClass(GarnetRouter_d): pass 928842Smrinmoy.ghosh@arm.com elif options.garnet_network == "flexible": 938842Smrinmoy.ghosh@arm.com class NetworkClass(GarnetNetwork): pass 948842Smrinmoy.ghosh@arm.com class IntLinkClass(GarnetIntLink): pass 9511434Smitch.hayenga@arm.com class ExtLinkClass(GarnetExtLink): pass 961062SN/A class RouterClass(GarnetRouter): pass 971062SN/A else: 981062SN/A class NetworkClass(SimpleNetwork): pass 991062SN/A class IntLinkClass(SimpleIntLink): pass 1002345SN/A class ExtLinkClass(SimpleExtLink): pass 1012345SN/A class RouterClass(BasicRouter): pass 1028842Smrinmoy.ghosh@arm.com 1038842Smrinmoy.ghosh@arm.com # 10413626Sjairo.balart@metempsy.com # Important: the topology must be created before the network and after the 10513626Sjairo.balart@metempsy.com # controllers. 10613626Sjairo.balart@metempsy.com # 1071062SN/A exec "import %s" % options.topology 10811434Smitch.hayenga@arm.com try: 10913626Sjairo.balart@metempsy.com net_topology = eval("%s.makeTopology(all_cntrls, options, \ 1101062SN/A IntLinkClass, ExtLinkClass, \ 1112345SN/A RouterClass)" \ 1122345SN/A % options.topology) 1132345SN/A except: 1142345SN/A print "Error: could not create topology %s" % options.topology 1152345SN/A raise 11611434Smitch.hayenga@arm.com 1172345SN/A if options.network_fault_model: 1181062SN/A assert(options.garnet_network == "fixed") 1192345SN/A fault_model = FaultModel() 1202345SN/A network = NetworkClass(ruby_system = ruby, topology = net_topology,\ 1212345SN/A enable_fault_model=True, fault_model = fault_model) 1222345SN/A else: 1232345SN/A network = NetworkClass(ruby_system = ruby, topology = net_topology) 1241062SN/A 1251062SN/A # 1262345SN/A # Loop through the directory controlers. 1272345SN/A # Determine the total memory size of the ruby system and verify it is equal 1282345SN/A # to physmem. However, if Ruby memory is using sparse memory in SE 1292345SN/A # mode, then the system should not back-up the memory state with 1301062SN/A # the Memory Vector and thus the memory size bytes should stay at 0. 1311062SN/A # Also set the numa bits to the appropriate values. 1322345SN/A # 13311434Smitch.hayenga@arm.com total_mem_size = MemorySize('0B') 1341062SN/A 1352345SN/A dir_bits = int(math.log(options.num_dirs, 2)) 13611434Smitch.hayenga@arm.com 1372345SN/A if options.numa_high_bit: 1382345SN/A numa_bit = options.numa_high_bit 1392345SN/A else: 1402345SN/A # if not specified, use the lowest bits above the block offest 1412345SN/A if dir_bits > 0: 1422345SN/A # add 5 because bits 0-5 are the block offset 1432345SN/A numa_bit = dir_bits + 5 1442345SN/A else: 1452345SN/A numa_bit = 6 1462345SN/A 1472345SN/A for dir_cntrl in dir_cntrls: 1482345SN/A total_mem_size.value += dir_cntrl.directory.size.value 1492345SN/A dir_cntrl.directory.numa_high_bit = numa_bit 1502345SN/A 1512345SN/A physmem_size = long(system.physmem.range.second) - \ 1522345SN/A long(system.physmem.range.first) + 1 1532345SN/A assert(total_mem_size.value == physmem_size) 1542345SN/A 1552345SN/A ruby_profiler = RubyProfiler(ruby_system = ruby, 1562345SN/A num_of_sequencers = len(cpu_sequencers)) 1572345SN/A ruby_tracer = RubyTracer(ruby_system = ruby) 1582345SN/A 1592345SN/A ruby.network = network 1602345SN/A ruby.profiler = ruby_profiler 1612345SN/A ruby.tracer = ruby_tracer 1622345SN/A ruby.mem_size = total_mem_size 1632345SN/A ruby._cpu_ruby_ports = cpu_sequencers 1642345SN/A ruby.random_seed = options.random_seed 1652345SN/A