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