sim: added option to serialize SimLoopExitEvent

SimLoopExitEvents weren't serialized by default. Some benchmarks
utilize a delayed m5 exit pseudo op call to terminate the simulation
and this event was lost when resuming from a checkpoint generated
after the pseudo op call. This patch adds the capability to serialize
the SimLoopExitEvents and enable serialization for m5_exit and m5_fail
pseudo ops by default. Does not affect other generic
SimLoopExitEvents.
This commit is contained in:
Dam Sunwoo 2013-10-31 13:41:13 -05:00
parent 19c2a606fa
commit 6b4543184e
4 changed files with 80 additions and 8 deletions

View file

@ -347,7 +347,7 @@ m5exit(ThreadContext *tc, Tick delay)
{
DPRINTF(PseudoInst, "PseudoInst::m5exit(%i)\n", delay);
Tick when = curTick() + delay * SimClock::Int::ns;
exitSimLoop("m5_exit instruction encountered", 0, when);
exitSimLoop("m5_exit instruction encountered", 0, when, 0, true);
}
void
@ -355,7 +355,7 @@ m5fail(ThreadContext *tc, Tick delay, uint64_t code)
{
DPRINTF(PseudoInst, "PseudoInst::m5fail(%i, %i)\n", delay, code);
Tick when = curTick() + delay * SimClock::Int::ns;
exitSimLoop("m5_fail instruction encountered", code, when);
exitSimLoop("m5_fail instruction encountered", code, when, 0, true);
}
void

View file

@ -1,4 +1,16 @@
/*
* Copyright (c) 2013 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
* not be construed as granting a license to any other intellectual
* property including but not limited to intellectual property relating
* to a hardware implementation of the functionality of the software
* licensed hereunder. You may use the software subject to the license
* terms below provided that you ensure that this notice is replicated
* unmodified and in its entirety in all distributions of the software,
* modified or unmodified, in source code or in binary form.
*
* Copyright (c) 2002-2005 The Regents of The University of Michigan
* All rights reserved.
*
@ -39,8 +51,16 @@
using namespace std;
SimLoopExitEvent::SimLoopExitEvent(const std::string &_cause, int c, Tick r)
: Event(Sim_Exit_Pri, IsExitEvent), cause(_cause), code(c), repeat(r)
SimLoopExitEvent::SimLoopExitEvent()
: Event(Sim_Exit_Pri, IsExitEvent | AutoSerialize),
cause(""), code(0), repeat(0)
{
}
SimLoopExitEvent::SimLoopExitEvent(const std::string &_cause, int c, Tick r,
bool serialize)
: Event(Sim_Exit_Pri, IsExitEvent | (serialize ? AutoSerialize : 0)),
cause(_cause), code(c), repeat(r)
{
}
@ -77,9 +97,39 @@ SimLoopExitEvent::description() const
}
void
exitSimLoop(const std::string &message, int exit_code, Tick when, Tick repeat)
SimLoopExitEvent::serialize(ostream &os)
{
Event *event = new SimLoopExitEvent(message, exit_code, repeat);
paramOut(os, "type", string("SimLoopExitEvent"));
Event::serialize(os);
SERIALIZE_SCALAR(cause);
SERIALIZE_SCALAR(code);
SERIALIZE_SCALAR(repeat);
}
void
SimLoopExitEvent::unserialize(Checkpoint *cp, const string &section)
{
Event::unserialize(cp, section);
UNSERIALIZE_SCALAR(cause);
UNSERIALIZE_SCALAR(code);
UNSERIALIZE_SCALAR(repeat);
}
Serializable *
SimLoopExitEvent::createForUnserialize(Checkpoint *cp, const string &section)
{
return new SimLoopExitEvent();
}
REGISTER_SERIALIZEABLE("SimLoopExitEvent", SimLoopExitEvent)
void
exitSimLoop(const std::string &message, int exit_code, Tick when, Tick repeat,
bool serialize)
{
Event *event = new SimLoopExitEvent(message, exit_code, repeat, serialize);
mainEventQueue.schedule(event, when);
}

View file

@ -1,4 +1,16 @@
/*
* Copyright (c) 2013 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
* not be construed as granting a license to any other intellectual
* property including but not limited to intellectual property relating
* to a hardware implementation of the functionality of the software
* licensed hereunder. You may use the software subject to the license
* terms below provided that you ensure that this notice is replicated
* unmodified and in its entirety in all distributions of the software,
* modified or unmodified, in source code or in binary form.
*
* Copyright (c) 2002-2005 The Regents of The University of Michigan
* All rights reserved.
*
@ -32,6 +44,7 @@
#define __SIM_SIM_EVENTS_HH__
#include "sim/eventq.hh"
#include "sim/serialize.hh"
//
// Event to terminate simulation at a particular cycle/instruction
@ -45,7 +58,10 @@ class SimLoopExitEvent : public Event
Tick repeat;
public:
SimLoopExitEvent(const std::string &_cause, int c, Tick repeat = 0);
// non-scheduling version for createForUnserialize()
SimLoopExitEvent();
SimLoopExitEvent(const std::string &_cause, int c, Tick repeat = 0,
bool serialize = false);
std::string getCause() { return cause; }
int getCode() { return code; }
@ -53,6 +69,11 @@ class SimLoopExitEvent : public Event
void process(); // process event
virtual const char *description() const;
virtual void serialize(std::ostream &os);
virtual void unserialize(Checkpoint *cp, const std::string &section);
static Serializable *createForUnserialize(Checkpoint *cp,
const std::string &section);
};
class CountedDrainEvent : public Event

View file

@ -51,6 +51,7 @@ void registerExitCallback(Callback *);
/// and exit_code parameters are saved in the SimLoopExitEvent to
/// indicate why the exit occurred.
void exitSimLoop(const std::string &message, int exit_code = 0,
Tick when = curTick(), Tick repeat = 0);
Tick when = curTick(), Tick repeat = 0,
bool serialize = false);
#endif // __SIM_EXIT_HH__