simplify maxtick parsing in both the python and the c++.

configs/common/Simulation.py:
    simplify maxtick code a little bit - instead of checking for -1, just set it at MaxTick.
src/python/m5/__init__.py:
    make a new m5 param called MaxTick.
src/sim/host.hh:
    fix the M5 def. of MaxTick
src/sim/main.cc:
    Simplify the MaxTick/num_cycles parsing within main.cc

--HG--
extra : convert_revision : f800addfbc1323591c2e05b892276b439b671668
This commit is contained in:
Lisa Hsu 2006-11-08 15:05:23 -05:00
parent 5a46f336a1
commit 64c0d82dec
4 changed files with 11 additions and 16 deletions

View file

@ -65,7 +65,7 @@ def run(options, root, testsys, cpu_class):
print "simulating for: ", simtime print "simulating for: ", simtime
maxtick = simtime maxtick = simtime
else: else:
maxtick = -1 maxtick = m5.MaxTick
if options.checkpoint_dir: if options.checkpoint_dir:
cptdir = options.checkpoint_dir cptdir = options.checkpoint_dir
@ -191,7 +191,7 @@ def run(options, root, testsys, cpu_class):
sim_ticks = when sim_ticks = when
exit_cause = "maximum %d checkpoints dropped" % max_checkpoints exit_cause = "maximum %d checkpoints dropped" % max_checkpoints
while num_checkpoints < max_checkpoints: while num_checkpoints < max_checkpoints:
if (sim_ticks + period) > maxtick and maxtick != -1: if (sim_ticks + period) > maxtick:
exit_event = m5.simulate(maxtick - sim_ticks) exit_event = m5.simulate(maxtick - sim_ticks)
exit_cause = exit_event.getCause() exit_cause = exit_event.getCause()
break break
@ -214,11 +214,7 @@ def run(options, root, testsys, cpu_class):
exit_cause = "maximum %d checkpoints dropped" % max_checkpoints exit_cause = "maximum %d checkpoints dropped" % max_checkpoints
break break
if maxtick == -1: exit_event = m5.simulate(maxtick - m5.curTick())
exit_event = m5.simulate(maxtick)
else:
exit_event = m5.simulate(maxtick - m5.curTick())
exit_cause = exit_event.getCause() exit_cause = exit_event.getCause()
if exit_cause == '': if exit_cause == '':

View file

@ -39,6 +39,9 @@ from cc_main import simulate, SimLoopExitEvent
# import the m5 compile options # import the m5 compile options
import defines import defines
# define a MaxTick parameter
MaxTick = 2**63 - 1
# define this here so we can use it right away if necessary # define this here so we can use it right away if necessary
def panic(string): def panic(string):
print >>sys.stderr, 'panic:', string print >>sys.stderr, 'panic:', string

View file

@ -56,7 +56,7 @@ typedef int64_t Counter;
*/ */
typedef int64_t Tick; typedef int64_t Tick;
const Tick MaxTick = (1LL << 62); const Tick MaxTick = (1LL << 63) - 1;
/** /**
* Address type * Address type

View file

@ -309,18 +309,14 @@ finalInit()
* @return The SimLoopExitEvent that caused the loop to exit. * @return The SimLoopExitEvent that caused the loop to exit.
*/ */
SimLoopExitEvent * SimLoopExitEvent *
simulate(Tick num_cycles = -1) simulate(Tick num_cycles = MaxTick)
{ {
warn("Entering event queue @ %d. Starting simulation...\n", curTick); warn("Entering event queue @ %d. Starting simulation...\n", curTick);
// Fix up num_cycles. Special default value -1 means simulate if (num_cycles < 0)
// "forever"... schedule event at MaxTick just to be safe.
// Otherwise it's a delta for additional cycles to simulate past
// curTick, and thus must be non-negative.
if (num_cycles == -1)
num_cycles = MaxTick;
else if (num_cycles < 0)
fatal("simulate: num_cycles must be >= 0 (was %d)\n", num_cycles); fatal("simulate: num_cycles must be >= 0 (was %d)\n", num_cycles);
else if (curTick + num_cycles < 0) //Overflow
num_cycles = MaxTick;
else else
num_cycles = curTick + num_cycles; num_cycles = curTick + num_cycles;