diff options
author | Andreas Sandberg <Andreas.Sandberg@ARM.com> | 2013-01-07 13:05:52 -0500 |
---|---|---|
committer | Andreas Sandberg <Andreas.Sandberg@ARM.com> | 2013-01-07 13:05:52 -0500 |
commit | 009970f59b86eac6c9a35eeb175dd9e3a3079d13 (patch) | |
tree | 03119f68fd1e03ff753954b63722b916b39f6737 /src/cpu/o3 | |
parent | 5fb00e1df6b2b7d9db472d0c25765263ed1b839f (diff) | |
download | gem5-009970f59b86eac6c9a35eeb175dd9e3a3079d13.tar.xz |
cpu: Unify the serialization code for all of the CPU models
Cleanup the serialization code for the simple CPUs and the O3 CPU. The
CPU-specific code has been replaced with a (un)serializeThread that
serializes the thread state / context of a specific thread. Assuming
that the thread state class uses the CPU-specific thread state uses
the base thread state serialization code, this allows us to restore a
checkpoint with any of the CPU models.
Diffstat (limited to 'src/cpu/o3')
-rw-r--r-- | src/cpu/o3/cpu.cc | 28 | ||||
-rw-r--r-- | src/cpu/o3/cpu.hh | 7 |
2 files changed, 8 insertions, 27 deletions
diff --git a/src/cpu/o3/cpu.cc b/src/cpu/o3/cpu.cc index cb17581e5..18c536090 100644 --- a/src/cpu/o3/cpu.cc +++ b/src/cpu/o3/cpu.cc @@ -1094,35 +1094,17 @@ FullO3CPU<Impl>::syscall(int64_t callnum, ThreadID tid) template <class Impl> void -FullO3CPU<Impl>::serialize(std::ostream &os) +FullO3CPU<Impl>::serializeThread(std::ostream &os, ThreadID tid) { - Drainable::State so_state(getDrainState()); - SERIALIZE_ENUM(so_state); - BaseCPU::serialize(os); - nameOut(os, csprintf("%s.tickEvent", name())); - tickEvent.serialize(os); - - for (ThreadID i = 0; i < thread.size(); i++) { - nameOut(os, csprintf("%s.xc.%i", name(), i)); - thread[i]->serialize(os); - } + thread[tid]->serialize(os); } template <class Impl> void -FullO3CPU<Impl>::unserialize(Checkpoint *cp, const std::string §ion) +FullO3CPU<Impl>::unserializeThread(Checkpoint *cp, const std::string §ion, + ThreadID tid) { - Drainable::State so_state; - UNSERIALIZE_ENUM(so_state); - BaseCPU::unserialize(cp, section); - tickEvent.unserialize(cp, csprintf("%s.tickEvent", section)); - - for (ThreadID i = 0; i < thread.size(); i++) { - thread[i]->unserialize(cp, - csprintf("%s.xc.%i", section, i)); - if (thread[i]->status() == ThreadContext::Active) - activateThread(i); - } + thread[tid]->unserialize(cp, section); } template <class Impl> diff --git a/src/cpu/o3/cpu.hh b/src/cpu/o3/cpu.hh index 24c4b46a8..5dd0e222d 100644 --- a/src/cpu/o3/cpu.hh +++ b/src/cpu/o3/cpu.hh @@ -446,11 +446,10 @@ class FullO3CPU : public BaseO3CPU /** Is the CPU draining? */ bool isDraining() const { return getDrainState() == Drainable::Draining; } - /** Serialize state. */ - virtual void serialize(std::ostream &os); + void serializeThread(std::ostream &os, ThreadID tid); - /** Unserialize from a checkpoint. */ - virtual void unserialize(Checkpoint *cp, const std::string §ion); + void unserializeThread(Checkpoint *cp, const std::string §ion, + ThreadID tid); public: /** Executes a syscall. |