summaryrefslogtreecommitdiff
path: root/src/cpu/o3/lsq.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/cpu/o3/lsq.hh')
-rw-r--r--src/cpu/o3/lsq.hh48
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;
};