Ruby.py revision 7563
11689SN/A# Copyright (c) 2006-2007 The Regents of The University of Michigan 27598Sminkyu.jeong@arm.com# Copyright (c) 2009 Advanced Micro Devices, Inc. 37598Sminkyu.jeong@arm.com# All rights reserved. 47598Sminkyu.jeong@arm.com# 57598Sminkyu.jeong@arm.com# Redistribution and use in source and binary forms, with or without 67598Sminkyu.jeong@arm.com# modification, are permitted provided that the following conditions are 77598Sminkyu.jeong@arm.com# met: redistributions of source code must retain the above copyright 87598Sminkyu.jeong@arm.com# notice, this list of conditions and the following disclaimer; 97598Sminkyu.jeong@arm.com# redistributions in binary form must reproduce the above copyright 107598Sminkyu.jeong@arm.com# notice, this list of conditions and the following disclaimer in the 117598Sminkyu.jeong@arm.com# documentation and/or other materials provided with the distribution; 127598Sminkyu.jeong@arm.com# neither the name of the copyright holders nor the names of its 137598Sminkyu.jeong@arm.com# contributors may be used to endorse or promote products derived from 142326SN/A# this software without specific prior written permission. 151689SN/A# 161689SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 171689SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 181689SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 191689SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 201689SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 211689SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 221689SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 231689SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 241689SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 251689SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 261689SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 271689SN/A# 281689SN/A# Authors: Brad Beckmann 291689SN/A 301689SN/Aimport math 311689SN/Aimport m5 321689SN/Afrom m5.objects import * 331689SN/Afrom m5.defines import buildEnv 341689SN/A 351689SN/Adef define_options(parser): 361689SN/A # ruby network options 371689SN/A parser.add_option("--topology", type="string", default="Crossbar", 381689SN/A help="check src/mem/ruby/network/topologies for complete set") 392665Ssaidi@eecs.umich.edu parser.add_option("--mesh-rows", type="int", default=1, 402665Ssaidi@eecs.umich.edu help="the number of rows in the mesh topology") 411689SN/A parser.add_option("--garnet-network", type="string", default=none, 421689SN/A help="'fixed'|'flexible'") 431060SN/A 441060SN/A # ruby mapping options 451689SN/A parser.add_option("--numa-high-bit", type="int", default=none, 461060SN/A help="high order address bit to use for numa mapping. " \ 471060SN/A "0 = highest bit, not specified = lowest bit") 481060SN/A 498230Snate@binkert.org # ruby sparse memory options 506658Snate@binkert.org parser.add_option("--use-map", action="store_true", default=False) 512292SN/A parser.add_option("--map-levels", type="int", default=4) 521717SN/A 538229Snate@binkert.org # ruby debug cmd line options 545529Snate@binkert.org parser.add_option("--ruby-debug", action="store_true", default=False) 551060SN/A parser.add_option("--ruby-debug-cycle", type="int", default=1) 566221Snate@binkert.org 576221Snate@binkert.org protocol = buildEnv['PROTOCOL'] 581681SN/A exec "import %s" % protocol 595529Snate@binkert.org eval("%s.define_options(parser)" % protocol) 602873Sktlim@umich.edu 614329Sktlim@umich.edudef create_system(options, system, piobus = None, dma_devices = []): 624329Sktlim@umich.edu 634329Sktlim@umich.edu protocol = buildEnv['PROTOCOL'] 642292SN/A exec "import %s" % protocol 652292SN/A try: 662292SN/A (cpu_sequencers, dir_cntrls, all_cntrls) = \ 672292SN/A eval("%s.create_system(options, system, piobus, dma_devices)" \ 682820Sktlim@umich.edu % protocol) 692292SN/A except: 702820Sktlim@umich.edu print "Error: could not create sytem for ruby protocol %s" % protocol 712820Sktlim@umich.edu raise 725529Snate@binkert.org 732307SN/A # 741060SN/A # Important: the topology must be created before the network and after the 752292SN/A # controllers. 762292SN/A # 772292SN/A exec "import %s" % options.topology 781060SN/A try: 791060SN/A net_topology = eval("%s.makeTopology(all_cntrls, options)" \ 801060SN/A % options.topology) 811060SN/A except: 821060SN/A print "Error: could not create topology %s" % options.topology 831060SN/A raise 841681SN/A 856221Snate@binkert.org if options.garnet_network == "fixed": 866221Snate@binkert.org network = GarnetNetwork_d(topology = net_topology) 876221Snate@binkert.org elif options.garnet_network == "flexible": 886221Snate@binkert.org network = GarnetNetwork(topology = net_topology) 892292SN/A else: 902292SN/A network = SimpleNetwork(topology = net_topology) 912820Sktlim@umich.edu 922820Sktlim@umich.edu # 932292SN/A # Loop through the directory controlers. 942292SN/A # Determine the total memory size of the ruby system and verify it is equal 952820Sktlim@umich.edu # to physmem. However, if Ruby memory is using sparse memory in SE 962820Sktlim@umich.edu # mode, then the system should not back-up the memory state with 972292SN/A # the Memory Vector and thus the memory size bytes should stay at 0. 982292SN/A # Also set the numa bits to the appropriate values. 992292SN/A # 1002292SN/A total_mem_size = MemorySize('0B') 1012292SN/A 1022292SN/A dir_bits = int(math.log(options.num_dirs, 2)) 1032292SN/A 1042292SN/A if options.numa_high_bit: 1051060SN/A numa_bit = options.numa_high_bit 1061060SN/A else: 1071681SN/A # if not specified, use the lowest bits above the block offest 1081062SN/A if options.numa_high_bit == 0: 1092292SN/A if dir_bits > 0: 1101062SN/A # add 5 because bits 0-5 are the block offset 1112301SN/A numa_bit = dir_bits + 5 1122301SN/A else: 1131062SN/A numa_bit = 6 1142727Sktlim@umich.edu 1151062SN/A for dir_cntrl in dir_cntrls: 1161062SN/A total_mem_size.value += dir_cntrl.directory.size.value 1171062SN/A dir_cntrl.directory.numa_high_bit = numa_bit 1181062SN/A 1191062SN/A physmem_size = long(system.physmem.range.second) - \ 1201062SN/A long(system.physmem.range.first) + 1 1211062SN/A assert(total_mem_size.value == physmem_size) 1221062SN/A 1231062SN/A ruby_profiler = RubyProfiler(num_of_sequencers = len(cpu_sequencers)) 1241062SN/A 1251062SN/A ruby = RubySystem(clock = options.clock, 1261062SN/A network = network, 1271062SN/A profiler = ruby_profiler, 1281062SN/A tracer = RubyTracer(), 1291062SN/A debug = RubyDebug(filter_string = 'none', 1301062SN/A verbosity_string = 'none', 1311062SN/A protocol_trace = options.ruby_debug, 1321062SN/A start_time = options.ruby_debug_cycle), 1331062SN/A mem_size = total_mem_size) 1341062SN/A 1351062SN/A ruby.cpu_ruby_ports = cpu_sequencers 1361062SN/A 1371062SN/A return ruby 1381062SN/A