1 # Copyright (c) 2006-2007 The Regents of The University of Michigan
2 # Copyright (c) 2010 Advanced Micro Devices, Inc.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
7 # met: redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer;
9 # redistributions in binary form must reproduce the above copyright
10 # notice, this list of conditions and the following disclaimer in the
11 # documentation and/or other materials provided with the distribution;
12 # neither the name of the copyright holders nor the names of its
13 # contributors may be used to endorse or promote products derived from
14 # this software without specific prior written permission.
16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 # Authors: Ron Dreslinski
32 from m5
.objects
import *
33 from m5
.defines
import buildEnv
34 from m5
.util
import addToPath
35 import os
, optparse
, sys
36 addToPath('../common')
40 # Get paths we might need. It's expected this file is in m5/configs/example.
41 config_path
= os
.path
.dirname(os
.path
.abspath(__file__
))
42 config_root
= os
.path
.dirname(config_path
)
43 m5_root
= os
.path
.dirname(config_root
)
45 parser
= optparse
.OptionParser()
47 parser
.add_option("--synthetic", type="int", default
=0,
48 help="Synthetic Traffic type. 0 = Uniform Random,\
49 1 = Tornado, 2 = Bit Complement")
51 parser
.add_option("-i", "--injectionrate", type="float", default
=0.1,
53 help="Injection rate in packets per cycle per node. \
54 Takes decimal value between 0 to 1 (eg. 0.225). \
55 Number of digits after 0 depends upon --precision.")
57 parser
.add_option("--precision", type="int", default
=3,
58 help="Number of digits of precision after decimal point\
61 parser
.add_option("--sim-cycles", type="int", default
=1000,
62 help="Number of simulation cycles")
64 parser
.add_option("--fixed-pkts", action
="store_true",
65 help="Network_test: inject --maxpackets and stop")
67 parser
.add_option("--maxpackets", type="int", default
=1,
68 help="Stop injecting after --maxpackets. \
69 Works only with --fixed-pkts")
72 # Add the ruby specific and protocol specific options
74 Ruby
.define_options(parser
)
76 execfile(os
.path
.join(config_root
, "common", "Options.py"))
78 (options
, args
) = parser
.parse_args()
81 print "Error: script doesn't take any positional arguments"
86 if options
.num_cpus
> block_size
:
87 print "Error: Number of cores %d limited to %d because of false sharing" \
88 % (options
.num_cpus
, block_size
)
92 cpus
= [ NetworkTest(fixed_pkts
=options
.fixed_pkts
,
93 max_packets
=options
.maxpackets
,
94 sim_cycles
=options
.sim_cycles
,
95 traffic_type
=options
.synthetic
,
96 inj_rate
=options
.injectionrate
,
97 precision
=options
.precision
,
98 num_memories
=options
.num_dirs
) \
99 for i
in xrange(options
.num_cpus
) ]
101 # create the desired simulated system
102 system
= System(cpu
= cpus
,
103 physmem
= PhysicalMemory())
105 Ruby
.create_system(options
, system
)
108 for ruby_port
in system
.ruby
._cpu
_ruby
_ports
:
110 # Tie the cpu test ports to the ruby cpu port
112 cpus
[i
].test
= ruby_port
.port
113 ruby_port
.access_phys_mem
= False
117 # -----------------------
119 # -----------------------
121 root
= Root( full_system
= False, system
= system
)
122 root
.system
.mem_mode
= 'timing'
124 # Not much point in this being higher than the L1 latency
125 m5
.ticks
.setGlobalFrequency('1ns')
127 # instantiate configuration
130 # simulate until program terminates
131 exit_event
= m5
.simulate(options
.maxtick
)
133 print 'Exiting @ tick', m5
.curTick(), 'because', exit_event
.getCause()