garnet_synth_traffic.py revision 11661
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
3411661Stushar@ece.gatech.eduaddToPath('../common')
3511661Stushar@ece.gatech.eduaddToPath('../ruby')
3611661Stushar@ece.gatech.eduaddToPath('../topologies')
3711661Stushar@ece.gatech.edu
3811661Stushar@ece.gatech.eduimport Options
3911661Stushar@ece.gatech.eduimport Ruby
4011661Stushar@ece.gatech.edu
4111661Stushar@ece.gatech.edu# Get paths we might need.  It's expected this file is in m5/configs/example.
4211661Stushar@ece.gatech.educonfig_path = os.path.dirname(os.path.abspath(__file__))
4311661Stushar@ece.gatech.educonfig_root = os.path.dirname(config_path)
4411661Stushar@ece.gatech.edum5_root = os.path.dirname(config_root)
4511661Stushar@ece.gatech.edu
4611661Stushar@ece.gatech.eduparser = optparse.OptionParser()
4711661Stushar@ece.gatech.eduOptions.addCommonOptions(parser)
4811661Stushar@ece.gatech.edu
4911661Stushar@ece.gatech.eduparser.add_option("--synthetic", type="choice", default="uniform_random",
5011661Stushar@ece.gatech.edu                  choices=['uniform_random', 'tornado', 'bit_complement', \
5111661Stushar@ece.gatech.edu                           'bit_reverse', 'bit_rotation', 'neighbor', \
5211661Stushar@ece.gatech.edu                            'shuffle', 'transpose'])
5311661Stushar@ece.gatech.edu
5411661Stushar@ece.gatech.eduparser.add_option("-i", "--injectionrate", type="float", default=0.1,
5511661Stushar@ece.gatech.edu                  metavar="I",
5611661Stushar@ece.gatech.edu                  help="Injection rate in packets per cycle per node. \
5711661Stushar@ece.gatech.edu                        Takes decimal value between 0 to 1 (eg. 0.225). \
5811661Stushar@ece.gatech.edu                        Number of digits after 0 depends upon --precision.")
5911661Stushar@ece.gatech.edu
6011661Stushar@ece.gatech.eduparser.add_option("--precision", type="int", default=3,
6111661Stushar@ece.gatech.edu                  help="Number of digits of precision after decimal point\
6211661Stushar@ece.gatech.edu                        for injection rate")
6311661Stushar@ece.gatech.edu
6411661Stushar@ece.gatech.eduparser.add_option("--sim-cycles", type="int", default=1000,
6511661Stushar@ece.gatech.edu                   help="Number of simulation cycles")
6611661Stushar@ece.gatech.edu
6711661Stushar@ece.gatech.eduparser.add_option("--num-packets-max", type="int", default=-1,
6811661Stushar@ece.gatech.edu                  help="Stop injecting after --num-packets-max.\
6911661Stushar@ece.gatech.edu                        Set to -1 to disable.")
7011661Stushar@ece.gatech.edu
7111661Stushar@ece.gatech.eduparser.add_option("--single-sender-id", type="int", default=-1,
7211661Stushar@ece.gatech.edu                  help="Only inject from this sender.\
7311661Stushar@ece.gatech.edu                        Set to -1 to disable.")
7411661Stushar@ece.gatech.edu
7511661Stushar@ece.gatech.eduparser.add_option("--single-dest-id", type="int", default=-1,
7611661Stushar@ece.gatech.edu                  help="Only send to this destination.\
7711661Stushar@ece.gatech.edu                        Set to -1 to disable.")
7811661Stushar@ece.gatech.edu
7911661Stushar@ece.gatech.eduparser.add_option("--inj-vnet", type="int", default=-1,
8011661Stushar@ece.gatech.edu                  help="Only inject in this vnet (0, 1 or 2).\
8111661Stushar@ece.gatech.edu                        0 and 1 are 1-flit, 2 is 5-flit.\
8211661Stushar@ece.gatech.edu                        Set to -1 to inject randomly in all vnets.")
8311661Stushar@ece.gatech.edu
8411661Stushar@ece.gatech.edu#
8511661Stushar@ece.gatech.edu# Add the ruby specific and protocol specific options
8611661Stushar@ece.gatech.edu#
8711661Stushar@ece.gatech.eduRuby.define_options(parser)
8811661Stushar@ece.gatech.edu
8911661Stushar@ece.gatech.eduexecfile(os.path.join(config_root, "common", "Options.py"))
9011661Stushar@ece.gatech.edu
9111661Stushar@ece.gatech.edu(options, args) = parser.parse_args()
9211661Stushar@ece.gatech.edu
9311661Stushar@ece.gatech.eduif args:
9411661Stushar@ece.gatech.edu     print "Error: script doesn't take any positional arguments"
9511661Stushar@ece.gatech.edu     sys.exit(1)
9611661Stushar@ece.gatech.edu
9711661Stushar@ece.gatech.edu
9811661Stushar@ece.gatech.eduif options.inj_vnet > 2:
9911661Stushar@ece.gatech.edu    print "Error: Injection vnet %d should be 0 (1-flit), 1 (1-flit) \
10011661Stushar@ece.gatech.edu                  or 2 (5-flit) or -1 (random)"\
10111661Stushar@ece.gatech.edu           % (options.inj_vnet)
10211661Stushar@ece.gatech.edu    sys.exit(1)
10311661Stushar@ece.gatech.edu
10411661Stushar@ece.gatech.edu
10511661Stushar@ece.gatech.educpus = [ GarnetSyntheticTraffic(
10611661Stushar@ece.gatech.edu                     num_packets_max=options.num_packets_max,
10711661Stushar@ece.gatech.edu                     single_sender=options.single_sender_id,
10811661Stushar@ece.gatech.edu                     single_dest=options.single_dest_id,
10911661Stushar@ece.gatech.edu                     sim_cycles=options.sim_cycles,
11011661Stushar@ece.gatech.edu                     traffic_type=options.synthetic,
11111661Stushar@ece.gatech.edu                     inj_rate=options.injectionrate,
11211661Stushar@ece.gatech.edu                     inj_vnet=options.inj_vnet,
11311661Stushar@ece.gatech.edu                     precision=options.precision,
11411661Stushar@ece.gatech.edu                     num_dest=options.num_dirs) \
11511661Stushar@ece.gatech.edu         for i in xrange(options.num_cpus) ]
11611661Stushar@ece.gatech.edu
11711661Stushar@ece.gatech.edu# create the desired simulated system
11811661Stushar@ece.gatech.edusystem = System(cpu = cpus, mem_ranges = [AddrRange(options.mem_size)])
11911661Stushar@ece.gatech.edu
12011661Stushar@ece.gatech.edu
12111661Stushar@ece.gatech.edu# Create a top-level voltage domain and clock domain
12211661Stushar@ece.gatech.edusystem.voltage_domain = VoltageDomain(voltage = options.sys_voltage)
12311661Stushar@ece.gatech.edu
12411661Stushar@ece.gatech.edusystem.clk_domain = SrcClockDomain(clock = options.sys_clock,
12511661Stushar@ece.gatech.edu                                   voltage_domain = system.voltage_domain)
12611661Stushar@ece.gatech.edu
12711661Stushar@ece.gatech.eduRuby.create_system(options, False, system)
12811661Stushar@ece.gatech.edu
12911661Stushar@ece.gatech.edu# Create a seperate clock domain for Ruby
13011661Stushar@ece.gatech.edusystem.ruby.clk_domain = SrcClockDomain(clock = options.ruby_clock,
13111661Stushar@ece.gatech.edu                                        voltage_domain = system.voltage_domain)
13211661Stushar@ece.gatech.edu
13311661Stushar@ece.gatech.edui = 0
13411661Stushar@ece.gatech.edufor ruby_port in system.ruby._cpu_ports:
13511661Stushar@ece.gatech.edu     #
13611661Stushar@ece.gatech.edu     # Tie the cpu test ports to the ruby cpu port
13711661Stushar@ece.gatech.edu     #
13811661Stushar@ece.gatech.edu     cpus[i].test = ruby_port.slave
13911661Stushar@ece.gatech.edu     i += 1
14011661Stushar@ece.gatech.edu
14111661Stushar@ece.gatech.edu# -----------------------
14211661Stushar@ece.gatech.edu# run simulation
14311661Stushar@ece.gatech.edu# -----------------------
14411661Stushar@ece.gatech.edu
14511661Stushar@ece.gatech.eduroot = Root(full_system = False, system = system)
14611661Stushar@ece.gatech.eduroot.system.mem_mode = 'timing'
14711661Stushar@ece.gatech.edu
14811661Stushar@ece.gatech.edu# Not much point in this being higher than the L1 latency
14911661Stushar@ece.gatech.edum5.ticks.setGlobalFrequency('1ns')
15011661Stushar@ece.gatech.edu
15111661Stushar@ece.gatech.edu# instantiate configuration
15211661Stushar@ece.gatech.edum5.instantiate()
15311661Stushar@ece.gatech.edu
15411661Stushar@ece.gatech.edu# simulate until program terminates
15511661Stushar@ece.gatech.eduexit_event = m5.simulate(options.abs_max_tick)
15611661Stushar@ece.gatech.edu
15711661Stushar@ece.gatech.eduprint 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause()
158