Ruby.py revision 7538
17639Sgblack@eecs.umich.edu# Copyright (c) 2006-2007 The Regents of The University of Michigan
27639Sgblack@eecs.umich.edu# Copyright (c) 2009 Advanced Micro Devices, Inc.
37639Sgblack@eecs.umich.edu# All rights reserved.
47639Sgblack@eecs.umich.edu#
57639Sgblack@eecs.umich.edu# Redistribution and use in source and binary forms, with or without
67639Sgblack@eecs.umich.edu# modification, are permitted provided that the following conditions are
77639Sgblack@eecs.umich.edu# met: redistributions of source code must retain the above copyright
87639Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer;
97639Sgblack@eecs.umich.edu# redistributions in binary form must reproduce the above copyright
107639Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the
117639Sgblack@eecs.umich.edu# documentation and/or other materials provided with the distribution;
127639Sgblack@eecs.umich.edu# neither the name of the copyright holders nor the names of its
137639Sgblack@eecs.umich.edu# contributors may be used to endorse or promote products derived from
147639Sgblack@eecs.umich.edu# this software without specific prior written permission.
157639Sgblack@eecs.umich.edu#
167639Sgblack@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
177639Sgblack@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
187639Sgblack@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
197639Sgblack@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
207639Sgblack@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
217639Sgblack@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
227639Sgblack@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
237639Sgblack@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
247639Sgblack@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
257639Sgblack@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
267639Sgblack@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
277639Sgblack@eecs.umich.edu#
287639Sgblack@eecs.umich.edu# Authors: Brad Beckmann
297639Sgblack@eecs.umich.edu
307639Sgblack@eecs.umich.eduimport m5
317639Sgblack@eecs.umich.edufrom m5.objects import *
327639Sgblack@eecs.umich.edufrom m5.defines import buildEnv
337639Sgblack@eecs.umich.edu
347639Sgblack@eecs.umich.edudef define_options(parser):
357639Sgblack@eecs.umich.edu    # ruby network options
367639Sgblack@eecs.umich.edu    parser.add_option("--topology", type="string", default="Crossbar",
377639Sgblack@eecs.umich.edu                 help="check src/mem/ruby/network/topologies for complete set")
387639Sgblack@eecs.umich.edu    parser.add_option("--mesh-rows", type="int", default=1,
397639Sgblack@eecs.umich.edu                      help="the number of rows in the mesh topology")
407639Sgblack@eecs.umich.edu    parser.add_option("--garnet-network", type="string", default=none,
417639Sgblack@eecs.umich.edu                      help="'fixed'|'flexible'")
427639Sgblack@eecs.umich.edu
437639Sgblack@eecs.umich.edu    # ruby mapping options
447639Sgblack@eecs.umich.edu    parser.add_option("--numa-high-bit", type="int", default=none,
457639Sgblack@eecs.umich.edu                      help="high order address bit to use for numa mapping")
467639Sgblack@eecs.umich.edu
477639Sgblack@eecs.umich.edu    # ruby sparse memory options
487639Sgblack@eecs.umich.edu    parser.add_option("--use-map", action="store_true", default=False)
497639Sgblack@eecs.umich.edu    parser.add_option("--map-levels", type="int", default=4)
507639Sgblack@eecs.umich.edu
517639Sgblack@eecs.umich.edu    protocol = buildEnv['PROTOCOL']
527639Sgblack@eecs.umich.edu    exec "import %s" % protocol
537639Sgblack@eecs.umich.edu    eval("%s.define_options(parser)" % protocol)
547639Sgblack@eecs.umich.edu
557639Sgblack@eecs.umich.edudef create_system(options, physmem, piobus = None, dma_devices = []):
567639Sgblack@eecs.umich.edu
577639Sgblack@eecs.umich.edu    protocol = buildEnv['PROTOCOL']
587639Sgblack@eecs.umich.edu    exec "import %s" % protocol
597639Sgblack@eecs.umich.edu    try:
607639Sgblack@eecs.umich.edu        (cpu_sequencers, dir_cntrls, all_cntrls) = \
617639Sgblack@eecs.umich.edu          eval("%s.create_system(options, physmem, piobus, dma_devices)" \
627639Sgblack@eecs.umich.edu               % protocol)
637639Sgblack@eecs.umich.edu    except:
647639Sgblack@eecs.umich.edu        print "Error: could not create sytem for ruby protocol %s" % protocol
657639Sgblack@eecs.umich.edu        sys.exit(1)
667639Sgblack@eecs.umich.edu
677639Sgblack@eecs.umich.edu    #
687639Sgblack@eecs.umich.edu    # Important: the topology must be created before the network and after the
697639Sgblack@eecs.umich.edu    # controllers.
707639Sgblack@eecs.umich.edu    #
717639Sgblack@eecs.umich.edu    exec "import %s" % options.topology
727639Sgblack@eecs.umich.edu    try:
737639Sgblack@eecs.umich.edu        net_topology = eval("%s.makeTopology(all_cntrls, options)" % options.topology)
747639Sgblack@eecs.umich.edu    except:
757639Sgblack@eecs.umich.edu        print "Error: could not create topology %s" % options.topology
767639Sgblack@eecs.umich.edu        sys.exit(1)
777639Sgblack@eecs.umich.edu
787639Sgblack@eecs.umich.edu    if options.garnet_network == "fixed":
797639Sgblack@eecs.umich.edu        network = GarnetNetwork_d(topology = net_topology)
807639Sgblack@eecs.umich.edu    elif options.garnet_network == "flexible":
817639Sgblack@eecs.umich.edu        network = GarnetNetwork(topology = net_topology)
827639Sgblack@eecs.umich.edu    else:
837639Sgblack@eecs.umich.edu        network = SimpleNetwork(topology = net_topology)
847639Sgblack@eecs.umich.edu
857639Sgblack@eecs.umich.edu    #
867639Sgblack@eecs.umich.edu    # Determine the total memory size of the ruby system and verify it is equal
877639Sgblack@eecs.umich.edu    # to physmem.  However, if Ruby memory is using sparse memory in SE
887639Sgblack@eecs.umich.edu    # mode, then the system should not back-up the memory state with
897639Sgblack@eecs.umich.edu    # the Memory Vector and thus the memory size bytes should stay at 0.
907639Sgblack@eecs.umich.edu    #
917639Sgblack@eecs.umich.edu    total_mem_size = MemorySize('0B')
927639Sgblack@eecs.umich.edu    for dir_cntrl in dir_cntrls:
937639Sgblack@eecs.umich.edu        total_mem_size.value += dir_cntrl.directory.size.value
947639Sgblack@eecs.umich.edu    physmem_size = long(physmem.range.second) - long(physmem.range.first) + 1
957639Sgblack@eecs.umich.edu    assert(total_mem_size.value == physmem_size)
967639Sgblack@eecs.umich.edu
977639Sgblack@eecs.umich.edu    ruby_profiler = RubyProfiler(num_of_sequencers = len(cpu_sequencers))
987639Sgblack@eecs.umich.edu
997639Sgblack@eecs.umich.edu    ruby = RubySystem(clock = options.clock,
1007639Sgblack@eecs.umich.edu                      network = network,
1017639Sgblack@eecs.umich.edu                      profiler = ruby_profiler,
1027639Sgblack@eecs.umich.edu                      tracer = RubyTracer(),
1037639Sgblack@eecs.umich.edu                      debug = RubyDebug(filter_string = 'none',
1047639Sgblack@eecs.umich.edu                                        verbosity_string = 'none',
1057639Sgblack@eecs.umich.edu                                        protocol_trace = False),
1067639Sgblack@eecs.umich.edu                      mem_size = total_mem_size)
1077639Sgblack@eecs.umich.edu
1087639Sgblack@eecs.umich.edu    ruby.cpu_ruby_ports = cpu_sequencers
1097639Sgblack@eecs.umich.edu
1107639Sgblack@eecs.umich.edu    return ruby
1117639Sgblack@eecs.umich.edu