summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Hestness <jthestness@gmail.com>2013-09-11 15:34:50 -0500
committerJoel Hestness <jthestness@gmail.com>2013-09-11 15:34:50 -0500
commita1f9081babaf67b5e98d6ad35a6b1f6130e12fd7 (patch)
tree1c93aa0980ee7b6287839835181b0e38c47903c5
parent073b27c257da7118e3b17a0dc77d9da1ac863621 (diff)
downloadgem5-a1f9081babaf67b5e98d6ad35a6b1f6130e12fd7.tar.xz
cpu: Dynamically instantiate O3 CPU LSQUnits
Previously, the LSQ would instantiate MaxThreads LSQUnits in the body of it's object, but it would only initialize numThreads LSQUnits as specified by the user. This had the effect of leaving some LSQUnits uninitialized when the number of threads was less than MaxThreads, and when adding statistics to the LSQUnit that must be initialized, this caused the stats initialization check to fail. By dynamically instantiating LSQUnits, they are all initialized and this avoids uninitialized LSQUnits from floating around during runtime.
-rw-r--r--src/cpu/o3/lsq.hh5
-rw-r--r--src/cpu/o3/lsq_impl.hh3
2 files changed, 7 insertions, 1 deletions
diff --git a/src/cpu/o3/lsq.hh b/src/cpu/o3/lsq.hh
index 6857a6aca..36ad75aed 100644
--- a/src/cpu/o3/lsq.hh
+++ b/src/cpu/o3/lsq.hh
@@ -70,6 +70,9 @@ class LSQ {
/** Constructs an LSQ with the given parameters. */
LSQ(O3CPU *cpu_ptr, IEW *iew_ptr, DerivO3CPUParams *params);
+ ~LSQ() {
+ if (thread) delete [] thread;
+ }
/** Returns the name of the LSQ. */
std::string name() const;
@@ -316,7 +319,7 @@ class LSQ {
LSQPolicy lsqPolicy;
/** The LSQ units for individual threads. */
- LSQUnit thread[Impl::MaxThreads];
+ LSQUnit *thread;
/** List of Active Threads in System. */
std::list<ThreadID> *activeThreads;
diff --git a/src/cpu/o3/lsq_impl.hh b/src/cpu/o3/lsq_impl.hh
index c796d7078..70db92714 100644
--- a/src/cpu/o3/lsq_impl.hh
+++ b/src/cpu/o3/lsq_impl.hh
@@ -61,6 +61,8 @@ LSQ<Impl>::LSQ(O3CPU *cpu_ptr, IEW *iew_ptr, DerivO3CPUParams *params)
numThreads(params->numThreads),
retryTid(-1)
{
+ assert(numThreads > 0 && numThreads <= Impl::MaxThreads);
+
//**********************************************/
//************ Handle SMT Parameters ***********/
//**********************************************/
@@ -109,6 +111,7 @@ LSQ<Impl>::LSQ(O3CPU *cpu_ptr, IEW *iew_ptr, DerivO3CPUParams *params)
}
//Initialize LSQs
+ thread = new LSQUnit[numThreads];
for (ThreadID tid = 0; tid < numThreads; tid++) {
thread[tid].init(cpu, iew_ptr, params, this,
maxLQEntries, maxSQEntries, tid);