+ if TmpClass.require_caches() and \
+ not options.caches and not options.ruby:
+ fatal("%s must be used with caches" % options.cpu_type)
+
+ if options.checkpoint_restore != None:
+ if options.restore_with_cpu != options.cpu_type:
+ CPUClass = TmpClass
+ TmpClass, test_mem_mode = getCPUClass(options.restore_with_cpu)
+ elif options.fast_forward:
+ CPUClass = TmpClass
+ TmpClass = AtomicSimpleCPU
+ test_mem_mode = 'atomic'
+
+ return (TmpClass, test_mem_mode, CPUClass)
+
+def setWorkCountOptions(system, options):
+ if options.work_item_id != None:
+ system.work_item_id = options.work_item_id
+ if options.work_begin_cpu_id_exit != None:
+ system.work_begin_cpu_id_exit = options.work_begin_cpu_id_exit
+ if options.work_end_exit_count != None:
+ system.work_end_exit_count = options.work_end_exit_count
+ if options.work_end_checkpoint_count != None:
+ system.work_end_ckpt_count = options.work_end_checkpoint_count
+ if options.work_begin_exit_count != None:
+ system.work_begin_exit_count = options.work_begin_exit_count
+ if options.work_begin_checkpoint_count != None:
+ system.work_begin_ckpt_count = options.work_begin_checkpoint_count
+ if options.work_cpus_checkpoint_count != None:
+ system.work_cpus_ckpt_count = options.work_cpus_checkpoint_count
+
+def findCptDir(options, maxtick, cptdir, testsys):
+ """Figures out the directory from which the checkpointed state is read.
+
+ There are two different ways in which the directories holding checkpoints
+ can be named --
+ 1. cpt.<benchmark name>.<instruction count when the checkpoint was taken>
+ 2. cpt.<some number, usually the tick value when the checkpoint was taken>
+
+ This function parses through the options to figure out which one of the
+ above should be used for selecting the checkpoint, and then figures out
+ the appropriate directory.
+
+ It also sets the value of the maximum tick value till which the simulation
+ will run.
+ """
+
+ from os.path import isdir, exists
+ from os import listdir
+ import re
+
+ if not isdir(cptdir):
+ fatal("checkpoint dir %s does not exist!", cptdir)
+
+ if options.at_instruction or options.simpoint:
+ inst = options.checkpoint_restore
+ if options.simpoint:
+ # assume workload 0 has the simpoint
+ if testsys.cpu[0].workload[0].simpoint == 0:
+ fatal('Unable to find simpoint')
+ inst += int(testsys.cpu[0].workload[0].simpoint)
+
+ checkpoint_dir = joinpath(cptdir, "cpt.%s.%s" % (options.bench, inst))
+ if not exists(checkpoint_dir):
+ fatal("Unable to find checkpoint directory %s", checkpoint_dir)
+ else:
+ dirs = listdir(cptdir)
+ expr = re.compile('cpt\.([0-9]*)')
+ cpts = []
+ for dir in dirs:
+ match = expr.match(dir)
+ if match:
+ cpts.append(match.group(1))
+
+ cpts.sort(lambda a,b: cmp(long(a), long(b)))
+
+ cpt_num = options.checkpoint_restore
+ if cpt_num > len(cpts):
+ fatal('Checkpoint %d not found', cpt_num)
+
+ maxtick = maxtick - int(cpts[cpt_num - 1])
+ checkpoint_dir = joinpath(cptdir, "cpt.%s" % cpts[cpt_num - 1])