SE/FS: Get rid of FULL_SYSTEM in the configs directory
[gem5.git] / configs / example / ruby_network_test.py
1 # Copyright (c) 2006-2007 The Regents of The University of Michigan
2 # Copyright (c) 2010 Advanced Micro Devices, Inc.
3 # All rights reserved.
4 #
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.
15 #
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.
27 #
28 # Authors: Ron Dreslinski
29 # Tushar Krishna
30
31 import m5
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')
37 addToPath('../ruby')
38 import Ruby
39
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)
44
45 parser = optparse.OptionParser()
46
47 parser.add_option("--synthetic", type="int", default=0,
48 help="Synthetic Traffic type. 0 = Uniform Random,\
49 1 = Tornado, 2 = Bit Complement")
50
51 parser.add_option("-i", "--injectionrate", type="float", default=0.1,
52 metavar="I",
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.")
56
57 parser.add_option("--precision", type="int", default=3,
58 help="Number of digits of precision after decimal point\
59 for injection rate")
60
61 parser.add_option("--sim-cycles", type="int", default=1000,
62 help="Number of simulation cycles")
63
64 parser.add_option("--fixed-pkts", action="store_true",
65 help="Network_test: inject --maxpackets and stop")
66
67 parser.add_option("--maxpackets", type="int", default=1,
68 help="Stop injecting after --maxpackets. \
69 Works only with --fixed-pkts")
70
71 #
72 # Add the ruby specific and protocol specific options
73 #
74 Ruby.define_options(parser)
75
76 execfile(os.path.join(config_root, "common", "Options.py"))
77
78 (options, args) = parser.parse_args()
79
80 if args:
81 print "Error: script doesn't take any positional arguments"
82 sys.exit(1)
83
84 block_size = 64
85
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)
89 sys.exit(1)
90
91
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) ]
100
101 # create the desired simulated system
102 system = System(cpu = cpus,
103 physmem = PhysicalMemory())
104
105 Ruby.create_system(options, system)
106
107 i = 0
108 for ruby_port in system.ruby._cpu_ruby_ports:
109 #
110 # Tie the cpu test ports to the ruby cpu port
111 #
112 cpus[i].test = ruby_port.port
113 ruby_port.access_phys_mem = False
114
115 i += 1
116
117 # -----------------------
118 # run simulation
119 # -----------------------
120
121 root = Root( full_system = False, system = system )
122 root.system.mem_mode = 'timing'
123
124 # Not much point in this being higher than the L1 latency
125 m5.ticks.setGlobalFrequency('1ns')
126
127 # instantiate configuration
128 m5.instantiate()
129
130 # simulate until program terminates
131 exit_event = m5.simulate(options.maxtick)
132
133 print 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause()