142a143,179
>
> elif options.restore_simpoint_checkpoint:
> # Restore from SimPoint checkpoints
> # Assumes that the checkpoint dir names are formatted as follows:
> dirs = listdir(cptdir)
> expr = re.compile('cpt\.simpoint_(\d+)_inst_(\d+)' +
> '_weight_([\d\.e\-]+)_interval_(\d+)_warmup_(\d+)')
> cpts = []
> for dir in dirs:
> match = expr.match(dir)
> if match:
> cpts.append(dir)
> cpts.sort()
>
> cpt_num = options.checkpoint_restore
> if cpt_num > len(cpts):
> fatal('Checkpoint %d not found', cpt_num)
> checkpoint_dir = joinpath(cptdir, cpts[cpt_num - 1])
> match = expr.match(cpts[cpt_num - 1])
> if match:
> index = int(match.group(1))
> start_inst = int(match.group(2))
> weight_inst = float(match.group(3))
> interval_length = int(match.group(4))
> warmup_length = int(match.group(5))
> print "Resuming from", checkpoint_dir
> simpoint_start_insts = []
> simpoint_start_insts.append(warmup_length)
> simpoint_start_insts.append(warmup_length + interval_length)
> testsys.cpu[0].simpoint_start_insts = simpoint_start_insts
> if testsys.switch_cpus != None:
> testsys.switch_cpus[0].simpoint_start_insts = simpoint_start_insts
>
> print "Resuming from SimPoint",
> print "#%d, start_inst:%d, weight:%f, interval:%d, warmup:%d" % \
> (index, start_inst, weight_inst, interval_length, warmup_length)
>
145c182
< expr = re.compile('cpt\.([0-9]*)')
---
> expr = re.compile('cpt\.([0-9]+)')
241a279,403
> # Set up environment for taking SimPoint checkpoints
> # Expecting SimPoint files generated by SimPoint 3.2
> def parseSimpointAnalysisFile(options, testsys):
> import re
>
> simpoint_filename, weight_filename, interval_length, warmup_length = \
> options.take_simpoint_checkpoints.split(",", 3)
> print "simpoint analysis file:", simpoint_filename
> print "simpoint weight file:", weight_filename
> print "interval length:", interval_length
> print "warmup length:", warmup_length
>
> interval_length = int(interval_length)
> warmup_length = int(warmup_length)
>
> # Simpoint analysis output starts interval counts with 0.
> simpoints = []
> simpoint_start_insts = []
>
> # Read in SimPoint analysis files
> simpoint_file = open(simpoint_filename)
> weight_file = open(weight_filename)
> while True:
> line = simpoint_file.readline()
> if not line:
> break
> m = re.match("(\d+)\s+(\d+)", line)
> if m:
> interval = int(m.group(1))
> else:
> fatal('unrecognized line in simpoint file!')
>
> line = weight_file.readline()
> if not line:
> fatal('not enough lines in simpoint weight file!')
> m = re.match("([0-9\.e\-]+)\s+(\d+)", line)
> if m:
> weight = float(m.group(1))
> else:
> fatal('unrecognized line in simpoint weight file!')
>
> if (interval * interval_length - warmup_length > 0):
> starting_inst_count = \
> interval * interval_length - warmup_length
> actual_warmup_length = warmup_length
> else:
> # Not enough room for proper warmup
> # Just starting from the beginning
> starting_inst_count = 0
> actual_warmup_length = interval * interval_length
>
> simpoints.append((interval, weight, starting_inst_count,
> actual_warmup_length))
>
> # Sort SimPoints by starting inst count
> simpoints.sort(key=lambda obj: obj[2])
> for s in simpoints:
> interval, weight, starting_inst_count, actual_warmup_length = s
> print str(interval), str(weight), starting_inst_count, \
> actual_warmup_length
> simpoint_start_insts.append(starting_inst_count)
>
> print "Total # of simpoints:", len(simpoints)
> testsys.cpu[0].simpoint_start_insts = simpoint_start_insts
>
> return (simpoints, interval_length)
>
> def takeSimpointCheckpoints(simpoints, interval_length, cptdir):
> num_checkpoints = 0
> index = 0
> last_chkpnt_inst_count = -1
> for simpoint in simpoints:
> interval, weight, starting_inst_count, actual_warmup_length = simpoint
> if starting_inst_count == last_chkpnt_inst_count:
> # checkpoint starting point same as last time
> # (when warmup period longer than starting point)
> exit_cause = "simpoint starting point found"
> code = 0
> else:
> exit_event = m5.simulate()
>
> # skip checkpoint instructions should they exist
> while exit_event.getCause() == "checkpoint":
> print "Found 'checkpoint' exit event...ignoring..."
> exit_event = m5.simulate()
>
> exit_cause = exit_event.getCause()
> code = exit_event.getCode()
>
> if exit_cause == "simpoint starting point found":
> m5.checkpoint(joinpath(cptdir,
> "cpt.simpoint_%02d_inst_%d_weight_%f_interval_%d_warmup_%d"
> % (index, starting_inst_count, weight, interval_length,
> actual_warmup_length)))
> print "Checkpoint #%d written. start inst:%d weight:%f" % \
> (num_checkpoints, starting_inst_count, weight)
> num_checkpoints += 1
> last_chkpnt_inst_count = starting_inst_count
> else:
> break
> index += 1
>
> print 'Exiting @ tick %i because %s' % (m5.curTick(), exit_cause)
> print "%d checkpoints taken" % num_checkpoints
> sys.exit(code)
>
> def restoreSimpointCheckpoint():
> exit_event = m5.simulate()
> exit_cause = exit_event.getCause()
>
> if exit_cause == "simpoint starting point found":
> print "Warmed up! Dumping and resetting stats!"
> m5.stats.dump()
> m5.stats.reset()
>
> exit_event = m5.simulate()
> exit_cause = exit_event.getCause()
>
> if exit_cause == "simpoint starting point found":
> print "Done running SimPoint!"
> sys.exit(exit_event.getCode())
>
> print 'Exiting @ tick %i because %s' % (m5.curTick(), exit_cause)
> sys.exit(exit_event.getCode())
>
413a576,578
> if options.take_simpoint_checkpoints != None:
> simpoints, interval_length = parseSimpointAnalysisFile(options, testsys)
>
488c653,655
< if options.take_checkpoints and options.checkpoint_restore:
---
> if (options.take_checkpoints or options.take_simpoint_checkpoints) \
> and options.checkpoint_restore:
>
499a667,675
>
> # Take SimPoint checkpoints
> elif options.take_simpoint_checkpoints != None:
> takeSimpointCheckpoints(simpoints, interval_length, cptdir)
>
> # Restore from SimPoint checkpoints
> elif options.restore_simpoint_checkpoint != None:
> restoreSimpointCheckpoint()
>