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"
84 :
Event(
Event::Progress_Event_Pri), _interval(ival), lastNumInst(0),
85 cpu(_cpu), _repeatEvent(true)
106 DPRINTFN(
"%s progress event, total committed:%i, progress insts committed: "
111 cprintf(
"%lli: %s progress event, total committed:%i, progress insts "
121 return "CPU Progress";
126 _instRequestorId(
p.
system->getRequestorId(this,
"inst")),
127 _dataRequestorId(
p.
system->getRequestorId(this,
"data")),
129 _switchedOut(
p.switched_out), _cacheLineSize(
p.
system->cacheLineSize()),
131 previousCycle(0), previousState(CPU_STATE_SLEEP),
132 functionTraceStream(nullptr), currentFunctionStart(0),
133 currentFunctionEnd(0), functionEntryTick(0),
135 addressMonitor(
p.numThreads),
136 syscallRetryLatency(
p.syscallRetryLatency),
137 pwrGatingLatency(
p.pwr_gating_latency),
138 powerGatingOnIdle(
p.power_gating_on_idle),
143 _cpuId = cpuList.size();
147 cpuList.push_back(
this);
149 DPRINTF(SyscallVerbose,
"Constructing CPU with id %d, socket id %d\n",
155 functionTracingEnabled =
false;
156 if (
p.function_trace) {
157 const std::string fname =
csprintf(
"ftrace.%s",
name());
160 currentFunctionStart = currentFunctionEnd = 0;
161 functionEntryTick =
p.function_trace_start;
163 if (
p.function_trace_start == 0) {
164 functionTracingEnabled =
true;
167 [
this]{ enableFunctionTrace(); },
name(),
true);
168 schedule(
event,
p.function_trace_start);
172 tracer = params().tracer;
174 if (params().isa.size() != numThreads) {
175 fatal(
"Number of ISAs (%i) assigned to the CPU does not equal number "
176 "of threads (%i).\n", params().isa.size(), numThreads);
207 monitor.
armed =
true;
208 monitor.
vAddr = address;
210 DPRINTF(Mwait,
"[tid:%d] Armed monitor (vAddr=0x%lx)\n", tid, address);
221 uint64_t
mask = ~((uint64_t)(block_size - 1));
223 assert(pkt->
req->hasPaddr());
227 DPRINTF(Mwait,
"[tid:%d] mwait called (vAddr=0x%lx, "
228 "line's paddr=0x%lx)\n", tid, monitor.
vAddr, monitor.
pAddr);
246 uint64_t
mask = ~((uint64_t)(block_size - 1));
247 int size = block_size;
252 if (secondAddr >
addr)
253 size = secondAddr -
addr;
264 DPRINTF(Mwait,
"[tid:%d] mwait called (vAddr=0x%lx, line's paddr=0x%lx)\n",
273 if (
params().max_insts_any_thread != 0) {
274 const char *cause =
"a thread reached the max instruction count";
283 if (!
params().simpoint_start_insts.empty()) {
284 const char *cause =
"simpoint starting point found";
285 for (
size_t i = 0;
i <
params().simpoint_start_insts.size(); ++
i)
289 if (
params().max_insts_all_threads != 0) {
290 const char *cause =
"all threads reached the max instruction count";
295 int *counter =
new int;
304 if (!
params().switched_out) {
314 if (
params().progress_interval) {
372 :
Stats::Group(parent),
375 "Number of work items this cpu started"),
377 "Number of work items this cpu completed")
392 using namespace Stats;
396 for (
int i = 0;
i < size; ++
i) {
397 std::stringstream namestr;
401 }
else if (size == 1)
411 if (if_name ==
"dcache_port")
413 else if (if_name ==
"icache_port")
425 "CPU %s has %i interrupt controllers, but is expecting one "
430 for (
ThreadID tid = 0; tid < size; ++tid) {
476 for (
ThreadID tid = 0; tid < size; ++tid) {
486 DPRINTF(Thread,
"activate contextId %d\n",
500 DPRINTF(Thread,
"suspend contextId %d\n",
555 assert(oldCPU !=
this);
592 if (old_checker && new_checker) {
685 assert(pkt->
req->hasPaddr());
686 if (armed && waiting) {
688 DPRINTF(Mwait,
"pAddr=0x%lx invalidated: waking up core\n",
730 return params().wait_for_remote_gdb;
738 "Number of ops (including micro ops) simulated"),
741 "Simulator instruction rate (inst/s)"),
744 "Simulator op (including micro ops) rate (op/s)")
#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.
static Root * root()
Use this function to get a pointer to the single Root object in the simulation.
void regStats() override
Callback to set stat parameters.
void mwaitAtomic(ThreadID tid, ThreadContext *tc, BaseMMU *mmu)
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.
#define UNSERIALIZE_SCALAR(scalar)
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
uint32_t _pid
The current OS process ID that is executing on this processor.
virtual void wakeup(ThreadID tid)=0
void set(Enums::PwrState p)
Change the power state of this object to the power state p.
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)
virtual BaseMMU * getMMUPtr()=0
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.
Derived & functor(const T &func)
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.
void enableFunctionTrace()
void postInterrupt(ThreadID tid, int int_num, int index)
void deschedule(Event &event)
BaseCPUStats(Stats::Group *parent)
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).
void schedule(Event &event, Tick when)
virtual void takeOverFrom(ThreadContext *old_context)=0
ThreadContext is the external interface to all thread state for anything outside of the CPU.
ClockedObjectParams Params
Parameters of ClockedObject.
static std::vector< BaseCPU * > cpuList
Static global cpu list.
Derived & prereq(const Stat &prereq)
Set the prerequisite stat and marks this stat to print at the end of simulation.
virtual void takeOverFrom(BaseMMU *old_mmu)
void traceFunctionsInternal(Addr pc)
virtual Port & getPort(const std::string &if_name, PortID idx=InvalidPortID)
Get a port with a given name and index.
static Counter numSimulatedInsts()
void cprintf(const char *format, const Args &...args)
std::ostream * stream() const
Get the output underlying output stream.
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
Tick instCnt
Instruction count used for SPARC misc register.
std::shared_ptr< FaultBase > Fault
std::vector< BaseInterrupts * > interrupts
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
Tick clockEdge(Cycles cycles=Cycles(0)) const
Determine the tick when a cycle begins, by default the current one, but the argument also enables the...
Enums::PwrState get() const
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.
Fault translateAtomic(const RequestPtr &req, ThreadContext *tc, BaseTLB::Mode mode)
virtual ContextID contextId() const =0
ProbePoints::PMUUPtr ppRetiredStores
Retired store instructions.
Stats::Value & hostSeconds
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.
ProbePoints::PMUUPtr ppRetiredInsts
Instruction commit probe point.
const std::string & name()
#define SERIALIZE_SCALAR(scalar)
::Stats::Formula hostInstRate
ProbeManager * getProbeManager()
Get the probe manager for this object.
std::unique_ptr< PMU > PMUUPtr
uint32_t taskId() const
Get cpu task id.
virtual const std::string name() const
#define UNIT_RATE(T1, T2)
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.
static std::unique_ptr< GlobalStats > globalStats
Pointer to the global stat structure.
Derived & precision(int _precision)
Set the precision and marks this stat to print at the end of simulation.
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.
GlobalStats(::Stats::Group *parent)
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.
#define UNIT_CYCLE
Convenience macros to declare the unit of a stat.
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 Counter numSimulatedOps()
void startup() override
startup() is the final initialization call before simulation.
void regProbePoints() override
Register probe points for this object.
virtual void suspendContext(ThreadID thread_num)
Notify the CPU that the indicated context is now suspended.
EventFunctionWrapper enterPwrGatingEvent
Tick curTick()
The universal simulation clock.
Addr currentFunctionStart
const Params & params() const
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.
BaseCPU(const Params ¶ms, bool is_checker=false)
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.
ProbePointArg< bool > * ppSleeping
ProbePoint that signals transitions of threadContexts sets.
::Stats::Formula hostOpRate
Global CPU statistics that are merged into the Root object.
const bool powerGatingOnIdle
Generated on Tue Mar 23 2021 19:41:24 for gem5 by doxygen 1.8.17