summaryrefslogtreecommitdiff
path: root/src/cpu/inorder/resource_pool.cc
diff options
context:
space:
mode:
authorKorey Sewell <ksewell@umich.edu>2010-01-31 18:26:13 -0500
committerKorey Sewell <ksewell@umich.edu>2010-01-31 18:26:13 -0500
commiteac5eac67ae8076e934d78063a24eeef08f25413 (patch)
treea782cc748f191af1b5ddf3027913067599019d02 /src/cpu/inorder/resource_pool.cc
parentd8e0935af2805bc2c4bdfbab7de2c63f7fde46f7 (diff)
downloadgem5-eac5eac67ae8076e934d78063a24eeef08f25413.tar.xz
inorder: squash on memory stall
add code to recognize memory stalls in resources and the pipeline as well as squash a thread if there is a stall and we are in the switch on cache miss model
Diffstat (limited to 'src/cpu/inorder/resource_pool.cc')
-rw-r--r--src/cpu/inorder/resource_pool.cc185
1 files changed, 124 insertions, 61 deletions
diff --git a/src/cpu/inorder/resource_pool.cc b/src/cpu/inorder/resource_pool.cc
index 0d78c232b..8822715c7 100644
--- a/src/cpu/inorder/resource_pool.cc
+++ b/src/cpu/inorder/resource_pool.cc
@@ -41,45 +41,62 @@ using namespace ThePipeline;
ResourcePool::ResourcePool(InOrderCPU *_cpu, ThePipeline::Params *params)
: cpu(_cpu)
{
- //@todo: use this function to instantiate the resources in resource pool. This will help in the
- //auto-generation of this pipeline model.
+ //@todo: use this function to instantiate the resources in resource pool.
+ //This will help in the auto-generation of this pipeline model.
//ThePipeline::addResources(resources, memObjects);
// Declare Resource Objects
// name - id - bandwidth - latency - CPU - Parameters
// --------------------------------------------------
- resources.push_back(new FetchSeqUnit("Fetch-Seq-Unit", FetchSeq, StageWidth * 2, 0, _cpu, params));
+ resources.push_back(new FetchSeqUnit("Fetch-Seq-Unit", FetchSeq,
+ StageWidth * 2, 0, _cpu, params));
memObjects.push_back(ICache);
- resources.push_back(new CacheUnit("icache_port", ICache, StageWidth * MaxThreads, 0, _cpu, params));
+ resources.push_back(new CacheUnit("icache_port", ICache,
+ StageWidth * MaxThreads, 0, _cpu,
+ params));
- resources.push_back(new DecodeUnit("Decode-Unit", Decode, StageWidth, 0, _cpu, params));
+ resources.push_back(new DecodeUnit("Decode-Unit", Decode,
+ StageWidth, 0, _cpu, params));
- resources.push_back(new BranchPredictor("Branch-Predictor", BPred, StageWidth, 0, _cpu, params));
+ resources.push_back(new BranchPredictor("Branch-Predictor", BPred,
+ StageWidth, 0, _cpu, params));
- resources.push_back(new InstBuffer("Fetch-Buffer-T0", FetchBuff, 4, 0, _cpu, params));
+ resources.push_back(new InstBuffer("Fetch-Buffer-T0", FetchBuff, 4,
+ 0, _cpu, params));
- resources.push_back(new UseDefUnit("RegFile-Manager", RegManager, StageWidth * MaxThreads, 0, _cpu, params));
+ resources.push_back(new UseDefUnit("RegFile-Manager", RegManager,
+ StageWidth * MaxThreads, 0, _cpu,
+ params));
- resources.push_back(new AGENUnit("AGEN-Unit", AGEN, StageWidth, 0, _cpu, params));
+ resources.push_back(new AGENUnit("AGEN-Unit", AGEN,
+ StageWidth, 0, _cpu, params));
- resources.push_back(new ExecutionUnit("Execution-Unit", ExecUnit, StageWidth, 0, _cpu, params));
+ resources.push_back(new ExecutionUnit("Execution-Unit", ExecUnit,
+ StageWidth, 0, _cpu, params));
- resources.push_back(new MultDivUnit("Mult-Div-Unit", MDU, 5, 0, _cpu, params));
+ resources.push_back(new MultDivUnit("Mult-Div-Unit", MDU, 5, 0, _cpu,
+ params));
memObjects.push_back(DCache);
- resources.push_back(new CacheUnit("dcache_port", DCache, StageWidth * MaxThreads, 0, _cpu, params));
+ resources.push_back(new CacheUnit("dcache_port", DCache,
+ StageWidth * MaxThreads, 0, _cpu,
+ params));
- resources.push_back(new GraduationUnit("Graduation-Unit", Grad, StageWidth * MaxThreads, 0, _cpu, params));
+ resources.push_back(new GraduationUnit("Graduation-Unit", Grad,
+ StageWidth * MaxThreads, 0, _cpu,
+ params));
- resources.push_back(new InstBuffer("Fetch-Buffer-T1", FetchBuff2, 4, 0, _cpu, params));
+ resources.push_back(new InstBuffer("Fetch-Buffer-T1", FetchBuff2, 4,
+ 0, _cpu, params));
}
void
ResourcePool::init()
{
for (int i=0; i < resources.size(); i++) {
- DPRINTF(Resource, "Initializing resource: %s.\n", resources[i]->name());
+ DPRINTF(Resource, "Initializing resource: %s.\n",
+ resources[i]->name());
resources[i]->init();
}
@@ -113,8 +130,8 @@ ResourcePool::getPort(const std::string &if_name, int idx)
int obj_idx = memObjects[i];
Port *port = resources[obj_idx]->getPort(if_name, idx);
if (port != NULL) {
- DPRINTF(Resource, "%s set to resource %s(#%i) in Resource Pool.\n", if_name,
- resources[obj_idx]->name(), obj_idx);
+ DPRINTF(Resource, "%s set to resource %s(#%i) in Resource Pool.\n",
+ if_name, resources[obj_idx]->name(), obj_idx);
return port;
}
}
@@ -131,7 +148,8 @@ ResourcePool::getPortIdx(const std::string &port_name)
unsigned obj_idx = memObjects[i];
Port *port = resources[obj_idx]->getPort(port_name, obj_idx);
if (port != NULL) {
- DPRINTF(Resource, "Returning Port Idx %i for %s.\n", obj_idx, port_name);
+ DPRINTF(Resource, "Returning Port Idx %i for %s.\n", obj_idx,
+ port_name);
return obj_idx;
}
}
@@ -167,7 +185,8 @@ void
ResourcePool::squash(DynInstPtr inst, int res_idx, InstSeqNum done_seq_num,
ThreadID tid)
{
- resources[res_idx]->squash(inst, ThePipeline::NumStages-1, done_seq_num, tid);
+ resources[res_idx]->squash(inst, ThePipeline::NumStages-1, done_seq_num,
+ tid);
}
int
@@ -192,15 +211,17 @@ ResourcePool::scheduleEvent(InOrderCPU::CPUEventType e_type, DynInstPtr inst,
{
case InOrderCPU::ActivateThread:
{
- DPRINTF(Resource, "Scheduling Activate Thread Resource Pool Event for tick %i.\n",
- curTick + delay);
- ResPoolEvent *res_pool_event = new ResPoolEvent(this,
- e_type,
- inst,
- inst->squashingStage,
- inst->bdelaySeqNum,
- inst->readTid());
- mainEventQueue.schedule(res_pool_event, curTick + cpu->ticks(delay));
+ DPRINTF(Resource, "Scheduling Activate Thread Resource Pool Event "
+ "for tick %i.\n", curTick + delay);
+ ResPoolEvent *res_pool_event =
+ new ResPoolEvent(this,
+ e_type,
+ inst,
+ inst->squashingStage,
+ inst->bdelaySeqNum,
+ inst->readTid());
+ mainEventQueue.schedule(res_pool_event,
+ curTick + cpu->ticks(delay));
}
break;
@@ -208,49 +229,72 @@ ResourcePool::scheduleEvent(InOrderCPU::CPUEventType e_type, DynInstPtr inst,
case InOrderCPU::DeallocateThread:
{
- DPRINTF(Resource, "Scheduling Deactivate Thread Resource Pool Event for tick %i.\n",
- curTick + delay);
- ResPoolEvent *res_pool_event = new ResPoolEvent(this,
- e_type,
- inst,
- inst->squashingStage,
- inst->bdelaySeqNum,
- tid);
+ DPRINTF(Resource, "Scheduling Deactivate Thread Resource Pool "
+ "Event for tick %i.\n", curTick + delay);
+ ResPoolEvent *res_pool_event =
+ new ResPoolEvent(this,
+ e_type,
+ inst,
+ inst->squashingStage,
+ inst->bdelaySeqNum,
+ tid);
- mainEventQueue.schedule(res_pool_event, curTick + cpu->ticks(delay));
+ mainEventQueue.schedule(res_pool_event,
+ curTick + cpu->ticks(delay));
}
break;
case ResourcePool::InstGraduated:
{
- DPRINTF(Resource, "Scheduling Inst-Graduated Resource Pool Event for tick %i.\n",
- curTick + delay);
- ResPoolEvent *res_pool_event = new ResPoolEvent(this,e_type,
- inst,
- inst->squashingStage,
- inst->seqNum,
- inst->readTid());
- mainEventQueue.schedule(res_pool_event, curTick + cpu->ticks(delay));
+ DPRINTF(Resource, "Scheduling Inst-Graduated Resource Pool "
+ "Event for tick %i.\n", curTick + delay);
+ ResPoolEvent *res_pool_event =
+ new ResPoolEvent(this,e_type,
+ inst,
+ inst->squashingStage,
+ inst->seqNum,
+ inst->readTid());
+ mainEventQueue.schedule(res_pool_event,
+ curTick + cpu->ticks(delay));
}
break;
case ResourcePool::SquashAll:
{
- DPRINTF(Resource, "Scheduling Squash Resource Pool Event for tick %i.\n",
+ DPRINTF(Resource, "Scheduling Squash Resource Pool Event for "
+ "tick %i.\n", curTick + delay);
+ ResPoolEvent *res_pool_event =
+ new ResPoolEvent(this,e_type,
+ inst,
+ inst->squashingStage,
+ inst->bdelaySeqNum,
+ inst->readTid());
+ mainEventQueue.schedule(res_pool_event,
+ curTick + cpu->ticks(delay));
+ }
+ break;
+
+ case InOrderCPU::SquashFromMemStall:
+ {
+ DPRINTF(Resource, "Scheduling Squash Due to Memory Stall Resource "
+ "Pool Event for tick %i.\n",
curTick + delay);
- ResPoolEvent *res_pool_event = new ResPoolEvent(this,e_type,
- inst,
- inst->squashingStage,
- inst->bdelaySeqNum,
- inst->readTid());
- mainEventQueue.schedule(res_pool_event, curTick + cpu->ticks(delay));
+ ResPoolEvent *res_pool_event =
+ new ResPoolEvent(this,e_type,
+ inst,
+ inst->squashingStage,
+ inst->seqNum - 1,
+ inst->readTid());
+ mainEventQueue.schedule(res_pool_event,
+ curTick + cpu->ticks(delay));
}
break;
default:
- DPRINTF(Resource, "Ignoring Unrecognized CPU Event (%s).\n", InOrderCPU::eventNames[e_type]);
+ DPRINTF(Resource, "Ignoring Unrecognized CPU Event (%s).\n",
+ InOrderCPU::eventNames[e_type]);
; // If Resource Pool doesnt recognize event, we ignore it.
}
}
@@ -265,8 +309,8 @@ void
ResourcePool::squashAll(DynInstPtr inst, int stage_num,
InstSeqNum done_seq_num, ThreadID tid)
{
- DPRINTF(Resource, "[tid:%i] Stage %i squashing all instructions above [sn:%i].\n",
- stage_num, tid, done_seq_num);
+ DPRINTF(Resource, "[tid:%i] Stage %i squashing all instructions above "
+ "[sn:%i].\n", stage_num, tid, done_seq_num);
int num_resources = resources.size();
@@ -276,10 +320,25 @@ ResourcePool::squashAll(DynInstPtr inst, int stage_num,
}
void
+ResourcePool::squashDueToMemStall(DynInstPtr inst, int stage_num,
+ InstSeqNum done_seq_num, ThreadID tid)
+{
+ DPRINTF(Resource, "[tid:%i] Stage %i squashing all instructions above "
+ "[sn:%i].\n", stage_num, tid, done_seq_num);
+
+ int num_resources = resources.size();
+
+ for (int idx = 0; idx < num_resources; idx++) {
+ resources[idx]->squashDueToMemStall(inst, stage_num, done_seq_num,
+ tid);
+ }
+}
+
+void
ResourcePool::activateAll(ThreadID tid)
{
- DPRINTF(Resource, "[tid:%i] Broadcasting Thread Activation to all resources.\n",
- tid);
+ DPRINTF(Resource, "[tid:%i] Broadcasting Thread Activation to all "
+ "resources.\n", tid);
int num_resources = resources.size();
@@ -291,8 +350,8 @@ ResourcePool::activateAll(ThreadID tid)
void
ResourcePool::deactivateAll(ThreadID tid)
{
- DPRINTF(Resource, "[tid:%i] Broadcasting Thread Deactivation to all resources.\n",
- tid);
+ DPRINTF(Resource, "[tid:%i] Broadcasting Thread Deactivation to all "
+ "resources.\n", tid);
int num_resources = resources.size();
@@ -304,8 +363,8 @@ ResourcePool::deactivateAll(ThreadID tid)
void
ResourcePool::instGraduated(InstSeqNum seq_num, ThreadID tid)
{
- DPRINTF(Resource, "[tid:%i] Broadcasting [sn:%i] graduation to all resources.\n",
- tid, seq_num);
+ DPRINTF(Resource, "[tid:%i] Broadcasting [sn:%i] graduation to all "
+ "resources.\n", tid, seq_num);
int num_resources = resources.size();
@@ -353,6 +412,10 @@ ResourcePool::ResPoolEvent::process()
resPool->squashAll(inst, stageNum, seqNum, tid);
break;
+ case InOrderCPU::SquashFromMemStall:
+ resPool->squashDueToMemStall(inst, stageNum, seqNum, tid);
+ break;
+
default:
fatal("Unrecognized Event Type");
}