Ruby.py revision 7663:abb78217021f
1955SN/A# Copyright (c) 2006-2007 The Regents of The University of Michigan 2955SN/A# Copyright (c) 2009 Advanced Micro Devices, Inc. 311408Sandreas.sandberg@arm.com# All rights reserved. 49812Sandreas.hansson@arm.com# 59812Sandreas.hansson@arm.com# Redistribution and use in source and binary forms, with or without 69812Sandreas.hansson@arm.com# modification, are permitted provided that the following conditions are 79812Sandreas.hansson@arm.com# met: redistributions of source code must retain the above copyright 89812Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer; 99812Sandreas.hansson@arm.com# redistributions in binary form must reproduce the above copyright 109812Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer in the 119812Sandreas.hansson@arm.com# documentation and/or other materials provided with the distribution; 129812Sandreas.hansson@arm.com# neither the name of the copyright holders nor the names of its 139812Sandreas.hansson@arm.com# contributors may be used to endorse or promote products derived from 149812Sandreas.hansson@arm.com# this software without specific prior written permission. 157816Ssteve.reinhardt@amd.com# 165871Snate@binkert.org# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 171762SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18955SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19955SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20955SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21955SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22955SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23955SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24955SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25955SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26955SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27955SN/A# 28955SN/A# Authors: Brad Beckmann 29955SN/A 30955SN/Aimport math 31955SN/Aimport m5 32955SN/Afrom m5.objects import * 33955SN/Afrom m5.defines import buildEnv 34955SN/A 35955SN/Adef define_options(parser): 36955SN/A # ruby network options 37955SN/A parser.add_option("--topology", type="string", default="Crossbar", 38955SN/A help="check src/mem/ruby/network/topologies for complete set") 39955SN/A parser.add_option("--mesh-rows", type="int", default=1, 40955SN/A help="the number of rows in the mesh topology") 41955SN/A parser.add_option("--garnet-network", type="string", default=None, 422665Ssaidi@eecs.umich.edu help="'fixed'|'flexible'") 432665Ssaidi@eecs.umich.edu 445863Snate@binkert.org # ruby mapping options 45955SN/A parser.add_option("--numa-high-bit", type="int", default=None, 46955SN/A help="high order address bit to use for numa mapping. " \ 47955SN/A "0 = highest bit, not specified = lowest bit") 48955SN/A 49955SN/A # ruby sparse memory options 508878Ssteve.reinhardt@amd.com parser.add_option("--use-map", action="store_true", default=False) 512632Sstever@eecs.umich.edu parser.add_option("--map-levels", type="int", default=4) 528878Ssteve.reinhardt@amd.com 532632Sstever@eecs.umich.edu # ruby debug cmd line options 54955SN/A parser.add_option("--ruby-debug", action="store_true", default=False) 558878Ssteve.reinhardt@amd.com parser.add_option("--ruby-debug-cycle", type="int", default=1) 562632Sstever@eecs.umich.edu 572761Sstever@eecs.umich.edu parser.add_option("--recycle-latency", type="int", default=10, 582632Sstever@eecs.umich.edu help="Recycle latency for ruby controller input buffers") 592632Sstever@eecs.umich.edu 602632Sstever@eecs.umich.edu protocol = buildEnv['PROTOCOL'] 612761Sstever@eecs.umich.edu exec "import %s" % protocol 622761Sstever@eecs.umich.edu eval("%s.define_options(parser)" % protocol) 632761Sstever@eecs.umich.edu 648878Ssteve.reinhardt@amd.comdef create_system(options, system, piobus = None, dma_devices = []): 658878Ssteve.reinhardt@amd.com 662761Sstever@eecs.umich.edu protocol = buildEnv['PROTOCOL'] 672761Sstever@eecs.umich.edu exec "import %s" % protocol 682761Sstever@eecs.umich.edu try: 692761Sstever@eecs.umich.edu (cpu_sequencers, dir_cntrls, all_cntrls) = \ 702761Sstever@eecs.umich.edu eval("%s.create_system(options, system, piobus, dma_devices)" \ 718878Ssteve.reinhardt@amd.com % protocol) 728878Ssteve.reinhardt@amd.com except: 732632Sstever@eecs.umich.edu print "Error: could not create sytem for ruby protocol %s" % protocol 742632Sstever@eecs.umich.edu raise 758878Ssteve.reinhardt@amd.com 768878Ssteve.reinhardt@amd.com # 772632Sstever@eecs.umich.edu # Important: the topology must be created before the network and after the 78955SN/A # controllers. 79955SN/A # 80955SN/A exec "import %s" % options.topology 815863Snate@binkert.org try: 825863Snate@binkert.org net_topology = eval("%s.makeTopology(all_cntrls, options)" \ 835863Snate@binkert.org % options.topology) 845863Snate@binkert.org except: 855863Snate@binkert.org print "Error: could not create topology %s" % options.topology 865863Snate@binkert.org raise 875863Snate@binkert.org 885863Snate@binkert.org if options.garnet_network == "fixed": 895863Snate@binkert.org network = GarnetNetwork_d(topology = net_topology) 905863Snate@binkert.org elif options.garnet_network == "flexible": 915863Snate@binkert.org network = GarnetNetwork(topology = net_topology) 928878Ssteve.reinhardt@amd.com else: 935863Snate@binkert.org network = SimpleNetwork(topology = net_topology) 945863Snate@binkert.org 955863Snate@binkert.org # 969812Sandreas.hansson@arm.com # Loop through the directory controlers. 979812Sandreas.hansson@arm.com # Determine the total memory size of the ruby system and verify it is equal 985863Snate@binkert.org # to physmem. However, if Ruby memory is using sparse memory in SE 999812Sandreas.hansson@arm.com # mode, then the system should not back-up the memory state with 1005863Snate@binkert.org # the Memory Vector and thus the memory size bytes should stay at 0. 1015863Snate@binkert.org # Also set the numa bits to the appropriate values. 1025863Snate@binkert.org # 1039812Sandreas.hansson@arm.com total_mem_size = MemorySize('0B') 1049812Sandreas.hansson@arm.com 1055863Snate@binkert.org dir_bits = int(math.log(options.num_dirs, 2)) 1065863Snate@binkert.org 1078878Ssteve.reinhardt@amd.com if options.numa_high_bit: 1085863Snate@binkert.org numa_bit = options.numa_high_bit 1095863Snate@binkert.org else: 1105863Snate@binkert.org # if not specified, use the lowest bits above the block offest 1116654Snate@binkert.org if dir_bits > 0: 11210196SCurtis.Dunham@arm.com # add 5 because bits 0-5 are the block offset 113955SN/A numa_bit = dir_bits + 5 1145396Ssaidi@eecs.umich.edu else: 11511401Sandreas.sandberg@arm.com numa_bit = 6 1165863Snate@binkert.org 1175863Snate@binkert.org for dir_cntrl in dir_cntrls: 1184202Sbinkertn@umich.edu total_mem_size.value += dir_cntrl.directory.size.value 1195863Snate@binkert.org dir_cntrl.directory.numa_high_bit = numa_bit 1205863Snate@binkert.org 1215863Snate@binkert.org physmem_size = long(system.physmem.range.second) - \ 1225863Snate@binkert.org long(system.physmem.range.first) + 1 123955SN/A assert(total_mem_size.value == physmem_size) 1246654Snate@binkert.org 1255273Sstever@gmail.com ruby_profiler = RubyProfiler(num_of_sequencers = len(cpu_sequencers)) 1265871Snate@binkert.org 1275273Sstever@gmail.com ruby = RubySystem(clock = options.clock, 1286655Snate@binkert.org network = network, 1298878Ssteve.reinhardt@amd.com profiler = ruby_profiler, 1306655Snate@binkert.org tracer = RubyTracer(), 1316655Snate@binkert.org debug = RubyDebug(filter_string = 'none', 1329219Spower.jg@gmail.com verbosity_string = 'none', 1336655Snate@binkert.org protocol_trace = options.ruby_debug, 1345871Snate@binkert.org start_time = options.ruby_debug_cycle), 1356654Snate@binkert.org mem_size = total_mem_size) 1368947Sandreas.hansson@arm.com 1375396Ssaidi@eecs.umich.edu ruby.cpu_ruby_ports = cpu_sequencers 1388120Sgblack@eecs.umich.edu 1398120Sgblack@eecs.umich.edu return ruby 1408120Sgblack@eecs.umich.edu