summaryrefslogtreecommitdiff
path: root/src/cpu/minor/cpu.hh
diff options
context:
space:
mode:
authorMitch Hayenga <mitch.hayenga@arm.com>2016-07-21 17:19:16 +0100
committerMitch Hayenga <mitch.hayenga@arm.com>2016-07-21 17:19:16 +0100
commitff4009ac005be0347015f8ba5a8e37a3aa930e69 (patch)
treeb80cfa7c70c0e39f54c8c3d78527722cb6658510 /src/cpu/minor/cpu.hh
parent8a476d387c84f037d0ccf3cc20dc88870ab45fec (diff)
downloadgem5-ff4009ac005be0347015f8ba5a8e37a3aa930e69.tar.xz
cpu: Add SMT support to MinorCPU
This patch adds SMT support to the MinorCPU. Currently RoundRobin or Random thread scheduling are supported. Change-Id: I91faf39ff881af5918cca05051829fc6261f20e3
Diffstat (limited to 'src/cpu/minor/cpu.hh')
-rw-r--r--src/cpu/minor/cpu.hh23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/cpu/minor/cpu.hh b/src/cpu/minor/cpu.hh
index dad015e89..4e4762390 100644
--- a/src/cpu/minor/cpu.hh
+++ b/src/cpu/minor/cpu.hh
@@ -50,6 +50,7 @@
#include "cpu/minor/stats.hh"
#include "cpu/base.hh"
#include "cpu/simple_thread.hh"
+#include "enums/ThreadPolicy.hh"
#include "params/MinorCPU.hh"
namespace Minor
@@ -109,6 +110,8 @@ class MinorCPU : public BaseCPU
};
+ /** Thread Scheduling Policy (RoundRobin, Random, etc) */
+ Enums::ThreadPolicy threadPolicy;
protected:
/** Return a reference to the data port. */
MasterPort &getDataPort() override;
@@ -162,6 +165,26 @@ class MinorCPU : public BaseCPU
void activateContext(ThreadID thread_id) override;
void suspendContext(ThreadID thread_id) override;
+ /** Thread scheduling utility functions */
+ std::vector<ThreadID> roundRobinPriority(ThreadID priority)
+ {
+ std::vector<ThreadID> prio_list;
+ for (ThreadID i = 1; i <= numThreads; i++) {
+ prio_list.push_back((priority + i) % numThreads);
+ }
+ return prio_list;
+ }
+
+ std::vector<ThreadID> randomPriority()
+ {
+ std::vector<ThreadID> prio_list;
+ for (ThreadID i = 0; i < numThreads; i++) {
+ prio_list.push_back(i);
+ }
+ std::random_shuffle(prio_list.begin(), prio_list.end());
+ return prio_list;
+ }
+
/** Interface for stages to signal that they have become active after
* a callback or eventq event where the pipeline itself may have
* already been idled. The stage argument should be from the