diff options
author | Andreas Sandberg <Andreas.Sandberg@ARM.com> | 2013-01-07 13:05:44 -0500 |
---|---|---|
committer | Andreas Sandberg <Andreas.Sandberg@ARM.com> | 2013-01-07 13:05:44 -0500 |
commit | 4ae02295d59036fa2f9d272ee288e0321bb8257a (patch) | |
tree | be3223b70e1e94585e7c2d50ca29c2a32ae4645b /src/cpu/o3 | |
parent | 6daada2701c7ea361843a7c2a50cb616b56b1519 (diff) | |
download | gem5-4ae02295d59036fa2f9d272ee288e0321bb8257a.tar.xz |
cpu: Unify SimpleCPU and O3 CPU serialization code
The O3 CPU used to copy its thread context to a SimpleThread in order
to do serialization. This was a bit of a hack involving two static
SimpleThread instances and a magic constructor that was only used by
the O3 CPU.
This patch moves the ThreadContext serialization code into two global
procedures that, in addition to the normal serialization parameters,
take a ThreadContext reference as a parameter. This allows us to reuse
the serialization code in all ThreadContext implementations.
Diffstat (limited to 'src/cpu/o3')
-rw-r--r-- | src/cpu/o3/cpu.cc | 26 | ||||
-rwxr-xr-x | src/cpu/o3/thread_context.hh | 5 | ||||
-rwxr-xr-x | src/cpu/o3/thread_context_impl.hh | 16 | ||||
-rw-r--r-- | src/cpu/o3/thread_state.hh | 33 |
4 files changed, 40 insertions, 40 deletions
diff --git a/src/cpu/o3/cpu.cc b/src/cpu/o3/cpu.cc index 0419a6173..2613a8da3 100644 --- a/src/cpu/o3/cpu.cc +++ b/src/cpu/o3/cpu.cc @@ -1097,16 +1097,9 @@ FullO3CPU<Impl>::serialize(std::ostream &os) nameOut(os, csprintf("%s.tickEvent", name())); tickEvent.serialize(os); - // Use SimpleThread's ability to checkpoint to make it easier to - // write out the registers. Also make this static so it doesn't - // get instantiated multiple times (causes a panic in statistics). - static SimpleThread temp; - - ThreadID size = thread.size(); - for (ThreadID i = 0; i < size; i++) { + for (ThreadID i = 0; i < thread.size(); i++) { nameOut(os, csprintf("%s.xc.%i", name(), i)); - temp.copyTC(thread[i]->getTC()); - temp.serialize(os); + thread[i]->serialize(os); } } @@ -1119,16 +1112,11 @@ FullO3CPU<Impl>::unserialize(Checkpoint *cp, const std::string §ion) BaseCPU::unserialize(cp, section); tickEvent.unserialize(cp, csprintf("%s.tickEvent", section)); - // Use SimpleThread's ability to checkpoint to make it easier to - // read in the registers. Also make this static so it doesn't - // get instantiated multiple times (causes a panic in statistics). - static SimpleThread temp; - - ThreadID size = thread.size(); - for (ThreadID i = 0; i < size; i++) { - temp.copyTC(thread[i]->getTC()); - temp.unserialize(cp, csprintf("%s.xc.%i", section, i)); - thread[i]->getTC()->copyArchRegs(temp.getTC()); + 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); } } diff --git a/src/cpu/o3/thread_context.hh b/src/cpu/o3/thread_context.hh index 1efcfff9c..4201878af 100755 --- a/src/cpu/o3/thread_context.hh +++ b/src/cpu/o3/thread_context.hh @@ -153,11 +153,6 @@ class O3ThreadContext : public ThreadContext /** Registers statistics associated with this TC. */ virtual void regStats(const std::string &name); - /** Serializes state. */ - virtual void serialize(std::ostream &os); - /** Unserializes state. */ - virtual void unserialize(Checkpoint *cp, const std::string §ion); - /** Reads the last tick that this thread was activated on. */ virtual Tick readLastActivate(); /** Reads the last tick that this thread was suspended on. */ diff --git a/src/cpu/o3/thread_context_impl.hh b/src/cpu/o3/thread_context_impl.hh index 4ab793538..2de6dbc1b 100755 --- a/src/cpu/o3/thread_context_impl.hh +++ b/src/cpu/o3/thread_context_impl.hh @@ -159,22 +159,6 @@ O3ThreadContext<Impl>::regStats(const std::string &name) } template <class Impl> -void -O3ThreadContext<Impl>::serialize(std::ostream &os) -{ - if (FullSystem && thread->kernelStats) - thread->kernelStats->serialize(os); -} - -template <class Impl> -void -O3ThreadContext<Impl>::unserialize(Checkpoint *cp, const std::string §ion) -{ - if (FullSystem && thread->kernelStats) - thread->kernelStats->unserialize(cp, section); -} - -template <class Impl> Tick O3ThreadContext<Impl>::readLastActivate() { diff --git a/src/cpu/o3/thread_state.hh b/src/cpu/o3/thread_state.hh index 96ccfc95c..406c798f0 100644 --- a/src/cpu/o3/thread_state.hh +++ b/src/cpu/o3/thread_state.hh @@ -1,4 +1,16 @@ /* + * Copyright (c) 2012 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) 2006 The Regents of The University of Michigan * All rights reserved. * @@ -99,6 +111,27 @@ struct O3ThreadState : public ThreadState { profilePC = 3; } + void serialize(std::ostream &os) + { + ThreadState::serialize(os); + // Use the ThreadContext serialization helper to serialize the + // TC. + ::serialize(*tc, os); + } + + void unserialize(Checkpoint *cp, const std::string §ion) + { + // Prevent squashing - we don't have any instructions in + // flight that we need to squash since we just instantiated a + // clean system. + noSquashFromTC = true; + ThreadState::unserialize(cp, section); + // Use the ThreadContext serialization helper to unserialize + // the TC. + ::unserialize(*tc, cp, section); + noSquashFromTC = false; + } + /** Pointer to the ThreadContext of this thread. */ ThreadContext *tc; |