Go to the documentation of this file.
58 #include "debug/Mwait.hh"
59 #include "debug/SyscallVerbose.hh"
60 #include "debug/Thread.hh"
62 #include "params/BaseCPU.hh"
83 :
Event(
Event::Progress_Event_Pri), _interval(ival), lastNumInst(0),
84 cpu(_cpu), _repeatEvent(true)
105 DPRINTFN(
"%s progress event, total committed:%i, progress insts committed: "
110 cprintf(
"%lli: %s progress event, total committed:%i, progress insts "
111 "committed: %lli\n",
curTick(),
cpu->name(), temp,
120 return "CPU Progress";
125 _instRequestorId(
p->
system->getRequestorId(this,
"inst")),
126 _dataRequestorId(
p->
system->getRequestorId(this,
"data")),
128 _switchedOut(
p->switched_out), _cacheLineSize(
p->
system->cacheLineSize()),
129 interrupts(
p->interrupts), numThreads(
p->numThreads),
system(
p->
system),
130 previousCycle(0), previousState(CPU_STATE_SLEEP),
131 functionTraceStream(nullptr), currentFunctionStart(0),
132 currentFunctionEnd(0), functionEntryTick(0),
133 addressMonitor(
p->numThreads),
134 syscallRetryLatency(
p->syscallRetryLatency),
135 pwrGatingLatency(
p->pwr_gating_latency),
136 powerGatingOnIdle(
p->power_gating_on_idle),
141 _cpuId = cpuList.size();
145 cpuList.push_back(
this);
147 DPRINTF(SyscallVerbose,
"Constructing CPU with id %d, socket id %d\n",
153 functionTracingEnabled =
false;
154 if (
p->function_trace) {
158 currentFunctionStart = currentFunctionEnd = 0;
159 functionEntryTick =
p->function_trace_start;
161 if (
p->function_trace_start == 0) {
162 functionTracingEnabled =
true;
165 [
this]{ enableFunctionTrace(); },
name(),
true);
166 schedule(
event,
p->function_trace_start);
170 tracer = params()->tracer;
172 if (params()->isa.size() != numThreads) {
173 fatal(
"Number of ISAs (%i) assigned to the CPU does not equal number "
174 "of threads (%i).\n", params()->isa.size(), numThreads);
205 monitor.
armed =
true;
206 monitor.
vAddr = address;
208 DPRINTF(Mwait,
"[tid:%d] Armed monitor (vAddr=0x%lx)\n", tid, address);
219 uint64_t
mask = ~((uint64_t)(block_size - 1));
221 assert(pkt->
req->hasPaddr());
225 DPRINTF(Mwait,
"[tid:%d] mwait called (vAddr=0x%lx, "
226 "line's paddr=0x%lx)\n", tid, monitor.
vAddr, monitor.
pAddr);
244 uint64_t
mask = ~((uint64_t)(block_size - 1));
245 int size = block_size;
250 if (secondAddr >
addr)
251 size = secondAddr -
addr;
262 DPRINTF(Mwait,
"[tid:%d] mwait called (vAddr=0x%lx, line's paddr=0x%lx)\n",
271 if (
params()->max_insts_any_thread != 0) {
272 const char *cause =
"a thread reached the max instruction count";
281 if (!
params()->simpoint_start_insts.empty()) {
282 const char *cause =
"simpoint starting point found";
283 for (
size_t i = 0;
i <
params()->simpoint_start_insts.size(); ++
i)
287 if (
params()->max_insts_all_threads != 0) {
288 const char *cause =
"all threads reached the max instruction count";
293 int *counter =
new int;
302 if (!
params()->switched_out) {
312 if (
params()->progress_interval) {
320 if (powerState->get() == Enums::PwrState::UNDEFINED)
321 powerState->set(Enums::PwrState::ON);
373 using namespace Stats;
377 .
desc(
"number of cpu cycles simulated")
381 .
name(
name() +
".numWorkItemsStarted")
382 .
desc(
"number of work items this cpu started")
386 .
name(
name() +
".numWorkItemsCompleted")
387 .
desc(
"number of work items this cpu completed")
392 for (
int i = 0;
i < size; ++
i) {
393 stringstream namestr;
397 }
else if (size == 1)
407 if (if_name ==
"dcache_port")
409 else if (if_name ==
"icache_port")
421 "CPU %s has %i interrupt controllers, but is expecting one "
426 for (
ThreadID tid = 0; tid < size; ++tid) {
459 if (powerState->get() == Enums::PwrState::CLK_GATED &&
472 for (
ThreadID tid = 0; tid < size; ++tid) {
482 DPRINTF(Thread,
"activate contextId %d\n",
488 powerState->set(Enums::PwrState::ON);
496 DPRINTF(Thread,
"suspend contextId %d\n",
509 powerState->set(Enums::PwrState::CLK_GATED);
551 assert(oldCPU !=
this);
555 powerState->set(oldCPU->powerState->get());
599 if (oldChecker && newChecker) {
600 Port *old_checker_itb_port =
602 Port *old_checker_dtb_port =
604 Port *new_checker_itb_port =
606 Port *new_checker_dtb_port =
613 if (new_checker_itb_port)
614 new_checker_itb_port->
takeOverFrom(old_checker_itb_port);
615 if (new_checker_dtb_port)
616 new_checker_dtb_port->
takeOverFrom(old_checker_dtb_port);
664 ScopedCheckpointSection sec(
cp,
csprintf(
"xc.%i",
i));
681 ScopedCheckpointSection sec(
cp,
csprintf(
"xc.%i",
i));
710 assert(pkt->
req->hasPaddr());
711 if (armed && waiting) {
713 DPRINTF(Mwait,
"pAddr=0x%lx invalidated: waking up core\n",
755 return params()->wait_for_remote_gdb;
#define fatal(...)
This implements a cprintf based fatal() function.
bool mwait(ThreadID tid, PacketPtr pkt)
virtual void regStats()
Callback to set stat parameters.
ProbePoints::PMUUPtr ppRetiredInstsPC
bool scheduled() const
Determine if the current event is scheduled.
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port on this CPU.
const_iterator findNearest(Addr addr, Addr &nextaddr) const
Find the nearest symbol equal to or less than the supplied address (e.g., the label for the enclosing...
T roundDown(const T &val, const U &align)
This function is used to align addresses in memory.
CPUProgressEvent(BaseCPU *_cpu, Tick ival=0)
void flushTLBs()
Flush all TLBs in the CPU.
virtual void serializeThread(CheckpointOut &cp, ThreadID tid) const
Serialize a single thread.
bool functionTracingEnabled
uint64_t getCurrentInstCount(ThreadID tid)
Get the number of instructions executed by the specified thread on this CPU.
virtual void setContextId(ContextID id)=0
ProbePoints::PMUUPtr ppRetiredBranches
Retired branches (any type)
virtual void verifyMemoryMode() const
Verify that the system is in a memory mode supported by the CPU.
virtual void takeOverFrom(BaseTLB *otlb)=0
Take over from an old tlb context.
virtual Fault translateAtomic(const RequestPtr &req, ThreadContext *tc, Mode mode)=0
#define UNSERIALIZE_SCALAR(scalar)
uint32_t _pid
The current OS process ID that is executing on this processor.
void assignThreadContext(ContextID context_id)
virtual Port & getDataPort()=0
Purely virtual method that returns a reference to the data port.
int16_t ThreadID
Thread index/ID type.
ProbePoints::PMUUPtr ppAllCycles
CPU cycle counter even if any thread Context is suspended.
virtual void setThreadContext(ThreadContext *_tc)
bool doMonitor(PacketPtr pkt)
virtual const char * description() const
Return a C string describing the event.
unsigned int cacheLineSize() const
Get the cache line size of the system.
ProbePointArg generates a point for the class of Arg.
void armMonitor(ThreadID tid, Addr address)
uint64_t Tick
Tick count type.
ContextID registerThreadContext(ThreadContext *tc, ContextID assigned=InvalidContextID)
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
std::shared_ptr< Request > RequestPtr
RequestPtr req
A pointer to the original request.
static void wakeup(ThreadID tid)
void mwaitAtomic(ThreadID tid, ThreadContext *tc, BaseTLB *dtb)
void enableFunctionTrace()
void postInterrupt(ThreadID tid, int int_num, int index)
void registerThreadContexts()
void deschedulePowerGatingEvent()
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
virtual Process * getProcessPtr()=0
virtual Counter totalOps() const =0
void replaceThreadContext(ThreadContext *tc, ContextID context_id)
ProbePoints::PMUUPtr ppRetiredLoads
Retired load instructions.
void takeOverFrom(Port *old)
A utility function to make it easier to swap out ports.
virtual int threadId() const =0
bool is_waiting(ThreadContext *tc)
Determine if the given thread context is currently waiting on a futex wait operation on any of the fu...
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
void updateCycleCounters(CPUState state)
base method keeping track of cycle progression
virtual BaseISA * getIsaPtr()=0
int64_t Counter
Statistics counter type.
OutputStream * findOrCreate(const std::string &name, bool binary=false)
int findContext(ThreadContext *tc)
Given a Thread Context pointer return the thread num.
SymbolTable debugSymbolTable
Global unified debugging symbol table (for target).
virtual void takeOverFrom(ThreadContext *old_context)=0
ThreadContext is the external interface to all thread state for anything outside of the CPU.
void traceFunctionsInternal(Addr pc)
virtual Port & getPort(const std::string &if_name, PortID idx=InvalidPortID)
Get a port with a given name and index.
void cprintf(const char *format, const Args &...args)
std::ostream * stream() const
Get the output underlying output stream.
Tick instCnt
Instruction count used for SPARC misc register.
std::shared_ptr< FaultBase > Fault
std::vector< BaseInterrupts * > interrupts
Stats::Scalar numWorkItemsStarted
BaseCPU(Params *params, bool is_checker=false)
Ports are used to interface objects to each other.
uint32_t _taskId
An intrenal representation of a task identifier within gem5.
ProbePoints::PMUUPtr ppActiveCycles
CPU cycle counter, only counts if any thread contexts is active.
std::vector< ThreadContext * > threadContexts
void serialize(CheckpointOut &cp) const override
Serialize this object to the given output stream.
virtual void activateContext(ThreadID thread_num)
Notify the CPU that the indicated context is now active.
ProbePoints::PMUUPtr pmuProbePoint(const char *name)
Helper method to instantiate probe points belonging to this object.
virtual ContextID contextId() const =0
virtual Port * getTableWalkerPort()
Get the table walker port if present.
ProbePoints::PMUUPtr ppRetiredStores
Retired store instructions.
Special TaskIds that are used for per-context-switch stats dumps and Cache Occupancy.
constexpr decltype(nullptr) NoFault
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
const Params * params() const
Derived & name(const std::string &name)
Set the name and marks this stat to print at the end of simulation.
ProbePoints::PMUUPtr ppRetiredInsts
Instruction commit probe point.
const std::string & name()
#define SERIALIZE_SCALAR(scalar)
virtual BaseTLB * getITBPtr()=0
std::unique_ptr< PMU > PMUUPtr
uint32_t taskId() const
Get cpu task id.
bool isLastMicroop() const
@ Suspended
Temporarily inactive.
const Cycles pwrGatingLatency
virtual void haltContext(ThreadID thread_num)
Notify the CPU that the indicated context is now halted.
Overload hash function for BasicBlockRange type.
void schedulePowerGatingEvent()
virtual void takeOverFrom(BaseCPU *cpu)
Load the state of a CPU from the previous CPU object, invoked on all new CPUs that are about to be sw...
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
virtual void switchOut()
Prepare for another CPU to take over execution.
virtual CheckerCPU * getCheckerCpuPtr()=0
int maxThreadsPerCPU
The maximum number of active threads across all cpus.
ThreadID numThreads
Number of threads we're actually simulating (<= SMT_MAX_THREADS).
void ccprintf(cp::Print &print)
RequestorID dataRequestorId() const
Reads this CPU's unique data requestor ID.
std::ostream * functionTraceStream
void scheduleInstStop(ThreadID tid, Counter insts, const char *cause)
Schedule an event that exits the simulation loops after a predefined number of instructions.
std::ostream CheckpointOut
static std::vector< BaseCPU * > cpuList
Static global cpu list.
void regProbePoints() override
virtual void suspendContext(ThreadID thread_num)
Notify the CPU that the indicated context is now suspended.
EventFunctionWrapper enterPwrGatingEvent
Stats::Scalar numWorkItemsCompleted
Addr currentFunctionStart
std::vector< AddressMonitor > addressMonitor
virtual void unserializeThread(CheckpointIn &cp, ThreadID tid)
Unserialize one thread.
bool switchedOut() const
Determine if the CPU is switched out.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
bool _switchedOut
Is the CPU switched out or active?
void unserialize(CheckpointIn &cp) override
Reconstruct the state of this object from a checkpoint.
Derived & desc(const std::string &_desc)
Set the description and marks this stat to print at the end of simulation.
virtual void probeInstCommit(const StaticInstPtr &inst, Addr pc)
Helper method to trigger PMU probes for a committed instruction.
virtual Port & getInstPort()=0
Purely virtual method that returns a reference to the instruction port.
virtual Addr instAddr() const =0
bool waitForRemoteGDB() const
std::string csprintf(const char *format, const Args &...args)
int cpuId() const
Reads this CPU's ID.
virtual void flushAll()=0
Remove all entries from the TLB.
virtual BaseTLB * getDTBPtr()=0
ProbePointArg< bool > * ppSleeping
ProbePoint that signals transitions of threadContexts sets.
Tick curTick()
The current simulated tick.
const bool powerGatingOnIdle
Generated on Wed Sep 30 2020 14:02:08 for gem5 by doxygen 1.8.17