changeset 7437cc334df1 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=7437cc334df1
description:
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:
src/sim/pseudo_inst.cc | 4 +-
src/sim/sim_events.cc | 58 ++++++++++++++++++++++++++++++++++++++++++++++---
src/sim/sim_events.hh | 23 ++++++++++++++++++-
src/sim/sim_exit.hh | 3 +-
4 files changed, 80 insertions(+), 8 deletions(-)
diffs (166 lines):
diff -r 2f5eec8c1010 -r 7437cc334df1 src/sim/pseudo_inst.cc
--- a/src/sim/pseudo_inst.cc Thu Oct 31 13:41:13 2013 -0500
+++ b/src/sim/pseudo_inst.cc Thu Oct 31 13:41:13 2013 -0500
@@ -347,7 +347,7 @@
{
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 @@
{
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 -r 2f5eec8c1010 -r 7437cc334df1 src/sim/sim_events.cc
--- a/src/sim/sim_events.cc Thu Oct 31 13:41:13 2013 -0500
+++ b/src/sim/sim_events.cc Thu Oct 31 13:41:13 2013 -0500
@@ -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 @@
}
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 §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, serialize);
mainEventQueue.schedule(event, when);
}
diff -r 2f5eec8c1010 -r 7437cc334df1 src/sim/sim_events.hh
--- a/src/sim/sim_events.hh Thu Oct 31 13:41:13 2013 -0500
+++ b/src/sim/sim_events.hh Thu Oct 31 13:41:13 2013 -0500
@@ -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 @@
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 @@
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 -r 2f5eec8c1010 -r 7437cc334df1 src/sim/sim_exit.hh
--- a/src/sim/sim_exit.hh Thu Oct 31 13:41:13 2013 -0500
+++ b/src/sim/sim_exit.hh Thu Oct 31 13:41:13 2013 -0500
@@ -51,6 +51,7 @@
/// 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__
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev