Ruby.py revision 7566
12068SN/A# Copyright (c) 2006-2007 The Regents of The University of Michigan 22068SN/A# Copyright (c) 2009 Advanced Micro Devices, Inc. 32068SN/A# All rights reserved. 42068SN/A# 52068SN/A# Redistribution and use in source and binary forms, with or without 62068SN/A# modification, are permitted provided that the following conditions are 72068SN/A# met: redistributions of source code must retain the above copyright 82068SN/A# notice, this list of conditions and the following disclaimer; 92068SN/A# redistributions in binary form must reproduce the above copyright 102068SN/A# notice, this list of conditions and the following disclaimer in the 112068SN/A# documentation and/or other materials provided with the distribution; 122068SN/A# neither the name of the copyright holders nor the names of its 132068SN/A# contributors may be used to endorse or promote products derived from 142068SN/A# this software without specific prior written permission. 152068SN/A# 162068SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172068SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182068SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192068SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202068SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212068SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222068SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232068SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242068SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252068SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262068SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272068SN/A# 282665Ssaidi@eecs.umich.edu# Authors: Brad Beckmann 292665Ssaidi@eecs.umich.edu 302665Ssaidi@eecs.umich.eduimport math 312068SN/Aimport m5 322649Ssaidi@eecs.umich.edufrom m5.objects import * 332649Ssaidi@eecs.umich.edufrom m5.defines import buildEnv 342649Ssaidi@eecs.umich.edu 352649Ssaidi@eecs.umich.edudef define_options(parser): 362649Ssaidi@eecs.umich.edu # ruby network options 372068SN/A parser.add_option("--topology", type="string", default="Crossbar", 382068SN/A help="check src/mem/ruby/network/topologies for complete set") 392068SN/A parser.add_option("--mesh-rows", type="int", default=1, 402068SN/A help="the number of rows in the mesh topology") 412068SN/A parser.add_option("--garnet-network", type="string", default=none, 422068SN/A help="'fixed'|'flexible'") 432068SN/A 442068SN/A # ruby mapping options 452068SN/A parser.add_option("--numa-high-bit", type="int", default=none, 465736Snate@binkert.org help="high order address bit to use for numa mapping. " \ 472068SN/A "0 = highest bit, not specified = lowest bit") 482068SN/A 496181Sksewell@umich.edu # ruby sparse memory options 506181Sksewell@umich.edu parser.add_option("--use-map", action="store_true", default=False) 512068SN/A parser.add_option("--map-levels", type="int", default=4) 522068SN/A 532068SN/A # ruby debug cmd line options 542068SN/A parser.add_option("--ruby-debug", action="store_true", default=False) 552068SN/A parser.add_option("--ruby-debug-cycle", type="int", default=1) 562068SN/A 576181Sksewell@umich.edu parser.add_option("--recycle-latency", type="int", default=10, 586179Sksewell@umich.edu help="Recycle latency for ruby controller input buffers") 596179Sksewell@umich.edu 602068SN/A protocol = buildEnv['PROTOCOL'] 612068SN/A exec "import %s" % protocol 622068SN/A eval("%s.define_options(parser)" % protocol) 632068SN/A 642068SN/Adef create_system(options, system, piobus = None, dma_devices = []): 652068SN/A 662068SN/A protocol = buildEnv['PROTOCOL'] 672068SN/A exec "import %s" % protocol 682068SN/A try: 692068SN/A (cpu_sequencers, dir_cntrls, all_cntrls) = \ 702068SN/A eval("%s.create_system(options, system, piobus, dma_devices)" \ 712068SN/A % protocol) 722068SN/A except: 736181Sksewell@umich.edu print "Error: could not create sytem for ruby protocol %s" % protocol 746181Sksewell@umich.edu raise 752068SN/A 762068SN/A # 772068SN/A # Important: the topology must be created before the network and after the 782068SN/A # controllers. 792068SN/A # 802068SN/A exec "import %s" % options.topology 812068SN/A try: 822068SN/A net_topology = eval("%s.makeTopology(all_cntrls, options)" \ 832068SN/A % options.topology) 842068SN/A except: 852068SN/A print "Error: could not create topology %s" % options.topology 862068SN/A raise 872068SN/A 882068SN/A if options.garnet_network == "fixed": 892068SN/A network = GarnetNetwork_d(topology = net_topology) 906181Sksewell@umich.edu elif options.garnet_network == "flexible": 916181Sksewell@umich.edu network = GarnetNetwork(topology = net_topology) 922068SN/A else: 932068SN/A network = SimpleNetwork(topology = net_topology) 942068SN/A 952068SN/A # 962068SN/A # Loop through the directory controlers. 972068SN/A # Determine the total memory size of the ruby system and verify it is equal 982068SN/A # to physmem. However, if Ruby memory is using sparse memory in SE 992068SN/A # mode, then the system should not back-up the memory state with 1002068SN/A # the Memory Vector and thus the memory size bytes should stay at 0. 1012068SN/A # Also set the numa bits to the appropriate values. 1022068SN/A # 1032068SN/A total_mem_size = MemorySize('0B') 1042068SN/A 1052068SN/A dir_bits = int(math.log(options.num_dirs, 2)) 1062068SN/A 1072068SN/A if options.numa_high_bit: 1082068SN/A numa_bit = options.numa_high_bit 1092068SN/A else: 1102068SN/A # if not specified, use the lowest bits above the block offest 1112068SN/A if options.numa_high_bit == 0: 1122068SN/A if dir_bits > 0: 1132068SN/A # add 5 because bits 0-5 are the block offset 1142068SN/A numa_bit = dir_bits + 5 1152068SN/A else: 1162068SN/A numa_bit = 6 1173953Sstever@eecs.umich.edu 1182068SN/A for dir_cntrl in dir_cntrls: 1192068SN/A total_mem_size.value += dir_cntrl.directory.size.value 1202068SN/A dir_cntrl.directory.numa_high_bit = numa_bit 1212068SN/A 1222068SN/A physmem_size = long(system.physmem.range.second) - \ 1232068SN/A long(system.physmem.range.first) + 1 1242068SN/A assert(total_mem_size.value == physmem_size) 1252068SN/A 1262068SN/A ruby_profiler = RubyProfiler(num_of_sequencers = len(cpu_sequencers)) 1272068SN/A 1282068SN/A ruby = RubySystem(clock = options.clock, 1292068SN/A network = network, 1302068SN/A profiler = ruby_profiler, 1312068SN/A tracer = RubyTracer(), 1322068SN/A debug = RubyDebug(filter_string = 'none', 1332068SN/A verbosity_string = 'none', 1342227SN/A protocol_trace = options.ruby_debug, 1352068SN/A start_time = options.ruby_debug_cycle), 1362068SN/A mem_size = total_mem_size) 1372095SN/A 1386181Sksewell@umich.edu ruby.cpu_ruby_ports = cpu_sequencers 1396181Sksewell@umich.edu 1402095SN/A return ruby 1412095SN/A