1 # Copyright (c) 2006 The Regents of The University of Michigan
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.
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.
29 import optparse
, os
, sys
32 from m5
.objects
import *
33 m5
.AddToPath('../common')
34 from FSConfig
import *
35 from SysPaths
import *
36 from Benchmarks
import *
38 if not m5
.build_env
['FULL_SYSTEM']:
39 m5
.panic("This script requires full-system mode (ALPHA_FS).")
41 parser
= optparse
.OptionParser()
43 parser
.add_option("-d", "--detailed", action
="store_true")
44 parser
.add_option("-t", "--timing", action
="store_true")
45 parser
.add_option("-n", "--num_cpus", type="int", default
=1)
46 parser
.add_option("--caches", action
="store_true")
47 parser
.add_option("-m", "--maxtick", type="int")
48 parser
.add_option("--maxtime", type="float")
49 parser
.add_option("--dual", action
="store_true",
50 help="Simulate two systems attached with an ethernet link")
51 parser
.add_option("-b", "--benchmark", action
="store", type="string",
53 help="Specify the benchmark to run. Available benchmarks: %s"\
55 parser
.add_option("--etherdump", action
="store", type="string", dest
="etherdump",
56 help="Specify the filename to dump a pcap capture of the" \
58 parser
.add_option("--checkpoint_dir", action
="store", type="string",
59 help="Place all checkpoints in this absolute directory")
60 parser
.add_option("-c", "--checkpoint", action
="store", type="int",
61 help="restore from checkpoint <N>")
63 (options
, args
) = parser
.parse_args()
66 print "Error: script doesn't take any positional arguments"
69 class MyCache(BaseCache
):
75 protocol
= CoherenceProtocol(protocol
='moesi')
77 # client system CPU is always simple... note this is an assignment of
78 # a class, not an instance.
79 ClientCPUClass
= AtomicSimpleCPU
80 client_mem_mode
= 'atomic'
83 ServerCPUClass
= DerivO3CPU
84 server_mem_mode
= 'timing'
86 ServerCPUClass
= TimingSimpleCPU
87 server_mem_mode
= 'timing'
89 ServerCPUClass
= AtomicSimpleCPU
90 server_mem_mode
= 'atomic'
92 ServerCPUClass
.clock
= '2GHz'
93 ClientCPUClass
.clock
= '2GHz'
97 bm
= Benchmarks
[options
.benchmark
]
99 print "Error benchmark %s has not been defined." % options
.benchmark
100 print "Valid benchmarks are: %s" % DefinedBenchmarks
104 bm
= [SysConfig(), SysConfig()]
108 server_sys
= makeLinuxAlphaSystem(server_mem_mode
, bm
[0])
109 np
= options
.num_cpus
110 server_sys
.cpu
= [ServerCPUClass(cpu_id
=i
) for i
in xrange(np
)]
113 server_sys
.cpu
[i
].addPrivateSplitL1Caches(MyCache(size
= '32kB'),
114 MyCache(size
= '64kB'))
115 server_sys
.cpu
[i
].connectMemPorts(server_sys
.membus
)
116 server_sys
.cpu
[i
].mem
= server_sys
.physmem
119 client_sys
= makeLinuxAlphaSystem(client_mem_mode
, bm
[1])
120 client_sys
.cpu
= ClientCPUClass(cpu_id
=0)
121 client_sys
.cpu
.connectMemPorts(client_sys
.membus
)
122 client_sys
.cpu
.mem
= client_sys
.physmem
123 root
= makeDualRoot(server_sys
, client_sys
, options
.etherdump
)
125 root
= Root(clock
= '1THz', system
= server_sys
)
127 print "Error I don't know how to create more than 2 systems."
132 if options
.checkpoint
:
133 from os
.path
import isdir
134 from os
import listdir
, getcwd
136 if options
.checkpoint_dir
:
137 cptdir
= options
.checkpoint_dir
141 if not isdir(cptdir
):
142 m5
.panic("checkpoint dir %s does not exist!" % cptdir
)
144 dirs
= listdir(cptdir
)
145 expr
= re
.compile('cpt.([0-9]*)')
148 match
= expr
.match(dir)
150 cpts
.append(match
.group(1))
152 if options
.checkpoint
> len(cpts
):
153 m5
.panic('Checkpoint %d not found' % options
.checkpoint
)
155 m5
.restoreCheckpoint(root
, "/".join([cptdir
, "cpt.%s" % cpts
[options
.checkpoint
- 1]]))
158 maxtick
= options
.maxtick
159 elif options
.maxtime
:
160 simtime
= int(options
.maxtime
* root
.clock
.value
)
161 print "simulating for: ", simtime
166 exit_event
= m5
.simulate(maxtick
)
168 while exit_event
.getCause() == "checkpoint":
169 if options
.checkpoint_dir
:
170 m5
.checkpoint(root
, "/".join([options
.checkpoint_dir
, "cpt.%d"]))
172 m5
.checkpoint(root
, "cpt.%d")
175 exit_event
= m5
.simulate(maxtick
)
177 exit_event
= m5
.simulate(maxtick
- m5
.curTick())
179 print 'Exiting @ cycle', m5
.curTick(), 'because', exit_event
.getCause()