diff options
author | Rekai Gonzalez-Alberquilla <rekai.gonzalezalberquilla@arm.com> | 2017-03-01 13:49:08 +0000 |
---|---|---|
committer | Giacomo Gabrielli <giacomo.gabrielli@arm.com> | 2018-12-03 14:23:56 +0000 |
commit | 9af1214ffe48178c0dadfb874fd62bd0ff2e0f31 (patch) | |
tree | 1b4dd7edf77791c81f40f6d919829495eb80db93 /src/cpu/o3/lsq.hh | |
parent | b5cc34d767410e98f54f2955bb274f0f8c3708e4 (diff) | |
download | gem5-9af1214ffe48178c0dadfb874fd62bd0ff2e0f31.tar.xz |
cpu: Change raw pointers to STL Containers
This patch changes two members from being raw pointers to being STL
containers. The reason behind, other than cleanlyness and arguable OO
best practices is that containers have more intronspections capabilities
than naked pointers do, as the size is known.
Using STL containers adds little overhead and eases the automation of
process during debugging (gdb).
Change-Id: I4d9d3eedafa8b5e50ac512ea93b458a4200229f2
Signed-off-by: Giacomo Gabrielli <giacomo.gabrielli@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/13126
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>
Diffstat (limited to 'src/cpu/o3/lsq.hh')
-rw-r--r-- | src/cpu/o3/lsq.hh | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/src/cpu/o3/lsq.hh b/src/cpu/o3/lsq.hh index 175821e69..0c93121e3 100644 --- a/src/cpu/o3/lsq.hh +++ b/src/cpu/o3/lsq.hh @@ -71,9 +71,7 @@ class LSQ { /** Constructs an LSQ with the given parameters. */ LSQ(O3CPU *cpu_ptr, IEW *iew_ptr, DerivO3CPUParams *params); - ~LSQ() { - if (thread) delete [] thread; - } + ~LSQ() { } /** Returns the name of the LSQ. */ std::string name() const; @@ -310,8 +308,45 @@ class LSQ { /** The LSQ policy for SMT mode. */ LSQPolicy lsqPolicy; - /** The LSQ units for individual threads. */ - LSQUnit *thread; + /** Transform a SMT sharing policy string into a LSQPolicy value. */ + static LSQPolicy readLSQPolicy(const std::string& policy) { + std::string policy_ = policy; + std::transform(policy_.begin(), policy_.end(), policy_.begin(), + (int(*)(int)) tolower); + if (policy_ == "dynamic") { + return Dynamic; + } else if (policy_ == "partitioned") { + return Partitioned; + } else if (policy_ == "threshold") { + return Threshold; + } + assert(0 && "Invalid LSQ Sharing Policy.Options Are:{Dynamic," + "Partitioned, Threshold}"); + + // Some compilers complain if there is no return. + return Dynamic; + } + + /** Auxiliary function to calculate per-thread max LSQ allocation limit. + * Depending on a policy, number of entries and possibly number of threads + * and threshold, this function calculates how many resources each thread + * can occupy at most. + */ + static uint32_t maxLSQAllocation(const LSQPolicy& pol, uint32_t entries, + uint32_t numThreads, uint32_t SMTThreshold) { + if (pol == Dynamic) { + return entries; + } else if (pol == Partitioned) { + //@todo:make work if part_amt doesnt divide evenly. + return entries / numThreads; + } else if (pol == Threshold) { + //Divide up by threshold amount + //@todo: Should threads check the max and the total + //amount of the LSQ + return SMTThreshold; + } + return 0; + } /** List of Active Threads in System. */ std::list<ThreadID> *activeThreads; @@ -327,6 +362,9 @@ class LSQ { /** Max SQ Size - Used to Enforce Sharing Policies. */ unsigned maxSQEntries; + /** The LSQ units for individual threads. */ + std::vector<LSQUnit> thread; + /** Number of Threads. */ ThreadID numThreads; }; |