diff options
author | Dam Sunwoo <dam.sunwoo@arm.com> | 2013-10-31 13:41:13 -0500 |
---|---|---|
committer | Dam Sunwoo <dam.sunwoo@arm.com> | 2013-10-31 13:41:13 -0500 |
commit | 6b4543184ea4203f44210f8061b888d8d683979a (patch) | |
tree | d9cba5515acc22363ffd7261e482e36e2f783d04 /src | |
parent | 19c2a606fadbf04d1839eec738bbabccb218c7f3 (diff) | |
download | gem5-6b4543184ea4203f44210f8061b888d8d683979a.tar.xz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/sim/pseudo_inst.cc | 4 | ||||
-rw-r--r-- | src/sim/sim_events.cc | 58 | ||||
-rw-r--r-- | src/sim/sim_events.hh | 23 | ||||
-rw-r--r-- | src/sim/sim_exit.hh | 3 |
4 files changed, 80 insertions, 8 deletions
diff --git a/src/sim/pseudo_inst.cc b/src/sim/pseudo_inst.cc index f4666a0cd..e85e3d19a 100644 --- a/src/sim/pseudo_inst.cc +++ b/src/sim/pseudo_inst.cc @@ -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 diff --git a/src/sim/sim_events.cc b/src/sim/sim_events.cc index 0ae7e573e..5380ddd83 100644 --- a/src/sim/sim_events.cc +++ b/src/sim/sim_events.cc @@ -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) +{ + paramOut(os, "type", string("SimLoopExitEvent")); + Event::serialize(os); + + SERIALIZE_SCALAR(cause); + SERIALIZE_SCALAR(code); + SERIALIZE_SCALAR(repeat); +} + +void +SimLoopExitEvent::unserialize(Checkpoint *cp, const string §ion) +{ + Event::unserialize(cp, section); + + UNSERIALIZE_SCALAR(cause); + UNSERIALIZE_SCALAR(code); + UNSERIALIZE_SCALAR(repeat); +} + +Serializable * +SimLoopExitEvent::createForUnserialize(Checkpoint *cp, const string §ion) +{ + 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); + Event *event = new SimLoopExitEvent(message, exit_code, repeat, serialize); mainEventQueue.schedule(event, when); } diff --git a/src/sim/sim_events.hh b/src/sim/sim_events.hh index 6ea361a05..4abfb317c 100644 --- a/src/sim/sim_events.hh +++ b/src/sim/sim_events.hh @@ -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 §ion); + static Serializable *createForUnserialize(Checkpoint *cp, + const std::string §ion); }; class CountedDrainEvent : public Event diff --git a/src/sim/sim_exit.hh b/src/sim/sim_exit.hh index da71cc912..ef73d822d 100644 --- a/src/sim/sim_exit.hh +++ b/src/sim/sim_exit.hh @@ -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__ |