Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/42118 )

Change subject: cpu: De-templatize the O3ThreadState.
......................................................................

cpu: De-templatize the O3ThreadState.

Change-Id: Ifa6342abe396e131ae8edcb8111453852cdbefd7
---
M src/cpu/o3/SConscript
M src/cpu/o3/commit.cc
M src/cpu/o3/commit.hh
M src/cpu/o3/cpu.cc
M src/cpu/o3/cpu.hh
M src/cpu/o3/dyn_inst.hh
M src/cpu/o3/thread_context.hh
A src/cpu/o3/thread_state.cc
M src/cpu/o3/thread_state.hh
9 files changed, 92 insertions(+), 62 deletions(-)



diff --git a/src/cpu/o3/SConscript b/src/cpu/o3/SConscript
index 62d01a1..c61c7cf 100755
--- a/src/cpu/o3/SConscript
+++ b/src/cpu/o3/SConscript
@@ -54,6 +54,7 @@
     Source('scoreboard.cc')
     Source('store_set.cc')
     Source('thread_context.cc')
+    Source('thread_state.cc')

     DebugFlag('CommitRate')
     DebugFlag('IEW')
diff --git a/src/cpu/o3/commit.cc b/src/cpu/o3/commit.cc
index ffca6ab..b1c2890 100644
--- a/src/cpu/o3/commit.cc
+++ b/src/cpu/o3/commit.cc
@@ -237,7 +237,7 @@
 }

 void
-DefaultCommit::setThreads(std::vector<Thread *> &threads)
+DefaultCommit::setThreads(std::vector<O3ThreadState *> &threads)
 {
     thread = threads;
 }
diff --git a/src/cpu/o3/commit.hh b/src/cpu/o3/commit.hh
index ccf6e7c..4319ed8 100644
--- a/src/cpu/o3/commit.hh
+++ b/src/cpu/o3/commit.hh
@@ -58,8 +58,7 @@

 struct DerivO3CPUParams;

-template <class>
-struct O3ThreadState;
+class O3ThreadState;

 /**
  * DefaultCommit handles single threaded and SMT commit. Its width is
@@ -86,8 +85,6 @@
 class DefaultCommit
 {
   public:
-    typedef O3ThreadState<O3CPUImpl> Thread;
-
     /** Overall commit status. Used to determine if the CPU can deschedule
      * itself due to a lack of activity.
      */
@@ -136,7 +133,7 @@
     void regProbePoints();

     /** Sets the list of threads. */
-    void setThreads(std::vector<Thread *> &threads);
+    void setThreads(std::vector<O3ThreadState *> &threads);

/** Sets the main time buffer pointer, used for backwards communication. */
     void setTimeBuffer(TimeBuffer<O3Comm::TimeStruct> *tb_ptr);
@@ -351,7 +348,7 @@
     FullO3CPU *cpu;

     /** Vector of all of the threads. */
-    std::vector<Thread *> thread;
+    std::vector<O3ThreadState *> thread;

/** Records that commit has written to the time buffer this cycle. Used for * the CPU to determine if it can deschedule itself if there is no activity.
diff --git a/src/cpu/o3/cpu.cc b/src/cpu/o3/cpu.cc
index 974de29..679d33d 100644
--- a/src/cpu/o3/cpu.cc
+++ b/src/cpu/o3/cpu.cc
@@ -290,24 +290,19 @@
         if (FullSystem) {
             // SMT is not supported in FS mode yet.
             assert(numThreads == 1);
-            thread[tid] = new O3ThreadState<O3CPUImpl>(this, 0, NULL);
+            thread[tid] = new O3ThreadState(this, 0, NULL);
         } else {
             if (tid < params.workload.size()) {
                 DPRINTF(O3CPU, "Workload[%i] process is %#x", tid,
                         thread[tid]);
-                thread[tid] = new O3ThreadState<O3CPUImpl>(this, tid,
+                thread[tid] = new O3ThreadState(this, tid,
                         params.workload[tid]);
-
-                //usedTids[tid] = true;
-                //threadMap[tid] = tid;
             } else {
                 //Allocate Empty thread so M5 can use later
                 //when scheduling threads to CPU
                 Process* dummy_proc = NULL;

-                thread[tid] = new O3ThreadState<O3CPUImpl>(this, tid,
-                        dummy_proc);
-                //usedTids[tid] = false;
+                thread[tid] = new O3ThreadState(this, tid, dummy_proc);
             }
         }

diff --git a/src/cpu/o3/cpu.hh b/src/cpu/o3/cpu.hh
index e1746a8..cc4d516 100644
--- a/src/cpu/o3/cpu.hh
+++ b/src/cpu/o3/cpu.hh
@@ -650,7 +650,7 @@
     System *system;

     /** Pointers to all of the threads in the CPU. */
-    std::vector<O3ThreadState<O3CPUImpl> *> thread;
+    std::vector<O3ThreadState *> thread;

     /** Threads Scheduled to Enter CPU */
     std::list<int> cpuWaitList;
diff --git a/src/cpu/o3/dyn_inst.hh b/src/cpu/o3/dyn_inst.hh
index 252a6b7..41fafba 100644
--- a/src/cpu/o3/dyn_inst.hh
+++ b/src/cpu/o3/dyn_inst.hh
@@ -106,7 +106,7 @@
     BaseCPU *getCpuPtr() { return cpu; }

     /** Pointer to the thread state. */
-    O3ThreadState<O3CPUImpl> *thread = nullptr;
+    O3ThreadState *thread = nullptr;

     /** The kind of fault this instruction has generated. */
     Fault fault = NoFault;
@@ -1014,11 +1014,7 @@
     void setTid(ThreadID tid) { threadNumber = tid; }

     /** Sets the pointer to the thread state. */
-    void
-    setThreadState(O3ThreadState<O3CPUImpl> *state)
-    {
-        thread = state;
-    }
+    void setThreadState(O3ThreadState *state) { thread = state; }

     /** Returns the thread context. */
     ThreadContext *tcBase() const override { return thread->getTC(); }
diff --git a/src/cpu/o3/thread_context.hh b/src/cpu/o3/thread_context.hh
index 245ef62..384635e 100644
--- a/src/cpu/o3/thread_context.hh
+++ b/src/cpu/o3/thread_context.hh
@@ -94,7 +94,7 @@
     }

     /** Pointer to the thread state that this TC corrseponds to. */
-    O3ThreadState<O3CPUImpl> *thread;
+    O3ThreadState *thread;

     /** Returns a pointer to the MMU. */
     BaseMMU *getMMUPtr() override { return cpu->mmu; }
diff --git a/src/cpu/o3/thread_state.cc b/src/cpu/o3/thread_state.cc
new file mode 100644
index 0000000..bbd45c0
--- /dev/null
+++ b/src/cpu/o3/thread_state.cc
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2012, 2019 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.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "cpu/o3/thread_state.hh"
+
+#include "cpu/o3/cpu.hh"
+
+O3ThreadState::O3ThreadState(FullO3CPU *_cpu, int _thread_num,
+        Process *_process) : ThreadState(_cpu, _thread_num, _process),
+    cpu(_cpu), comInstEventQueue("instruction-based event queue")
+{}
+
+void
+O3ThreadState::serialize(CheckpointOut &cp) const
+{
+    ThreadState::serialize(cp);
+    // Use the ThreadContext serialization helper to serialize the
+    // TC.
+    ::serialize(*tc, cp);
+}
+
+void
+O3ThreadState::unserialize(CheckpointIn &cp)
+{
+    // 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);
+    // Use the ThreadContext serialization helper to unserialize
+    // the TC.
+    ::unserialize(*tc, cp);
+    noSquashFromTC = false;
+}
diff --git a/src/cpu/o3/thread_state.hh b/src/cpu/o3/thread_state.hh
index a45f7d8..564ca81 100644
--- a/src/cpu/o3/thread_state.hh
+++ b/src/cpu/o3/thread_state.hh
@@ -41,17 +41,13 @@
 #ifndef __CPU_O3_THREAD_STATE_HH__
 #define __CPU_O3_THREAD_STATE_HH__

-#include "base/callback.hh"
-#include "base/compiler.hh"
-#include "base/output.hh"
+#include <memory>
+
 #include "cpu/thread_context.hh"
 #include "cpu/thread_state.hh"
-#include "sim/full_system.hh"
-#include "sim/sim_exit.hh"

-class Event;
-class FunctionalMemory;
 class Process;
+class FullO3CPU;

 /**
  * Class that has various thread state, such as the status, the
@@ -60,11 +56,8 @@
  * pointer, etc.  It also handles anything related to a specific
  * thread's process, such as syscalls and checking valid addresses.
  */
-template <class Impl>
 struct O3ThreadState : public ThreadState
 {
-    typedef ThreadContext::Status Status;
-
   private:
     /** Pointer to the CPU. */
     FullO3CPU *cpu;
@@ -85,46 +78,23 @@
* lead to successive restarts and forward progress couldn't be made. This
      * variable controls if the squashing will occur.
      */
-    bool noSquashFromTC;
+    bool noSquashFromTC = false;

     /** Whether or not the thread is currently waiting on a trap, and
      * thus able to be externally updated without squashing.
      */
-    bool trapPending;
+    bool trapPending = false;

     /** Pointer to the hardware transactional memory checkpoint. */
     std::unique_ptr<BaseHTMCheckpoint> htmCheckpoint;

-    O3ThreadState(FullO3CPU *_cpu, int _thread_num, Process *_process)
-        : ThreadState(_cpu, _thread_num, _process), cpu(_cpu),
-          comInstEventQueue("instruction-based event queue"),
-          noSquashFromTC(false), trapPending(false), tc(nullptr)
-    {
-    }
+    O3ThreadState(FullO3CPU *_cpu, int _thread_num, Process *_process);

-    void serialize(CheckpointOut &cp) const override
-    {
-        ThreadState::serialize(cp);
-        // Use the ThreadContext serialization helper to serialize the
-        // TC.
-        ::serialize(*tc, cp);
-    }
-
-    void unserialize(CheckpointIn &cp) override
-    {
-        // 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);
-        // Use the ThreadContext serialization helper to unserialize
-        // the TC.
-        ::unserialize(*tc, cp);
-        noSquashFromTC = false;
-    }
+    void serialize(CheckpointOut &cp) const override;
+    void unserialize(CheckpointIn &cp) override;

     /** Pointer to the ThreadContext of this thread. */
-    ThreadContext *tc;
+    ThreadContext *tc = nullptr;

     /** Returns a pointer to the TC of this thread. */
     ThreadContext *getTC() { return tc; }

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/42118
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ifa6342abe396e131ae8edcb8111453852cdbefd7
Gerrit-Change-Number: 42118
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to