summaryrefslogtreecommitdiff
path: root/src/cpu/o3
diff options
context:
space:
mode:
Diffstat (limited to 'src/cpu/o3')
-rw-r--r--src/cpu/o3/cpu.cc214
-rw-r--r--src/cpu/o3/cpu.hh124
-rw-r--r--src/cpu/o3/fetch_impl.hh8
-rwxr-xr-xsrc/cpu/o3/thread_context.hh9
-rwxr-xr-xsrc/cpu/o3/thread_context_impl.hh11
5 files changed, 27 insertions, 339 deletions
diff --git a/src/cpu/o3/cpu.cc b/src/cpu/o3/cpu.cc
index fdbbd5c14..2ae185532 100644
--- a/src/cpu/o3/cpu.cc
+++ b/src/cpu/o3/cpu.cc
@@ -148,67 +148,6 @@ FullO3CPU<Impl>::TickEvent::description() const
}
template <class Impl>
-FullO3CPU<Impl>::ActivateThreadEvent::ActivateThreadEvent()
- : Event(CPU_Switch_Pri)
-{
-}
-
-template <class Impl>
-void
-FullO3CPU<Impl>::ActivateThreadEvent::init(int thread_num,
- FullO3CPU<Impl> *thread_cpu)
-{
- tid = thread_num;
- cpu = thread_cpu;
-}
-
-template <class Impl>
-void
-FullO3CPU<Impl>::ActivateThreadEvent::process()
-{
- cpu->activateThread(tid);
-}
-
-template <class Impl>
-const char *
-FullO3CPU<Impl>::ActivateThreadEvent::description() const
-{
- return "FullO3CPU \"Activate Thread\"";
-}
-
-template <class Impl>
-FullO3CPU<Impl>::DeallocateContextEvent::DeallocateContextEvent()
- : Event(CPU_Tick_Pri), tid(0), remove(false), cpu(NULL)
-{
-}
-
-template <class Impl>
-void
-FullO3CPU<Impl>::DeallocateContextEvent::init(int thread_num,
- FullO3CPU<Impl> *thread_cpu)
-{
- tid = thread_num;
- cpu = thread_cpu;
- remove = false;
-}
-
-template <class Impl>
-void
-FullO3CPU<Impl>::DeallocateContextEvent::process()
-{
- cpu->deactivateThread(tid);
- if (remove)
- cpu->removeThread(tid);
-}
-
-template <class Impl>
-const char *
-FullO3CPU<Impl>::DeallocateContextEvent::description() const
-{
- return "FullO3CPU \"Deallocate Context\"";
-}
-
-template <class Impl>
FullO3CPU<Impl>::FullO3CPU(DerivO3CPUParams *params)
: BaseO3CPU(params),
itb(params->itb),
@@ -346,9 +285,6 @@ FullO3CPU<Impl>::FullO3CPU(DerivO3CPUParams *params)
renameMap[tid].init(&regFile, TheISA::ZeroReg, fpZeroReg,
&freeList);
-
- activateThreadEvent[tid].init(tid, this);
- deallocateContextEvent[tid].init(tid, this);
}
// Initialize rename map to assign physical registers to the
@@ -389,7 +325,6 @@ FullO3CPU<Impl>::FullO3CPU(DerivO3CPUParams *params)
globalSeqNum[tid] = 1;
#endif
- contextSwitch = false;
DPRINTF(O3CPU, "Creating O3CPU object.\n");
// Setup any thread state.
@@ -613,9 +548,6 @@ FullO3CPU<Impl>::tick()
commit.tick();
- if (!FullSystem)
- doContextSwitch();
-
// Now advance the time buffers
timeBuffer.advance();
@@ -761,18 +693,12 @@ FullO3CPU<Impl>::totalOps() const
template <class Impl>
void
-FullO3CPU<Impl>::activateContext(ThreadID tid, Cycles delay)
+FullO3CPU<Impl>::activateContext(ThreadID tid)
{
assert(!switchedOut());
// Needs to set each stage to running as well.
- if (delay){
- DPRINTF(O3CPU, "[tid:%i]: Scheduling thread context to activate "
- "on cycle %d\n", tid, clockEdge(delay));
- scheduleActivateThreadEvent(tid, delay);
- } else {
- activateThread(tid);
- }
+ activateThread(tid);
// We don't want to wake the CPU if it is drained. In that case,
// we just want to flag the thread as active and schedule the tick
@@ -783,7 +709,7 @@ FullO3CPU<Impl>::activateContext(ThreadID tid, Cycles delay)
// If we are time 0 or if the last activation time is in the past,
// schedule the next tick and wake up the fetch unit
if (lastActivatedCycle == 0 || lastActivatedCycle < curTick()) {
- scheduleTickEvent(delay);
+ scheduleTickEvent(Cycles(0));
// Be sure to signal that there's some activity so the CPU doesn't
// deschedule itself.
@@ -803,22 +729,12 @@ FullO3CPU<Impl>::activateContext(ThreadID tid, Cycles delay)
}
template <class Impl>
-bool
-FullO3CPU<Impl>::scheduleDeallocateContext(ThreadID tid, bool remove,
- Cycles delay)
-{
- // Schedule removal of thread data from CPU
- if (delay){
- DPRINTF(O3CPU, "[tid:%i]: Scheduling thread context to deallocate "
- "on tick %d\n", tid, clockEdge(delay));
- scheduleDeallocateContextEvent(tid, remove, delay);
- return false;
- } else {
- deactivateThread(tid);
- if (remove)
- removeThread(tid);
- return true;
- }
+void
+FullO3CPU<Impl>::deallocateContext(ThreadID tid, bool remove)
+{
+ deactivateThread(tid);
+ if (remove)
+ removeThread(tid);
}
template <class Impl>
@@ -827,10 +743,10 @@ FullO3CPU<Impl>::suspendContext(ThreadID tid)
{
DPRINTF(O3CPU,"[tid: %i]: Suspending Thread Context.\n", tid);
assert(!switchedOut());
- bool deallocated = scheduleDeallocateContext(tid, false, Cycles(1));
+ deallocateContext(tid, false);
+
// If this was the last thread then unschedule the tick event.
- if ((activeThreads.size() == 1 && !deallocated) ||
- activeThreads.size() == 0)
+ if (activeThreads.size() == 0)
unscheduleTickEvent();
DPRINTF(Quiesce, "Suspending Context\n");
@@ -845,7 +761,7 @@ FullO3CPU<Impl>::haltContext(ThreadID tid)
//For now, this is the same as deallocate
DPRINTF(O3CPU,"[tid:%i]: Halt Context called. Deallocating", tid);
assert(!switchedOut());
- scheduleDeallocateContext(tid, true, Cycles(1));
+ deallocateContext(tid, true);
}
template <class Impl>
@@ -896,7 +812,7 @@ FullO3CPU<Impl>::insertThread(ThreadID tid)
src_tc->setStatus(ThreadContext::Active);
- activateContext(tid, Cycles(1));
+ activateContext(tid);
//Reset ROB/IQ/LSQ Entries
commit.rob->resetEntries();
@@ -973,77 +889,6 @@ FullO3CPU<Impl>::removeThread(ThreadID tid)
*/
}
-
-template <class Impl>
-void
-FullO3CPU<Impl>::activateWhenReady(ThreadID tid)
-{
- DPRINTF(O3CPU,"[tid:%i]: Checking if resources are available for incoming"
- "(e.g. PhysRegs/ROB/IQ/LSQ) \n",
- tid);
-
- bool ready = true;
-
- // Should these all be '<' not '>='? This seems backwards...
- if (freeList.numFreeIntRegs() >= TheISA::NumIntRegs) {
- DPRINTF(O3CPU,"[tid:%i] Suspending thread due to not enough "
- "Phys. Int. Regs.\n",
- tid);
- ready = false;
- } else if (freeList.numFreeFloatRegs() >= TheISA::NumFloatRegs) {
- DPRINTF(O3CPU,"[tid:%i] Suspending thread due to not enough "
- "Phys. Float. Regs.\n",
- tid);
- ready = false;
- } else if (freeList.numFreeCCRegs() >= TheISA::NumCCRegs) {
- DPRINTF(O3CPU,"[tid:%i] Suspending thread due to not enough "
- "Phys. CC. Regs.\n",
- tid);
- ready = false;
- } else if (commit.rob->numFreeEntries() >=
- commit.rob->entryAmount(activeThreads.size() + 1)) {
- DPRINTF(O3CPU,"[tid:%i] Suspending thread due to not enough "
- "ROB entries.\n",
- tid);
- ready = false;
- } else if (iew.instQueue.numFreeEntries() >=
- iew.instQueue.entryAmount(activeThreads.size() + 1)) {
- DPRINTF(O3CPU,"[tid:%i] Suspending thread due to not enough "
- "IQ entries.\n",
- tid);
- ready = false;
- } else if (iew.ldstQueue.numFreeLoadEntries() >=
- iew.ldstQueue.entryAmount(activeThreads.size() + 1)) {
- DPRINTF(O3CPU,"[tid:%i] Suspending thread due to not enough "
- "LQ entries.\n",
- tid);
- ready = false;
- } else if (iew.ldstQueue.numFreeStoreEntries() >=
- iew.ldstQueue.entryAmount(activeThreads.size() + 1)) {
- DPRINTF(O3CPU,"[tid:%i] Suspending thread due to not enough "
- "SQ entries.\n",
- tid);
- ready = false;
- }
-
- if (ready) {
- insertThread(tid);
-
- contextSwitch = false;
-
- cpuWaitList.remove(tid);
- } else {
- suspendContext(tid);
-
- //blocks fetch
- contextSwitch = true;
-
- //@todo: dont always add to waitlist
- //do waitlist
- cpuWaitList.push_back(tid);
- }
-}
-
template <class Impl>
Fault
FullO3CPU<Impl>::hwrei(ThreadID tid)
@@ -1243,19 +1088,6 @@ FullO3CPU<Impl>::isDrained() const
{
bool drained(true);
- for (ThreadID i = 0; i < thread.size(); ++i) {
- if (activateThreadEvent[i].scheduled()) {
- DPRINTF(Drain, "CPU not drained, tread %i has a "
- "pending activate event\n", i);
- drained = false;
- }
- if (deallocateContextEvent[i].scheduled()) {
- DPRINTF(Drain, "CPU not drained, tread %i has a "
- "pending deallocate context event\n", i);
- drained = false;
- }
- }
-
if (!instList.empty() || !removeList.empty()) {
DPRINTF(Drain, "Main CPU structures not drained.\n");
drained = false;
@@ -1832,24 +1664,6 @@ FullO3CPU<Impl>::getFreeTid()
template <class Impl>
void
-FullO3CPU<Impl>::doContextSwitch()
-{
- if (contextSwitch) {
-
- //ADD CODE TO DEACTIVE THREAD HERE (???)
-
- ThreadID size = cpuWaitList.size();
- for (ThreadID tid = 0; tid < size; tid++) {
- activateWhenReady(tid);
- }
-
- if (cpuWaitList.size() == 0)
- contextSwitch = true;
- }
-}
-
-template <class Impl>
-void
FullO3CPU<Impl>::updateThreadPriority()
{
if (activeThreads.size() > 1) {
diff --git a/src/cpu/o3/cpu.hh b/src/cpu/o3/cpu.hh
index cfed216c3..0fd08a68b 100644
--- a/src/cpu/o3/cpu.hh
+++ b/src/cpu/o3/cpu.hh
@@ -229,116 +229,6 @@ class FullO3CPU : public BaseO3CPU
tickEvent.squash();
}
- class ActivateThreadEvent : public Event
- {
- private:
- /** Number of Thread to Activate */
- ThreadID tid;
-
- /** Pointer to the CPU. */
- FullO3CPU<Impl> *cpu;
-
- public:
- /** Constructs the event. */
- ActivateThreadEvent();
-
- /** Initialize Event */
- void init(int thread_num, FullO3CPU<Impl> *thread_cpu);
-
- /** Processes the event, calling activateThread() on the CPU. */
- void process();
-
- /** Returns the description of the event. */
- const char *description() const;
- };
-
- /** Schedule thread to activate , regardless of its current state. */
- void
- scheduleActivateThreadEvent(ThreadID tid, Cycles delay)
- {
- // Schedule thread to activate, regardless of its current state.
- if (activateThreadEvent[tid].squashed())
- reschedule(activateThreadEvent[tid],
- clockEdge(delay));
- else if (!activateThreadEvent[tid].scheduled()) {
- Tick when = clockEdge(delay);
-
- // Check if the deallocateEvent is also scheduled, and make
- // sure they do not happen at same time causing a sleep that
- // is never woken from.
- if (deallocateContextEvent[tid].scheduled() &&
- deallocateContextEvent[tid].when() == when) {
- when++;
- }
-
- schedule(activateThreadEvent[tid], when);
- }
- }
-
- /** Unschedule actiavte thread event, regardless of its current state. */
- void
- unscheduleActivateThreadEvent(ThreadID tid)
- {
- if (activateThreadEvent[tid].scheduled())
- activateThreadEvent[tid].squash();
- }
-
- /** The tick event used for scheduling CPU ticks. */
- ActivateThreadEvent activateThreadEvent[Impl::MaxThreads];
-
- class DeallocateContextEvent : public Event
- {
- private:
- /** Number of Thread to deactivate */
- ThreadID tid;
-
- /** Should the thread be removed from the CPU? */
- bool remove;
-
- /** Pointer to the CPU. */
- FullO3CPU<Impl> *cpu;
-
- public:
- /** Constructs the event. */
- DeallocateContextEvent();
-
- /** Initialize Event */
- void init(int thread_num, FullO3CPU<Impl> *thread_cpu);
-
- /** Processes the event, calling activateThread() on the CPU. */
- void process();
-
- /** Sets whether the thread should also be removed from the CPU. */
- void setRemove(bool _remove) { remove = _remove; }
-
- /** Returns the description of the event. */
- const char *description() const;
- };
-
- /** Schedule cpu to deallocate thread context.*/
- void
- scheduleDeallocateContextEvent(ThreadID tid, bool remove, Cycles delay)
- {
- // Schedule thread to activate, regardless of its current state.
- if (deallocateContextEvent[tid].squashed())
- reschedule(deallocateContextEvent[tid],
- clockEdge(delay));
- else if (!deallocateContextEvent[tid].scheduled())
- schedule(deallocateContextEvent[tid],
- clockEdge(delay));
- }
-
- /** Unschedule thread deallocation in CPU */
- void
- unscheduleDeallocateContextEvent(ThreadID tid)
- {
- if (deallocateContextEvent[tid].scheduled())
- deallocateContextEvent[tid].squash();
- }
-
- /** The tick event used for scheduling CPU ticks. */
- DeallocateContextEvent deallocateContextEvent[Impl::MaxThreads];
-
/**
* Check if the pipeline has drained and signal the DrainManager.
*
@@ -430,7 +320,7 @@ class FullO3CPU : public BaseO3CPU
virtual Counter totalOps() const;
/** Add Thread to Active Threads List. */
- void activateContext(ThreadID tid, Cycles delay);
+ void activateContext(ThreadID tid);
/** Remove Thread from Active Threads List */
void suspendContext(ThreadID tid);
@@ -438,20 +328,13 @@ class FullO3CPU : public BaseO3CPU
/** Remove Thread from Active Threads List &&
* Possibly Remove Thread Context from CPU.
*/
- bool scheduleDeallocateContext(ThreadID tid, bool remove,
- Cycles delay = Cycles(1));
+ void deallocateContext(ThreadID tid, bool remove);
/** Remove Thread from Active Threads List &&
* Remove Thread Context from CPU.
*/
void haltContext(ThreadID tid);
- /** Activate a Thread When CPU Resources are Available. */
- void activateWhenReady(ThreadID tid);
-
- /** Add or Remove a Thread Context in the CPU. */
- void doContextSwitch();
-
/** Update The Order In Which We Process Threads. */
void updateThreadPriority();
@@ -792,9 +675,6 @@ class FullO3CPU : public BaseO3CPU
/** Pointers to all of the threads in the CPU. */
std::vector<Thread *> thread;
- /** Is there a context switch pending? */
- bool contextSwitch;
-
/** Threads Scheduled to Enter CPU */
std::list<int> cpuWaitList;
diff --git a/src/cpu/o3/fetch_impl.hh b/src/cpu/o3/fetch_impl.hh
index b9e3b78c5..7319b38a5 100644
--- a/src/cpu/o3/fetch_impl.hh
+++ b/src/cpu/o3/fetch_impl.hh
@@ -811,10 +811,7 @@ DefaultFetch<Impl>::checkStall(ThreadID tid) const
{
bool ret_val = false;
- if (cpu->contextSwitch) {
- DPRINTF(Fetch,"[tid:%i]: Stalling for a context switch.\n",tid);
- ret_val = true;
- } else if (stalls[tid].drain) {
+ if (stalls[tid].drain) {
assert(cpu->isDraining());
DPRINTF(Fetch,"[tid:%i]: Drain stall detected.\n",tid);
ret_val = true;
@@ -970,9 +967,8 @@ DefaultFetch<Impl>::tick()
}
// If there was activity this cycle, inform the CPU of it.
- if (wroteToTimeBuffer || cpu->contextSwitch) {
+ if (wroteToTimeBuffer) {
DPRINTF(Activity, "Activity this cycle.\n");
-
cpu->activityThisCycle();
}
diff --git a/src/cpu/o3/thread_context.hh b/src/cpu/o3/thread_context.hh
index a00d2ffa3..b27fbb386 100755
--- a/src/cpu/o3/thread_context.hh
+++ b/src/cpu/o3/thread_context.hh
@@ -136,15 +136,14 @@ class O3ThreadContext : public ThreadContext
virtual void setStatus(Status new_status)
{ thread->setStatus(new_status); }
- /** Set the status to Active. Optional delay indicates number of
- * cycles to wait before beginning execution. */
- virtual void activate(Cycles delay = Cycles(1));
+ /** Set the status to Active. */
+ virtual void activate();
/** Set the status to Suspended. */
- virtual void suspend(Cycles delay = Cycles(0));
+ virtual void suspend();
/** Set the status to Halted. */
- virtual void halt(Cycles delay = Cycles(0));
+ virtual void halt();
/** Dumps the function profiling information.
* @todo: Implement.
diff --git a/src/cpu/o3/thread_context_impl.hh b/src/cpu/o3/thread_context_impl.hh
index 43e903135..e6a3d5083 100755
--- a/src/cpu/o3/thread_context_impl.hh
+++ b/src/cpu/o3/thread_context_impl.hh
@@ -84,7 +84,7 @@ O3ThreadContext<Impl>::takeOverFrom(ThreadContext *old_context)
template <class Impl>
void
-O3ThreadContext<Impl>::activate(Cycles delay)
+O3ThreadContext<Impl>::activate()
{
DPRINTF(O3CPU, "Calling activate on Thread Context %d\n",
threadId());
@@ -96,12 +96,12 @@ O3ThreadContext<Impl>::activate(Cycles delay)
thread->setStatus(ThreadContext::Active);
// status() == Suspended
- cpu->activateContext(thread->threadId(), delay);
+ cpu->activateContext(thread->threadId());
}
template <class Impl>
void
-O3ThreadContext<Impl>::suspend(Cycles delay)
+O3ThreadContext<Impl>::suspend()
{
DPRINTF(O3CPU, "Calling suspend on Thread Context %d\n",
threadId());
@@ -118,10 +118,9 @@ O3ThreadContext<Impl>::suspend(Cycles delay)
template <class Impl>
void
-O3ThreadContext<Impl>::halt(Cycles delay)
+O3ThreadContext<Impl>::halt()
{
- DPRINTF(O3CPU, "Calling halt on Thread Context %d\n",
- threadId());
+ DPRINTF(O3CPU, "Calling halt on Thread Context %d\n", threadId());
if (thread->status() == ThreadContext::Halted)
return;