ruby_gpu_random_test.py revision 11670:6ce719503eae
14661Sksewell@umich.edu#
25268Sksewell@umich.edu#  Copyright (c) 2010-2015 Advanced Micro Devices, Inc.
35268Sksewell@umich.edu#  All rights reserved.
44661Sksewell@umich.edu#
55268Sksewell@umich.edu#  For use for simulation and test purposes only
65268Sksewell@umich.edu#
75268Sksewell@umich.edu#  Redistribution and use in source and binary forms, with or without
85268Sksewell@umich.edu#  modification, are permitted provided that the following conditions are met:
95268Sksewell@umich.edu#
105268Sksewell@umich.edu#  1. Redistributions of source code must retain the above copyright notice,
115268Sksewell@umich.edu#  this list of conditions and the following disclaimer.
125268Sksewell@umich.edu#
135268Sksewell@umich.edu#  2. Redistributions in binary form must reproduce the above copyright notice,
145268Sksewell@umich.edu#  this list of conditions and the following disclaimer in the documentation
154661Sksewell@umich.edu#  and/or other materials provided with the distribution.
165268Sksewell@umich.edu#
175268Sksewell@umich.edu#  3. Neither the name of the copyright holder nor the names of its contributors
185268Sksewell@umich.edu#  may be used to endorse or promote products derived from this software
195268Sksewell@umich.edu#  without specific prior written permission.
205268Sksewell@umich.edu#
215268Sksewell@umich.edu#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
225268Sksewell@umich.edu#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
235268Sksewell@umich.edu#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
245268Sksewell@umich.edu#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
255268Sksewell@umich.edu#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
265268Sksewell@umich.edu#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
274661Sksewell@umich.edu#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
284661Sksewell@umich.edu#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
294661Sksewell@umich.edu#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
304661Sksewell@umich.edu#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
314661Sksewell@umich.edu#  POSSIBILITY OF SUCH DAMAGE.
324661Sksewell@umich.edu#
334661Sksewell@umich.edu#  Author: Brad Beckmann
344661Sksewell@umich.edu#
354661Sksewell@umich.edu
364661Sksewell@umich.eduimport m5
376216Snate@binkert.orgfrom m5.objects import *
384661Sksewell@umich.edufrom m5.defines import buildEnv
394661Sksewell@umich.edufrom m5.util import addToPath
404661Sksewell@umich.eduimport os, optparse, sys
414661Sksewell@umich.eduaddToPath('../common')
424661Sksewell@umich.eduaddToPath('../')
434661Sksewell@umich.edu
445558Snate@binkert.orgimport Options
455558Snate@binkert.orgfrom ruby import Ruby
465558Snate@binkert.org
475558Snate@binkert.org# Get paths we might need.
485558Snate@binkert.orgconfig_path = os.path.dirname(os.path.abspath(__file__))
495558Snate@binkert.orgconfig_root = os.path.dirname(config_path)
505558Snate@binkert.orgm5_root = os.path.dirname(config_root)
514661Sksewell@umich.edu
524661Sksewell@umich.eduparser = optparse.OptionParser()
535558Snate@binkert.orgOptions.addCommonOptions(parser)
545558Snate@binkert.org
555558Snate@binkert.orgparser.add_option("--maxloads", metavar="N", default=100,
565558Snate@binkert.org                  help="Stop after N loads")
575558Snate@binkert.orgparser.add_option("-f", "--wakeup_freq", metavar="N", default=10,
585558Snate@binkert.org                  help="Wakeup every N cycles")
595558Snate@binkert.orgparser.add_option("-u", "--num-compute-units", type="int", default=1,
605558Snate@binkert.org                  help="number of compute units in the GPU")
615558Snate@binkert.orgparser.add_option("--num-cp", type="int", default=0,
625558Snate@binkert.org                  help="Number of GPU Command Processors (CP)")
635558Snate@binkert.org# not super important now, but to avoid putting the number 4 everywhere, make
645558Snate@binkert.org# it an option/knob
655558Snate@binkert.orgparser.add_option("--cu-per-sqc", type="int", default=4, help="number of CUs \
665558Snate@binkert.org                  sharing an SQC (icache, and thus icache TLB)")
675558Snate@binkert.orgparser.add_option("--simds-per-cu", type="int", default=4, help="SIMD units" \
685558Snate@binkert.org                  "per CU")
695558Snate@binkert.orgparser.add_option("--wf-size", type="int", default=64,
705558Snate@binkert.org                  help="Wavefront size(in workitems)")
715558Snate@binkert.orgparser.add_option("--wfs-per-simd", type="int", default=10, help="Number of " \
725558Snate@binkert.org                  "WF slots per SIMD")
735558Snate@binkert.org
745558Snate@binkert.org#
755558Snate@binkert.org# Add the ruby specific and protocol specific options
765558Snate@binkert.org#
775558Snate@binkert.orgRuby.define_options(parser)
785558Snate@binkert.org
795558Snate@binkert.orgexecfile(os.path.join(config_root, "common", "Options.py"))
805558Snate@binkert.org
815558Snate@binkert.org(options, args) = parser.parse_args()
825558Snate@binkert.org
835558Snate@binkert.org#
845558Snate@binkert.org# Set the default cache size and associativity to be very small to encourage
855558Snate@binkert.org# races between requests and writebacks.
865558Snate@binkert.org#
875558Snate@binkert.orgoptions.l1d_size="256B"
885558Snate@binkert.orgoptions.l1i_size="256B"
895558Snate@binkert.orgoptions.l2_size="512B"
905558Snate@binkert.orgoptions.l3_size="1kB"
915558Snate@binkert.orgoptions.l1d_assoc=2
925558Snate@binkert.orgoptions.l1i_assoc=2
935558Snate@binkert.orgoptions.l2_assoc=2
945558Snate@binkert.orgoptions.l3_assoc=2
955558Snate@binkert.org
965558Snate@binkert.org# This file can support multiple compute units
975558Snate@binkert.orgassert(options.num_compute_units >= 1)
985558Snate@binkert.orgn_cu = options.num_compute_units
995558Snate@binkert.org
1005558Snate@binkert.orgoptions.num_sqc = int((n_cu + options.cu_per_sqc - 1) / options.cu_per_sqc)
1015558Snate@binkert.org
1025558Snate@binkert.orgif args:
1035558Snate@binkert.org     print "Error: script doesn't take any positional arguments"
1045558Snate@binkert.org     sys.exit(1)
1055558Snate@binkert.org
1065558Snate@binkert.org#
1075558Snate@binkert.org# Create the ruby random tester
1085558Snate@binkert.org#
1095558Snate@binkert.org
1105558Snate@binkert.org# Check to for the GPU_RfO protocol.  Other GPU protocols are non-SC and will
1115558Snate@binkert.org# not work with the Ruby random tester.
1125558Snate@binkert.orgassert(buildEnv['PROTOCOL'] == 'GPU_RfO')
1135558Snate@binkert.org
1145558Snate@binkert.org# The GPU_RfO protocol does not support cache flushes
1155558Snate@binkert.orgcheck_flush = False
1165558Snate@binkert.org
1175558Snate@binkert.orgtester = RubyTester(check_flush=check_flush,
1185558Snate@binkert.org                    checks_to_complete=options.maxloads,
1195558Snate@binkert.org                    wakeup_frequency=options.wakeup_freq,
1205558Snate@binkert.org                    deadlock_threshold=1000000)
1215558Snate@binkert.org
1225558Snate@binkert.org#
1235558Snate@binkert.org# Create the M5 system.  Note that the Memory Object isn't
1245558Snate@binkert.org# actually used by the rubytester, but is included to support the
1255558Snate@binkert.org# M5 memory size == Ruby memory size checks
1265558Snate@binkert.org#
1275558Snate@binkert.orgsystem = System(cpu=tester, mem_ranges=[AddrRange(options.mem_size)])
1285558Snate@binkert.org
1295558Snate@binkert.org# Create a top-level voltage domain and clock domain
1305558Snate@binkert.orgsystem.voltage_domain = VoltageDomain(voltage=options.sys_voltage)
1315558Snate@binkert.org
1325558Snate@binkert.orgsystem.clk_domain = SrcClockDomain(clock=options.sys_clock,
1335558Snate@binkert.org                                   voltage_domain=system.voltage_domain)
1345558Snate@binkert.org
1355558Snate@binkert.orgRuby.create_system(options, False, system)
1365558Snate@binkert.org
1375558Snate@binkert.org# Create a seperate clock domain for Ruby
1385558Snate@binkert.orgsystem.ruby.clk_domain = SrcClockDomain(clock=options.ruby_clock,
1395558Snate@binkert.org                                       voltage_domain=system.voltage_domain)
1405558Snate@binkert.org
1415558Snate@binkert.orgtester.num_cpus = len(system.ruby._cpu_ports)
1425558Snate@binkert.org
1435558Snate@binkert.org#
1445558Snate@binkert.org# The tester is most effective when randomization is turned on and
1455558Snate@binkert.org# artifical delay is randomly inserted on messages
1465558Snate@binkert.org#
1475558Snate@binkert.orgsystem.ruby.randomization = True
1485558Snate@binkert.org
1495558Snate@binkert.orgfor ruby_port in system.ruby._cpu_ports:
1505558Snate@binkert.org
1515558Snate@binkert.org    #
1525558Snate@binkert.org    # Tie the ruby tester ports to the ruby cpu read and write ports
1535558Snate@binkert.org    #
1545558Snate@binkert.org    if ruby_port.support_data_reqs and ruby_port.support_inst_reqs:
1555558Snate@binkert.org        tester.cpuInstDataPort = ruby_port.slave
1565558Snate@binkert.org    elif ruby_port.support_data_reqs:
1575558Snate@binkert.org        tester.cpuDataPort = ruby_port.slave
1585558Snate@binkert.org    elif ruby_port.support_inst_reqs:
1595558Snate@binkert.org        tester.cpuInstPort = ruby_port.slave
1605558Snate@binkert.org
1615558Snate@binkert.org    # Do not automatically retry stalled Ruby requests
1625558Snate@binkert.org    ruby_port.no_retry_on_stall = True
1635558Snate@binkert.org
1645558Snate@binkert.org    #
1655558Snate@binkert.org    # Tell each sequencer this is the ruby tester so that it
1665558Snate@binkert.org    # copies the subblock back to the checker
1675558Snate@binkert.org    #
1685558Snate@binkert.org    ruby_port.using_ruby_tester = True
1695558Snate@binkert.org
1705558Snate@binkert.org# -----------------------
1715558Snate@binkert.org# run simulation
1725558Snate@binkert.org# -----------------------
1735558Snate@binkert.org
1745558Snate@binkert.orgroot = Root( full_system = False, system = system )
1755558Snate@binkert.orgroot.system.mem_mode = 'timing'
1765558Snate@binkert.org
1775558Snate@binkert.org# Not much point in this being higher than the L1 latency
1785558Snate@binkert.orgm5.ticks.setGlobalFrequency('1ns')
1795558Snate@binkert.org
1805558Snate@binkert.org# instantiate configuration
1815558Snate@binkert.orgm5.instantiate()
1825558Snate@binkert.org
1835558Snate@binkert.org# simulate until program terminates
1845558Snate@binkert.orgexit_event = m5.simulate(options.abs_max_tick)
1855558Snate@binkert.org
1865558Snate@binkert.orgprint 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause()
1875558Snate@binkert.org