Ruby.py revision 10012
12600SN/A# Copyright (c) 2012 ARM Limited 22600SN/A# All rights reserved. 32600SN/A# 42600SN/A# The license below extends only to copyright in the software and shall 52600SN/A# not be construed as granting a license to any other intellectual 62600SN/A# property including but not limited to intellectual property relating 72600SN/A# to a hardware implementation of the functionality of the software 82600SN/A# licensed hereunder. You may use the software subject to the license 92600SN/A# terms below provided that you ensure that this notice is replicated 102600SN/A# unmodified and in its entirety in all distributions of the software, 112600SN/A# modified or unmodified, in source code or in binary form. 122600SN/A# 132600SN/A# Copyright (c) 2006-2007 The Regents of The University of Michigan 142600SN/A# Copyright (c) 2009 Advanced Micro Devices, Inc. 152600SN/A# All rights reserved. 162600SN/A# 172600SN/A# Redistribution and use in source and binary forms, with or without 182600SN/A# modification, are permitted provided that the following conditions are 192600SN/A# met: redistributions of source code must retain the above copyright 202600SN/A# notice, this list of conditions and the following disclaimer; 212600SN/A# redistributions in binary form must reproduce the above copyright 222600SN/A# notice, this list of conditions and the following disclaimer in the 232600SN/A# documentation and/or other materials provided with the distribution; 242600SN/A# neither the name of the copyright holders nor the names of its 252600SN/A# contributors may be used to endorse or promote products derived from 262600SN/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 292600SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 302600SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 312600SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 322600SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 336215Snate@binkert.org# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 346215Snate@binkert.org# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 353113Sgblack@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 362600SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 372600SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 382600SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 392600SN/A# 402600SN/A# Authors: Brad Beckmann 412600SN/A 423113Sgblack@eecs.umich.eduimport math 433113Sgblack@eecs.umich.eduimport m5 442600SN/Afrom m5.objects import * 452600SN/Afrom m5.defines import buildEnv 462600SN/A 472600SN/Adef define_options(parser): 482600SN/A # By default, ruby uses the simple timing cpu 493122Sgblack@eecs.umich.edu parser.set_defaults(cpu_type="timing") 502600SN/A 512600SN/A parser.add_option("--ruby-clock", action="store", type="string", 522600SN/A default='2GHz', 532600SN/A help="Clock for blocks running at Ruby system's speed") 542600SN/A 552600SN/A # Options related to cache structure 562600SN/A parser.add_option("--ports", action="store", type="int", default=4, 572600SN/A help="used of transitions per cycle which is a proxy \ 583122Sgblack@eecs.umich.edu for the number of ports.") 592600SN/A 602600SN/A # ruby network options 612600SN/A parser.add_option("--topology", type="string", default="Crossbar", 622600SN/A help="check src/mem/ruby/network/topologies for complete set") 632600SN/A parser.add_option("--mesh-rows", type="int", default=1, 642600SN/A help="the number of rows in the mesh topology") 652600SN/A parser.add_option("--garnet-network", type="choice", 662600SN/A choices=['fixed', 'flexible'], help="'fixed'|'flexible'") 672600SN/A parser.add_option("--network-fault-model", action="store_true", default=False, 683113Sgblack@eecs.umich.edu help="enable network fault model: see src/mem/ruby/network/fault_model/") 695543Ssaidi@eecs.umich.edu 705543Ssaidi@eecs.umich.edu # ruby mapping options 715543Ssaidi@eecs.umich.edu parser.add_option("--numa-high-bit", type="int", default=0, 725543Ssaidi@eecs.umich.edu help="high order address bit to use for numa mapping. " \ 735543Ssaidi@eecs.umich.edu "0 = highest bit, not specified = lowest bit") 745543Ssaidi@eecs.umich.edu 755543Ssaidi@eecs.umich.edu # ruby sparse memory options 765543Ssaidi@eecs.umich.edu parser.add_option("--use-map", action="store_true", default=False) 775543Ssaidi@eecs.umich.edu parser.add_option("--map-levels", type="int", default=4) 785543Ssaidi@eecs.umich.edu 795543Ssaidi@eecs.umich.edu parser.add_option("--recycle-latency", type="int", default=10, 803113Sgblack@eecs.umich.edu help="Recycle latency for ruby controller input buffers") 815543Ssaidi@eecs.umich.edu 825543Ssaidi@eecs.umich.edu parser.add_option("--random_seed", type="int", default=1234, 832600SN/A help="Used for seeding the random number generator") 843113Sgblack@eecs.umich.edu 852600SN/A parser.add_option("--ruby_stats", type="string", default="ruby.stats") 862600SN/A 873113Sgblack@eecs.umich.edu protocol = buildEnv['PROTOCOL'] 885543Ssaidi@eecs.umich.edu exec "import %s" % protocol 895543Ssaidi@eecs.umich.edu eval("%s.define_options(parser)" % protocol) 905543Ssaidi@eecs.umich.edu 915543Ssaidi@eecs.umich.edudef create_topology(controllers, options): 925543Ssaidi@eecs.umich.edu """ Called from create_system in configs/ruby/<protocol>.py 935543Ssaidi@eecs.umich.edu Must return an object which is a subclass of BaseTopology 945543Ssaidi@eecs.umich.edu found in configs/topologies/BaseTopology.py 955543Ssaidi@eecs.umich.edu This is a wrapper for the legacy topologies. 965543Ssaidi@eecs.umich.edu """ 975543Ssaidi@eecs.umich.edu exec "import %s as Topo" % options.topology 985543Ssaidi@eecs.umich.edu topology = eval("Topo.%s(controllers)" % options.topology) 993113Sgblack@eecs.umich.edu return topology 1005543Ssaidi@eecs.umich.edu 1015543Ssaidi@eecs.umich.edudef create_system(options, system, piobus = None, dma_ports = []): 1022600SN/A 1033113Sgblack@eecs.umich.edu system.ruby = RubySystem(no_mem_vec = options.use_map) 1042600SN/A ruby = system.ruby 1052600SN/A 1062600SN/A protocol = buildEnv['PROTOCOL'] 1072600SN/A exec "import %s" % protocol 1082600SN/A try: 1093113Sgblack@eecs.umich.edu (cpu_sequencers, dir_cntrls, topology) = \ 1105543Ssaidi@eecs.umich.edu eval("%s.create_system(options, system, piobus, dma_ports, ruby)" 1115543Ssaidi@eecs.umich.edu % protocol) 1125543Ssaidi@eecs.umich.edu except: 1135543Ssaidi@eecs.umich.edu print "Error: could not create sytem for ruby protocol %s" % protocol 1145543Ssaidi@eecs.umich.edu raise 1153113Sgblack@eecs.umich.edu 1162600SN/A # Create a port proxy for connecting the system port. This is 11711907SBrandon.Potter@amd.com # independent of the protocol and kept in the protocol-agnostic 11811907SBrandon.Potter@amd.com # part (i.e. here). 11911907SBrandon.Potter@amd.com sys_port_proxy = RubyPortProxy(ruby_system = ruby) 1202600SN/A # Give the system port proxy a SimObject parent without creating a 1212600SN/A # full-fledged controller 1222600SN/A system.sys_port_proxy = sys_port_proxy 123 124 # Connect the system port for loading of binaries etc 125 system.system_port = system.sys_port_proxy.slave 126 127 128 # 129 # Set the network classes based on the command line options 130 # 131 if options.garnet_network == "fixed": 132 class NetworkClass(GarnetNetwork_d): pass 133 class IntLinkClass(GarnetIntLink_d): pass 134 class ExtLinkClass(GarnetExtLink_d): pass 135 class RouterClass(GarnetRouter_d): pass 136 elif options.garnet_network == "flexible": 137 class NetworkClass(GarnetNetwork): pass 138 class IntLinkClass(GarnetIntLink): pass 139 class ExtLinkClass(GarnetExtLink): pass 140 class RouterClass(GarnetRouter): pass 141 else: 142 class NetworkClass(SimpleNetwork): pass 143 class IntLinkClass(SimpleIntLink): pass 144 class ExtLinkClass(SimpleExtLink): pass 145 class RouterClass(Switch): pass 146 147 148 # Create the network topology 149 network = NetworkClass(ruby_system = ruby, topology = topology.description, 150 routers = [], ext_links = [], int_links = []) 151 topology.makeTopology(options, network, IntLinkClass, ExtLinkClass, 152 RouterClass) 153 154 if options.network_fault_model: 155 assert(options.garnet_network == "fixed") 156 network.enable_fault_model = True 157 network.fault_model = FaultModel() 158 159 # 160 # Loop through the directory controlers. 161 # Determine the total memory size of the ruby system and verify it is equal 162 # to physmem. However, if Ruby memory is using sparse memory in SE 163 # mode, then the system should not back-up the memory state with 164 # the Memory Vector and thus the memory size bytes should stay at 0. 165 # Also set the numa bits to the appropriate values. 166 # 167 total_mem_size = MemorySize('0B') 168 169 ruby.block_size_bytes = options.cacheline_size 170 block_size_bits = int(math.log(options.cacheline_size, 2)) 171 172 if options.numa_high_bit: 173 numa_bit = options.numa_high_bit 174 else: 175 # if the numa_bit is not specified, set the directory bits as the 176 # lowest bits above the block offset bits, and the numa_bit as the 177 # highest of those directory bits 178 dir_bits = int(math.log(options.num_dirs, 2)) 179 numa_bit = block_size_bits + dir_bits - 1 180 181 for dir_cntrl in dir_cntrls: 182 total_mem_size.value += dir_cntrl.directory.size.value 183 dir_cntrl.directory.numa_high_bit = numa_bit 184 185 phys_mem_size = sum(map(lambda r: r.size(), system.mem_ranges)) 186 assert(total_mem_size.value == phys_mem_size) 187 188 ruby.network = network 189 ruby.mem_size = total_mem_size 190 ruby._cpu_ruby_ports = cpu_sequencers 191 ruby.num_of_sequencers = len(cpu_sequencers) 192 ruby.random_seed = options.random_seed 193