garnet_synth_traffic.py revision 11688
111661Stushar@ece.gatech.edu# Copyright (c) 2016 Georgia Institute of Technology
211661Stushar@ece.gatech.edu# All rights reserved.
311661Stushar@ece.gatech.edu#
411661Stushar@ece.gatech.edu# Redistribution and use in source and binary forms, with or without
511661Stushar@ece.gatech.edu# modification, are permitted provided that the following conditions are
611661Stushar@ece.gatech.edu# met: redistributions of source code must retain the above copyright
711661Stushar@ece.gatech.edu# notice, this list of conditions and the following disclaimer;
811661Stushar@ece.gatech.edu# redistributions in binary form must reproduce the above copyright
911661Stushar@ece.gatech.edu# notice, this list of conditions and the following disclaimer in the
1011661Stushar@ece.gatech.edu# documentation and/or other materials provided with the distribution;
1111661Stushar@ece.gatech.edu# neither the name of the copyright holders nor the names of its
1211661Stushar@ece.gatech.edu# contributors may be used to endorse or promote products derived from
1311661Stushar@ece.gatech.edu# this software without specific prior written permission.
1411661Stushar@ece.gatech.edu#
1511661Stushar@ece.gatech.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1611661Stushar@ece.gatech.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1711661Stushar@ece.gatech.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1811661Stushar@ece.gatech.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1911661Stushar@ece.gatech.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2011661Stushar@ece.gatech.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2111661Stushar@ece.gatech.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2211661Stushar@ece.gatech.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2311661Stushar@ece.gatech.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2411661Stushar@ece.gatech.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2511661Stushar@ece.gatech.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2611661Stushar@ece.gatech.edu#
2711661Stushar@ece.gatech.edu# Author: Tushar Krishna
2811661Stushar@ece.gatech.edu
2911661Stushar@ece.gatech.eduimport m5
3011661Stushar@ece.gatech.edufrom m5.objects import *
3111661Stushar@ece.gatech.edufrom m5.defines import buildEnv
3211661Stushar@ece.gatech.edufrom m5.util import addToPath
3311661Stushar@ece.gatech.eduimport os, optparse, sys
3411682Sandreas.hansson@arm.com
3511670Sandreas.hansson@arm.comaddToPath('../')
3611661Stushar@ece.gatech.edu
3711682Sandreas.hansson@arm.comfrom common import Options
3811670Sandreas.hansson@arm.comfrom ruby import Ruby
3911661Stushar@ece.gatech.edu
4011661Stushar@ece.gatech.edu# Get paths we might need.  It's expected this file is in m5/configs/example.
4111661Stushar@ece.gatech.educonfig_path = os.path.dirname(os.path.abspath(__file__))
4211661Stushar@ece.gatech.educonfig_root = os.path.dirname(config_path)
4311661Stushar@ece.gatech.edum5_root = os.path.dirname(config_root)
4411661Stushar@ece.gatech.edu
4511661Stushar@ece.gatech.eduparser = optparse.OptionParser()
4611688Sandreas.hansson@arm.comOptions.addNoISAOptions(parser)
4711661Stushar@ece.gatech.edu
4811661Stushar@ece.gatech.eduparser.add_option("--synthetic", type="choice", default="uniform_random",
4911661Stushar@ece.gatech.edu                  choices=['uniform_random', 'tornado', 'bit_complement', \
5011661Stushar@ece.gatech.edu                           'bit_reverse', 'bit_rotation', 'neighbor', \
5111661Stushar@ece.gatech.edu                            'shuffle', 'transpose'])
5211661Stushar@ece.gatech.edu
5311661Stushar@ece.gatech.eduparser.add_option("-i", "--injectionrate", type="float", default=0.1,
5411661Stushar@ece.gatech.edu                  metavar="I",
5511661Stushar@ece.gatech.edu                  help="Injection rate in packets per cycle per node. \
5611661Stushar@ece.gatech.edu                        Takes decimal value between 0 to 1 (eg. 0.225). \
5711661Stushar@ece.gatech.edu                        Number of digits after 0 depends upon --precision.")
5811661Stushar@ece.gatech.edu
5911661Stushar@ece.gatech.eduparser.add_option("--precision", type="int", default=3,
6011661Stushar@ece.gatech.edu                  help="Number of digits of precision after decimal point\
6111661Stushar@ece.gatech.edu                        for injection rate")
6211661Stushar@ece.gatech.edu
6311661Stushar@ece.gatech.eduparser.add_option("--sim-cycles", type="int", default=1000,
6411661Stushar@ece.gatech.edu                   help="Number of simulation cycles")
6511661Stushar@ece.gatech.edu
6611661Stushar@ece.gatech.eduparser.add_option("--num-packets-max", type="int", default=-1,
6711661Stushar@ece.gatech.edu                  help="Stop injecting after --num-packets-max.\
6811661Stushar@ece.gatech.edu                        Set to -1 to disable.")
6911661Stushar@ece.gatech.edu
7011661Stushar@ece.gatech.eduparser.add_option("--single-sender-id", type="int", default=-1,
7111661Stushar@ece.gatech.edu                  help="Only inject from this sender.\
7211661Stushar@ece.gatech.edu                        Set to -1 to disable.")
7311661Stushar@ece.gatech.edu
7411661Stushar@ece.gatech.eduparser.add_option("--single-dest-id", type="int", default=-1,
7511661Stushar@ece.gatech.edu                  help="Only send to this destination.\
7611661Stushar@ece.gatech.edu                        Set to -1 to disable.")
7711661Stushar@ece.gatech.edu
7811661Stushar@ece.gatech.eduparser.add_option("--inj-vnet", type="int", default=-1,
7911661Stushar@ece.gatech.edu                  help="Only inject in this vnet (0, 1 or 2).\
8011661Stushar@ece.gatech.edu                        0 and 1 are 1-flit, 2 is 5-flit.\
8111661Stushar@ece.gatech.edu                        Set to -1 to inject randomly in all vnets.")
8211661Stushar@ece.gatech.edu
8311661Stushar@ece.gatech.edu#
8411661Stushar@ece.gatech.edu# Add the ruby specific and protocol specific options
8511661Stushar@ece.gatech.edu#
8611661Stushar@ece.gatech.eduRuby.define_options(parser)
8711661Stushar@ece.gatech.edu
8811661Stushar@ece.gatech.eduexecfile(os.path.join(config_root, "common", "Options.py"))
8911661Stushar@ece.gatech.edu
9011661Stushar@ece.gatech.edu(options, args) = parser.parse_args()
9111661Stushar@ece.gatech.edu
9211661Stushar@ece.gatech.eduif args:
9311661Stushar@ece.gatech.edu     print "Error: script doesn't take any positional arguments"
9411661Stushar@ece.gatech.edu     sys.exit(1)
9511661Stushar@ece.gatech.edu
9611661Stushar@ece.gatech.edu
9711661Stushar@ece.gatech.eduif options.inj_vnet > 2:
9811661Stushar@ece.gatech.edu    print "Error: Injection vnet %d should be 0 (1-flit), 1 (1-flit) \
9911661Stushar@ece.gatech.edu                  or 2 (5-flit) or -1 (random)"\
10011661Stushar@ece.gatech.edu           % (options.inj_vnet)
10111661Stushar@ece.gatech.edu    sys.exit(1)
10211661Stushar@ece.gatech.edu
10311661Stushar@ece.gatech.edu
10411661Stushar@ece.gatech.educpus = [ GarnetSyntheticTraffic(
10511661Stushar@ece.gatech.edu                     num_packets_max=options.num_packets_max,
10611661Stushar@ece.gatech.edu                     single_sender=options.single_sender_id,
10711661Stushar@ece.gatech.edu                     single_dest=options.single_dest_id,
10811661Stushar@ece.gatech.edu                     sim_cycles=options.sim_cycles,
10911661Stushar@ece.gatech.edu                     traffic_type=options.synthetic,
11011661Stushar@ece.gatech.edu                     inj_rate=options.injectionrate,
11111661Stushar@ece.gatech.edu                     inj_vnet=options.inj_vnet,
11211661Stushar@ece.gatech.edu                     precision=options.precision,
11311661Stushar@ece.gatech.edu                     num_dest=options.num_dirs) \
11411661Stushar@ece.gatech.edu         for i in xrange(options.num_cpus) ]
11511661Stushar@ece.gatech.edu
11611661Stushar@ece.gatech.edu# create the desired simulated system
11711661Stushar@ece.gatech.edusystem = System(cpu = cpus, mem_ranges = [AddrRange(options.mem_size)])
11811661Stushar@ece.gatech.edu
11911661Stushar@ece.gatech.edu
12011661Stushar@ece.gatech.edu# Create a top-level voltage domain and clock domain
12111661Stushar@ece.gatech.edusystem.voltage_domain = VoltageDomain(voltage = options.sys_voltage)
12211661Stushar@ece.gatech.edu
12311661Stushar@ece.gatech.edusystem.clk_domain = SrcClockDomain(clock = options.sys_clock,
12411661Stushar@ece.gatech.edu                                   voltage_domain = system.voltage_domain)
12511661Stushar@ece.gatech.edu
12611661Stushar@ece.gatech.eduRuby.create_system(options, False, system)
12711661Stushar@ece.gatech.edu
12811661Stushar@ece.gatech.edu# Create a seperate clock domain for Ruby
12911661Stushar@ece.gatech.edusystem.ruby.clk_domain = SrcClockDomain(clock = options.ruby_clock,
13011661Stushar@ece.gatech.edu                                        voltage_domain = system.voltage_domain)
13111661Stushar@ece.gatech.edu
13211661Stushar@ece.gatech.edui = 0
13311661Stushar@ece.gatech.edufor ruby_port in system.ruby._cpu_ports:
13411661Stushar@ece.gatech.edu     #
13511661Stushar@ece.gatech.edu     # Tie the cpu test ports to the ruby cpu port
13611661Stushar@ece.gatech.edu     #
13711661Stushar@ece.gatech.edu     cpus[i].test = ruby_port.slave
13811661Stushar@ece.gatech.edu     i += 1
13911661Stushar@ece.gatech.edu
14011661Stushar@ece.gatech.edu# -----------------------
14111661Stushar@ece.gatech.edu# run simulation
14211661Stushar@ece.gatech.edu# -----------------------
14311661Stushar@ece.gatech.edu
14411661Stushar@ece.gatech.eduroot = Root(full_system = False, system = system)
14511661Stushar@ece.gatech.eduroot.system.mem_mode = 'timing'
14611661Stushar@ece.gatech.edu
14711661Stushar@ece.gatech.edu# Not much point in this being higher than the L1 latency
14811661Stushar@ece.gatech.edum5.ticks.setGlobalFrequency('1ns')
14911661Stushar@ece.gatech.edu
15011661Stushar@ece.gatech.edu# instantiate configuration
15111661Stushar@ece.gatech.edum5.instantiate()
15211661Stushar@ece.gatech.edu
15311661Stushar@ece.gatech.edu# simulate until program terminates
15411661Stushar@ece.gatech.eduexit_event = m5.simulate(options.abs_max_tick)
15511661Stushar@ece.gatech.edu
15611661Stushar@ece.gatech.eduprint 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause()
157