garnet_synth_traffic.py (11688:725fef71f376) garnet_synth_traffic.py (12564:2778478ca882)
1# Copyright (c) 2016 Georgia Institute of Technology
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright
9# notice, this list of conditions and the following disclaimer in the
10# documentation and/or other materials provided with the distribution;
11# neither the name of the copyright holders nor the names of its
12# contributors may be used to endorse or promote products derived from
13# this software without specific prior written permission.
14#
15# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26#
27# Author: Tushar Krishna
28
1# Copyright (c) 2016 Georgia Institute of Technology
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright
9# notice, this list of conditions and the following disclaimer in the
10# documentation and/or other materials provided with the distribution;
11# neither the name of the copyright holders nor the names of its
12# contributors may be used to endorse or promote products derived from
13# this software without specific prior written permission.
14#
15# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26#
27# Author: Tushar Krishna
28
29from __future__ import print_function
30
29import m5
30from m5.objects import *
31from m5.defines import buildEnv
32from m5.util import addToPath
33import os, optparse, sys
34
35addToPath('../')
36
37from common import Options
38from ruby import Ruby
39
40# Get paths we might need. It's expected this file is in m5/configs/example.
41config_path = os.path.dirname(os.path.abspath(__file__))
42config_root = os.path.dirname(config_path)
43m5_root = os.path.dirname(config_root)
44
45parser = optparse.OptionParser()
46Options.addNoISAOptions(parser)
47
48parser.add_option("--synthetic", type="choice", default="uniform_random",
49 choices=['uniform_random', 'tornado', 'bit_complement', \
50 'bit_reverse', 'bit_rotation', 'neighbor', \
51 'shuffle', 'transpose'])
52
53parser.add_option("-i", "--injectionrate", type="float", default=0.1,
54 metavar="I",
55 help="Injection rate in packets per cycle per node. \
56 Takes decimal value between 0 to 1 (eg. 0.225). \
57 Number of digits after 0 depends upon --precision.")
58
59parser.add_option("--precision", type="int", default=3,
60 help="Number of digits of precision after decimal point\
61 for injection rate")
62
63parser.add_option("--sim-cycles", type="int", default=1000,
64 help="Number of simulation cycles")
65
66parser.add_option("--num-packets-max", type="int", default=-1,
67 help="Stop injecting after --num-packets-max.\
68 Set to -1 to disable.")
69
70parser.add_option("--single-sender-id", type="int", default=-1,
71 help="Only inject from this sender.\
72 Set to -1 to disable.")
73
74parser.add_option("--single-dest-id", type="int", default=-1,
75 help="Only send to this destination.\
76 Set to -1 to disable.")
77
78parser.add_option("--inj-vnet", type="int", default=-1,
79 help="Only inject in this vnet (0, 1 or 2).\
80 0 and 1 are 1-flit, 2 is 5-flit.\
81 Set to -1 to inject randomly in all vnets.")
82
83#
84# Add the ruby specific and protocol specific options
85#
86Ruby.define_options(parser)
87
88execfile(os.path.join(config_root, "common", "Options.py"))
89
90(options, args) = parser.parse_args()
91
92if args:
31import m5
32from m5.objects import *
33from m5.defines import buildEnv
34from m5.util import addToPath
35import os, optparse, sys
36
37addToPath('../')
38
39from common import Options
40from ruby import Ruby
41
42# Get paths we might need. It's expected this file is in m5/configs/example.
43config_path = os.path.dirname(os.path.abspath(__file__))
44config_root = os.path.dirname(config_path)
45m5_root = os.path.dirname(config_root)
46
47parser = optparse.OptionParser()
48Options.addNoISAOptions(parser)
49
50parser.add_option("--synthetic", type="choice", default="uniform_random",
51 choices=['uniform_random', 'tornado', 'bit_complement', \
52 'bit_reverse', 'bit_rotation', 'neighbor', \
53 'shuffle', 'transpose'])
54
55parser.add_option("-i", "--injectionrate", type="float", default=0.1,
56 metavar="I",
57 help="Injection rate in packets per cycle per node. \
58 Takes decimal value between 0 to 1 (eg. 0.225). \
59 Number of digits after 0 depends upon --precision.")
60
61parser.add_option("--precision", type="int", default=3,
62 help="Number of digits of precision after decimal point\
63 for injection rate")
64
65parser.add_option("--sim-cycles", type="int", default=1000,
66 help="Number of simulation cycles")
67
68parser.add_option("--num-packets-max", type="int", default=-1,
69 help="Stop injecting after --num-packets-max.\
70 Set to -1 to disable.")
71
72parser.add_option("--single-sender-id", type="int", default=-1,
73 help="Only inject from this sender.\
74 Set to -1 to disable.")
75
76parser.add_option("--single-dest-id", type="int", default=-1,
77 help="Only send to this destination.\
78 Set to -1 to disable.")
79
80parser.add_option("--inj-vnet", type="int", default=-1,
81 help="Only inject in this vnet (0, 1 or 2).\
82 0 and 1 are 1-flit, 2 is 5-flit.\
83 Set to -1 to inject randomly in all vnets.")
84
85#
86# Add the ruby specific and protocol specific options
87#
88Ruby.define_options(parser)
89
90execfile(os.path.join(config_root, "common", "Options.py"))
91
92(options, args) = parser.parse_args()
93
94if args:
93 print "Error: script doesn't take any positional arguments"
95 print("Error: script doesn't take any positional arguments")
94 sys.exit(1)
95
96
97if options.inj_vnet > 2:
96 sys.exit(1)
97
98
99if options.inj_vnet > 2:
98 print "Error: Injection vnet %d should be 0 (1-flit), 1 (1-flit) \
99 or 2 (5-flit) or -1 (random)"\
100 % (options.inj_vnet)
100 print("Error: Injection vnet %d should be 0 (1-flit), 1 (1-flit) "
101 "or 2 (5-flit) or -1 (random)" % (options.inj_vnet))
101 sys.exit(1)
102
103
104cpus = [ GarnetSyntheticTraffic(
105 num_packets_max=options.num_packets_max,
106 single_sender=options.single_sender_id,
107 single_dest=options.single_dest_id,
108 sim_cycles=options.sim_cycles,
109 traffic_type=options.synthetic,
110 inj_rate=options.injectionrate,
111 inj_vnet=options.inj_vnet,
112 precision=options.precision,
113 num_dest=options.num_dirs) \
114 for i in xrange(options.num_cpus) ]
115
116# create the desired simulated system
117system = System(cpu = cpus, mem_ranges = [AddrRange(options.mem_size)])
118
119
120# Create a top-level voltage domain and clock domain
121system.voltage_domain = VoltageDomain(voltage = options.sys_voltage)
122
123system.clk_domain = SrcClockDomain(clock = options.sys_clock,
124 voltage_domain = system.voltage_domain)
125
126Ruby.create_system(options, False, system)
127
128# Create a seperate clock domain for Ruby
129system.ruby.clk_domain = SrcClockDomain(clock = options.ruby_clock,
130 voltage_domain = system.voltage_domain)
131
132i = 0
133for ruby_port in system.ruby._cpu_ports:
134 #
135 # Tie the cpu test ports to the ruby cpu port
136 #
137 cpus[i].test = ruby_port.slave
138 i += 1
139
140# -----------------------
141# run simulation
142# -----------------------
143
144root = Root(full_system = False, system = system)
145root.system.mem_mode = 'timing'
146
147# Not much point in this being higher than the L1 latency
148m5.ticks.setGlobalFrequency('1ns')
149
150# instantiate configuration
151m5.instantiate()
152
153# simulate until program terminates
154exit_event = m5.simulate(options.abs_max_tick)
155
102 sys.exit(1)
103
104
105cpus = [ GarnetSyntheticTraffic(
106 num_packets_max=options.num_packets_max,
107 single_sender=options.single_sender_id,
108 single_dest=options.single_dest_id,
109 sim_cycles=options.sim_cycles,
110 traffic_type=options.synthetic,
111 inj_rate=options.injectionrate,
112 inj_vnet=options.inj_vnet,
113 precision=options.precision,
114 num_dest=options.num_dirs) \
115 for i in xrange(options.num_cpus) ]
116
117# create the desired simulated system
118system = System(cpu = cpus, mem_ranges = [AddrRange(options.mem_size)])
119
120
121# Create a top-level voltage domain and clock domain
122system.voltage_domain = VoltageDomain(voltage = options.sys_voltage)
123
124system.clk_domain = SrcClockDomain(clock = options.sys_clock,
125 voltage_domain = system.voltage_domain)
126
127Ruby.create_system(options, False, system)
128
129# Create a seperate clock domain for Ruby
130system.ruby.clk_domain = SrcClockDomain(clock = options.ruby_clock,
131 voltage_domain = system.voltage_domain)
132
133i = 0
134for ruby_port in system.ruby._cpu_ports:
135 #
136 # Tie the cpu test ports to the ruby cpu port
137 #
138 cpus[i].test = ruby_port.slave
139 i += 1
140
141# -----------------------
142# run simulation
143# -----------------------
144
145root = Root(full_system = False, system = system)
146root.system.mem_mode = 'timing'
147
148# Not much point in this being higher than the L1 latency
149m5.ticks.setGlobalFrequency('1ns')
150
151# instantiate configuration
152m5.instantiate()
153
154# simulate until program terminates
155exit_event = m5.simulate(options.abs_max_tick)
156
156print 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause()
157print('Exiting @ tick', m5.curTick(), 'because', exit_event.getCause())