Deleted Added
sdiff udiff text old ( 6641:59f08019c39a ) new ( 6654:4c84e771cca7 )
full compact
1# Copyright (c) 2006-2008 The Regents of The University of Michigan
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

--- 14 unchanged lines hidden (view full) ---

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# Authors: Lisa Hsu
28
29from os import getcwd
30from os.path import join as joinpath
31import m5
32from m5.objects import *
33m5.AddToPath('../common')
34
35def setCPUClass(options):
36
37 atomic = False
38 if options.timing:
39 class TmpClass(TimingSimpleCPU): pass
40 elif options.detailed:
41 if not options.caches:
42 print "O3 CPU must be used with caches"

--- 34 unchanged lines hidden (view full) ---

77 if options.checkpoint_dir:
78 cptdir = options.checkpoint_dir
79 elif m5.options.outdir:
80 cptdir = m5.options.outdir
81 else:
82 cptdir = getcwd()
83
84 if options.fast_forward and options.checkpoint_restore != None:
85 m5.fatal("Error: Can't specify both --fast-forward and --checkpoint-restore")
86
87 if options.standard_switch and not options.caches:
88 m5.fatal("Error: Must specify --caches when using --standard-switch")
89
90 np = options.num_cpus
91 max_checkpoints = options.max_checkpoints
92 switch_cpus = None
93
94 if options.prog_intvl:
95 for i in xrange(np):
96 testsys.cpu[i].progress_interval = options.prog_intvl

--- 5 unchanged lines hidden (view full) ---

102 if cpu_class:
103 switch_cpus = [cpu_class(defer_registration=True, cpu_id=(np+i))
104 for i in xrange(np)]
105
106 for i in xrange(np):
107 if options.fast_forward:
108 testsys.cpu[i].max_insts_any_thread = int(options.fast_forward)
109 switch_cpus[i].system = testsys
110 if not m5.build_env['FULL_SYSTEM']:
111 switch_cpus[i].workload = testsys.cpu[i].workload
112 switch_cpus[i].clock = testsys.cpu[0].clock
113 # simulation period
114 if options.max_inst:
115 switch_cpus[i].max_insts_any_thread = options.max_inst
116
117 testsys.switch_cpus = switch_cpus
118 switch_cpu_list = [(testsys.cpu[i], switch_cpus[i]) for i in xrange(np)]
119
120 if options.standard_switch:
121 switch_cpus = [TimingSimpleCPU(defer_registration=True, cpu_id=(np+i))
122 for i in xrange(np)]
123 switch_cpus_1 = [DerivO3CPU(defer_registration=True, cpu_id=(2*np+i))
124 for i in xrange(np)]
125
126 for i in xrange(np):
127 switch_cpus[i].system = testsys
128 switch_cpus_1[i].system = testsys
129 if not m5.build_env['FULL_SYSTEM']:
130 switch_cpus[i].workload = testsys.cpu[i].workload
131 switch_cpus_1[i].workload = testsys.cpu[i].workload
132 switch_cpus[i].clock = testsys.cpu[0].clock
133 switch_cpus_1[i].clock = testsys.cpu[0].clock
134
135 # if restoring, make atomic cpu simulate only a few instructions
136 if options.checkpoint_restore != None:
137 testsys.cpu[i].max_insts_any_thread = 1
138 # Fast forward to specified location if we are not restoring
139 elif options.fast_forward:
140 testsys.cpu[i].max_insts_any_thread = int(options.fast_forward)
141 # Fast forward to a simpoint (warning: time consuming)
142 elif options.simpoint:
143 if testsys.cpu[i].workload[0].simpoint == 0:
144 m5.fatal('simpoint not found')
145 testsys.cpu[i].max_insts_any_thread = \
146 testsys.cpu[i].workload[0].simpoint
147 # No distance specified, just switch
148 else:
149 testsys.cpu[i].max_insts_any_thread = 1
150
151 # warmup period
152 if options.warmup_insts:

--- 16 unchanged lines hidden (view full) ---

169 # set the checkpoint in the cpu before m5.instantiate is called
170 if options.take_checkpoints != None and \
171 (options.simpoint or options.at_instruction):
172 offset = int(options.take_checkpoints)
173 # Set an instruction break point
174 if options.simpoint:
175 for i in xrange(np):
176 if testsys.cpu[i].workload[0].simpoint == 0:
177 m5.fatal('no simpoint for testsys.cpu[%d].workload[0]', i)
178 checkpoint_inst = int(testsys.cpu[i].workload[0].simpoint) + offset
179 testsys.cpu[i].max_insts_any_thread = checkpoint_inst
180 # used for output below
181 options.take_checkpoints = checkpoint_inst
182 else:
183 options.take_checkpoints = offset
184 # Set all test cpus with the right number of instructions
185 # for the upcoming simulation
186 for i in xrange(np):
187 testsys.cpu[i].max_insts_any_thread = offset
188
189 m5.instantiate(root)
190
191 if options.checkpoint_restore != None:
192 from os.path import isdir, exists
193 from os import listdir
194 import re
195
196 if not isdir(cptdir):
197 m5.fatal("checkpoint dir %s does not exist!", cptdir)
198
199 if options.at_instruction:
200 checkpoint_dir = joinpath(cptdir, "cpt.%s.%s" % \
201 (options.bench, options.checkpoint_restore))
202 if not exists(checkpoint_dir):
203 m5.fatal("Unable to find checkpoint directory %s",
204 checkpoint_dir)
205
206 print "Restoring checkpoint ..."
207 m5.restoreCheckpoint(root, checkpoint_dir)
208 print "Done."
209 elif options.simpoint:
210 # assume workload 0 has the simpoint
211 if testsys.cpu[0].workload[0].simpoint == 0:
212 m5.fatal('Unable to find simpoint')
213
214 options.checkpoint_restore += \
215 int(testsys.cpu[0].workload[0].simpoint)
216
217 checkpoint_dir = joinpath(cptdir, "cpt.%s.%d" % \
218 (options.bench, options.checkpoint_restore))
219 if not exists(checkpoint_dir):
220 m5.fatal("Unable to find checkpoint directory %s.%s",
221 options.bench, options.checkpoint_restore)
222
223 print "Restoring checkpoint ..."
224 m5.restoreCheckpoint(root,checkpoint_dir)
225 print "Done."
226 else:
227 dirs = listdir(cptdir)
228 expr = re.compile('cpt\.([0-9]*)')
229 cpts = []
230 for dir in dirs:
231 match = expr.match(dir)
232 if match:
233 cpts.append(match.group(1))
234
235 cpts.sort(lambda a,b: cmp(long(a), long(b)))
236
237 cpt_num = options.checkpoint_restore
238
239 if cpt_num > len(cpts):
240 m5.fatal('Checkpoint %d not found', cpt_num)
241
242 ## Adjust max tick based on our starting tick
243 maxtick = maxtick - int(cpts[cpt_num - 1])
244
245 ## Restore the checkpoint
246 m5.restoreCheckpoint(root,
247 joinpath(cptdir, "cpt.%s" % cpts[cpt_num - 1]))
248

--- 125 unchanged lines hidden ---