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"
87 :
Event(
Event::Progress_Event_Pri), _interval(ival), lastNumInst(0),
88 cpu(_cpu), _repeatEvent(true)
109 DPRINTFN(
"%s progress event, total committed:%i, progress insts committed: "
114 cprintf(
"%lli: %s progress event, total committed:%i, progress insts "
124 return "CPU Progress";
129 _instRequestorId(
p.
system->getRequestorId(this,
"inst")),
130 _dataRequestorId(
p.
system->getRequestorId(this,
"data")),
131 _taskId(context_switch_task_id::
Unknown), _pid(invldPid),
132 _switchedOut(
p.switched_out), _cacheLineSize(
p.
system->cacheLineSize()),
134 previousCycle(0), previousState(CPU_STATE_SLEEP),
135 functionTraceStream(nullptr), currentFunctionStart(0),
136 currentFunctionEnd(0), functionEntryTick(0),
138 addressMonitor(
p.numThreads),
139 syscallRetryLatency(
p.syscallRetryLatency),
140 pwrGatingLatency(
p.pwr_gating_latency),
141 powerGatingOnIdle(
p.power_gating_on_idle),
146 _cpuId = cpuList.size();
150 cpuList.push_back(
this);
152 DPRINTF(SyscallVerbose,
"Constructing CPU with id %d, socket id %d\n",
158 functionTracingEnabled =
false;
159 if (
p.function_trace) {
160 const std::string fname =
csprintf(
"ftrace.%s",
name());
163 currentFunctionStart = currentFunctionEnd = 0;
164 functionEntryTick =
p.function_trace_start;
166 if (
p.function_trace_start == 0) {
167 functionTracingEnabled =
true;
169 Event *
event =
new EventFunctionWrapper(
170 [
this]{ enableFunctionTrace(); },
name(),
true);
171 schedule(
event,
p.function_trace_start);
175 tracer = params().tracer;
177 if (params().isa.size() != numThreads) {
178 fatal(
"Number of ISAs (%i) assigned to the CPU does not equal number "
179 "of threads (%i).\n", params().isa.size(), numThreads);
210 monitor.
armed =
true;
211 monitor.
vAddr = address;
213 DPRINTF(Mwait,
"[tid:%d] Armed monitor (vAddr=0x%lx)\n", tid, address);
224 uint64_t
mask = ~((uint64_t)(block_size - 1));
226 assert(pkt->
req->hasPaddr());
230 DPRINTF(Mwait,
"[tid:%d] mwait called (vAddr=0x%lx, "
231 "line's paddr=0x%lx)\n", tid, monitor.
vAddr, monitor.
pAddr);
249 uint64_t
mask = ~((uint64_t)(block_size - 1));
250 int size = block_size;
255 if (secondAddr >
addr)
256 size = secondAddr -
addr;
267 DPRINTF(Mwait,
"[tid:%d] mwait called (vAddr=0x%lx, line's paddr=0x%lx)\n",
276 if (
params().max_insts_any_thread != 0) {
277 const char *cause =
"a thread reached the max instruction count";
286 if (!
params().simpoint_start_insts.empty()) {
287 const char *cause =
"simpoint starting point found";
288 for (
size_t i = 0;
i <
params().simpoint_start_insts.size(); ++
i)
292 if (
params().max_insts_all_threads != 0) {
293 const char *cause =
"all threads reached the max instruction count";
298 int *counter =
new int;
307 if (!
params().switched_out) {
317 if (
params().progress_interval) {
375 : statistics::
Group(parent),
376 ADD_STAT(numCycles, statistics::units::Cycle::get(),
377 "Number of cpu cycles simulated"),
378 ADD_STAT(numWorkItemsStarted, statistics::units::Count::get(),
379 "Number of work items this cpu started"),
380 ADD_STAT(numWorkItemsCompleted, statistics::units::Count::get(),
381 "Number of work items this cpu completed")
396 using namespace statistics;
400 for (
int i = 0;
i < size; ++
i) {
401 std::stringstream namestr;
405 }
else if (size == 1)
415 if (if_name ==
"dcache_port")
417 else if (if_name ==
"icache_port")
429 "CPU %s has %i interrupt controllers, but is expecting one "
434 for (
ThreadID tid = 0; tid < size; ++tid) {
480 for (
ThreadID tid = 0; tid < size; ++tid) {
490 DPRINTF(Thread,
"activate contextId %d\n",
504 DPRINTF(Thread,
"suspend contextId %d\n",
559 assert(oldCPU !=
this);
596 if (old_checker && new_checker) {
689 assert(pkt->
req->hasPaddr());
690 if (armed && waiting) {
692 DPRINTF(Mwait,
"pAddr=0x%lx invalidated: waking up core\n",
733 : statistics::
Group(parent),
734 ADD_STAT(simInsts, statistics::units::Count::get(),
735 "Number of instructions simulated"),
736 ADD_STAT(simOps, statistics::units::Count::get(),
737 "Number of ops (including micro ops) simulated"),
738 ADD_STAT(hostInstRate, statistics::units::Rate<
739 statistics::units::Count, statistics::units::Second>::get(),
740 "Simulator instruction rate (inst/s)"),
741 ADD_STAT(hostOpRate, statistics::units::Rate<
742 statistics::units::Count, statistics::units::Second>::get(),
743 "Simulator op (including micro ops) rate (op/s)")
CPUProgressEvent(BaseCPU *_cpu, Tick ival=0)
Tick curTick()
The universal simulation clock.
#define fatal(...)
This implements a cprintf based fatal() function.
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
void assignThreadContext(ContextID context_id)
virtual Port & getPort(const std::string &if_name, PortID idx=InvalidPortID)
Get a port with a given name and index.
Addr currentFunctionStart
int maxThreadsPerCPU
The maximum number of active threads across all cpus.
void armMonitor(ThreadID tid, Addr address)
std::ostream * functionTraceStream
constexpr decltype(nullptr) NoFault
bool switchedOut() const
Determine if the CPU is switched out.
std::vector< BaseInterrupts * > interrupts
virtual Port & getInstPort()=0
Purely virtual method that returns a reference to the instruction port.
void cprintf(const char *format, const Args &...args)
void mwaitAtomic(ThreadID tid, ThreadContext *tc, BaseMMU *mmu)
ProbePointArg< bool > * ppSleeping
ProbePoint that signals transitions of threadContexts sets.
void startup() override
startup() is the final initialization call before simulation.
#define UNSERIALIZE_SCALAR(scalar)
BaseCPUStats(statistics::Group *parent)
Static instruction class for unknown (illegal) instructions.
void enableFunctionTrace()
virtual void unserializeThread(CheckpointIn &cp, ThreadID tid)
Unserialize one thread.
statistics::Formula hostOpRate
void unserialize(CheckpointIn &cp) override
Reconstruct the state of this object from a checkpoint.
RequestPtr req
A pointer to the original request.
probing::PMUUPtr ppRetiredInsts
Instruction commit probe point.
probing::PMUUPtr pmuProbePoint(const char *name)
Helper method to instantiate probe points belonging to this object.
unsigned int cacheLineSize() const
Get the cache line size of the system.
virtual BaseMMU * getMMUPtr()=0
bool doMonitor(PacketPtr pkt)
void updateCycleCounters(CPUState state)
base method keeping track of cycle progression
Global CPU statistics that are merged into the Root object.
BaseCPU(const Params ¶ms, bool is_checker=false)
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
enums::PwrState get() const
virtual ContextID contextId() const =0
static std::vector< BaseCPU * > cpuList
Static global cpu list.
static Counter numSimulatedOps()
void schedule(Event &event, Tick when)
virtual Addr instAddr() const =0
std::string csprintf(const char *format, const Args &...args)
void takeOverFrom(Port *old)
A utility function to make it easier to swap out ports.
void schedulePowerGatingEvent()
OutputStream * findOrCreate(const std::string &name, bool binary=false)
void ccprintf(cp::Print &print)
uint32_t _taskId
An intrenal representation of a task identifier within gem5.
constexpr uint64_t mask(unsigned nbits)
Generate a 64-bit mask of 'nbits' 1s, right justified.
probing::PMUUPtr ppAllCycles
CPU cycle counter even if any thread Context is suspended.
ThreadID numThreads
Number of threads we're actually simulating (<= SMT_MAX_THREADS).
virtual void serializeThread(CheckpointOut &cp, ThreadID tid) const
Serialize a single thread.
void regStats() override
Callback to set stat parameters.
probing::PMUUPtr ppRetiredInstsPC
virtual void wakeup(ThreadID tid)=0
virtual Port & getDataPort()=0
Purely virtual method that returns a reference to the data port.
void deschedulePowerGatingEvent()
std::ostream * stream() const
Get the output underlying output stream.
virtual const char * description() const
Return a C string describing the event.
virtual void suspendContext(ThreadID thread_num)
Notify the CPU that the indicated context is now suspended.
void registerThreadContexts()
uint32_t taskId() const
Get cpu task id.
statistics::Value simInsts
probing::PMUUPtr ppRetiredStores
Retired store instructions.
void scheduleInstStop(ThreadID tid, Counter insts, const char *cause)
Schedule an event that exits the simulation loops after a predefined number of instructions.
virtual BaseISA * getIsaPtr()=0
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual std::string name() const
std::shared_ptr< FaultBase > Fault
void flushTLBs()
Flush all TLBs in the CPU.
const Params & params() const
std::unique_ptr< PMU > PMUUPtr
const Cycles pwrGatingLatency
@ Suspended
Temporarily inactive.
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
uint64_t Tick
Tick count type.
virtual void haltContext(ThreadID thread_num)
Notify the CPU that the indicated context is now halted.
statistics::Formula hostInstRate
std::shared_ptr< Request > RequestPtr
void regProbePoints() override
Register probe points for this object.
virtual void setThreadContext(ThreadContext *_tc)
void serialize(CheckpointOut &cp) const override
Serialize this object to the given output stream.
const_iterator findNearest(Addr addr, Addr &next_addr) const
Find the nearest symbol equal to or less than the supplied address (e.g., the label for the enclosing...
virtual Counter totalOps() const =0
int findContext(ThreadContext *tc)
Given a Thread Context pointer return the thread num.
Derived & functor(const T &func)
virtual void takeOverFrom(ThreadContext *old_context)=0
static constexpr T roundDown(const T &val, const U &align)
This function is used to align addresses in memory.
static Counter numSimulatedInsts()
bool functionTracingEnabled
Derived & precision(int _precision)
Set the precision and marks this stat to print at the end of simulation.
void postInterrupt(ThreadID tid, int int_num, int index)
EventFunctionWrapper enterPwrGatingEvent
virtual void probeInstCommit(const StaticInstPtr &inst, Addr pc)
Helper method to trigger PMU probes for a committed instruction.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
const std::string & name()
bool isLastMicroop() const
#define SERIALIZE_SCALAR(scalar)
virtual void regStats()
Callback to set stat parameters.
Tick instCnt
Instruction count used for SPARC misc register.
GlobalStats(statistics::Group *parent)
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 ...
bool _switchedOut
Is the CPU switched out or active?
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...
void deschedule(Event &event)
ProbePointArg generates a point for the class of Arg.
virtual Process * getProcessPtr()=0
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
ProbeManager * getProbeManager()
Get the probe manager for this object.
std::vector< ThreadContext * > threadContexts
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...
virtual void activateContext(ThreadID thread_num)
Notify the CPU that the indicated context is now active.
Ports are used to interface objects to each other.
Derived & prereq(const Stat &prereq)
Set the prerequisite stat and marks this stat to print at the end of simulation.
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port on this CPU.
int cpuId() const
Reads this CPU's ID.
virtual void verifyMemoryMode() const
Verify that the system is in a memory mode supported by the CPU.
probing::PMUUPtr ppRetiredLoads
Retired load instructions.
double Counter
All counters are of 64-bit values.
void traceFunctionsInternal(Addr pc)
virtual void switchOut()
Prepare for another CPU to take over execution.
uint64_t getCurrentInstCount(ThreadID tid)
Get the number of instructions executed by the specified thread on this CPU.
void registerThreadContext(ThreadContext *tc, ContextID assigned=InvalidContextID)
std::ostream CheckpointOut
void replaceThreadContext(ThreadContext *tc, ContextID context_id)
virtual int threadId() const =0
RequestorID dataRequestorId() const
Reads this CPU's unique data requestor ID.
ClockedObjectParams Params
Parameters of ClockedObject.
bool mwait(ThreadID tid, PacketPtr pkt)
SymbolTable debugSymbolTable
Global unified debugging symbol table (for target).
probing::PMUUPtr ppActiveCycles
CPU cycle counter, only counts if any thread contexts is active.
Fault translateAtomic(const RequestPtr &req, ThreadContext *tc, Mode mode)
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
void set(enums::PwrState p)
Change the power state of this object to the power state p.
statistics::Value & hostSeconds
virtual void takeOverFrom(BaseMMU *old_mmu)
probing::PMUUPtr ppRetiredBranches
Retired branches (any type)
virtual CheckerCPU * getCheckerCpuPtr()=0
uint32_t _pid
The current OS process ID that is executing on this processor.
static Root * root()
Use this function to get a pointer to the single Root object in the simulation.
const bool powerGatingOnIdle
static std::unique_ptr< GlobalStats > globalStats
Pointer to the global stat structure.
bool scheduled() const
Determine if the current event is scheduled.
int16_t ThreadID
Thread index/ID type.
std::vector< AddressMonitor > addressMonitor
Generated on Tue Sep 7 2021 14:53:43 for gem5 by doxygen 1.8.17