ruby_mem_test.py revision 9793:6e6cefc1db1f
1955SN/A# Copyright (c) 2006-2007 The Regents of The University of Michigan
2955SN/A# Copyright (c) 2009 Advanced Micro Devices, Inc.
31762SN/A# All rights reserved.
4955SN/A#
5955SN/A# Redistribution and use in source and binary forms, with or without
6955SN/A# modification, are permitted provided that the following conditions are
7955SN/A# met: redistributions of source code must retain the above copyright
8955SN/A# notice, this list of conditions and the following disclaimer;
9955SN/A# redistributions in binary form must reproduce the above copyright
10955SN/A# notice, this list of conditions and the following disclaimer in the
11955SN/A# documentation and/or other materials provided with the distribution;
12955SN/A# neither the name of the copyright holders nor the names of its
13955SN/A# contributors may be used to endorse or promote products derived from
14955SN/A# this software without specific prior written permission.
15955SN/A#
16955SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17955SN/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#
282665Ssaidi@eecs.umich.edu# Authors: Ron Dreslinski
294762Snate@binkert.org#          Brad Beckmann
30955SN/A
315522Snate@binkert.orgimport m5
326143Snate@binkert.orgfrom m5.objects import *
334762Snate@binkert.orgfrom m5.defines import buildEnv
345522Snate@binkert.orgfrom m5.util import addToPath
35955SN/Aimport os, optparse, sys
365522Snate@binkert.orgaddToPath('../common')
37955SN/AaddToPath('../ruby')
385522Snate@binkert.orgaddToPath('../topologies')
394202Sbinkertn@umich.edu
405742Snate@binkert.orgimport Options
41955SN/Aimport Ruby
424381Sbinkertn@umich.edu
434381Sbinkertn@umich.edu# Get paths we might need.  It's expected this file is in m5/configs/example.
448334Snate@binkert.orgconfig_path = os.path.dirname(os.path.abspath(__file__))
45955SN/Aconfig_root = os.path.dirname(config_path)
46955SN/A
474202Sbinkertn@umich.eduparser = optparse.OptionParser()
48955SN/AOptions.addCommonOptions(parser)
494382Sbinkertn@umich.edu
504382Sbinkertn@umich.eduparser.add_option("-l", "--maxloads", metavar="N", default=0,
514382Sbinkertn@umich.edu                  help="Stop after N loads")
526654Snate@binkert.orgparser.add_option("--progress", type="int", default=1000,
535517Snate@binkert.org                  metavar="NLOADS",
548614Sgblack@eecs.umich.edu                  help="Progress message interval "
557674Snate@binkert.org                  "[default: %default]")
566143Snate@binkert.orgparser.add_option("--num-dmas", type="int", default=0, help="# of dma testers")
576143Snate@binkert.orgparser.add_option("--functional", type="int", default=0,
586143Snate@binkert.org                  help="percentage of accesses that should be functional")
598233Snate@binkert.orgparser.add_option("--suppress-func-warnings", action="store_true",
608233Snate@binkert.org                  help="suppress warnings when functional accesses fail")
618233Snate@binkert.org
628233Snate@binkert.org#
638233Snate@binkert.org# Add the ruby specific and protocol specific options
648334Snate@binkert.org#
658334Snate@binkert.orgRuby.define_options(parser)
6610453SAndrew.Bardsley@arm.com
6710453SAndrew.Bardsley@arm.comexecfile(os.path.join(config_root, "common", "Options.py"))
688233Snate@binkert.org
698233Snate@binkert.org(options, args) = parser.parse_args()
708233Snate@binkert.org
718233Snate@binkert.org#
728233Snate@binkert.org# Set the default cache size and associativity to be very small to encourage
738233Snate@binkert.org# races between requests and writebacks.
746143Snate@binkert.org#
758233Snate@binkert.orgoptions.l1d_size="256B"
768233Snate@binkert.orgoptions.l1i_size="256B"
778233Snate@binkert.orgoptions.l2_size="512B"
786143Snate@binkert.orgoptions.l3_size="1kB"
796143Snate@binkert.orgoptions.l1d_assoc=2
806143Snate@binkert.orgoptions.l1i_assoc=2
816143Snate@binkert.orgoptions.l2_assoc=2
828233Snate@binkert.orgoptions.l3_assoc=2
838233Snate@binkert.org
848233Snate@binkert.orgif args:
856143Snate@binkert.org     print "Error: script doesn't take any positional arguments"
868233Snate@binkert.org     sys.exit(1)
878233Snate@binkert.org
888233Snate@binkert.orgblock_size = 64
898233Snate@binkert.org
906143Snate@binkert.orgif options.num_cpus > block_size:
916143Snate@binkert.org     print "Error: Number of testers %d limited to %d because of false sharing" \
926143Snate@binkert.org           % (options.num_cpus, block_size)
934762Snate@binkert.org     sys.exit(1)
946143Snate@binkert.org
958233Snate@binkert.org#
968233Snate@binkert.org# Currently ruby does not support atomic or uncacheable accesses
978233Snate@binkert.org#
988233Snate@binkert.orgcpus = [ MemTest(atomic = False,
998233Snate@binkert.org                 max_loads = options.maxloads,
1006143Snate@binkert.org                 issue_dmas = False,
1018233Snate@binkert.org                 percent_functional = options.functional,
1028233Snate@binkert.org                 percent_uncacheable = 0,
1038233Snate@binkert.org                 progress_interval = options.progress,
1048233Snate@binkert.org                 suppress_func_warnings = options.suppress_func_warnings) \
1056143Snate@binkert.org         for i in xrange(options.num_cpus) ]
1066143Snate@binkert.org
1076143Snate@binkert.orgsystem = System(cpu = cpus,
1086143Snate@binkert.org                funcmem = SimpleMemory(in_addr_map = False),
1096143Snate@binkert.org                funcbus = NoncoherentBus(),
1106143Snate@binkert.org                physmem = SimpleMemory(),
1116143Snate@binkert.org                clk_domain = SrcClockDomain(clock = options.sys_clock))
1126143Snate@binkert.org
1136143Snate@binkert.orgif options.num_dmas > 0:
1147065Snate@binkert.org    dmas = [ MemTest(atomic = False,
1156143Snate@binkert.org                     max_loads = options.maxloads,
1168233Snate@binkert.org                     issue_dmas = True,
1178233Snate@binkert.org                     percent_functional = 0,
1188233Snate@binkert.org                     percent_uncacheable = 0,
1198233Snate@binkert.org                     progress_interval = options.progress,
1208233Snate@binkert.org                     suppress_func_warnings =
1218233Snate@binkert.org                                        not options.suppress_func_warnings) \
1228233Snate@binkert.org             for i in xrange(options.num_dmas) ]
1238233Snate@binkert.org    system.dma_devices = dmas
1248233Snate@binkert.orgelse:
1258233Snate@binkert.org    dmas = []
1268233Snate@binkert.org
1278233Snate@binkert.orgdma_ports = []
1288233Snate@binkert.orgfor (i, dma) in enumerate(dmas):
1298233Snate@binkert.org    dma_ports.append(dma.test)
1308233Snate@binkert.orgRuby.create_system(options, system, dma_ports = dma_ports)
1318233Snate@binkert.org
1328233Snate@binkert.org# Create a seperate clock domain for Ruby
1338233Snate@binkert.orgsystem.ruby.clk_domain = SrcClockDomain(clock = options.ruby_clock)
1348233Snate@binkert.org
1358233Snate@binkert.org#
1368233Snate@binkert.org# The tester is most effective when randomization is turned on and
1378233Snate@binkert.org# artifical delay is randomly inserted on messages
1388233Snate@binkert.org#
1398233Snate@binkert.orgsystem.ruby.randomization = True
1408233Snate@binkert.org
1418233Snate@binkert.orgassert(len(cpus) == len(system.ruby._cpu_ruby_ports))
1428233Snate@binkert.org
1438233Snate@binkert.orgfor (i, cpu) in enumerate(cpus):
1448233Snate@binkert.org    #
1458233Snate@binkert.org    # Tie the cpu memtester ports to the correct system ports
1468233Snate@binkert.org    #
1476143Snate@binkert.org    cpu.test = system.ruby._cpu_ruby_ports[i].slave
1486143Snate@binkert.org    cpu.functional = system.funcbus.slave
1496143Snate@binkert.org
1506143Snate@binkert.org    #
1516143Snate@binkert.org    # Since the memtester is incredibly bursty, increase the deadlock
1526143Snate@binkert.org    # threshold to 5 million cycles
1539982Satgutier@umich.edu    #
15410196SCurtis.Dunham@arm.com    system.ruby._cpu_ruby_ports[i].deadlock_threshold = 5000000
15510196SCurtis.Dunham@arm.com
15610196SCurtis.Dunham@arm.com    #
15710196SCurtis.Dunham@arm.com    # Ruby doesn't need the backing image of memory when running with
15810196SCurtis.Dunham@arm.com    # the tester.
15910196SCurtis.Dunham@arm.com    #
16010196SCurtis.Dunham@arm.com    system.ruby._cpu_ruby_ports[i].access_phys_mem = False
16110196SCurtis.Dunham@arm.com
1626143Snate@binkert.orgfor (i, dma) in enumerate(dmas):
1636143Snate@binkert.org    #
1648945Ssteve.reinhardt@amd.com    # Tie the dma memtester ports to the correct functional port
1658233Snate@binkert.org    # Note that the test port has already been connected to the dma_sequencer
1668233Snate@binkert.org    #
1676143Snate@binkert.org    dma.functional = system.funcbus.slave
1688945Ssteve.reinhardt@amd.com
1696143Snate@binkert.org# connect reference memory to funcbus
1706143Snate@binkert.orgsystem.funcbus.master = system.funcmem.port
1716143Snate@binkert.org
1726143Snate@binkert.org# -----------------------
1735522Snate@binkert.org# run simulation
1746143Snate@binkert.org# -----------------------
1756143Snate@binkert.org
1766143Snate@binkert.orgroot = Root( full_system = False, system = system )
1779982Satgutier@umich.eduroot.system.mem_mode = 'timing'
1788233Snate@binkert.org
1798233Snate@binkert.org# Not much point in this being higher than the L1 latency
1808233Snate@binkert.orgm5.ticks.setGlobalFrequency('1ns')
1816143Snate@binkert.org
1826143Snate@binkert.org# instantiate configuration
1836143Snate@binkert.orgm5.instantiate()
1846143Snate@binkert.org
1855522Snate@binkert.org# simulate until program terminates
1865522Snate@binkert.orgexit_event = m5.simulate(options.maxtick)
1875522Snate@binkert.org
1885522Snate@binkert.orgprint 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause()
1895604Snate@binkert.org