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