ruby_direct_test.py revision 8931
112855Sgabeblack@google.com# Copyright (c) 2006-2007 The Regents of The University of Michigan 212855Sgabeblack@google.com# Copyright (c) 2009 Advanced Micro Devices, Inc. 312855Sgabeblack@google.com# All rights reserved. 412855Sgabeblack@google.com# 512855Sgabeblack@google.com# Redistribution and use in source and binary forms, with or without 612855Sgabeblack@google.com# modification, are permitted provided that the following conditions are 712855Sgabeblack@google.com# met: redistributions of source code must retain the above copyright 812855Sgabeblack@google.com# notice, this list of conditions and the following disclaimer; 912855Sgabeblack@google.com# redistributions in binary form must reproduce the above copyright 1012855Sgabeblack@google.com# notice, this list of conditions and the following disclaimer in the 1112855Sgabeblack@google.com# documentation and/or other materials provided with the distribution; 1212855Sgabeblack@google.com# neither the name of the copyright holders nor the names of its 1312855Sgabeblack@google.com# contributors may be used to endorse or promote products derived from 1412855Sgabeblack@google.com# this software without specific prior written permission. 1512855Sgabeblack@google.com# 1612855Sgabeblack@google.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1712855Sgabeblack@google.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1812855Sgabeblack@google.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1912855Sgabeblack@google.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2012855Sgabeblack@google.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2112855Sgabeblack@google.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2212855Sgabeblack@google.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2312855Sgabeblack@google.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2412855Sgabeblack@google.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2512855Sgabeblack@google.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2612855Sgabeblack@google.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2712855Sgabeblack@google.com# 2812855Sgabeblack@google.com# Authors: Ron Dreslinski 2912855Sgabeblack@google.com# Brad Beckmann 3012855Sgabeblack@google.com 3112855Sgabeblack@google.comimport m5 3212855Sgabeblack@google.comfrom m5.objects import * 3312855Sgabeblack@google.comfrom m5.defines import buildEnv 3412855Sgabeblack@google.comfrom m5.util import addToPath 3512855Sgabeblack@google.comimport os, optparse, sys 3612855Sgabeblack@google.comaddToPath('../common') 3712855Sgabeblack@google.comaddToPath('../ruby') 3812855Sgabeblack@google.com 3912855Sgabeblack@google.comimport Options 4012855Sgabeblack@google.comimport Ruby 4112855Sgabeblack@google.com 4212855Sgabeblack@google.com# Get paths we might need. It's expected this file is in m5/configs/example. 4312855Sgabeblack@google.comconfig_path = os.path.dirname(os.path.abspath(__file__)) 4412855Sgabeblack@google.comconfig_root = os.path.dirname(config_path) 4512855Sgabeblack@google.comm5_root = os.path.dirname(config_root) 4612855Sgabeblack@google.com 4712855Sgabeblack@google.comparser = optparse.OptionParser() 4812855Sgabeblack@google.comOptions.addCommonOptions(parser) 4912855Sgabeblack@google.com 5012855Sgabeblack@google.comparser.add_option("-l", "--requests", metavar="N", default=100, 5112855Sgabeblack@google.com help="Stop after N requests") 5212855Sgabeblack@google.comparser.add_option("-f", "--wakeup_freq", metavar="N", default=10, 5312855Sgabeblack@google.com help="Wakeup every N cycles") 5412855Sgabeblack@google.comparser.add_option("--test-type", type="string", default="SeriesGetx", 5512855Sgabeblack@google.com help="SeriesGetx|SeriesGets|Invalidate") 5612855Sgabeblack@google.com 5712855Sgabeblack@google.com# 5812855Sgabeblack@google.com# Add the ruby specific and protocol specific options 5912855Sgabeblack@google.com# 6012855Sgabeblack@google.comRuby.define_options(parser) 6112855Sgabeblack@google.com 6212855Sgabeblack@google.comexecfile(os.path.join(config_root, "common", "Options.py")) 6312855Sgabeblack@google.com 6412855Sgabeblack@google.com(options, args) = parser.parse_args() 6512855Sgabeblack@google.com 6612855Sgabeblack@google.comif args: 6712855Sgabeblack@google.com print "Error: script doesn't take any positional arguments" 6812855Sgabeblack@google.com sys.exit(1) 6912855Sgabeblack@google.com 7012855Sgabeblack@google.com# 7112855Sgabeblack@google.com# Select the direct test generator 7212855Sgabeblack@google.com# 7312855Sgabeblack@google.comif options.test_type == "SeriesGetx": 7412855Sgabeblack@google.com generator = SeriesRequestGenerator(num_cpus = options.num_cpus, 7512855Sgabeblack@google.com issue_writes = True) 7612855Sgabeblack@google.comelif options.test_type == "SeriesGets": 7712855Sgabeblack@google.com generator = SeriesRequestGenerator(num_cpus = options.num_cpus, 7812855Sgabeblack@google.com issue_writes = False) 7912855Sgabeblack@google.comelif options.test_type == "Invalidate": 8012855Sgabeblack@google.com generator = InvalidateGenerator(num_cpus = options.num_cpus) 8112855Sgabeblack@google.comelse: 8212855Sgabeblack@google.com print "Error: unknown direct test generator" 8312855Sgabeblack@google.com sys.exit(1) 8412855Sgabeblack@google.com 8512855Sgabeblack@google.com# 8612855Sgabeblack@google.com# Create the M5 system. Note that the Memory Object isn't 8712855Sgabeblack@google.com# actually used by the rubytester, but is included to support the 8812855Sgabeblack@google.com# M5 memory size == Ruby memory size checks 8912855Sgabeblack@google.com# 9012855Sgabeblack@google.comsystem = System(physmem = SimpleMemory()) 9112855Sgabeblack@google.com 9212855Sgabeblack@google.com# 9312855Sgabeblack@google.com# Create the ruby random tester 9412855Sgabeblack@google.com# 9512855Sgabeblack@google.comsystem.tester = RubyDirectedTester(requests_to_complete = \ 9612855Sgabeblack@google.com options.requests, 9712855Sgabeblack@google.com generator = generator) 9812855Sgabeblack@google.com 9912855Sgabeblack@google.comRuby.create_system(options, system) 10012855Sgabeblack@google.com 10112855Sgabeblack@google.comassert(options.num_cpus == len(system.ruby._cpu_ruby_ports)) 10212855Sgabeblack@google.com 10312855Sgabeblack@google.comfor ruby_port in system.ruby._cpu_ruby_ports: 10412855Sgabeblack@google.com # 10512855Sgabeblack@google.com # Tie the ruby tester ports to the ruby cpu ports 10612855Sgabeblack@google.com # 10712855Sgabeblack@google.com system.tester.cpuPort = ruby_port.slave 10812855Sgabeblack@google.com 10912855Sgabeblack@google.com# ----------------------- 11012855Sgabeblack@google.com# run simulation 11112855Sgabeblack@google.com# ----------------------- 11212855Sgabeblack@google.com 11312855Sgabeblack@google.comroot = Root( full_system = False, system = system ) 11412855Sgabeblack@google.comroot.system.mem_mode = 'timing' 11512855Sgabeblack@google.com 11612855Sgabeblack@google.com# Not much point in this being higher than the L1 latency 11712855Sgabeblack@google.comm5.ticks.setGlobalFrequency('1ns') 11812855Sgabeblack@google.com 11912855Sgabeblack@google.com# instantiate configuration 12012855Sgabeblack@google.comm5.instantiate() 12112855Sgabeblack@google.com 12212855Sgabeblack@google.com# simulate until program terminates 12312855Sgabeblack@google.comexit_event = m5.simulate(options.maxtick) 12412855Sgabeblack@google.com 12512855Sgabeblack@google.comprint 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause() 12612855Sgabeblack@google.com