-# Copyright (c) 2012-2013, 2015 ARM Limited
+# Copyright (c) 2012-2013, 2015-2017 ARM Limited
# All rights reserved.
#
# The license below extends only to copyright in the software and shall
cpu_id = Param.Int(-1, "CPU identifier")
socket_id = Param.Unsigned(0, "Physical Socket identifier")
numThreads = Param.Unsigned(1, "number of HW thread contexts")
+ pwr_gating_latency = Param.Cycles(300,
+ "Latency to enter power gating state when all contexts are suspended")
function_trace = Param.Bool(False, "Enable function trace")
function_trace_start = Param.Tick(0, "Tick to start function trace")
/*
- * Copyright (c) 2011-2012,2016 ARM Limited
+ * Copyright (c) 2011-2012,2016-2017 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
functionTraceStream(nullptr), currentFunctionStart(0),
currentFunctionEnd(0), functionEntryTick(0),
addressMonitor(p->numThreads),
- syscallRetryLatency(p->syscallRetryLatency)
+ syscallRetryLatency(p->syscallRetryLatency),
+ pwrGatingLatency(p->pwr_gating_latency),
+ enterPwrGatingEvent([this]{ enterPwrGating(); }, name())
{
// if Python did not provide a valid ID, do it here
if (_cpuId == -1 ) {
new CPUProgressEvent(this, params()->progress_interval);
}
+ if (_switchedOut)
+ ClockedObject::pwrState(Enums::PwrState::OFF);
+
// Assumption CPU start to operate instantaneously without any latency
if (ClockedObject::pwrState() == Enums::PwrState::UNDEFINED)
ClockedObject::pwrState(Enums::PwrState::ON);
}
}
+void
+BaseCPU::deschedulePowerGatingEvent()
+{
+ if (enterPwrGatingEvent.scheduled()){
+ deschedule(enterPwrGatingEvent);
+ }
+}
+
+void
+BaseCPU::schedulePowerGatingEvent()
+{
+ for (auto tc : threadContexts) {
+ if (tc->status() == ThreadContext::Active)
+ return;
+ }
+
+ if (ClockedObject::pwrState() == Enums::PwrState::CLK_GATED) {
+ assert(!enterPwrGatingEvent.scheduled());
+ // Schedule a power gating event when clock gated for the specified
+ // amount of time
+ schedule(enterPwrGatingEvent, clockEdge(pwrGatingLatency));
+ }
+}
int
BaseCPU::findContext(ThreadContext *tc)
void
BaseCPU::activateContext(ThreadID thread_num)
{
+ // Squash enter power gating event while cpu gets activated
+ if (enterPwrGatingEvent.scheduled())
+ deschedule(enterPwrGatingEvent);
+
// For any active thread running, update CPU power state to active (ON)
ClockedObject::pwrState(Enums::PwrState::ON);
}
// All CPU threads suspended, enter lower power state for the CPU
ClockedObject::pwrState(Enums::PwrState::CLK_GATED);
+
+ //Schedule power gating event when clock gated for a configurable cycles
+ schedule(enterPwrGatingEvent, clockEdge(pwrGatingLatency));
+}
+
+void
+BaseCPU::enterPwrGating(void)
+{
+ ClockedObject::pwrState(Enums::PwrState::OFF);
}
void
// Flush all TLBs in the CPU to avoid having stale translations if
// it gets switched in later.
flushTLBs();
+
+ // Go to the power gating state
+ ClockedObject::pwrState(Enums::PwrState::OFF);
}
void
assert(oldCPU != this);
_pid = oldCPU->getPid();
_taskId = oldCPU->taskId();
+ // Take over the power state of the switchedOut CPU
+ ClockedObject::pwrState(oldCPU->pwrState());
_switchedOut = false;
ThreadID size = threadContexts.size();
/*
- * Copyright (c) 2011-2013 ARM Limited
+ * Copyright (c) 2011-2013, 2017 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
void registerThreadContexts();
+ // Functions to deschedule and reschedule the events to enter the
+ // power gating sleep before and after checkpoiting respectively.
+ void deschedulePowerGatingEvent();
+ void schedulePowerGatingEvent();
+
/**
* Prepare for another CPU to take over execution.
*
bool waitForRemoteGDB() const;
Cycles syscallRetryLatency;
+ // Enables CPU to enter power gating on a configurable cycle count
+ protected:
+ const Cycles pwrGatingLatency;
+ void enterPwrGating();
+ EventFunctionWrapper enterPwrGatingEvent;
};
#endif // THE_ISA == NULL_ISA
/*
- * Copyright (c) 2012-2014 ARM Limited
+ * Copyright (c) 2012-2014, 2017 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
DrainState
MinorCPU::drain()
{
+ // Deschedule any power gating event (if any)
+ deschedulePowerGatingEvent();
+
if (switchedOut()) {
DPRINTF(Drain, "Minor CPU switched out, draining not needed.\n");
return DrainState::Drained;
"'timing' mode.\n");
}
- for (ThreadID tid = 0; tid < numThreads; tid++)
+ for (ThreadID tid = 0; tid < numThreads; tid++){
wakeup(tid);
+ }
pipeline->drainResume();
+
+ // Reschedule any power gating event (if any)
+ schedulePowerGatingEvent();
}
void
DrainState
FullO3CPU<Impl>::drain()
{
+ // Deschedule any power gating event (if any)
+ deschedulePowerGatingEvent();
+
// If the CPU isn't doing anything, then return immediately.
if (switchedOut())
return DrainState::Drained;
assert(!tickEvent.scheduled());
if (_status == Running)
schedule(tickEvent, nextCycle());
+
+ // Reschedule any power gating event (if any)
+ schedulePowerGatingEvent();
}
template <class Impl>
/*
* Copyright 2014 Google, Inc.
- * Copyright (c) 2012-2013,2015 ARM Limited
+ * Copyright (c) 2012-2013,2015,2017 ARM Limited
* All rights reserved.
*
* The license below extends only to copyright in the software and shall
DrainState
AtomicSimpleCPU::drain()
{
+ // Deschedule any power gating event (if any)
+ deschedulePowerGatingEvent();
+
if (switchedOut())
return DrainState::Drained;
threadInfo[tid]->notIdleFraction = 0;
}
}
+
+ // Reschedule any power gating event (if any)
+ schedulePowerGatingEvent();
}
bool
/*
* Copyright 2014 Google, Inc.
- * Copyright (c) 2010-2013,2015 ARM Limited
+ * Copyright (c) 2010-2013,2015,2017 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
DrainState
TimingSimpleCPU::drain()
{
+ // Deschedule any power gating event (if any)
+ deschedulePowerGatingEvent();
+
if (switchedOut())
return DrainState::Drained;
}
}
+ // Reschedule any power gating event (if any)
+ schedulePowerGatingEvent();
+
system->totalNumInsts = 0;
}