fix cpu builder to build the correct name...
add activateThread event and functions src/cpu/o3/alpha/cpu_builder.cc: Have CPU builder build a DerivO3CPU not a DerivAlphaO3CPU src/cpu/o3/cpu.cc: add activateThread Event add activateThread function adjust activateContext to schedule a thread to activate within the CPU instead of activating thread right away. This will lead to stages trying to use threads that arent ready yet and wasting execution time & possibly performance. src/cpu/o3/cpu.hh: add activateThread Event add activateThread function add schedule/descheculed activate thread event --HG-- extra : convert_revision : 236d30dc160910507ad36f7f527ab185ed38dc04
This commit is contained in:
parent
ed821702e0
commit
62961a2916
|
@ -31,21 +31,21 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "cpu/base.hh"
|
#include "cpu/base.hh"
|
||||||
#include "cpu/o3/alpha_cpu.hh"
|
#include "cpu/o3/alpha/cpu.hh"
|
||||||
#include "cpu/o3/alpha_impl.hh"
|
#include "cpu/o3/alpha/impl.hh"
|
||||||
#include "cpu/o3/alpha_params.hh"
|
#include "cpu/o3/alpha/params.hh"
|
||||||
#include "cpu/o3/fu_pool.hh"
|
#include "cpu/o3/fu_pool.hh"
|
||||||
#include "sim/builder.hh"
|
#include "sim/builder.hh"
|
||||||
|
|
||||||
class DerivAlphaO3CPU : public AlphaO3CPU<AlphaSimpleImpl>
|
class DerivO3CPU : public AlphaO3CPU<AlphaSimpleImpl>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DerivAlphaO3CPU(AlphaSimpleParams *p)
|
DerivO3CPU(AlphaSimpleParams *p)
|
||||||
: AlphaO3CPU<AlphaSimpleImpl>(p)
|
: AlphaO3CPU<AlphaSimpleImpl>(p)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
BEGIN_DECLARE_SIM_OBJECT_PARAMS(DerivAlphaO3CPU)
|
BEGIN_DECLARE_SIM_OBJECT_PARAMS(DerivO3CPU)
|
||||||
|
|
||||||
Param<int> clock;
|
Param<int> clock;
|
||||||
Param<int> numThreads;
|
Param<int> numThreads;
|
||||||
|
@ -144,9 +144,9 @@ Param<bool> defer_registration;
|
||||||
Param<bool> function_trace;
|
Param<bool> function_trace;
|
||||||
Param<Tick> function_trace_start;
|
Param<Tick> function_trace_start;
|
||||||
|
|
||||||
END_DECLARE_SIM_OBJECT_PARAMS(DerivAlphaO3CPU)
|
END_DECLARE_SIM_OBJECT_PARAMS(DerivO3CPU)
|
||||||
|
|
||||||
BEGIN_INIT_SIM_OBJECT_PARAMS(DerivAlphaO3CPU)
|
BEGIN_INIT_SIM_OBJECT_PARAMS(DerivO3CPU)
|
||||||
|
|
||||||
INIT_PARAM(clock, "clock speed"),
|
INIT_PARAM(clock, "clock speed"),
|
||||||
INIT_PARAM(numThreads, "number of HW thread contexts"),
|
INIT_PARAM(numThreads, "number of HW thread contexts"),
|
||||||
|
@ -261,11 +261,11 @@ BEGIN_INIT_SIM_OBJECT_PARAMS(DerivAlphaO3CPU)
|
||||||
INIT_PARAM(function_trace, "Enable function trace"),
|
INIT_PARAM(function_trace, "Enable function trace"),
|
||||||
INIT_PARAM(function_trace_start, "Cycle to start function trace")
|
INIT_PARAM(function_trace_start, "Cycle to start function trace")
|
||||||
|
|
||||||
END_INIT_SIM_OBJECT_PARAMS(DerivAlphaO3CPU)
|
END_INIT_SIM_OBJECT_PARAMS(DerivO3CPU)
|
||||||
|
|
||||||
CREATE_SIM_OBJECT(DerivAlphaO3CPU)
|
CREATE_SIM_OBJECT(DerivO3CPU)
|
||||||
{
|
{
|
||||||
DerivAlphaO3CPU *cpu;
|
DerivO3CPU *cpu;
|
||||||
|
|
||||||
#if FULL_SYSTEM
|
#if FULL_SYSTEM
|
||||||
// Full-system only supports a single thread for the moment.
|
// Full-system only supports a single thread for the moment.
|
||||||
|
@ -386,10 +386,10 @@ CREATE_SIM_OBJECT(DerivAlphaO3CPU)
|
||||||
params->functionTrace = function_trace;
|
params->functionTrace = function_trace;
|
||||||
params->functionTraceStart = function_trace_start;
|
params->functionTraceStart = function_trace_start;
|
||||||
|
|
||||||
cpu = new DerivAlphaO3CPU(params);
|
cpu = new DerivO3CPU(params);
|
||||||
|
|
||||||
return cpu;
|
return cpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
REGISTER_SIM_OBJECT("DerivAlphaO3CPU", DerivAlphaO3CPU)
|
REGISTER_SIM_OBJECT("DerivO3CPU", DerivO3CPU)
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,35 @@ FullO3CPU<Impl>::TickEvent::description()
|
||||||
return "FullO3CPU tick event";
|
return "FullO3CPU tick event";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class Impl>
|
||||||
|
FullO3CPU<Impl>::ActivateThreadEvent::ActivateThreadEvent()
|
||||||
|
: Event(&mainEventQueue, CPU_Tick_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()
|
||||||
|
{
|
||||||
|
return "FullO3CPU \"Activate Thread\" event";
|
||||||
|
}
|
||||||
|
|
||||||
template <class Impl>
|
template <class Impl>
|
||||||
FullO3CPU<Impl>::FullO3CPU(Params *params)
|
FullO3CPU<Impl>::FullO3CPU(Params *params)
|
||||||
: BaseO3CPU(params),
|
: BaseO3CPU(params),
|
||||||
|
@ -257,6 +286,8 @@ FullO3CPU<Impl>::FullO3CPU(Params *params)
|
||||||
|
|
||||||
lastRunningCycle = curTick;
|
lastRunningCycle = curTick;
|
||||||
|
|
||||||
|
lastActivatedCycle = -1;
|
||||||
|
|
||||||
contextSwitch = false;
|
contextSwitch = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -574,31 +605,45 @@ FullO3CPU<Impl>::activateWhenReady(int tid)
|
||||||
|
|
||||||
template <class Impl>
|
template <class Impl>
|
||||||
void
|
void
|
||||||
FullO3CPU<Impl>::activateContext(int tid, int delay)
|
FullO3CPU<Impl>::activateThread(unsigned int tid)
|
||||||
{
|
{
|
||||||
// Needs to set each stage to running as well.
|
|
||||||
list<unsigned>::iterator isActive = find(
|
list<unsigned>::iterator isActive = find(
|
||||||
activeThreads.begin(), activeThreads.end(), tid);
|
activeThreads.begin(), activeThreads.end(), tid);
|
||||||
|
|
||||||
if (isActive == activeThreads.end()) {
|
if (isActive == activeThreads.end()) {
|
||||||
//May Need to Re-code this if the delay variable is the
|
DPRINTF(O3CPU, "[tid:%i]: Adding to active threads list\n",
|
||||||
//delay needed for thread to activate
|
|
||||||
DPRINTF(O3CPU, "Adding Thread %i to active threads list\n",
|
|
||||||
tid);
|
tid);
|
||||||
|
|
||||||
activeThreads.push_back(tid);
|
activeThreads.push_back(tid);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
assert(_status == Idle || _status == SwitchedOut);
|
|
||||||
|
|
||||||
scheduleTickEvent(delay);
|
template <class Impl>
|
||||||
|
void
|
||||||
|
FullO3CPU<Impl>::activateContext(int tid, int delay)
|
||||||
|
{
|
||||||
|
// 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, curTick + cycles(delay));
|
||||||
|
scheduleActivateThreadEvent(tid, delay);
|
||||||
|
} else {
|
||||||
|
activateThread(tid);
|
||||||
|
}
|
||||||
|
|
||||||
// Be sure to signal that there's some activity so the CPU doesn't
|
if(lastActivatedCycle < curTick) {
|
||||||
// deschedule itself.
|
scheduleTickEvent(delay);
|
||||||
activityRec.activity();
|
|
||||||
fetch.wakeFromQuiesce();
|
|
||||||
|
|
||||||
_status = Running;
|
// Be sure to signal that there's some activity so the CPU doesn't
|
||||||
|
// deschedule itself.
|
||||||
|
activityRec.activity();
|
||||||
|
fetch.wakeFromQuiesce();
|
||||||
|
|
||||||
|
lastActivatedCycle = curTick;
|
||||||
|
|
||||||
|
_status = Running;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Impl>
|
template <class Impl>
|
||||||
|
|
|
@ -102,6 +102,7 @@ class FullO3CPU : public BaseO3CPU
|
||||||
typedef typename std::list<DynInstPtr>::iterator ListIt;
|
typedef typename std::list<DynInstPtr>::iterator ListIt;
|
||||||
|
|
||||||
friend class O3ThreadContext<Impl>;
|
friend class O3ThreadContext<Impl>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Status {
|
enum Status {
|
||||||
Running,
|
Running,
|
||||||
|
@ -114,6 +115,9 @@ class FullO3CPU : public BaseO3CPU
|
||||||
/** Overall CPU status. */
|
/** Overall CPU status. */
|
||||||
Status _status;
|
Status _status;
|
||||||
|
|
||||||
|
/** Per-thread status in CPU, used for SMT. */
|
||||||
|
Status _threadStatus[Impl::MaxThreads];
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class TickEvent : public Event
|
class TickEvent : public Event
|
||||||
{
|
{
|
||||||
|
@ -150,6 +154,49 @@ class FullO3CPU : public BaseO3CPU
|
||||||
tickEvent.squash();
|
tickEvent.squash();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ActivateThreadEvent : public Event
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
/** Number of Thread to Activate */
|
||||||
|
int 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();
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Schedule thread to activate , regardless of its current state. */
|
||||||
|
void scheduleActivateThreadEvent(int tid, int delay)
|
||||||
|
{
|
||||||
|
// Schedule thread to activate, regardless of its current state.
|
||||||
|
if (activateThreadEvent[tid].squashed())
|
||||||
|
activateThreadEvent[tid].reschedule(curTick + cycles(delay));
|
||||||
|
else if (!activateThreadEvent[tid].scheduled())
|
||||||
|
activateThreadEvent[tid].schedule(curTick + cycles(delay));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Unschedule actiavte thread event, regardless of its current state. */
|
||||||
|
void unscheduleActivateThreadEvent(int tid)
|
||||||
|
{
|
||||||
|
if (activateThreadEvent[tid].scheduled())
|
||||||
|
activateThreadEvent[tid].squash();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The tick event used for scheduling CPU ticks. */
|
||||||
|
ActivateThreadEvent activateThreadEvent[Impl::MaxThreads];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Constructs a CPU with the given parameters. */
|
/** Constructs a CPU with the given parameters. */
|
||||||
FullO3CPU(Params *params);
|
FullO3CPU(Params *params);
|
||||||
|
@ -167,6 +214,9 @@ class FullO3CPU : public BaseO3CPU
|
||||||
/** Initialize the CPU */
|
/** Initialize the CPU */
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
|
/** Add Thread to Active Threads List */
|
||||||
|
void activateThread(unsigned int tid);
|
||||||
|
|
||||||
/** Setup CPU to insert a thread's context */
|
/** Setup CPU to insert a thread's context */
|
||||||
void insertThread(unsigned tid);
|
void insertThread(unsigned tid);
|
||||||
|
|
||||||
|
@ -522,6 +572,9 @@ class FullO3CPU : public BaseO3CPU
|
||||||
/** The cycle that the CPU was last running, used for statistics. */
|
/** The cycle that the CPU was last running, used for statistics. */
|
||||||
Tick lastRunningCycle;
|
Tick lastRunningCycle;
|
||||||
|
|
||||||
|
/** The cycle that the CPU was last activated by a new thread*/
|
||||||
|
Tick lastActivatedCycle;
|
||||||
|
|
||||||
/** Number of Threads CPU can process */
|
/** Number of Threads CPU can process */
|
||||||
unsigned numThreads;
|
unsigned numThreads;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue