gpu-randomtest-ruby.py revision 11308
1# 2# Copyright (c) 2010-2015 Advanced Micro Devices, Inc. 3# All rights reserved. 4# 5# For use for simulation and test purposes only 6# 7# Redistribution and use in source and binary forms, with or without 8# modification, are permitted provided that the following conditions are met: 9# 10# 1. Redistributions of source code must retain the above copyright notice, 11# this list of conditions and the following disclaimer. 12# 13# 2. Redistributions in binary form must reproduce the above copyright notice, 14# this list of conditions and the following disclaimer in the documentation 15# and/or other materials provided with the distribution. 16# 17# 3. Neither the name of the copyright holder nor the names of its contributors 18# may be used to endorse or promote products derived from this software 19# without specific prior written permission. 20# 21# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31# POSSIBILITY OF SUCH DAMAGE. 32# 33# Author: Brad Beckmann 34# 35 36import m5 37from m5.objects import * 38from m5.defines import buildEnv 39from m5.util import addToPath 40import os, optparse, sys 41 42# Get paths we might need. It's expected this file is in m5/configs/example. 43config_path = os.path.dirname(os.path.abspath(__file__)) 44config_root = os.path.dirname(config_path) 45m5_root = os.path.dirname(config_root) 46addToPath(config_root+'/configs/common') 47addToPath(config_root+'/configs/ruby') 48addToPath(config_root+'/configs/topologies') 49 50import Ruby 51import Options 52 53parser = optparse.OptionParser() 54Options.addCommonOptions(parser) 55 56# add the gpu specific options expected by the the gpu and gpu_RfO 57parser.add_option("-u", "--num-compute-units", type="int", default=8, 58 help="number of compute units in the GPU") 59parser.add_option("--numCPs", type="int", default=0, 60 help="Number of GPU Command Processors (CP)") 61parser.add_option("--simds-per-cu", type="int", default=4, help="SIMD units" \ 62 "per CU") 63parser.add_option("--wf-size", type="int", default=64, 64 help="Wavefront size(in workitems)") 65parser.add_option("--wfs-per-simd", type="int", default=10, help="Number of " \ 66 "WF slots per SIMD") 67 68# Add the ruby specific and protocol specific options 69Ruby.define_options(parser) 70 71(options, args) = parser.parse_args() 72 73# 74# Set the default cache size and associativity to be very small to encourage 75# races between requests and writebacks. 76# 77options.l1d_size="256B" 78options.l1i_size="256B" 79options.l2_size="512B" 80options.l3_size="1kB" 81options.l1d_assoc=2 82options.l1i_assoc=2 83options.l2_assoc=2 84options.l3_assoc=2 85options.num_compute_units=8 86options.num_sqc=2 87 88# Check to for the GPU_RfO protocol. Other GPU protocols are non-SC and will 89# not work with the Ruby random tester. 90assert(buildEnv['PROTOCOL'] == 'GPU_RfO') 91 92# 93# create the tester and system, including ruby 94# 95tester = RubyTester(check_flush = False, checks_to_complete = 100, 96 wakeup_frequency = 10, num_cpus = options.num_cpus) 97 98# We set the testers as cpu for ruby to find the correct clock domains 99# for the L1 Objects. 100system = System(cpu = tester) 101 102# Dummy voltage domain for all our clock domains 103system.voltage_domain = VoltageDomain(voltage = options.sys_voltage) 104system.clk_domain = SrcClockDomain(clock = '1GHz', 105 voltage_domain = system.voltage_domain) 106 107system.mem_ranges = AddrRange('256MB') 108 109Ruby.create_system(options, False, system) 110 111# Create a separate clock domain for Ruby 112system.ruby.clk_domain = SrcClockDomain(clock = '1GHz', 113 voltage_domain = system.voltage_domain) 114 115tester.num_cpus = len(system.ruby._cpu_ports) 116 117# 118# The tester is most effective when randomization is turned on and 119# artifical delay is randomly inserted on messages 120# 121system.ruby.randomization = True 122 123for ruby_port in system.ruby._cpu_ports: 124 # 125 # Tie the ruby tester ports to the ruby cpu read and write ports 126 # 127 if ruby_port.support_data_reqs and ruby_port.support_inst_reqs: 128 tester.cpuInstDataPort = ruby_port.slave 129 elif ruby_port.support_data_reqs: 130 tester.cpuDataPort = ruby_port.slave 131 elif ruby_port.support_inst_reqs: 132 tester.cpuInstPort = ruby_port.slave 133 134 # Do not automatically retry stalled Ruby requests 135 ruby_port.no_retry_on_stall = True 136 137 # 138 # Tell the sequencer this is the ruby tester so that it 139 # copies the subblock back to the checker 140 # 141 ruby_port.using_ruby_tester = True 142 143# ----------------------- 144# run simulation 145# ----------------------- 146 147root = Root(full_system = False, system = system ) 148root.system.mem_mode = 'timing' 149 150# Not much point in this being higher than the L1 latency 151m5.ticks.setGlobalFrequency('1ns') 152