46 #include "arch/kernel_stats.hh"
47 #include "arch/stacktrace.hh"
48 #include "arch/tlb.hh"
49 #include "arch/utility.hh"
50 #include "arch/vtophys.hh"
59 #include "config/the_isa.hh"
71 #include "debug/Decode.hh"
72 #include "debug/Fetch.hh"
73 #include "debug/Quiesce.hh"
77 #include "params/BaseSimpleCPU.hh"
88 using namespace TheISA;
93 branchPred(p->branchPred),
100 for (
unsigned i = 0;
i < numThreads;
i++) {
103 p->itb, p->dtb, p->isa[
i]);
106 p->itb, p->dtb, p->isa[
i]);
110 threadContexts.push_back(tc);
115 fatal(
"Checker currently does not support SMT");
117 BaseCPU *temp_checker = p->checker;
133 for (
auto tc : threadContexts) {
135 tc->initMemProxies(tc);
152 }
while (oldpc != pc);
158 if (numThreads > 1) {
192 total_inst += t_info->numInst;
203 total_op += t_info->numOp;
217 suspendContext(thread_num);
224 using namespace Stats;
228 for (
ThreadID tid = 0; tid < numThreads; tid++) {
231 std::string thread_str =
name();
233 thread_str +=
".thread" + std::to_string(tid);
236 .
name(thread_str +
".committedInsts")
237 .
desc(
"Number of instructions committed")
241 .
name(thread_str +
".committedOps")
242 .
desc(
"Number of ops (including micro ops) committed")
246 .
name(thread_str +
".num_int_alu_accesses")
247 .
desc(
"Number of integer alu accesses")
251 .
name(thread_str +
".num_fp_alu_accesses")
252 .
desc(
"Number of float alu accesses")
256 .
name(thread_str +
".num_func_calls")
257 .
desc(
"number of times a function call or return occured")
261 .
name(thread_str +
".num_conditional_control_insts")
262 .
desc(
"number of instructions that are conditional controls")
266 .
name(thread_str +
".num_int_insts")
267 .
desc(
"number of integer instructions")
271 .
name(thread_str +
".num_fp_insts")
272 .
desc(
"number of float instructions")
276 .
name(thread_str +
".num_int_register_reads")
277 .
desc(
"number of times the integer registers were read")
281 .
name(thread_str +
".num_int_register_writes")
282 .
desc(
"number of times the integer registers were written")
286 .
name(thread_str +
".num_fp_register_reads")
287 .
desc(
"number of times the floating registers were read")
291 .
name(thread_str +
".num_fp_register_writes")
292 .
desc(
"number of times the floating registers were written")
296 .
name(thread_str +
".num_cc_register_reads")
297 .
desc(
"number of times the CC registers were read")
302 .
name(thread_str +
".num_cc_register_writes")
303 .
desc(
"number of times the CC registers were written")
308 .
name(thread_str +
".num_mem_refs")
309 .
desc(
"number of memory refs")
313 .
name(thread_str +
".num_store_insts")
314 .
desc(
"Number of store instructions")
318 .
name(thread_str +
".num_load_insts")
319 .
desc(
"Number of load instructions")
323 .
name(thread_str +
".not_idle_fraction")
324 .
desc(
"Percentage of non-idle cycles")
328 .
name(thread_str +
".idle_fraction")
329 .
desc(
"Percentage of idle cycles")
333 .
name(thread_str +
".num_busy_cycles")
334 .
desc(
"Number of busy cycles")
338 .
name(thread_str +
".num_idle_cycles")
339 .
desc(
"Number of idle cycles")
343 .
name(thread_str +
".icache_stall_cycles")
344 .
desc(
"ICache total stall cycles")
349 .
name(thread_str +
".dcache_stall_cycles")
350 .
desc(
"DCache total stall cycles")
355 .
init(Enums::Num_OpClass)
356 .
name(thread_str +
".op_class")
357 .
desc(
"Class of executed instruction")
370 .
name(thread_str +
".Branches")
371 .
desc(
"Number of branches fetched")
375 .
name(thread_str +
".predictedBranches")
376 .
desc(
"Number of branches predicted as taken")
380 .
name(thread_str +
".BranchMispred")
381 .
desc(
"Number of branch mispredictions")
422 getCpuAddrMonitor(tid)->gotWakeup =
true;
425 DPRINTF(Quiesce,
"[tid:%d] Suspended Processor awoke\n", tid);
437 if (checkInterrupts(tc)) {
442 interrupts[
curThread]->updateIntrInfo(tc);
443 interrupt->invoke(tc);
459 DPRINTF(Fetch,
"Fetch: PC:%08p\n", instAddr);
475 #if THE_ISA == ALPHA_ISA
481 system->instEventQueue.serviceEvents(
system->totalNumInsts);
496 TheISA::Decoder *decoder = &(thread->
decoder);
502 decoder->moreBytes(pcState, fetchPC,
inst);
508 instPtr = decoder->decode(pcState);
537 DPRINTF(Decode,
"Decode: Decoded %s instruction: %#x\n",
548 const bool predict_taken(
566 Addr instAddr = pc.instAddr();
569 thread->
profilePC = usermode ? 1 : instAddr;
629 traceFunctions(instAddr);
647 const bool branching(thread->
pcState().branching());
686 t_info->thread->startup();
StaticInstPtr curStaticInst
Counter totalInsts() const override
void advancePC(const Fault &fault)
const FlagsType pdf
Print the percent of the total that this entry represents.
Stats::Scalar numFpAluAccesses
ProfileNode * profileNode
std::list< ThreadID > activeThreads
decltype(nullptr) constexpr NoFault
Derived & subname(off_type index, const std::string &name)
Set the subfield name for the given index, and marks this stat to print at the end of simulation...
FunctionProfile * profile
Stats::Average notIdleFraction
const std::string & name()
Stats::Scalar numLoadInsts
Stats::Scalar numIntAluAccesses
Stats::Vector statExecutedInstType
Addr dbg_vtophys(Addr addr)
bool isDelayedCommit() const
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
TheISA::MachInst inst
Current instruction.
OpClass opClass() const
Operation class. Used to select appropriate function unit in issue.
void wakeup(ThreadID tid) override
Stats::Scalar numCCRegReads
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
Stats::Scalar numFpRegWrites
Stats::Scalar numIntRegReads
virtual StaticInstPtr fetchMicroop(MicroPC upc) const
Return the microop that goes with a particular micropc.
The SimpleThread object provides a combination of the ThreadState object and the ThreadContext interf...
std::string getName()
Return name of machine instruction.
void checkForInterrupts()
void update(const InstSeqNum &done_sn, ThreadID tid)
Tells the branch predictor to commit any updates until the given sequence number. ...
Stats::Formula numIdleCycles
BaseSimpleCPU(BaseSimpleCPUParams *params)
Derived & flags(Flags _flags)
Set the flags and marks this stat to print at the end of simulation.
ThreadContext is the external interface to all thread state for anything outside of the CPU...
void resetStats() override
Derived & init(size_type size)
Set this vector to have the given size.
Derived ThreadContext class for use with the Checker.
void change_thread_state(ThreadID tid, int activate, int priority)
Changes the status and priority of the thread with the given number.
Stats::Scalar icacheStallCycles
const ExtMachInst machInst
The binary machine instruction.
void swAutoBegin(ThreadContext *tc, Addr next_pc)
Tick curTick()
The current simulated tick.
void haltContext(ThreadID thread_num) override
Stats::Scalar numPredictedBranches
Number of branches predicted as taken.
void unserializeThread(CheckpointIn &cp, ThreadID tid) override
void initCPU(ThreadContext *tc, int cpuId)
Derived & prereq(const Stat &prereq)
Set the prerequisite stat and marks this stat to print at the end of simulation.
Stats::Scalar dcacheStallCycles
Stats::Scalar numIntRegWrites
bool predict(const StaticInstPtr &inst, const InstSeqNum &seqNum, TheISA::PCState &pc, ThreadID tid)
Predicts whether or not the instruction is a taken branch, and the target of the branch if it is take...
Stats::Scalar numIntInsts
StaticInstPtr curMacroStaticInst
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
ThreadContext * getTC()
Returns the pointer to this SimpleThread's ThreadContext.
Declaration of IniFile object.
bool inUserMode(ThreadContext *tc)
Stats::Formula numBusyCycles
void advancePC(PCState &pc, const StaticInstPtr &inst)
int64_t Counter
Statistics counter type.
static bool isRomMicroPC(MicroPC upc)
void setFloatReg(int reg_idx, FloatReg val)
Stats::Scalar numBranches
const FlagsType total
Print the total.
void serializeThread(CheckpointOut &cp, ThreadID tid) const override
Counter numInst
PER-THREAD STATS.
TheISA::PCState pcState()
Derived & name(const std::string &name)
Set the name and marks this stat to print at the end of simulation.
int16_t ThreadID
Thread index/ID type.
Stats::Scalar numCallsReturns
void setIntReg(int reg_idx, uint64_t val)
Stats::Scalar numFpRegReads
Declaration of the Packet class.
Counter totalOps() const override
std::ostream CheckpointOut
void setSystem(System *system)
Trace::InstRecord * traceData
static const OpClass Num_OpClasses
GenericISA::SimplePCState< MachInst > PCState
The request was an instruction fetch.
void setVirt(int asid, Addr vaddr, unsigned size, Flags flags, MasterID mid, Addr pc)
Set up a virtual (e.g., CPU) request in a previously allocated Request object.
std::vector< SimpleExecContext * > threadInfo
Stats::Scalar numStoreInsts
void squash(const InstSeqNum &squashed_sn, ThreadID tid)
Squashes all outstanding updates until a given sequence number.
Stats::Scalar numCCRegWrites
Stats::Formula idleFraction
Derived & desc(const std::string &_desc)
Set the description and marks this stat to print at the end of simulation.
static StaticInstPtr nullStaticInstPtr
Pointer to a statically allocated "null" instruction object.
ProfileNode * consume(ThreadContext *tc, const StaticInstPtr &inst)
const FlagsType nozero
Don't print if this is zero.
const FlagsType dist
Print the distribution.
bool isLastMicroop() const
std::shared_ptr< FaultBase > Fault
void setupFetchRequest(Request *req)
Stats::Scalar numBranchMispred
Number of misprediced branches.
const FlagsType init
This Stat is Initialized.
Stats::Scalar numCondCtrlInsts