From 214cc0fafce09dbee6aedafa5e1148476cc6463f Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Fri, 7 Jan 2011 21:50:29 -0800 Subject: inorder: get rid of references to mainEventQueue. Events need to be scheduled on the queue assigned to the SimObject, not on the global queue (which should be going away). Also cleaned up a number of redundant expressions that made the code unnecessarily verbose. --- src/cpu/inorder/cpu.cc | 14 +++++------ src/cpu/inorder/cpu.hh | 8 +++--- src/cpu/inorder/resource.cc | 12 +++++++++ src/cpu/inorder/resource.hh | 8 +----- src/cpu/inorder/resource_pool.cc | 53 ++++++++++++++-------------------------- 5 files changed, 43 insertions(+), 52 deletions(-) diff --git a/src/cpu/inorder/cpu.cc b/src/cpu/inorder/cpu.cc index 5f723d0b3..bb324ce64 100644 --- a/src/cpu/inorder/cpu.cc +++ b/src/cpu/inorder/cpu.cc @@ -157,12 +157,12 @@ InOrderCPU::CPUEvent::description() void InOrderCPU::CPUEvent::scheduleEvent(int delay) { + Tick when = cpu->nextCycle(curTick + cpu->ticks(delay)); + if (squashed()) - mainEventQueue.reschedule(this, cpu->nextCycle(curTick + - cpu->ticks(delay))); + cpu->reschedule(this, when); else if (!scheduled()) - mainEventQueue.schedule(this, cpu->nextCycle(curTick + - cpu->ticks(delay))); + cpu->schedule(this, when); } void @@ -540,7 +540,7 @@ InOrderCPU::tick() } else { //Tick next_tick = curTick + cycles(1); //tickEvent.schedule(next_tick); - mainEventQueue.schedule(&tickEvent, nextCycle(curTick + 1)); + schedule(&tickEvent, nextCycle(curTick + 1)); DPRINTF(InOrderCPU, "Scheduled CPU for next tick @ %i.\n", nextCycle(curTick + 1)); } @@ -701,7 +701,7 @@ InOrderCPU::scheduleCpuEvent(CPUEventType c_event, Fault fault, if (delay >= 0) { DPRINTF(InOrderCPU, "Scheduling CPU Event (%s) for cycle %i, [tid:%i].\n", eventNames[c_event], curTick + delay, tid); - mainEventQueue.schedule(cpu_event, sked_tick); + schedule(cpu_event, sked_tick); } else { cpu_event->process(); cpuEventRemoveList.push(cpu_event); @@ -1403,7 +1403,7 @@ InOrderCPU::wakeCPU() numCycles += extra_cycles; - mainEventQueue.schedule(&tickEvent, nextCycle(curTick)); + schedule(&tickEvent, nextCycle(curTick)); } #if FULL_SYSTEM diff --git a/src/cpu/inorder/cpu.hh b/src/cpu/inorder/cpu.hh index 3b2041cfa..42bae0d31 100644 --- a/src/cpu/inorder/cpu.hh +++ b/src/cpu/inorder/cpu.hh @@ -156,12 +156,12 @@ class InOrderCPU : public BaseCPU /** Schedule tick event, regardless of its current state. */ void scheduleTickEvent(int delay) { + Tick when = nextCycle(curTick + ticks(delay)); + if (tickEvent.squashed()) - mainEventQueue.reschedule(&tickEvent, - nextCycle(curTick + ticks(delay))); + reschedule(&tickEvent, when); else if (!tickEvent.scheduled()) - mainEventQueue.schedule(&tickEvent, - nextCycle(curTick + ticks(delay))); + schedule(&tickEvent, when); } /** Unschedule tick event, regardless of its current state. */ diff --git a/src/cpu/inorder/resource.cc b/src/cpu/inorder/resource.cc index 8cc8f9fe1..4eab89687 100644 --- a/src/cpu/inorder/resource.cc +++ b/src/cpu/inorder/resource.cc @@ -498,3 +498,15 @@ ResourceEvent::description() return desc.c_str(); } + +void +ResourceEvent::scheduleEvent(int delay) +{ + InOrderCPU *cpu = resource->cpu; + Tick when = curTick + resource->ticks(delay); + + if (squashed()) + cpu->reschedule(this, when); + else if (!scheduled()) + cpu->schedule(this, when); +} diff --git a/src/cpu/inorder/resource.hh b/src/cpu/inorder/resource.hh index 2e0143f9f..5684dc166 100644 --- a/src/cpu/inorder/resource.hh +++ b/src/cpu/inorder/resource.hh @@ -277,13 +277,7 @@ class ResourceEvent : public Event void setSlot(int slot) { slotIdx = slot; } /** Schedule resource event, regardless of its current state. */ - void scheduleEvent(int delay) - { - if (squashed()) - mainEventQueue.reschedule(this, curTick + resource->ticks(delay)); - else if (!scheduled()) - mainEventQueue.schedule(this, curTick + resource->ticks(delay)); - } + void scheduleEvent(int delay); /** Unschedule resource event, regardless of its current state. */ void unscheduleEvent() diff --git a/src/cpu/inorder/resource_pool.cc b/src/cpu/inorder/resource_pool.cc index d7ae18d3d..97ea889fd 100644 --- a/src/cpu/inorder/resource_pool.cc +++ b/src/cpu/inorder/resource_pool.cc @@ -244,6 +244,8 @@ ResourcePool::scheduleEvent(InOrderCPU::CPUEventType e_type, DynInstPtr inst, { assert(delay >= 0); + Tick when = cpu->nextCycle(curTick + cpu->ticks(delay)); + switch (e_type) { case InOrderCPU::ActivateThread: @@ -258,9 +260,7 @@ ResourcePool::scheduleEvent(InOrderCPU::CPUEventType e_type, DynInstPtr inst, inst->squashingStage, inst->bdelaySeqNum, inst->readTid()); - mainEventQueue.schedule(res_pool_event, - cpu->nextCycle(curTick + - cpu->ticks(delay))); + cpu->schedule(res_pool_event, when); } break; @@ -278,19 +278,17 @@ ResourcePool::scheduleEvent(InOrderCPU::CPUEventType e_type, DynInstPtr inst, inst->bdelaySeqNum, tid); - mainEventQueue.schedule(res_pool_event, - cpu->nextCycle(curTick + - cpu->ticks(delay))); - + cpu->schedule(res_pool_event, when); } break; case InOrderCPU::SuspendThread: { + // not sure why we add another nextCycle() call here... + Tick sked_tick = cpu->nextCycle(when); DPRINTF(Resource, "Scheduling Suspend Thread Resource Pool " - "Event for tick %i.\n", - cpu->nextCycle(cpu->nextCycle(curTick + cpu->ticks(delay)))); + "Event for tick %i.\n", sked_tick); ResPoolEvent *res_pool_event = new ResPoolEvent(this, e_type, @@ -299,10 +297,7 @@ ResourcePool::scheduleEvent(InOrderCPU::CPUEventType e_type, DynInstPtr inst, inst->bdelaySeqNum, tid); - Tick sked_tick = curTick + cpu->ticks(delay); - mainEventQueue.schedule(res_pool_event, - cpu->nextCycle(cpu->nextCycle(sked_tick))); - + cpu->schedule(res_pool_event, sked_tick); } break; @@ -316,10 +311,7 @@ ResourcePool::scheduleEvent(InOrderCPU::CPUEventType e_type, DynInstPtr inst, inst->squashingStage, inst->seqNum, inst->readTid()); - mainEventQueue.schedule(res_pool_event, - cpu->nextCycle(curTick + - cpu->ticks(delay))); - + cpu->schedule(res_pool_event, when); } break; @@ -333,9 +325,7 @@ ResourcePool::scheduleEvent(InOrderCPU::CPUEventType e_type, DynInstPtr inst, inst->squashingStage, inst->bdelaySeqNum, inst->readTid()); - mainEventQueue.schedule(res_pool_event, - cpu->nextCycle(curTick + - cpu->ticks(delay))); + cpu->schedule(res_pool_event, when); } break; @@ -350,23 +340,21 @@ ResourcePool::scheduleEvent(InOrderCPU::CPUEventType e_type, DynInstPtr inst, inst->squashingStage, inst->seqNum - 1, inst->readTid()); - mainEventQueue.schedule(res_pool_event, - cpu->nextCycle(curTick + cpu->ticks(delay))); + cpu->schedule(res_pool_event, when); } break; case ResourcePool::UpdateAfterContextSwitch: { - DPRINTF(Resource, "Scheduling UpdatePC Resource Pool Event for tick %i.\n", + DPRINTF(Resource, "Scheduling UpdatePC 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, - cpu->nextCycle(curTick + cpu->ticks(delay))); - + cpu->schedule(res_pool_event, when); } break; @@ -552,16 +540,13 @@ ResourcePool::ResPoolEvent::description() void ResourcePool::ResPoolEvent::scheduleEvent(int delay) { + InOrderCPU *cpu = resPool->cpu; + Tick when = cpu->nextCycle(curTick + cpu->ticks(delay)); + if (squashed()) { - mainEventQueue.reschedule(this, - resPool->cpu->nextCycle(curTick + - resPool-> - cpu->ticks(delay))); + cpu->reschedule(this, when); } else if (!scheduled()) { - mainEventQueue.schedule(this, - resPool->cpu->nextCycle(curTick + - resPool-> - cpu->ticks(delay))); + cpu->schedule(this, when); } } -- cgit v1.2.3