garnet_synth_traffic.py revision 12564
16019Shines@cs.fsu.edu# Copyright (c) 2016 Georgia Institute of Technology
27093Sgblack@eecs.umich.edu# All rights reserved.
37093Sgblack@eecs.umich.edu#
47093Sgblack@eecs.umich.edu# Redistribution and use in source and binary forms, with or without
57093Sgblack@eecs.umich.edu# modification, are permitted provided that the following conditions are
67093Sgblack@eecs.umich.edu# met: redistributions of source code must retain the above copyright
77093Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer;
87093Sgblack@eecs.umich.edu# redistributions in binary form must reproduce the above copyright
97093Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the
107093Sgblack@eecs.umich.edu# documentation and/or other materials provided with the distribution;
117093Sgblack@eecs.umich.edu# neither the name of the copyright holders nor the names of its
127093Sgblack@eecs.umich.edu# contributors may be used to endorse or promote products derived from
137093Sgblack@eecs.umich.edu# this software without specific prior written permission.
146019Shines@cs.fsu.edu#
156019Shines@cs.fsu.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
166019Shines@cs.fsu.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
176019Shines@cs.fsu.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
186019Shines@cs.fsu.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
196019Shines@cs.fsu.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
206019Shines@cs.fsu.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
216019Shines@cs.fsu.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
226019Shines@cs.fsu.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
236019Shines@cs.fsu.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
246019Shines@cs.fsu.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
256019Shines@cs.fsu.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
266019Shines@cs.fsu.edu#
276019Shines@cs.fsu.edu# Author: Tushar Krishna
286019Shines@cs.fsu.edu
296019Shines@cs.fsu.edufrom __future__ import print_function
306019Shines@cs.fsu.edu
316019Shines@cs.fsu.eduimport m5
326019Shines@cs.fsu.edufrom m5.objects import *
336019Shines@cs.fsu.edufrom m5.defines import buildEnv
346019Shines@cs.fsu.edufrom m5.util import addToPath
356019Shines@cs.fsu.eduimport os, optparse, sys
366019Shines@cs.fsu.edu
376019Shines@cs.fsu.eduaddToPath('../')
386019Shines@cs.fsu.edu
396019Shines@cs.fsu.edufrom common import Options
406019Shines@cs.fsu.edufrom ruby import Ruby
416735Sgblack@eecs.umich.edu
426735Sgblack@eecs.umich.edu# Get paths we might need.  It's expected this file is in m5/configs/example.
436019Shines@cs.fsu.educonfig_path = os.path.dirname(os.path.abspath(__file__))
446019Shines@cs.fsu.educonfig_root = os.path.dirname(config_path)
456019Shines@cs.fsu.edum5_root = os.path.dirname(config_root)
466019Shines@cs.fsu.edu
476019Shines@cs.fsu.eduparser = optparse.OptionParser()
486019Shines@cs.fsu.eduOptions.addNoISAOptions(parser)
496019Shines@cs.fsu.edu
506019Shines@cs.fsu.eduparser.add_option("--synthetic", type="choice", default="uniform_random",
516019Shines@cs.fsu.edu                  choices=['uniform_random', 'tornado', 'bit_complement', \
526019Shines@cs.fsu.edu                           'bit_reverse', 'bit_rotation', 'neighbor', \
536735Sgblack@eecs.umich.edu                            'shuffle', 'transpose'])
546735Sgblack@eecs.umich.edu
556019Shines@cs.fsu.eduparser.add_option("-i", "--injectionrate", type="float", default=0.1,
566735Sgblack@eecs.umich.edu                  metavar="I",
576735Sgblack@eecs.umich.edu                  help="Injection rate in packets per cycle per node. \
586019Shines@cs.fsu.edu                        Takes decimal value between 0 to 1 (eg. 0.225). \
596735Sgblack@eecs.umich.edu                        Number of digits after 0 depends upon --precision.")
606735Sgblack@eecs.umich.edu
616019Shines@cs.fsu.eduparser.add_option("--precision", type="int", default=3,
626735Sgblack@eecs.umich.edu                  help="Number of digits of precision after decimal point\
636735Sgblack@eecs.umich.edu                        for injection rate")
646019Shines@cs.fsu.edu
656735Sgblack@eecs.umich.eduparser.add_option("--sim-cycles", type="int", default=1000,
666735Sgblack@eecs.umich.edu                   help="Number of simulation cycles")
676019Shines@cs.fsu.edu
686735Sgblack@eecs.umich.eduparser.add_option("--num-packets-max", type="int", default=-1,
696735Sgblack@eecs.umich.edu                  help="Stop injecting after --num-packets-max.\
706019Shines@cs.fsu.edu                        Set to -1 to disable.")
716735Sgblack@eecs.umich.edu
726735Sgblack@eecs.umich.eduparser.add_option("--single-sender-id", type="int", default=-1,
736019Shines@cs.fsu.edu                  help="Only inject from this sender.\
746735Sgblack@eecs.umich.edu                        Set to -1 to disable.")
756735Sgblack@eecs.umich.edu
766735Sgblack@eecs.umich.eduparser.add_option("--single-dest-id", type="int", default=-1,
776735Sgblack@eecs.umich.edu                  help="Only send to this destination.\
786019Shines@cs.fsu.edu                        Set to -1 to disable.")
796735Sgblack@eecs.umich.edu
806735Sgblack@eecs.umich.eduparser.add_option("--inj-vnet", type="int", default=-1,
816735Sgblack@eecs.umich.edu                  help="Only inject in this vnet (0, 1 or 2).\
826735Sgblack@eecs.umich.edu                        0 and 1 are 1-flit, 2 is 5-flit.\
836735Sgblack@eecs.umich.edu                        Set to -1 to inject randomly in all vnets.")
846735Sgblack@eecs.umich.edu
856735Sgblack@eecs.umich.edu#
866735Sgblack@eecs.umich.edu# Add the ruby specific and protocol specific options
876735Sgblack@eecs.umich.edu#
886019Shines@cs.fsu.eduRuby.define_options(parser)
896019Shines@cs.fsu.edu
906019Shines@cs.fsu.eduexecfile(os.path.join(config_root, "common", "Options.py"))
916735Sgblack@eecs.umich.edu
926735Sgblack@eecs.umich.edu(options, args) = parser.parse_args()
936735Sgblack@eecs.umich.edu
946735Sgblack@eecs.umich.eduif args:
956019Shines@cs.fsu.edu     print("Error: script doesn't take any positional arguments")
966735Sgblack@eecs.umich.edu     sys.exit(1)
976735Sgblack@eecs.umich.edu
986735Sgblack@eecs.umich.edu
996019Shines@cs.fsu.eduif options.inj_vnet > 2:
1006735Sgblack@eecs.umich.edu    print("Error: Injection vnet %d should be 0 (1-flit), 1 (1-flit) "
1016735Sgblack@eecs.umich.edu          "or 2 (5-flit) or -1 (random)" % (options.inj_vnet))
1026735Sgblack@eecs.umich.edu    sys.exit(1)
1036735Sgblack@eecs.umich.edu
1046735Sgblack@eecs.umich.edu
1056735Sgblack@eecs.umich.educpus = [ GarnetSyntheticTraffic(
1066735Sgblack@eecs.umich.edu                     num_packets_max=options.num_packets_max,
1076735Sgblack@eecs.umich.edu                     single_sender=options.single_sender_id,
1086735Sgblack@eecs.umich.edu                     single_dest=options.single_dest_id,
1096735Sgblack@eecs.umich.edu                     sim_cycles=options.sim_cycles,
1107093Sgblack@eecs.umich.edu                     traffic_type=options.synthetic,
1116735Sgblack@eecs.umich.edu                     inj_rate=options.injectionrate,
1126735Sgblack@eecs.umich.edu                     inj_vnet=options.inj_vnet,
1136735Sgblack@eecs.umich.edu                     precision=options.precision,
1146735Sgblack@eecs.umich.edu                     num_dest=options.num_dirs) \
1156735Sgblack@eecs.umich.edu         for i in xrange(options.num_cpus) ]
1166735Sgblack@eecs.umich.edu
1176735Sgblack@eecs.umich.edu# create the desired simulated system
1186735Sgblack@eecs.umich.edusystem = System(cpu = cpus, mem_ranges = [AddrRange(options.mem_size)])
1196735Sgblack@eecs.umich.edu
1206735Sgblack@eecs.umich.edu
1216735Sgblack@eecs.umich.edu# Create a top-level voltage domain and clock domain
1226735Sgblack@eecs.umich.edusystem.voltage_domain = VoltageDomain(voltage = options.sys_voltage)
1236735Sgblack@eecs.umich.edu
1246735Sgblack@eecs.umich.edusystem.clk_domain = SrcClockDomain(clock = options.sys_clock,
1256735Sgblack@eecs.umich.edu                                   voltage_domain = system.voltage_domain)
1266735Sgblack@eecs.umich.edu
1276735Sgblack@eecs.umich.eduRuby.create_system(options, False, system)
1286735Sgblack@eecs.umich.edu
1296735Sgblack@eecs.umich.edu# Create a seperate clock domain for Ruby
1306735Sgblack@eecs.umich.edusystem.ruby.clk_domain = SrcClockDomain(clock = options.ruby_clock,
1316735Sgblack@eecs.umich.edu                                        voltage_domain = system.voltage_domain)
1326735Sgblack@eecs.umich.edu
1336735Sgblack@eecs.umich.edui = 0
1346735Sgblack@eecs.umich.edufor ruby_port in system.ruby._cpu_ports:
1356735Sgblack@eecs.umich.edu     #
1367093Sgblack@eecs.umich.edu     # Tie the cpu test ports to the ruby cpu port
1377093Sgblack@eecs.umich.edu     #
1387093Sgblack@eecs.umich.edu     cpus[i].test = ruby_port.slave
1397093Sgblack@eecs.umich.edu     i += 1
1407093Sgblack@eecs.umich.edu
1417093Sgblack@eecs.umich.edu# -----------------------
1427093Sgblack@eecs.umich.edu# run simulation
1437093Sgblack@eecs.umich.edu# -----------------------
1447295Sgblack@eecs.umich.edu
1456019Shines@cs.fsu.eduroot = Root(full_system = False, system = system)
1467189Sgblack@eecs.umich.eduroot.system.mem_mode = 'timing'
1477189Sgblack@eecs.umich.edu
1487189Sgblack@eecs.umich.edu# Not much point in this being higher than the L1 latency
1497189Sgblack@eecs.umich.edum5.ticks.setGlobalFrequency('1ns')
1507189Sgblack@eecs.umich.edu
1517189Sgblack@eecs.umich.edu# instantiate configuration
1527189Sgblack@eecs.umich.edum5.instantiate()
1537189Sgblack@eecs.umich.edu
1547189Sgblack@eecs.umich.edu# simulate until program terminates
1557189Sgblack@eecs.umich.eduexit_event = m5.simulate(options.abs_max_tick)
1567189Sgblack@eecs.umich.edu
1577189Sgblack@eecs.umich.eduprint('Exiting @ tick', m5.curTick(), 'because', exit_event.getCause())
1587189Sgblack@eecs.umich.edu