# HG changeset patch
# User Korey Sewell <[email protected]>
# Date 1254427253 14400
# Node ID 49442d9f1ae850af8d1b1ceb304344cd68b43ca1
# Parent 8147d7518509ec83ceb5fb27f95584a409572c7d
inorder: ready thread wakeup
allow a thread to wakeup and be activated after
it has been in suspended state and another
thread is switched out. Need to give
pipeline stages a "activateThread" function
so that can get to their suspended instruction
when the time is right.
diff --git a/src/cpu/inorder/cpu.cc b/src/cpu/inorder/cpu.cc
--- a/src/cpu/inorder/cpu.cc
+++ b/src/cpu/inorder/cpu.cc
@@ -655,6 +655,8 @@
DPRINTF(InOrderCPU,
"Attempting to activate new thread, but No Ready Threads to"
"activate.\n");
+ DPRINTF(InOrderCPU,
+ "Unable to switch to next active thread.\n");
}
}
@@ -677,7 +679,7 @@
"Ignoring activation of [tid:%i], since [tid:%i] is "
"already running.\n", tid, activeThreadId());
- DPRINTF(InOrderCPU,"Placing [tid:%i] ready threads list\n",
+ DPRINTF(InOrderCPU,"Placing [tid:%i] on ready threads list\n",
tid);
readyThreads.push_back(tid);
@@ -687,11 +689,21 @@
"Adding [tid:%i] to active threads list.\n", tid);
activeThreads.push_back(tid);
+ activateThreadInPipeline(tid);
+
wakeCPU();
}
}
void
+InOrderCPU::activateThreadInPipeline(ThreadID tid)
+{
+ for (int stNum=0; stNum < NumStages; stNum++) {
+ pipelineStage[stNum]->activateThread(tid);
+ }
+}
+
+void
InOrderCPU::deactivateContext(ThreadID tid, int delay)
{
DPRINTF(InOrderCPU,"[tid:%i]: Deactivating ...\n", tid);
diff --git a/src/cpu/inorder/cpu.hh b/src/cpu/inorder/cpu.hh
--- a/src/cpu/inorder/cpu.hh
+++ b/src/cpu/inorder/cpu.hh
@@ -341,7 +341,8 @@
/** Add Thread to Active Threads List. */
void activateContext(ThreadID tid, int delay = 0);
void activateThread(ThreadID tid);
-
+ void activateThreadInPipeline(ThreadID tid);
+
/** Add Thread to Active Threads List. */
void activateNextReadyContext(int delay = 0);
void activateNextReadyThread();
diff --git a/src/cpu/inorder/pipeline_stage.cc
b/src/cpu/inorder/pipeline_stage.cc
--- a/src/cpu/inorder/pipeline_stage.cc
+++ b/src/cpu/inorder/pipeline_stage.cc
@@ -541,6 +541,28 @@
}
}
+void
+PipelineStage::activateThread(ThreadID tid)
+{
+ if (cpu->threadModel == InOrderCPU::SwitchOnCacheMiss) {
+ if (!switchedOutValid[tid]) {
+ DPRINTF(InOrderStage, "[tid:%i] No instruction available in "
+ "switch out buffer.\n", tid);
+ } else {
+ DynInstPtr inst = switchedOutBuffer[tid];
+
+ DPRINTF(InOrderStage,"[tid:%i]: Re-Inserting [sn:%lli] PC:%#x into
stage skidBuffer %i\n",
+ tid, inst->seqNum, inst->readPC(), inst->threadNumber);
+
+ skidBuffer[tid].push(inst);
+
+ switchedOutBuffer[tid] = NULL;
+
+ switchedOutValid[tid] = false;
+ }
+ }
+
+}
void
@@ -926,6 +948,11 @@
if (req->isMemStall() && cpu->threadModel ==
InOrderCPU::SwitchOnCacheMiss) {
// Save Stalling Instruction
+ DPRINTF(ThreadModel, "[tid:%i] Detected cache miss.\n",
tid);
+
+ DPRINTF(InOrderStage, "Inserting [tid:%i][sn:%i] into
switch out buffer.\n",
+ tid, inst->seqNum);
+
switchedOutBuffer[tid] = inst;
switchedOutValid[tid] = true;
@@ -937,9 +964,12 @@
// Switch On Cache Miss
//=====================
// Suspend Thread at end of cycle
+ DPRINTF(ThreadModel, "Suspending [tid:%i] due to cache
miss.\n", tid);
cpu->suspendContext(tid);
// Activate Next Ready Thread at end of cycle
+ DPRINTF(ThreadModel, "Attempting to activate next ready
thread due to"
+ " cache miss.\n");
cpu->activateNextReadyContext();
}
diff --git a/src/cpu/inorder/pipeline_stage.hh
b/src/cpu/inorder/pipeline_stage.hh
--- a/src/cpu/inorder/pipeline_stage.hh
+++ b/src/cpu/inorder/pipeline_stage.hh
@@ -235,6 +235,8 @@
public:
+ virtual void activateThread(ThreadID tid);
+
/** Squashes if there is a PC-relative branch that was predicted
* incorrectly. Sends squash information back to fetch.
*/
diff --git a/src/cpu/inorder/resources/cache_unit.cc
b/src/cpu/inorder/resources/cache_unit.cc
--- a/src/cpu/inorder/resources/cache_unit.cc
+++ b/src/cpu/inorder/resources/cache_unit.cc
@@ -704,9 +704,12 @@
if (cache_req->isMemStall() &&
cpu->threadModel == InOrderCPU::SwitchOnCacheMiss) {
- DPRINTF(InOrderCachePort, "[tid:%u] Waking up from Cache Miss.\n");
+ DPRINTF(InOrderCachePort, "[tid:%u] Waking up from Cache Miss.\n",
tid);
cpu->activateContext(tid);
+
+ DPRINTF(ThreadModel, "Activating [tid:%i] after return from cache"
+ "miss.\n", tid);
}
// Wake up the CPU (if it went to sleep and was waiting on this
_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev