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 |
31 |
32import m5 |
33from m5.defines import buildEnv |
34from m5.objects import * |
35from m5.util import * |
36 |
37addToPath('../common') 38 |
39def setCPUClass(options): 40 41 atomic = False 42 if options.timing: 43 class TmpClass(TimingSimpleCPU): pass 44 elif options.detailed: 45 if not options.caches: 46 print "O3 CPU must be used with caches" --- 34 unchanged lines hidden (view full) --- 81 if options.checkpoint_dir: 82 cptdir = options.checkpoint_dir 83 elif m5.options.outdir: 84 cptdir = m5.options.outdir 85 else: 86 cptdir = getcwd() 87 88 if options.fast_forward and options.checkpoint_restore != None: |
89 fatal("Can't specify both --fast-forward and --checkpoint-restore") |
90 91 if options.standard_switch and not options.caches: |
92 fatal("Must specify --caches when using --standard-switch") |
93 94 np = options.num_cpus 95 max_checkpoints = options.max_checkpoints 96 switch_cpus = None 97 98 if options.prog_intvl: 99 for i in xrange(np): 100 testsys.cpu[i].progress_interval = options.prog_intvl --- 5 unchanged lines hidden (view full) --- 106 if cpu_class: 107 switch_cpus = [cpu_class(defer_registration=True, cpu_id=(np+i)) 108 for i in xrange(np)] 109 110 for i in xrange(np): 111 if options.fast_forward: 112 testsys.cpu[i].max_insts_any_thread = int(options.fast_forward) 113 switch_cpus[i].system = testsys |
114 if not buildEnv['FULL_SYSTEM']: |
115 switch_cpus[i].workload = testsys.cpu[i].workload 116 switch_cpus[i].clock = testsys.cpu[0].clock 117 # simulation period 118 if options.max_inst: 119 switch_cpus[i].max_insts_any_thread = options.max_inst 120 121 testsys.switch_cpus = switch_cpus 122 switch_cpu_list = [(testsys.cpu[i], switch_cpus[i]) for i in xrange(np)] 123 124 if options.standard_switch: 125 switch_cpus = [TimingSimpleCPU(defer_registration=True, cpu_id=(np+i)) 126 for i in xrange(np)] 127 switch_cpus_1 = [DerivO3CPU(defer_registration=True, cpu_id=(2*np+i)) 128 for i in xrange(np)] 129 130 for i in xrange(np): 131 switch_cpus[i].system = testsys 132 switch_cpus_1[i].system = testsys |
133 if not buildEnv['FULL_SYSTEM']: |
134 switch_cpus[i].workload = testsys.cpu[i].workload 135 switch_cpus_1[i].workload = testsys.cpu[i].workload 136 switch_cpus[i].clock = testsys.cpu[0].clock 137 switch_cpus_1[i].clock = testsys.cpu[0].clock 138 139 # if restoring, make atomic cpu simulate only a few instructions 140 if options.checkpoint_restore != None: 141 testsys.cpu[i].max_insts_any_thread = 1 142 # Fast forward to specified location if we are not restoring 143 elif options.fast_forward: 144 testsys.cpu[i].max_insts_any_thread = int(options.fast_forward) 145 # Fast forward to a simpoint (warning: time consuming) 146 elif options.simpoint: 147 if testsys.cpu[i].workload[0].simpoint == 0: |
148 fatal('simpoint not found') |
149 testsys.cpu[i].max_insts_any_thread = \ 150 testsys.cpu[i].workload[0].simpoint 151 # No distance specified, just switch 152 else: 153 testsys.cpu[i].max_insts_any_thread = 1 154 155 # warmup period 156 if options.warmup_insts: --- 16 unchanged lines hidden (view full) --- 173 # set the checkpoint in the cpu before m5.instantiate is called 174 if options.take_checkpoints != None and \ 175 (options.simpoint or options.at_instruction): 176 offset = int(options.take_checkpoints) 177 # Set an instruction break point 178 if options.simpoint: 179 for i in xrange(np): 180 if testsys.cpu[i].workload[0].simpoint == 0: |
181 fatal('no simpoint for testsys.cpu[%d].workload[0]', i) |
182 checkpoint_inst = int(testsys.cpu[i].workload[0].simpoint) + offset 183 testsys.cpu[i].max_insts_any_thread = checkpoint_inst 184 # used for output below 185 options.take_checkpoints = checkpoint_inst 186 else: 187 options.take_checkpoints = offset 188 # Set all test cpus with the right number of instructions 189 # for the upcoming simulation 190 for i in xrange(np): 191 testsys.cpu[i].max_insts_any_thread = offset 192 193 m5.instantiate(root) 194 195 if options.checkpoint_restore != None: 196 from os.path import isdir, exists 197 from os import listdir 198 import re 199 200 if not isdir(cptdir): |
201 fatal("checkpoint dir %s does not exist!", cptdir) |
202 203 if options.at_instruction: 204 checkpoint_dir = joinpath(cptdir, "cpt.%s.%s" % \ 205 (options.bench, options.checkpoint_restore)) 206 if not exists(checkpoint_dir): |
207 fatal("Unable to find checkpoint directory %s", checkpoint_dir) |
208 209 print "Restoring checkpoint ..." 210 m5.restoreCheckpoint(root, checkpoint_dir) 211 print "Done." 212 elif options.simpoint: 213 # assume workload 0 has the simpoint 214 if testsys.cpu[0].workload[0].simpoint == 0: |
215 fatal('Unable to find simpoint') |
216 217 options.checkpoint_restore += \ 218 int(testsys.cpu[0].workload[0].simpoint) 219 220 checkpoint_dir = joinpath(cptdir, "cpt.%s.%d" % \ 221 (options.bench, options.checkpoint_restore)) 222 if not exists(checkpoint_dir): |
223 fatal("Unable to find checkpoint directory %s.%s", 224 options.bench, options.checkpoint_restore) |
225 226 print "Restoring checkpoint ..." 227 m5.restoreCheckpoint(root,checkpoint_dir) 228 print "Done." 229 else: 230 dirs = listdir(cptdir) 231 expr = re.compile('cpt\.([0-9]*)') 232 cpts = [] 233 for dir in dirs: 234 match = expr.match(dir) 235 if match: 236 cpts.append(match.group(1)) 237 238 cpts.sort(lambda a,b: cmp(long(a), long(b))) 239 240 cpt_num = options.checkpoint_restore 241 242 if cpt_num > len(cpts): |
243 fatal('Checkpoint %d not found', cpt_num) |
244 245 ## Adjust max tick based on our starting tick 246 maxtick = maxtick - int(cpts[cpt_num - 1]) 247 248 ## Restore the checkpoint 249 m5.restoreCheckpoint(root, 250 joinpath(cptdir, "cpt.%s" % cpts[cpt_num - 1])) 251 --- 125 unchanged lines hidden --- |