Simulation.py (9793:6e6cefc1db1f) Simulation.py (9816:971507cbbe65)
1# Copyright (c) 2012-2013 ARM Limited
2# All rights reserved
3#
4# The license below extends only to copyright in the software and shall
5# not be construed as granting a license to any other intellectual
6# property including but not limited to intellectual property relating
7# to a hardware implementation of the functionality of the software
8# licensed hereunder. You may use the software subject to the license

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

101 system.work_end_ckpt_count = options.work_end_checkpoint_count
102 if options.work_begin_exit_count != None:
103 system.work_begin_exit_count = options.work_begin_exit_count
104 if options.work_begin_checkpoint_count != None:
105 system.work_begin_ckpt_count = options.work_begin_checkpoint_count
106 if options.work_cpus_checkpoint_count != None:
107 system.work_cpus_ckpt_count = options.work_cpus_checkpoint_count
108
1# Copyright (c) 2012-2013 ARM Limited
2# All rights reserved
3#
4# The license below extends only to copyright in the software and shall
5# not be construed as granting a license to any other intellectual
6# property including but not limited to intellectual property relating
7# to a hardware implementation of the functionality of the software
8# licensed hereunder. You may use the software subject to the license

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

101 system.work_end_ckpt_count = options.work_end_checkpoint_count
102 if options.work_begin_exit_count != None:
103 system.work_begin_exit_count = options.work_begin_exit_count
104 if options.work_begin_checkpoint_count != None:
105 system.work_begin_ckpt_count = options.work_begin_checkpoint_count
106 if options.work_cpus_checkpoint_count != None:
107 system.work_cpus_ckpt_count = options.work_cpus_checkpoint_count
108
109def findCptDir(options, maxtick, cptdir, testsys):
109def findCptDir(options, cptdir, testsys):
110 """Figures out the directory from which the checkpointed state is read.
111
112 There are two different ways in which the directories holding checkpoints
113 can be named --
114 1. cpt.<benchmark name>.<instruction count when the checkpoint was taken>
115 2. cpt.<some number, usually the tick value when the checkpoint was taken>
116
117 This function parses through the options to figure out which one of the
118 above should be used for selecting the checkpoint, and then figures out
119 the appropriate directory.
110 """Figures out the directory from which the checkpointed state is read.
111
112 There are two different ways in which the directories holding checkpoints
113 can be named --
114 1. cpt.<benchmark name>.<instruction count when the checkpoint was taken>
115 2. cpt.<some number, usually the tick value when the checkpoint was taken>
116
117 This function parses through the options to figure out which one of the
118 above should be used for selecting the checkpoint, and then figures out
119 the appropriate directory.
120
121 It also sets the value of the maximum tick value till which the simulation
122 will run.
123 """
124
125 from os.path import isdir, exists
126 from os import listdir
127 import re
128
129 if not isdir(cptdir):
130 fatal("checkpoint dir %s does not exist!", cptdir)

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

150 cpts.append(match.group(1))
151
152 cpts.sort(lambda a,b: cmp(long(a), long(b)))
153
154 cpt_num = options.checkpoint_restore
155 if cpt_num > len(cpts):
156 fatal('Checkpoint %d not found', cpt_num)
157
120 """
121
122 from os.path import isdir, exists
123 from os import listdir
124 import re
125
126 if not isdir(cptdir):
127 fatal("checkpoint dir %s does not exist!", cptdir)

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

147 cpts.append(match.group(1))
148
149 cpts.sort(lambda a,b: cmp(long(a), long(b)))
150
151 cpt_num = options.checkpoint_restore
152 if cpt_num > len(cpts):
153 fatal('Checkpoint %d not found', cpt_num)
154
158 maxtick = maxtick - int(cpts[cpt_num - 1])
155 cpt_starttick = int(cpts[cpt_num - 1])
159 checkpoint_dir = joinpath(cptdir, "cpt.%s" % cpts[cpt_num - 1])
160
156 checkpoint_dir = joinpath(cptdir, "cpt.%s" % cpts[cpt_num - 1])
157
161 return maxtick, checkpoint_dir
158 return cpt_starttick, checkpoint_dir
162
163def scriptCheckpoints(options, maxtick, cptdir):
164 if options.at_instruction or options.simpoint:
165 checkpoint_inst = int(options.take_checkpoints)
166
167 # maintain correct offset if we restored from some instruction
168 if options.checkpoint_restore != None:
169 checkpoint_inst += options.checkpoint_restore

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

255 tmp_cpu_list.append((new_cpu, old_cpu))
256 repeat_switch_cpu_list = tmp_cpu_list
257
258 if (maxtick - m5.curTick()) <= switch_freq:
259 exit_event = m5.simulate(maxtick - m5.curTick())
260 return exit_event
261
262def run(options, root, testsys, cpu_class):
159
160def scriptCheckpoints(options, maxtick, cptdir):
161 if options.at_instruction or options.simpoint:
162 checkpoint_inst = int(options.take_checkpoints)
163
164 # maintain correct offset if we restored from some instruction
165 if options.checkpoint_restore != None:
166 checkpoint_inst += options.checkpoint_restore

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

252 tmp_cpu_list.append((new_cpu, old_cpu))
253 repeat_switch_cpu_list = tmp_cpu_list
254
255 if (maxtick - m5.curTick()) <= switch_freq:
256 exit_event = m5.simulate(maxtick - m5.curTick())
257 return exit_event
258
259def run(options, root, testsys, cpu_class):
263 if options.maxtick:
264 maxtick = options.maxtick
265 elif options.maxtime:
266 simtime = m5.ticks.seconds(simtime)
267 print "simulating for: ", simtime
268 maxtick = simtime
269 else:
270 maxtick = m5.MaxTick
271
272 if options.checkpoint_dir:
273 cptdir = options.checkpoint_dir
274 elif m5.options.outdir:
275 cptdir = m5.options.outdir
276 else:
277 cptdir = getcwd()
278
279 if options.fast_forward and options.checkpoint_restore != None:

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

416 else:
417 options.take_checkpoints = offset
418 # Set all test cpus with the right number of instructions
419 # for the upcoming simulation
420 for i in xrange(np):
421 testsys.cpu[i].max_insts_any_thread = offset
422
423 checkpoint_dir = None
260 if options.checkpoint_dir:
261 cptdir = options.checkpoint_dir
262 elif m5.options.outdir:
263 cptdir = m5.options.outdir
264 else:
265 cptdir = getcwd()
266
267 if options.fast_forward and options.checkpoint_restore != None:

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

404 else:
405 options.take_checkpoints = offset
406 # Set all test cpus with the right number of instructions
407 # for the upcoming simulation
408 for i in xrange(np):
409 testsys.cpu[i].max_insts_any_thread = offset
410
411 checkpoint_dir = None
424 if options.checkpoint_restore != None:
425 maxtick, checkpoint_dir = findCptDir(options, maxtick, cptdir, testsys)
412 if options.checkpoint_restore:
413 cpt_starttick, checkpoint_dir = findCptDir(options, cptdir, testsys)
426 m5.instantiate(checkpoint_dir)
427
414 m5.instantiate(checkpoint_dir)
415
416 # Handle the max tick settings now that tick frequency was resolved
417 # during system instantiation
418 # NOTE: the maxtick variable here is in absolute ticks, so it must
419 # include any simulated ticks before a checkpoint
420 explicit_maxticks = 0
421 maxtick_from_abs = m5.MaxTick
422 maxtick_from_rel = m5.MaxTick
423 maxtick_from_maxtime = m5.MaxTick
424 if options.abs_max_tick:
425 maxtick_from_abs = options.abs_max_tick
426 explicit_maxticks += 1
427 if options.rel_max_tick:
428 maxtick_from_rel = options.rel_max_tick
429 if options.checkpoint_restore:
430 # NOTE: this may need to be updated if checkpoints ever store
431 # the ticks per simulated second
432 maxtick_from_rel += cpt_starttick
433 explicit_maxticks += 1
434 if options.maxtime:
435 maxtick_from_maxtime = m5.ticks.fromSeconds(options.maxtime)
436 explicit_maxticks += 1
437 if explicit_maxticks > 1:
438 warn("Specified multiple of --abs-max-tick, --rel-max-tick, --maxtime."\
439 " Using least")
440 maxtick = min([maxtick_from_abs, maxtick_from_rel, maxtick_from_maxtime])
441
442 if options.checkpoint_restore != None and maxtick < cpt_starttick:
443 fatal("Bad maxtick (%d) specified: " \
444 "Checkpoint starts starts from tick: %d", maxtick, cpt_starttick)
445
428 if options.standard_switch or cpu_class:
429 if options.standard_switch:
430 print "Switch at instruction count:%s" % \
431 str(testsys.cpu[0].max_insts_any_thread)
432 exit_event = m5.simulate()
433 elif cpu_class and options.fast_forward:
434 print "Switch at instruction count:%s" % \
435 str(testsys.cpu[0].max_insts_any_thread)

--- 57 unchanged lines hidden ---
446 if options.standard_switch or cpu_class:
447 if options.standard_switch:
448 print "Switch at instruction count:%s" % \
449 str(testsys.cpu[0].max_insts_any_thread)
450 exit_event = m5.simulate()
451 elif cpu_class and options.fast_forward:
452 print "Switch at instruction count:%s" % \
453 str(testsys.cpu[0].max_insts_any_thread)

--- 57 unchanged lines hidden ---