Ruby.py revision 8706
12SN/A# Copyright (c) 2012 ARM Limited 21762SN/A# All rights reserved. 32SN/A# 42SN/A# The license below extends only to copyright in the software and shall 52SN/A# not be construed as granting a license to any other intellectual 62SN/A# property including but not limited to intellectual property relating 72SN/A# to a hardware implementation of the functionality of the software 82SN/A# licensed hereunder. You may use the software subject to the license 92SN/A# terms below provided that you ensure that this notice is replicated 102SN/A# unmodified and in its entirety in all distributions of the software, 112SN/A# modified or unmodified, in source code or in binary form. 122SN/A# 132SN/A# Copyright (c) 2006-2007 The Regents of The University of Michigan 142SN/A# Copyright (c) 2009 Advanced Micro Devices, Inc. 152SN/A# All rights reserved. 162SN/A# 172SN/A# Redistribution and use in source and binary forms, with or without 182SN/A# modification, are permitted provided that the following conditions are 192SN/A# met: redistributions of source code must retain the above copyright 202SN/A# notice, this list of conditions and the following disclaimer; 212SN/A# redistributions in binary form must reproduce the above copyright 222SN/A# notice, this list of conditions and the following disclaimer in the 232SN/A# documentation and/or other materials provided with the distribution; 242SN/A# neither the name of the copyright holders nor the names of its 252SN/A# contributors may be used to endorse or promote products derived from 262SN/A# this software without specific prior written permission. 272665Ssaidi@eecs.umich.edu# 282665Ssaidi@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 292665Ssaidi@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 302SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 312SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 322SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 332SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 342SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 352147SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 362147SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 372174SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 382147SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 392680Sktlim@umich.edu# 402132SN/A# Authors: Brad Beckmann 412147SN/A 422132SN/Aimport math 432147SN/Aimport m5 442147SN/Afrom m5.objects import * 452147SN/Afrom m5.defines import buildEnv 462147SN/A 472147SN/Adef define_options(parser): 482147SN/A # ruby network options 492147SN/A parser.add_option("--topology", type="string", default="Crossbar", 502147SN/A help="check src/mem/ruby/network/topologies for complete set") 512147SN/A parser.add_option("--mesh-rows", type="int", default=1, 522147SN/A help="the number of rows in the mesh topology") 532147SN/A parser.add_option("--garnet-network", type="string", default=None, 542090SN/A help="'fixed'|'flexible'") 552147SN/A parser.add_option("--network-fault-model", action="store_true", default=False, 564695Sgblack@eecs.umich.edu help="enable network fault model: see src/mem/ruby/network/fault_model/") 572680Sktlim@umich.edu 582201SN/A # ruby mapping options 592201SN/A parser.add_option("--numa-high-bit", type="int", default=0, 604695Sgblack@eecs.umich.edu help="high order address bit to use for numa mapping. " \ 614695Sgblack@eecs.umich.edu "0 = highest bit, not specified = lowest bit") 622SN/A 632SN/A # ruby sparse memory options 642168SN/A parser.add_option("--use-map", action="store_true", default=False) 652168SN/A parser.add_option("--map-levels", type="int", default=4) 662612SN/A 672612SN/A parser.add_option("--recycle-latency", type="int", default=10, 682612SN/A help="Recycle latency for ruby controller input buffers") 692612SN/A 702612SN/A parser.add_option("--random_seed", type="int", default=1234, 712612SN/A help="Used for seeding the random number generator") 722612SN/A 732612SN/A parser.add_option("--ruby_stats", type="string", default="ruby.stats") 742612SN/A 754695Sgblack@eecs.umich.edu protocol = buildEnv['PROTOCOL'] 762680Sktlim@umich.edu exec "import %s" % protocol 772612SN/A eval("%s.define_options(parser)" % protocol) 782612SN/A 794183Sgblack@eecs.umich.edudef create_system(options, system, piobus = None, dma_devices = []): 804183Sgblack@eecs.umich.edu 814183Sgblack@eecs.umich.edu system.ruby = RubySystem(clock = options.clock, 824183Sgblack@eecs.umich.edu stats_filename = options.ruby_stats, 834183Sgblack@eecs.umich.edu no_mem_vec = options.use_map) 844183Sgblack@eecs.umich.edu ruby = system.ruby 854695Sgblack@eecs.umich.edu 864183Sgblack@eecs.umich.edu protocol = buildEnv['PROTOCOL'] 874183Sgblack@eecs.umich.edu exec "import %s" % protocol 884183Sgblack@eecs.umich.edu try: 894183Sgblack@eecs.umich.edu (cpu_sequencers, dir_cntrls, all_cntrls) = \ 904183Sgblack@eecs.umich.edu eval("%s.create_system(options, system, piobus, \ 912SN/A dma_devices, ruby)" \ 92 % protocol) 93 except: 94 print "Error: could not create sytem for ruby protocol %s" % protocol 95 raise 96 97 # Create a port proxy for connecting the system port. This is 98 # independent of the protocol and kept in the protocol-agnostic 99 # part (i.e. here). 100 sys_port_proxy = RubyPortProxy(version = 0, 101 physMemPort = system.physmem.port, 102 physmem = system.physmem, 103 ruby_system = ruby) 104 # Give the system port proxy a SimObject parent without creating a 105 # full-fledged controller 106 system.sys_port_proxy = sys_port_proxy 107 108 # 109 # Set the network classes based on the command line options 110 # 111 if options.garnet_network == "fixed": 112 class NetworkClass(GarnetNetwork_d): pass 113 class IntLinkClass(GarnetIntLink_d): pass 114 class ExtLinkClass(GarnetExtLink_d): pass 115 class RouterClass(GarnetRouter_d): pass 116 elif options.garnet_network == "flexible": 117 class NetworkClass(GarnetNetwork): pass 118 class IntLinkClass(GarnetIntLink): pass 119 class ExtLinkClass(GarnetExtLink): pass 120 class RouterClass(GarnetRouter): pass 121 else: 122 class NetworkClass(SimpleNetwork): pass 123 class IntLinkClass(SimpleIntLink): pass 124 class ExtLinkClass(SimpleExtLink): pass 125 class RouterClass(BasicRouter): pass 126 127 # 128 # Important: the topology must be created before the network and after the 129 # controllers. 130 # 131 exec "import %s" % options.topology 132 try: 133 net_topology = eval("%s.makeTopology(all_cntrls, options, \ 134 IntLinkClass, ExtLinkClass, \ 135 RouterClass)" \ 136 % options.topology) 137 except: 138 print "Error: could not create topology %s" % options.topology 139 raise 140 141 if options.network_fault_model: 142 assert(options.garnet_network == "fixed") 143 fault_model = FaultModel() 144 network = NetworkClass(ruby_system = ruby, topology = net_topology,\ 145 enable_fault_model=True, fault_model = fault_model) 146 else: 147 network = NetworkClass(ruby_system = ruby, topology = net_topology) 148 149 # 150 # Loop through the directory controlers. 151 # Determine the total memory size of the ruby system and verify it is equal 152 # to physmem. However, if Ruby memory is using sparse memory in SE 153 # mode, then the system should not back-up the memory state with 154 # the Memory Vector and thus the memory size bytes should stay at 0. 155 # Also set the numa bits to the appropriate values. 156 # 157 total_mem_size = MemorySize('0B') 158 159 dir_bits = int(math.log(options.num_dirs, 2)) 160 161 if options.numa_high_bit: 162 numa_bit = options.numa_high_bit 163 else: 164 # if not specified, use the lowest bits above the block offest 165 if dir_bits > 0: 166 # add 5 because bits 0-5 are the block offset 167 numa_bit = dir_bits + 5 168 else: 169 numa_bit = 6 170 171 for dir_cntrl in dir_cntrls: 172 total_mem_size.value += dir_cntrl.directory.size.value 173 dir_cntrl.directory.numa_high_bit = numa_bit 174 175 physmem_size = long(system.physmem.range.second) - \ 176 long(system.physmem.range.first) + 1 177 assert(total_mem_size.value == physmem_size) 178 179 ruby_profiler = RubyProfiler(ruby_system = ruby, 180 num_of_sequencers = len(cpu_sequencers)) 181 ruby.network = network 182 ruby.profiler = ruby_profiler 183 ruby.mem_size = total_mem_size 184 ruby._cpu_ruby_ports = cpu_sequencers 185 ruby._sys_port_proxy = sys_port_proxy 186 ruby.random_seed = options.random_seed 187