Ruby.py revision 8839
1# Copyright (c) 2012 ARM Limited 2# All rights reserved. 3# 4# The license below extends only to copyright in the software and shall 5# not be construed as granting a license to any other intellectual 6# property including but not limited to intellectual property relating 7# to a hardware implementation of the functionality of the software 8# licensed hereunder. You may use the software subject to the license 9# terms below provided that you ensure that this notice is replicated 10# unmodified and in its entirety in all distributions of the software, 11# modified or unmodified, in source code or in binary form. 12# 13# Copyright (c) 2006-2007 The Regents of The University of Michigan 14# Copyright (c) 2009 Advanced Micro Devices, Inc. 15# All rights reserved. 16# 17# Redistribution and use in source and binary forms, with or without 18# modification, are permitted provided that the following conditions are 19# met: redistributions of source code must retain the above copyright 20# notice, this list of conditions and the following disclaimer; 21# redistributions in binary form must reproduce the above copyright 22# notice, this list of conditions and the following disclaimer in the 23# documentation and/or other materials provided with the distribution; 24# neither the name of the copyright holders nor the names of its 25# contributors may be used to endorse or promote products derived from 26# this software without specific prior written permission. 27# 28# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 31# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 32# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39# 40# Authors: Brad Beckmann 41 42import math 43import m5 44from m5.objects import * 45from m5.defines import buildEnv 46 47def define_options(parser): 48 # ruby network options 49 parser.add_option("--topology", type="string", default="Crossbar", 50 help="check src/mem/ruby/network/topologies for complete set") 51 parser.add_option("--mesh-rows", type="int", default=1, 52 help="the number of rows in the mesh topology") 53 parser.add_option("--garnet-network", type="string", default=None, 54 help="'fixed'|'flexible'") 55 parser.add_option("--network-fault-model", action="store_true", default=False, 56 help="enable network fault model: see src/mem/ruby/network/fault_model/") 57 58 # ruby mapping options 59 parser.add_option("--numa-high-bit", type="int", default=0, 60 help="high order address bit to use for numa mapping. " \ 61 "0 = highest bit, not specified = lowest bit") 62 63 # ruby sparse memory options 64 parser.add_option("--use-map", action="store_true", default=False) 65 parser.add_option("--map-levels", type="int", default=4) 66 67 parser.add_option("--recycle-latency", type="int", default=10, 68 help="Recycle latency for ruby controller input buffers") 69 70 parser.add_option("--random_seed", type="int", default=1234, 71 help="Used for seeding the random number generator") 72 73 parser.add_option("--ruby_stats", type="string", default="ruby.stats") 74 75 protocol = buildEnv['PROTOCOL'] 76 exec "import %s" % protocol 77 eval("%s.define_options(parser)" % protocol) 78 79def create_system(options, system, piobus = None, dma_devices = []): 80 81 system.ruby = RubySystem(clock = options.clock, 82 stats_filename = options.ruby_stats, 83 no_mem_vec = options.use_map) 84 ruby = system.ruby 85 86 protocol = buildEnv['PROTOCOL'] 87 exec "import %s" % protocol 88 try: 89 (cpu_sequencers, dir_cntrls, all_cntrls) = \ 90 eval("%s.create_system(options, system, piobus, \ 91 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 # Connect the system port for loading of binaries etc 109 system.system_port = system.sys_port_proxy.slave 110 111 112 # 113 # Set the network classes based on the command line options 114 # 115 if options.garnet_network == "fixed": 116 class NetworkClass(GarnetNetwork_d): pass 117 class IntLinkClass(GarnetIntLink_d): pass 118 class ExtLinkClass(GarnetExtLink_d): pass 119 class RouterClass(GarnetRouter_d): pass 120 elif options.garnet_network == "flexible": 121 class NetworkClass(GarnetNetwork): pass 122 class IntLinkClass(GarnetIntLink): pass 123 class ExtLinkClass(GarnetExtLink): pass 124 class RouterClass(GarnetRouter): pass 125 else: 126 class NetworkClass(SimpleNetwork): pass 127 class IntLinkClass(SimpleIntLink): pass 128 class ExtLinkClass(SimpleExtLink): pass 129 class RouterClass(BasicRouter): pass 130 131 # 132 # Important: the topology must be created before the network and after the 133 # controllers. 134 # 135 exec "import %s" % options.topology 136 try: 137 net_topology = eval("%s.makeTopology(all_cntrls, options, \ 138 IntLinkClass, ExtLinkClass, \ 139 RouterClass)" \ 140 % options.topology) 141 except: 142 print "Error: could not create topology %s" % options.topology 143 raise 144 145 if options.network_fault_model: 146 assert(options.garnet_network == "fixed") 147 fault_model = FaultModel() 148 network = NetworkClass(ruby_system = ruby, topology = net_topology,\ 149 enable_fault_model=True, fault_model = fault_model) 150 else: 151 network = NetworkClass(ruby_system = ruby, topology = net_topology) 152 153 # 154 # Loop through the directory controlers. 155 # Determine the total memory size of the ruby system and verify it is equal 156 # to physmem. However, if Ruby memory is using sparse memory in SE 157 # mode, then the system should not back-up the memory state with 158 # the Memory Vector and thus the memory size bytes should stay at 0. 159 # Also set the numa bits to the appropriate values. 160 # 161 total_mem_size = MemorySize('0B') 162 163 dir_bits = int(math.log(options.num_dirs, 2)) 164 165 if options.numa_high_bit: 166 numa_bit = options.numa_high_bit 167 else: 168 # if not specified, use the lowest bits above the block offest 169 if dir_bits > 0: 170 # add 5 because bits 0-5 are the block offset 171 numa_bit = dir_bits + 5 172 else: 173 numa_bit = 6 174 175 for dir_cntrl in dir_cntrls: 176 total_mem_size.value += dir_cntrl.directory.size.value 177 dir_cntrl.directory.numa_high_bit = numa_bit 178 179 physmem_size = long(system.physmem.range.second) - \ 180 long(system.physmem.range.first) + 1 181 assert(total_mem_size.value == physmem_size) 182 183 ruby_profiler = RubyProfiler(ruby_system = ruby, 184 num_of_sequencers = len(cpu_sequencers)) 185 ruby.network = network 186 ruby.profiler = ruby_profiler 187 ruby.mem_size = total_mem_size 188 ruby._cpu_ruby_ports = cpu_sequencers 189 ruby.random_seed = options.random_seed 190