ruby_mem_test.py revision 11662:004d34b65092
12221SN/A# Copyright (c) 2006-2007 The Regents of The University of Michigan 22221SN/A# Copyright (c) 2009 Advanced Micro Devices, Inc. 32221SN/A# All rights reserved. 42221SN/A# 52221SN/A# Redistribution and use in source and binary forms, with or without 62221SN/A# modification, are permitted provided that the following conditions are 72221SN/A# met: redistributions of source code must retain the above copyright 82221SN/A# notice, this list of conditions and the following disclaimer; 92221SN/A# redistributions in binary form must reproduce the above copyright 102221SN/A# notice, this list of conditions and the following disclaimer in the 112221SN/A# documentation and/or other materials provided with the distribution; 122221SN/A# neither the name of the copyright holders nor the names of its 132221SN/A# contributors may be used to endorse or promote products derived from 142221SN/A# this software without specific prior written permission. 152221SN/A# 162221SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172221SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182221SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192221SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202221SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212221SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222221SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232221SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242221SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252221SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262221SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu# 282665Ssaidi@eecs.umich.edu# Authors: Ron Dreslinski 292665Ssaidi@eecs.umich.edu# Brad Beckmann 302221SN/A 312221SN/Aimport m5 323415Sgblack@eecs.umich.edufrom m5.objects import * 333415Sgblack@eecs.umich.edufrom m5.defines import buildEnv 342223SN/Afrom m5.util import addToPath 353415Sgblack@eecs.umich.eduimport os, optparse, sys 363578Sgblack@eecs.umich.eduaddToPath('../common') 373415Sgblack@eecs.umich.eduaddToPath('../ruby') 383415Sgblack@eecs.umich.eduaddToPath('../network') 393523Sgblack@eecs.umich.eduaddToPath('../topologies') 403415Sgblack@eecs.umich.edu 412680Sktlim@umich.eduimport Options 422800Ssaidi@eecs.umich.eduimport Ruby 433523Sgblack@eecs.umich.eduimport Network 443415Sgblack@eecs.umich.edu 452800Ssaidi@eecs.umich.edu# Get paths we might need. It's expected this file is in m5/configs/example. 462800Ssaidi@eecs.umich.educonfig_path = os.path.dirname(os.path.abspath(__file__)) 472221SN/Aconfig_root = os.path.dirname(config_path) 483415Sgblack@eecs.umich.edu 493415Sgblack@eecs.umich.eduparser = optparse.OptionParser() 502223SN/AOptions.addCommonOptions(parser) 512221SN/A 522221SN/Aparser.add_option("--maxloads", metavar="N", default=0, 533573Sgblack@eecs.umich.edu help="Stop after N loads") 543576Sgblack@eecs.umich.eduparser.add_option("--progress", type="int", default=1000, 553576Sgblack@eecs.umich.edu metavar="NLOADS", 562221SN/A help="Progress message interval " 573573Sgblack@eecs.umich.edu "[default: %default]") 583576Sgblack@eecs.umich.eduparser.add_option("--num-dmas", type="int", default=0, help="# of dma testers") 593576Sgblack@eecs.umich.eduparser.add_option("--functional", type="int", default=0, 602221SN/A help="percentage of accesses that should be functional") 613573Sgblack@eecs.umich.eduparser.add_option("--suppress-func-warnings", action="store_true", 623576Sgblack@eecs.umich.edu help="suppress warnings when functional accesses fail") 633576Sgblack@eecs.umich.edu 642221SN/A# 653573Sgblack@eecs.umich.edu# Add the ruby specific and protocol specific options 663576Sgblack@eecs.umich.edu# 673576Sgblack@eecs.umich.eduRuby.define_options(parser) 682221SN/ANetwork.define_options(parser) 693573Sgblack@eecs.umich.edu 703576Sgblack@eecs.umich.eduexecfile(os.path.join(config_root, "common", "Options.py")) 713576Sgblack@eecs.umich.edu 722221SN/A(options, args) = parser.parse_args() 733573Sgblack@eecs.umich.edu 743576Sgblack@eecs.umich.edu# 753576Sgblack@eecs.umich.edu# Set the default cache size and associativity to be very small to encourage 762221SN/A# races between requests and writebacks. 773573Sgblack@eecs.umich.edu# 783576Sgblack@eecs.umich.eduoptions.l1d_size="256B" 793576Sgblack@eecs.umich.eduoptions.l1i_size="256B" 803576Sgblack@eecs.umich.eduoptions.l2_size="512B" 813576Sgblack@eecs.umich.eduoptions.l3_size="1kB" 823576Sgblack@eecs.umich.eduoptions.l1d_assoc=2 833576Sgblack@eecs.umich.eduoptions.l1i_assoc=2 843576Sgblack@eecs.umich.eduoptions.l2_assoc=2 852221SN/Aoptions.l3_assoc=2 863573Sgblack@eecs.umich.edu 873576Sgblack@eecs.umich.eduif args: 883576Sgblack@eecs.umich.edu print "Error: script doesn't take any positional arguments" 892221SN/A sys.exit(1) 903573Sgblack@eecs.umich.edu 913576Sgblack@eecs.umich.edublock_size = 64 923576Sgblack@eecs.umich.edu 932221SN/Aif options.num_cpus > block_size: 943573Sgblack@eecs.umich.edu print "Error: Number of testers %d limited to %d because of false sharing" \ 953576Sgblack@eecs.umich.edu % (options.num_cpus, block_size) 963576Sgblack@eecs.umich.edu sys.exit(1) 973576Sgblack@eecs.umich.edu 983576Sgblack@eecs.umich.edu# 993576Sgblack@eecs.umich.edu# Currently ruby does not support atomic or uncacheable accesses 1003576Sgblack@eecs.umich.edu# 1013576Sgblack@eecs.umich.educpus = [ MemTest(atomic = False, 1023576Sgblack@eecs.umich.edu max_loads = options.maxloads, 1033576Sgblack@eecs.umich.edu issue_dmas = False, 1043576Sgblack@eecs.umich.edu percent_functional = options.functional, 1053576Sgblack@eecs.umich.edu percent_uncacheable = 0, 1063576Sgblack@eecs.umich.edu progress_interval = options.progress, 1072221SN/A suppress_func_warnings = options.suppress_func_warnings) \ 1083573Sgblack@eecs.umich.edu for i in xrange(options.num_cpus) ] 1093576Sgblack@eecs.umich.edu 1103576Sgblack@eecs.umich.edusystem = System(cpu = cpus, 1112221SN/A funcmem = SimpleMemory(in_addr_map = False), 1123573Sgblack@eecs.umich.edu funcbus = IOXBar(), 1133576Sgblack@eecs.umich.edu clk_domain = SrcClockDomain(clock = options.sys_clock), 1143576Sgblack@eecs.umich.edu mem_ranges = [AddrRange(options.mem_size)]) 1152221SN/A 1163573Sgblack@eecs.umich.eduif options.num_dmas > 0: 1173576Sgblack@eecs.umich.edu dmas = [ MemTest(atomic = False, 1183576Sgblack@eecs.umich.edu max_loads = options.maxloads, 1192221SN/A issue_dmas = True, 1203573Sgblack@eecs.umich.edu percent_functional = 0, 1213576Sgblack@eecs.umich.edu percent_uncacheable = 0, 1223576Sgblack@eecs.umich.edu progress_interval = options.progress, 1232221SN/A suppress_func_warnings = 1243573Sgblack@eecs.umich.edu not options.suppress_func_warnings) \ 1253576Sgblack@eecs.umich.edu for i in xrange(options.num_dmas) ] 1263576Sgblack@eecs.umich.edu system.dma_devices = dmas 1272221SN/Aelse: 1283573Sgblack@eecs.umich.edu dmas = [] 1293576Sgblack@eecs.umich.edu 1303576Sgblack@eecs.umich.edudma_ports = [] 1312223SN/Afor (i, dma) in enumerate(dmas): 1323573Sgblack@eecs.umich.edu dma_ports.append(dma.test) 1333576Sgblack@eecs.umich.eduRuby.create_system(options, False, system, dma_ports = dma_ports) 1343576Sgblack@eecs.umich.edu 1352223SN/A# Create a top-level voltage domain and clock domain 1363573Sgblack@eecs.umich.edusystem.voltage_domain = VoltageDomain(voltage = options.sys_voltage) 1373576Sgblack@eecs.umich.edusystem.clk_domain = SrcClockDomain(clock = options.sys_clock, 1383576Sgblack@eecs.umich.edu voltage_domain = system.voltage_domain) 1392223SN/A# Create a seperate clock domain for Ruby 1403573Sgblack@eecs.umich.edusystem.ruby.clk_domain = SrcClockDomain(clock = options.ruby_clock, 1413576Sgblack@eecs.umich.edu voltage_domain = system.voltage_domain) 1423576Sgblack@eecs.umich.edu 1432223SN/A# 1443573Sgblack@eecs.umich.edu# The tester is most effective when randomization is turned on and 1453576Sgblack@eecs.umich.edu# artifical delay is randomly inserted on messages 1463576Sgblack@eecs.umich.edu# 1473576Sgblack@eecs.umich.edusystem.ruby.randomization = True 1483576Sgblack@eecs.umich.edu 1493576Sgblack@eecs.umich.eduassert(len(cpus) == len(system.ruby._cpu_ports)) 1503576Sgblack@eecs.umich.edu 1513576Sgblack@eecs.umich.edufor (i, cpu) in enumerate(cpus): 1522223SN/A # 1533573Sgblack@eecs.umich.edu # Tie the cpu memtester ports to the correct system ports 1543576Sgblack@eecs.umich.edu # 1553576Sgblack@eecs.umich.edu cpu.test = system.ruby._cpu_ports[i].slave 1562223SN/A cpu.functional = system.funcbus.slave 1573573Sgblack@eecs.umich.edu 1583576Sgblack@eecs.umich.edu # 1593576Sgblack@eecs.umich.edu # Since the memtester is incredibly bursty, increase the deadlock 1602223SN/A # threshold to 5 million cycles 1613573Sgblack@eecs.umich.edu # 1623576Sgblack@eecs.umich.edu system.ruby._cpu_ports[i].deadlock_threshold = 5000000 1633576Sgblack@eecs.umich.edu 1642223SN/Afor (i, dma) in enumerate(dmas): 1653573Sgblack@eecs.umich.edu # 1663576Sgblack@eecs.umich.edu # Tie the dma memtester ports to the correct functional port 1673576Sgblack@eecs.umich.edu # Note that the test port has already been connected to the dma_sequencer 1682223SN/A # 1693573Sgblack@eecs.umich.edu dma.functional = system.funcbus.slave 1703576Sgblack@eecs.umich.edu 1713576Sgblack@eecs.umich.edu# connect reference memory to funcbus 1722223SN/Asystem.funcbus.master = system.funcmem.port 1733573Sgblack@eecs.umich.edu 1743576Sgblack@eecs.umich.edu# ----------------------- 1753576Sgblack@eecs.umich.edu# run simulation 1762223SN/A# ----------------------- 1773573Sgblack@eecs.umich.edu 1783576Sgblack@eecs.umich.eduroot = Root( full_system = False, system = system ) 1793576Sgblack@eecs.umich.eduroot.system.mem_mode = 'timing' 1802223SN/A 1813573Sgblack@eecs.umich.edu# Not much point in this being higher than the L1 latency 1823576Sgblack@eecs.umich.edum5.ticks.setGlobalFrequency('1ns') 1833576Sgblack@eecs.umich.edu 1842223SN/A# instantiate configuration 1853573Sgblack@eecs.umich.edum5.instantiate() 1863576Sgblack@eecs.umich.edu 1873576Sgblack@eecs.umich.edu# simulate until program terminates 1882223SN/Aexit_event = m5.simulate(options.abs_max_tick) 1893573Sgblack@eecs.umich.edu 1903576Sgblack@eecs.umich.eduprint 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause() 1913576Sgblack@eecs.umich.edu