gem5  v21.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
base.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2012,2016-2017, 2019-2020 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Copyright (c) 2002-2005 The Regents of The University of Michigan
15  * Copyright (c) 2011 Regents of the University of California
16  * Copyright (c) 2013 Advanced Micro Devices, Inc.
17  * Copyright (c) 2013 Mark D. Hill and David A. Wood
18  * All rights reserved.
19  *
20  * Redistribution and use in source and binary forms, with or without
21  * modification, are permitted provided that the following conditions are
22  * met: redistributions of source code must retain the above copyright
23  * notice, this list of conditions and the following disclaimer;
24  * redistributions in binary form must reproduce the above copyright
25  * notice, this list of conditions and the following disclaimer in the
26  * documentation and/or other materials provided with the distribution;
27  * neither the name of the copyright holders nor the names of its
28  * contributors may be used to endorse or promote products derived from
29  * this software without specific prior written permission.
30  *
31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
36  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
37  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
38  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
39  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
41  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42  */
43 
44 #include "cpu/base.hh"
45 
46 #include <iostream>
47 #include <sstream>
48 #include <string>
49 
50 #include "arch/generic/tlb.hh"
51 #include "base/cprintf.hh"
52 #include "base/loader/symtab.hh"
53 #include "base/logging.hh"
54 #include "base/output.hh"
55 #include "base/trace.hh"
56 #include "cpu/checker/cpu.hh"
57 #include "cpu/thread_context.hh"
58 #include "debug/Mwait.hh"
59 #include "debug/SyscallVerbose.hh"
60 #include "debug/Thread.hh"
61 #include "mem/page_table.hh"
62 #include "params/BaseCPU.hh"
63 #include "sim/clocked_object.hh"
64 #include "sim/full_system.hh"
65 #include "sim/process.hh"
66 #include "sim/root.hh"
67 #include "sim/sim_events.hh"
68 #include "sim/sim_exit.hh"
69 #include "sim/system.hh"
70 
71 // Hack
72 #include "sim/stat_control.hh"
73 
74 std::unique_ptr<BaseCPU::GlobalStats> BaseCPU::globalStats;
75 
77 
78 // This variable reflects the max number of threads in any CPU. Be
79 // careful to only use it once all the CPUs that you care about have
80 // been initialized
82 
84  : Event(Event::Progress_Event_Pri), _interval(ival), lastNumInst(0),
85  cpu(_cpu), _repeatEvent(true)
86 {
87  if (_interval)
88  cpu->schedule(this, curTick() + _interval);
89 }
90 
91 void
93 {
94  Counter temp = cpu->totalOps();
95 
96  if (_repeatEvent)
97  cpu->schedule(this, curTick() + _interval);
98 
99  if (cpu->switchedOut()) {
100  return;
101  }
102 
103 #ifndef NDEBUG
104  double ipc = double(temp - lastNumInst) / (_interval / cpu->clockPeriod());
105 
106  DPRINTFN("%s progress event, total committed:%i, progress insts committed: "
107  "%lli, IPC: %0.8d\n", cpu->name(), temp, temp - lastNumInst,
108  ipc);
109  ipc = 0.0;
110 #else
111  cprintf("%lli: %s progress event, total committed:%i, progress insts "
112  "committed: %lli\n", curTick(), cpu->name(), temp,
113  temp - lastNumInst);
114 #endif
115  lastNumInst = temp;
116 }
117 
118 const char *
120 {
121  return "CPU Progress";
122 }
123 
124 BaseCPU::BaseCPU(const Params &p, bool is_checker)
125  : ClockedObject(p), instCnt(0), _cpuId(p.cpu_id), _socketId(p.socket_id),
126  _instRequestorId(p.system->getRequestorId(this, "inst")),
127  _dataRequestorId(p.system->getRequestorId(this, "data")),
128  _taskId(ContextSwitchTaskId::Unknown), _pid(invldPid),
129  _switchedOut(p.switched_out), _cacheLineSize(p.system->cacheLineSize()),
130  interrupts(p.interrupts), numThreads(p.numThreads), system(p.system),
131  previousCycle(0), previousState(CPU_STATE_SLEEP),
132  functionTraceStream(nullptr), currentFunctionStart(0),
133  currentFunctionEnd(0), functionEntryTick(0),
134  baseStats(this),
135  addressMonitor(p.numThreads),
136  syscallRetryLatency(p.syscallRetryLatency),
137  pwrGatingLatency(p.pwr_gating_latency),
138  powerGatingOnIdle(p.power_gating_on_idle),
139  enterPwrGatingEvent([this]{ enterPwrGating(); }, name())
140 {
141  // if Python did not provide a valid ID, do it here
142  if (_cpuId == -1 ) {
143  _cpuId = cpuList.size();
144  }
145 
146  // add self to global list of CPUs
147  cpuList.push_back(this);
148 
149  DPRINTF(SyscallVerbose, "Constructing CPU with id %d, socket id %d\n",
150  _cpuId, _socketId);
151 
152  if (numThreads > maxThreadsPerCPU)
153  maxThreadsPerCPU = numThreads;
154 
155  functionTracingEnabled = false;
156  if (p.function_trace) {
157  const std::string fname = csprintf("ftrace.%s", name());
158  functionTraceStream = simout.findOrCreate(fname)->stream();
159 
160  currentFunctionStart = currentFunctionEnd = 0;
161  functionEntryTick = p.function_trace_start;
162 
163  if (p.function_trace_start == 0) {
164  functionTracingEnabled = true;
165  } else {
166  Event *event = new EventFunctionWrapper(
167  [this]{ enableFunctionTrace(); }, name(), true);
168  schedule(event, p.function_trace_start);
169  }
170  }
171 
172  tracer = params().tracer;
173 
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);
177  }
178 }
179 
180 void
182 {
183  functionTracingEnabled = true;
184 }
185 
187 {
188 }
189 
190 void
191 BaseCPU::postInterrupt(ThreadID tid, int int_num, int index)
192 {
193  interrupts[tid]->post(int_num, index);
194  // Only wake up syscall emulation if it is not waiting on a futex.
195  // This is to model the fact that instructions such as ARM SEV
196  // should wake up a WFE sleep, but not a futex syscall WAIT. */
198  wakeup(tid);
199 }
200 
201 void
203 {
204  assert(tid < numThreads);
205  AddressMonitor &monitor = addressMonitor[tid];
206 
207  monitor.armed = true;
208  monitor.vAddr = address;
209  monitor.pAddr = 0x0;
210  DPRINTF(Mwait,"[tid:%d] Armed monitor (vAddr=0x%lx)\n", tid, address);
211 }
212 
213 bool
215 {
216  assert(tid < numThreads);
217  AddressMonitor &monitor = addressMonitor[tid];
218 
219  if (!monitor.gotWakeup) {
220  int block_size = cacheLineSize();
221  uint64_t mask = ~((uint64_t)(block_size - 1));
222 
223  assert(pkt->req->hasPaddr());
224  monitor.pAddr = pkt->getAddr() & mask;
225  monitor.waiting = true;
226 
227  DPRINTF(Mwait,"[tid:%d] mwait called (vAddr=0x%lx, "
228  "line's paddr=0x%lx)\n", tid, monitor.vAddr, monitor.pAddr);
229  return true;
230  } else {
231  monitor.gotWakeup = false;
232  return false;
233  }
234 }
235 
236 void
238 {
239  assert(tid < numThreads);
240  AddressMonitor &monitor = addressMonitor[tid];
241 
242  RequestPtr req = std::make_shared<Request>();
243 
244  Addr addr = monitor.vAddr;
245  int block_size = cacheLineSize();
246  uint64_t mask = ~((uint64_t)(block_size - 1));
247  int size = block_size;
248 
249  //The address of the next line if it crosses a cache line boundary.
250  Addr secondAddr = roundDown(addr + size - 1, block_size);
251 
252  if (secondAddr > addr)
253  size = secondAddr - addr;
254 
255  req->setVirt(addr, size, 0x0, dataRequestorId(), tc->instAddr());
256 
257  // translate to physical address
258  Fault fault = mmu->translateAtomic(req, tc, BaseTLB::Read);
259  assert(fault == NoFault);
260 
261  monitor.pAddr = req->getPaddr() & mask;
262  monitor.waiting = true;
263 
264  DPRINTF(Mwait,"[tid:%d] mwait called (vAddr=0x%lx, line's paddr=0x%lx)\n",
265  tid, monitor.vAddr, monitor.pAddr);
266 }
267 
268 void
270 {
271  // Set up instruction-count-based termination events, if any. This needs
272  // to happen after threadContexts has been constructed.
273  if (params().max_insts_any_thread != 0) {
274  const char *cause = "a thread reached the max instruction count";
275  for (ThreadID tid = 0; tid < numThreads; ++tid)
276  scheduleInstStop(tid, params().max_insts_any_thread, cause);
277  }
278 
279  // Set up instruction-count-based termination events for SimPoints
280  // Typically, there are more than one action points.
281  // Simulation.py is responsible to take the necessary actions upon
282  // exitting the simulation loop.
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)
286  scheduleInstStop(0, params().simpoint_start_insts[i], cause);
287  }
288 
289  if (params().max_insts_all_threads != 0) {
290  const char *cause = "all threads reached the max instruction count";
291 
292  // allocate & initialize shared downcounter: each event will
293  // decrement this when triggered; simulation will terminate
294  // when counter reaches 0
295  int *counter = new int;
296  *counter = numThreads;
297  for (ThreadID tid = 0; tid < numThreads; ++tid) {
298  Event *event = new CountedExitEvent(cause, *counter);
299  threadContexts[tid]->scheduleInstCountEvent(
300  event, params().max_insts_all_threads);
301  }
302  }
303 
304  if (!params().switched_out) {
306 
308  }
309 }
310 
311 void
313 {
314  if (params().progress_interval) {
315  new CPUProgressEvent(this, params().progress_interval);
316  }
317 
318  if (_switchedOut)
320 
321  // Assumption CPU start to operate instantaneously without any latency
322  if (powerState->get() == Enums::PwrState::UNDEFINED)
323  powerState->set(Enums::PwrState::ON);
324 
325 }
326 
329 {
331  ptr.reset(new ProbePoints::PMU(getProbeManager(), name));
332 
333  return ptr;
334 }
335 
336 void
338 {
339  ppAllCycles = pmuProbePoint("Cycles");
340  ppActiveCycles = pmuProbePoint("ActiveCycles");
341 
342  ppRetiredInsts = pmuProbePoint("RetiredInsts");
343  ppRetiredInstsPC = pmuProbePoint("RetiredInstsPC");
344  ppRetiredLoads = pmuProbePoint("RetiredLoads");
345  ppRetiredStores = pmuProbePoint("RetiredStores");
346  ppRetiredBranches = pmuProbePoint("RetiredBranches");
347 
349  "Sleeping");
350 }
351 
352 void
354 {
355  if (!inst->isMicroop() || inst->isLastMicroop()) {
356  ppRetiredInsts->notify(1);
357  ppRetiredInstsPC->notify(pc);
358  }
359 
360  if (inst->isLoad())
361  ppRetiredLoads->notify(1);
362 
363  if (inst->isStore() || inst->isAtomic())
364  ppRetiredStores->notify(1);
365 
366  if (inst->isControl())
367  ppRetiredBranches->notify(1);
368 }
369 
370 BaseCPU::
372  : Stats::Group(parent),
373  ADD_STAT(numCycles, UNIT_CYCLE, "Number of cpu cycles simulated"),
374  ADD_STAT(numWorkItemsStarted, UNIT_COUNT,
375  "Number of work items this cpu started"),
376  ADD_STAT(numWorkItemsCompleted, UNIT_COUNT,
377  "Number of work items this cpu completed")
378 {
379 }
380 
381 void
383 {
385 
386  if (!globalStats) {
387  /* We need to construct the global CPU stat structure here
388  * since it needs a pointer to the Root object. */
389  globalStats.reset(new GlobalStats(Root::root()));
390  }
391 
392  using namespace Stats;
393 
394  int size = threadContexts.size();
395  if (size > 1) {
396  for (int i = 0; i < size; ++i) {
397  std::stringstream namestr;
398  ccprintf(namestr, "%s.ctx%d", name(), i);
399  threadContexts[i]->regStats(namestr.str());
400  }
401  } else if (size == 1)
402  threadContexts[0]->regStats(name());
403 }
404 
405 Port &
406 BaseCPU::getPort(const std::string &if_name, PortID idx)
407 {
408  // Get the right port based on name. This applies to all the
409  // subclasses of the base CPU and relies on their implementation
410  // of getDataPort and getInstPort.
411  if (if_name == "dcache_port")
412  return getDataPort();
413  else if (if_name == "icache_port")
414  return getInstPort();
415  else
416  return ClockedObject::getPort(if_name, idx);
417 }
418 
419 void
421 {
422  assert(system->multiThread || numThreads == 1);
423 
424  fatal_if(interrupts.size() != numThreads,
425  "CPU %s has %i interrupt controllers, but is expecting one "
426  "per thread (%i)\n",
427  name(), interrupts.size(), numThreads);
428 
429  ThreadID size = threadContexts.size();
430  for (ThreadID tid = 0; tid < size; ++tid) {
431  ThreadContext *tc = threadContexts[tid];
432 
433  if (system->multiThread) {
435  } else {
437  }
438 
439  if (!FullSystem)
441 
442  interrupts[tid]->setThreadContext(tc);
443  tc->getIsaPtr()->setThreadContext(tc);
444  }
445 }
446 
447 void
449 {
452  }
453 }
454 
455 void
457 {
458  for (auto tc : threadContexts) {
459  if (tc->status() == ThreadContext::Active)
460  return;
461  }
462 
463  if (powerState->get() == Enums::PwrState::CLK_GATED &&
465  assert(!enterPwrGatingEvent.scheduled());
466  // Schedule a power gating event when clock gated for the specified
467  // amount of time
469  }
470 }
471 
472 int
474 {
475  ThreadID size = threadContexts.size();
476  for (ThreadID tid = 0; tid < size; ++tid) {
477  if (tc == threadContexts[tid])
478  return tid;
479  }
480  return 0;
481 }
482 
483 void
485 {
486  DPRINTF(Thread, "activate contextId %d\n",
487  threadContexts[thread_num]->contextId());
488  // Squash enter power gating event while cpu gets activated
491  // For any active thread running, update CPU power state to active (ON)
492  powerState->set(Enums::PwrState::ON);
493 
495 }
496 
497 void
499 {
500  DPRINTF(Thread, "suspend contextId %d\n",
501  threadContexts[thread_num]->contextId());
502  // Check if all threads are suspended
503  for (auto t : threadContexts) {
504  if (t->status() != ThreadContext::Suspended) {
505  return;
506  }
507  }
508 
509  // All CPU thread are suspended, update cycle count
511 
512  // All CPU threads suspended, enter lower power state for the CPU
513  powerState->set(Enums::PwrState::CLK_GATED);
514 
515  // If pwrGatingLatency is set to 0 then this mechanism is disabled
516  if (powerGatingOnIdle) {
517  // Schedule power gating event when clock gated for pwrGatingLatency
518  // cycles
520  }
521 }
522 
523 void
525 {
527 }
528 
529 void
531 {
533 }
534 
535 void
537 {
538  assert(!_switchedOut);
539  _switchedOut = true;
540 
541  // Flush all TLBs in the CPU to avoid having stale translations if
542  // it gets switched in later.
543  flushTLBs();
544 
545  // Go to the power gating state
547 }
548 
549 void
551 {
552  assert(threadContexts.size() == oldCPU->threadContexts.size());
553  assert(_cpuId == oldCPU->cpuId());
554  assert(_switchedOut);
555  assert(oldCPU != this);
556  _pid = oldCPU->getPid();
557  _taskId = oldCPU->taskId();
558  // Take over the power state of the switchedOut CPU
559  powerState->set(oldCPU->powerState->get());
560 
561  previousState = oldCPU->previousState;
562  previousCycle = oldCPU->previousCycle;
563 
564  _switchedOut = false;
565 
566  ThreadID size = threadContexts.size();
567  for (ThreadID i = 0; i < size; ++i) {
568  ThreadContext *newTC = threadContexts[i];
569  ThreadContext *oldTC = oldCPU->threadContexts[i];
570 
571  newTC->getIsaPtr()->setThreadContext(newTC);
572 
573  newTC->takeOverFrom(oldTC);
574 
575  assert(newTC->contextId() == oldTC->contextId());
576  assert(newTC->threadId() == oldTC->threadId());
577  system->replaceThreadContext(newTC, newTC->contextId());
578 
579  /* This code no longer works since the zero register (e.g.,
580  * r31 on Alpha) doesn't necessarily contain zero at this
581  * point.
582  if (DTRACE(Context))
583  ThreadContext::compare(oldTC, newTC);
584  */
585 
586  newTC->getMMUPtr()->takeOverFrom(oldTC->getMMUPtr());
587 
588  // Checker whether or not we have to transfer CheckerCPU
589  // objects over in the switch
590  CheckerCPU *old_checker = oldTC->getCheckerCpuPtr();
591  CheckerCPU *new_checker = newTC->getCheckerCpuPtr();
592  if (old_checker && new_checker) {
593  new_checker->getMMUPtr()->takeOverFrom(old_checker->getMMUPtr());
594  }
595  }
596 
597  interrupts = oldCPU->interrupts;
598  for (ThreadID tid = 0; tid < numThreads; tid++) {
599  interrupts[tid]->setThreadContext(threadContexts[tid]);
600  }
601  oldCPU->interrupts.clear();
602 
603  // All CPUs have an instruction and a data port, and the new CPU's
604  // ports are dangling while the old CPU has its ports connected
605  // already. Unbind the old CPU and then bind the ports of the one
606  // we are switching to.
607  getInstPort().takeOverFrom(&oldCPU->getInstPort());
608  getDataPort().takeOverFrom(&oldCPU->getDataPort());
609 }
610 
611 void
613 {
614  for (ThreadID i = 0; i < threadContexts.size(); ++i) {
616  CheckerCPU *checker(tc.getCheckerCpuPtr());
617 
618  tc.getMMUPtr()->flushAll();
619  if (checker) {
620  checker->getMMUPtr()->flushAll();
621  }
622  }
623 }
624 
625 void
627 {
629 
630  if (!_switchedOut) {
631  /* Unlike _pid, _taskId is not serialized, as they are dynamically
632  * assigned unique ids that are only meaningful for the duration of
633  * a specific run. We will need to serialize the entire taskMap in
634  * system. */
636 
637  // Serialize the threads, this is done by the CPU implementation.
638  for (ThreadID i = 0; i < numThreads; ++i) {
639  ScopedCheckpointSection sec(cp, csprintf("xc.%i", i));
640  interrupts[i]->serialize(cp);
641  serializeThread(cp, i);
642  }
643  }
644 }
645 
646 void
648 {
650 
651  if (!_switchedOut) {
653 
654  // Unserialize the threads, this is done by the CPU implementation.
655  for (ThreadID i = 0; i < numThreads; ++i) {
656  ScopedCheckpointSection sec(cp, csprintf("xc.%i", i));
657  interrupts[i]->unserialize(cp);
659  }
660  }
661 }
662 
663 void
664 BaseCPU::scheduleInstStop(ThreadID tid, Counter insts, const char *cause)
665 {
666  const Tick now(getCurrentInstCount(tid));
667  Event *event(new LocalSimLoopExitEvent(cause, 0));
668 
669  threadContexts[tid]->scheduleInstCountEvent(event, now + insts);
670 }
671 
672 Tick
674 {
675  return threadContexts[tid]->getCurrentInstCount();
676 }
677 
679  armed = false;
680  waiting = false;
681  gotWakeup = false;
682 }
683 
685  assert(pkt->req->hasPaddr());
686  if (armed && waiting) {
687  if (pAddr == pkt->getAddr()) {
688  DPRINTF(Mwait,"pAddr=0x%lx invalidated: waking up core\n",
689  pkt->getAddr());
690  waiting = false;
691  return true;
692  }
693  }
694  return false;
695 }
696 
697 
698 void
700 {
701  if (Loader::debugSymbolTable.empty())
702  return;
703 
704  // if pc enters different function, print new function symbol and
705  // update saved range. Otherwise do nothing.
706  if (pc < currentFunctionStart || pc >= currentFunctionEnd) {
709 
710  std::string sym_str;
711  if (it == Loader::debugSymbolTable.end()) {
712  // no symbol found: use addr as label
713  sym_str = csprintf("%#x", pc);
715  currentFunctionEnd = pc + 1;
716  } else {
717  sym_str = it->name;
718  currentFunctionStart = it->address;
719  }
720 
721  ccprintf(*functionTraceStream, " (%d)\n%d: %s",
722  curTick() - functionEntryTick, curTick(), sym_str);
724  }
725 }
726 
727 bool
729 {
730  return params().wait_for_remote_gdb;
731 }
732 
733 
735  : ::Stats::Group(parent),
736  ADD_STAT(simInsts, UNIT_COUNT, "Number of instructions simulated"),
737  ADD_STAT(simOps, UNIT_COUNT,
738  "Number of ops (including micro ops) simulated"),
739  ADD_STAT(hostInstRate,
740  UNIT_RATE(Stats::Units::Count, Stats::Units::Second),
741  "Simulator instruction rate (inst/s)"),
742  ADD_STAT(hostOpRate,
743  UNIT_RATE(Stats::Units::Count, Stats::Units::Second),
744  "Simulator op (including micro ops) rate (op/s)")
745 {
746  simInsts
748  .precision(0)
749  .prereq(simInsts)
750  ;
751 
752  simOps
754  .precision(0)
755  .prereq(simOps)
756  ;
757 
759  .precision(0)
760  .prereq(simInsts)
761  ;
762 
763  hostOpRate
764  .precision(0)
765  .prereq(simOps)
766  ;
767 
770 }
fatal
#define fatal(...)
This implements a cprintf based fatal() function.
Definition: logging.hh:183
BaseCPU::mwait
bool mwait(ThreadID tid, PacketPtr pkt)
Definition: base.cc:214
Stats::Group::regStats
virtual void regStats()
Callback to set stat parameters.
Definition: group.cc:63
BaseCPU::ppRetiredInstsPC
ProbePoints::PMUUPtr ppRetiredInstsPC
Definition: base.hh:495
Event::scheduled
bool scheduled() const
Determine if the current event is scheduled.
Definition: eventq.hh:462
BaseCPU::_cpuId
int _cpuId
Definition: base.hh:116
Root::root
static Root * root()
Use this function to get a pointer to the single Root object in the simulation.
Definition: root.hh:87
BaseCPU::regStats
void regStats() override
Callback to set stat parameters.
Definition: base.cc:382
BaseCPU::mwaitAtomic
void mwaitAtomic(ThreadID tid, ThreadContext *tc, BaseMMU *mmu)
Definition: base.cc:237
BaseCPU::getPort
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port on this CPU.
Definition: base.cc:406
Loader::SymbolTable::findNearest
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...
Definition: symtab.hh:207
roundDown
T roundDown(const T &val, const U &align)
This function is used to align addresses in memory.
Definition: intmath.hh:150
CPUProgressEvent::CPUProgressEvent
CPUProgressEvent(BaseCPU *_cpu, Tick ival=0)
Definition: base.cc:83
BaseCPU::flushTLBs
void flushTLBs()
Flush all TLBs in the CPU.
Definition: base.cc:612
BaseCPU::serializeThread
virtual void serializeThread(CheckpointOut &cp, ThreadID tid) const
Serialize a single thread.
Definition: base.hh:423
BaseCPU::functionTracingEnabled
bool functionTracingEnabled
Definition: base.hh:560
BaseCPU::getCurrentInstCount
uint64_t getCurrentInstCount(ThreadID tid)
Get the number of instructions executed by the specified thread on this CPU.
Definition: base.cc:673
ThreadContext::setContextId
virtual void setContextId(ContextID id)=0
system.hh
BaseCPU::ppRetiredBranches
ProbePoints::PMUUPtr ppRetiredBranches
Retired branches (any type)
Definition: base.hh:503
BaseCPU::previousState
CPUState previousState
Definition: base.hh:529
BaseTLB::Read
@ Read
Definition: tlb.hh:57
BaseCPU::verifyMemoryMode
virtual void verifyMemoryMode() const
Verify that the system is in a memory mode supported by the CPU.
Definition: base.hh:378
BaseMMU
Definition: mmu.hh:45
MipsISA::index
Bitfield< 30, 0 > index
Definition: pra_constants.hh:44
UNSERIALIZE_SCALAR
#define UNSERIALIZE_SCALAR(scalar)
Definition: serialize.hh:591
BaseCPU::init
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: base.cc:269
BaseCPU::_pid
uint32_t _pid
The current OS process ID that is executing on this processor.
Definition: base.hh:140
Packet::getAddr
Addr getAddr() const
Definition: packet.hh:755
CPUProgressEvent::lastNumInst
Counter lastNumInst
Definition: base.hh:87
BaseCPU::wakeup
virtual void wakeup(ThreadID tid)=0
PowerState::set
void set(Enums::PwrState p)
Change the power state of this object to the power state p.
Definition: power_state.cc:92
Process::assignThreadContext
void assignThreadContext(ContextID context_id)
Definition: process.hh:117
sim_events.hh
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
BaseCPU::getDataPort
virtual Port & getDataPort()=0
Purely virtual method that returns a reference to the data port.
ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:233
BaseCPU::ppAllCycles
ProbePoints::PMUUPtr ppAllCycles
CPU cycle counter even if any thread Context is suspended.
Definition: base.hh:506
BaseISA::setThreadContext
virtual void setThreadContext(ThreadContext *_tc)
Definition: isa.hh:56
ThreadContext::getMMUPtr
virtual BaseMMU * getMMUPtr()=0
AddressMonitor::doMonitor
bool doMonitor(PacketPtr pkt)
Definition: base.cc:684
CPUProgressEvent::description
virtual const char * description() const
Return a C string describing the event.
Definition: base.cc:119
BaseCPU::cacheLineSize
unsigned int cacheLineSize() const
Get the cache line size of the system.
Definition: base.hh:391
tlb.hh
CPUProgressEvent::_interval
Tick _interval
Definition: base.hh:86
ProbePointArg
ProbePointArg generates a point for the class of Arg.
Definition: thermal_domain.hh:51
Stats::ValueBase::functor
Derived & functor(const T &func)
Definition: statistics.hh:722
BaseCPU::armMonitor
void armMonitor(ThreadID tid, Addr address)
Definition: base.cc:202
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:59
System::registerThreadContext
ContextID registerThreadContext(ThreadContext *tc, ContextID assigned=InvalidContextID)
Definition: system.cc:315
PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:243
RequestPtr
std::shared_ptr< Request > RequestPtr
Definition: request.hh:86
Packet::req
RequestPtr req
A pointer to the original request.
Definition: packet.hh:341
CheckerCPU
CheckerCPU class.
Definition: cpu.hh:85
BaseCPU::enableFunctionTrace
void enableFunctionTrace()
Definition: base.cc:181
BaseCPU::postInterrupt
void postInterrupt(ThreadID tid, int int_num, int index)
Definition: base.cc:191
EventManager::deschedule
void deschedule(Event &event)
Definition: eventq.hh:1025
BaseCPU::BaseCPUStats::BaseCPUStats
BaseCPUStats(Stats::Group *parent)
Definition: base.cc:371
std::vector< BaseCPU * >
BaseCPU::registerThreadContexts
void registerThreadContexts()
Definition: base.cc:420
BaseCPU::deschedulePowerGatingEvent
void deschedulePowerGatingEvent()
Definition: base.cc:448
FullSystem
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
Definition: root.cc:204
ThreadContext::getProcessPtr
virtual Process * getProcessPtr()=0
BaseCPU::totalOps
virtual Counter totalOps() const =0
System::replaceThreadContext
void replaceThreadContext(ThreadContext *tc, ContextID context_id)
Definition: system.cc:346
BaseCPU::ppRetiredLoads
ProbePoints::PMUUPtr ppRetiredLoads
Retired load instructions.
Definition: base.hh:498
BaseCPU::getPid
uint32_t getPid() const
Definition: base.hh:223
sim_exit.hh
RiscvISA::OFF
@ OFF
Definition: isa.hh:65
output.hh
ContextSwitchTaskId::Unknown
@ Unknown
Definition: request.hh:79
Port::takeOverFrom
void takeOverFrom(Port *old)
A utility function to make it easier to swap out ports.
Definition: port.hh:132
BaseMMU::flushAll
void flushAll()
Definition: mmu.hh:65
AddressMonitor::vAddr
Addr vAddr
Definition: base.hh:76
ThreadContext::threadId
virtual int threadId() const =0
AddressMonitor
Definition: base.hh:70
root.hh
FutexMap::is_waiting
bool is_waiting(ThreadContext *tc)
Determine if the given thread context is currently waiting on a futex wait operation on any of the fu...
Definition: futex_map.cc:194
ClockedObject
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Definition: clocked_object.hh:231
BaseCPU::updateCycleCounters
void updateCycleCounters(CPUState state)
base method keeping track of cycle progression
Definition: base.hh:532
EventFunctionWrapper
Definition: eventq.hh:1112
ThreadContext::getIsaPtr
virtual BaseISA * getIsaPtr()=0
BaseCPU::GlobalStats::simOps
::Stats::Value simOps
Definition: base.hh:153
CPUProgressEvent::cpu
BaseCPU * cpu
Definition: base.hh:88
LocalSimLoopExitEvent
Definition: sim_events.hh:73
X86ISA::system
Bitfield< 15 > system
Definition: misc.hh:997
Counter
int64_t Counter
Statistics counter type.
Definition: types.hh:54
CPUProgressEvent
Definition: base.hh:83
OutputDirectory::findOrCreate
OutputStream * findOrCreate(const std::string &name, bool binary=false)
Definition: output.cc:259
StaticInst::isStore
bool isStore() const
Definition: static_inst.hh:167
BaseCPU::findContext
int findContext(ThreadContext *tc)
Given a Thread Context pointer return the thread num.
Definition: base.cc:473
Loader::debugSymbolTable
SymbolTable debugSymbolTable
Global unified debugging symbol table (for target).
Definition: symtab.cc:40
cp
Definition: cprintf.cc:37
StaticInst::isLoad
bool isLoad() const
Definition: static_inst.hh:166
EventManager::schedule
void schedule(Event &event, Tick when)
Definition: eventq.hh:1016
ThreadContext::takeOverFrom
virtual void takeOverFrom(ThreadContext *old_context)=0
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
ClockedObject::Params
ClockedObjectParams Params
Parameters of ClockedObject.
Definition: clocked_object.hh:237
BaseCPU::cpuList
static std::vector< BaseCPU * > cpuList
Static global cpu list.
Definition: base.hh:569
Stats::DataWrap::prereq
Derived & prereq(const Stat &prereq)
Set the prerequisite stat and marks this stat to print at the end of simulation.
Definition: statistics.hh:353
BaseMMU::takeOverFrom
virtual void takeOverFrom(BaseMMU *old_mmu)
Definition: mmu.cc:47
Event
Definition: eventq.hh:248
BaseCPU::traceFunctionsInternal
void traceFunctionsInternal(Addr pc)
Definition: base.cc:699
SimObject::getPort
virtual Port & getPort(const std::string &if_name, PortID idx=InvalidPortID)
Get a port with a given name and index.
Definition: sim_object.cc:120
BaseCPU::numSimulatedInsts
static Counter numSimulatedInsts()
Definition: base.hh:579
cprintf
void cprintf(const char *format, const Args &...args)
Definition: cprintf.hh:152
OutputStream::stream
std::ostream * stream() const
Get the output underlying output stream.
Definition: output.hh:59
System::multiThread
const bool multiThread
Definition: system.hh:306
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:237
ADD_STAT
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
Definition: group.hh:71
BaseCPU::instCnt
Tick instCnt
Instruction count used for SPARC misc register.
Definition: base.hh:110
StaticInst::isAtomic
bool isAtomic() const
Definition: static_inst.hh:168
StaticInst::isControl
bool isControl() const
Definition: static_inst.hh:179
Fault
std::shared_ptr< FaultBase > Fault
Definition: types.hh:246
MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:240
System::futexMap
FutexMap futexMap
Definition: system.hh:605
MipsISA::event
Bitfield< 10, 5 > event
Definition: pra_constants.hh:297
BaseCPU::interrupts
std::vector< BaseInterrupts * > interrupts
Definition: base.hh:232
Port
Ports are used to interface objects to each other.
Definition: port.hh:56
cpu.hh
BaseCPU::_taskId
uint32_t _taskId
An intrenal representation of a task identifier within gem5.
Definition: base.hh:136
BaseCPU::ppActiveCycles
ProbePoints::PMUUPtr ppActiveCycles
CPU cycle counter, only counts if any thread contexts is active.
Definition: base.hh:509
BaseCPU::threadContexts
std::vector< ThreadContext * > threadContexts
Definition: base.hh:269
Clocked::clockEdge
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...
Definition: clocked_object.hh:174
process.hh
BaseCPU::currentFunctionEnd
Addr currentFunctionEnd
Definition: base.hh:563
PowerState::get
Enums::PwrState get() const
Definition: power_state.hh:82
BaseCPU::serialize
void serialize(CheckpointOut &cp) const override
Serialize this object to the given output stream.
Definition: base.cc:626
BaseCPU::activateContext
virtual void activateContext(ThreadID thread_num)
Notify the CPU that the indicated context is now active.
Definition: base.cc:484
BaseCPU::previousCycle
Cycles previousCycle
Definition: base.hh:528
BaseCPU::pmuProbePoint
ProbePoints::PMUUPtr pmuProbePoint(const char *name)
Helper method to instantiate probe points belonging to this object.
Definition: base.cc:328
BaseMMU::translateAtomic
Fault translateAtomic(const RequestPtr &req, ThreadContext *tc, BaseTLB::Mode mode)
Definition: mmu.hh:79
BaseCPU::functionEntryTick
Tick functionEntryTick
Definition: base.hh:564
ThreadContext::contextId
virtual ContextID contextId() const =0
cprintf.hh
BaseCPU::ppRetiredStores
ProbePoints::PMUUPtr ppRetiredStores
Retired store instructions.
Definition: base.hh:500
hostSeconds
Stats::Value & hostSeconds
Definition: stats.cc:45
ContextSwitchTaskId
Special TaskIds that are used for per-context-switch stats dumps and Cache Occupancy.
Definition: request.hh:74
UNIT_COUNT
#define UNIT_COUNT
Definition: units.hh:49
NoFault
constexpr decltype(nullptr) NoFault
Definition: types.hh:251
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:148
AddressMonitor::pAddr
Addr pAddr
Definition: base.hh:77
BaseCPU::CPU_STATE_WAKEUP
@ CPU_STATE_WAKEUP
Definition: base.hh:525
Serializable::ScopedCheckpointSection
Definition: serialize.hh:178
BaseCPU::ppRetiredInsts
ProbePoints::PMUUPtr ppRetiredInsts
Instruction commit probe point.
Definition: base.hh:494
name
const std::string & name()
Definition: trace.cc:48
SERIALIZE_SCALAR
#define SERIALIZE_SCALAR(scalar)
Definition: serialize.hh:584
BaseCPU::GlobalStats::hostInstRate
::Stats::Formula hostInstRate
Definition: base.hh:155
Clocked::clockPeriod
Tick clockPeriod() const
Definition: clocked_object.hh:214
SimObject::getProbeManager
ProbeManager * getProbeManager()
Get the probe manager for this object.
Definition: sim_object.cc:114
full_system.hh
ProbePoints::PMUUPtr
std::unique_ptr< PMU > PMUUPtr
Definition: pmu.hh:56
StaticInst::isMicroop
bool isMicroop() const
Definition: static_inst.hh:205
BaseCPU::taskId
uint32_t taskId() const
Get cpu task id.
Definition: base.hh:219
X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:80
SimObject::name
virtual const std::string name() const
Definition: sim_object.hh:182
ClockedObject::powerState
PowerState * powerState
Definition: clocked_object.hh:242
BaseCPU
Definition: base.hh:104
UNIT_RATE
#define UNIT_RATE(T1, T2)
Definition: units.hh:47
stat_control.hh
AddressMonitor::AddressMonitor
AddressMonitor()
Definition: base.cc:678
StaticInst::isLastMicroop
bool isLastMicroop() const
Definition: static_inst.hh:207
ThreadContext::Suspended
@ Suspended
Temporarily inactive.
Definition: thread_context.hh:107
BaseCPU::pwrGatingLatency
const Cycles pwrGatingLatency
Definition: base.hh:632
BaseCPU::haltContext
virtual void haltContext(ThreadID thread_num)
Notify the CPU that the indicated context is now halted.
Definition: base.cc:524
BaseCPU::globalStats
static std::unique_ptr< GlobalStats > globalStats
Pointer to the global stat structure.
Definition: base.hh:163
base.hh
Stats::DataWrap::precision
Derived & precision(int _precision)
Set the precision and marks this stat to print at the end of simulation.
Definition: statistics.hh:327
ArmISA::t
Bitfield< 5 > t
Definition: miscregs_types.hh:67
BaseCPU::schedulePowerGatingEvent
void schedulePowerGatingEvent()
Definition: base.cc:456
BaseCPU::system
System * system
Definition: base.hh:386
BaseCPU::takeOverFrom
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...
Definition: base.cc:550
clocked_object.hh
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:258
BaseCPU::switchOut
virtual void switchOut()
Prepare for another CPU to take over execution.
Definition: base.cc:536
Stats::Group
Statistics container.
Definition: group.hh:87
BaseCPU::GlobalStats::GlobalStats
GlobalStats(::Stats::Group *parent)
Definition: base.cc:734
ThreadContext::getCheckerCpuPtr
virtual CheckerCPU * getCheckerCpuPtr()=0
maxThreadsPerCPU
int maxThreadsPerCPU
The maximum number of active threads across all cpus.
Definition: base.cc:81
BaseCPU::numThreads
ThreadID numThreads
Number of threads we're actually simulating (<= SMT_MAX_THREADS).
Definition: base.hh:378
CPUProgressEvent::process
void process()
Definition: base.cc:92
ccprintf
void ccprintf(cp::Print &print)
Definition: cprintf.hh:127
logging.hh
BaseCPU::dataRequestorId
RequestorID dataRequestorId() const
Reads this CPU's unique data requestor ID.
Definition: base.hh:201
UNIT_CYCLE
#define UNIT_CYCLE
Convenience macros to declare the unit of a stat.
Definition: units.hh:39
CountedExitEvent
Definition: sim_events.hh:101
ThreadContext::Active
@ Active
Running.
Definition: thread_context.hh:103
BaseCPU::functionTraceStream
std::ostream * functionTraceStream
Definition: base.hh:561
BaseCPU::scheduleInstStop
void scheduleInstStop(ThreadID tid, Counter insts, const char *cause)
Schedule an event that exits the simulation loops after a predefined number of instructions.
Definition: base.cc:664
CPUProgressEvent::_repeatEvent
bool _repeatEvent
Definition: base.hh:89
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:64
BaseCPU::numSimulatedOps
static Counter numSimulatedOps()
Definition: base.hh:590
BaseCPU::startup
void startup() override
startup() is the final initialization call before simulation.
Definition: base.cc:312
Stats
Definition: statistics.cc:53
BaseCPU::regProbePoints
void regProbePoints() override
Register probe points for this object.
Definition: base.cc:337
BaseCPU::GlobalStats::simInsts
::Stats::Value simInsts
Definition: base.hh:152
BaseCPU::enterPwrGating
void enterPwrGating()
Definition: base.cc:530
BaseCPU::suspendContext
virtual void suspendContext(ThreadID thread_num)
Notify the CPU that the indicated context is now suspended.
Definition: base.cc:498
RefCountingPtr< StaticInst >
BaseCPU::enterPwrGatingEvent
EventFunctionWrapper enterPwrGatingEvent
Definition: base.hh:634
curTick
Tick curTick()
The universal simulation clock.
Definition: cur_tick.hh:43
trace.hh
BaseCPU::currentFunctionStart
Addr currentFunctionStart
Definition: base.hh:562
symtab.hh
BaseCPU::CPU_STATE_SLEEP
@ CPU_STATE_SLEEP
Definition: base.hh:524
DPRINTFN
#define DPRINTFN(...)
Definition: trace.hh:241
SimObject::params
const Params & params() const
Definition: sim_object.hh:168
BaseCPU::addressMonitor
std::vector< AddressMonitor > addressMonitor
Definition: base.hh:612
simout
OutputDirectory simout
Definition: output.cc:59
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
AddressMonitor::gotWakeup
bool gotWakeup
Definition: base.hh:80
BaseCPU::unserializeThread
virtual void unserializeThread(CheckpointIn &cp, ThreadID tid)
Unserialize one thread.
Definition: base.hh:431
BaseCPU::switchedOut
bool switchedOut() const
Determine if the CPU is switched out.
Definition: base.hh:367
fatal_if
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Definition: logging.hh:219
BaseCPU::_switchedOut
bool _switchedOut
Is the CPU switched out or active?
Definition: base.hh:143
page_table.hh
CheckpointIn
Definition: serialize.hh:68
BaseCPU::unserialize
void unserialize(CheckpointIn &cp) override
Reconstruct the state of this object from a checkpoint.
Definition: base.cc:647
BaseCPU::BaseCPU
BaseCPU(const Params &params, bool is_checker=false)
Definition: base.cc:124
BaseCPU::probeInstCommit
virtual void probeInstCommit(const StaticInstPtr &inst, Addr pc)
Helper method to trigger PMU probes for a committed instruction.
Definition: base.cc:353
BaseCPU::getInstPort
virtual Port & getInstPort()=0
Purely virtual method that returns a reference to the instruction port.
ThreadContext::instAddr
virtual Addr instAddr() const =0
BaseCPU::waitForRemoteGDB
bool waitForRemoteGDB() const
Definition: base.cc:728
AddressMonitor::armed
bool armed
Definition: base.hh:75
csprintf
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:158
BaseCPU::~BaseCPU
virtual ~BaseCPU()
Definition: base.cc:186
thread_context.hh
BaseCPU::cpuId
int cpuId() const
Reads this CPU's ID.
Definition: base.hh:195
AddressMonitor::waiting
bool waiting
Definition: base.hh:79
BaseCPU::ppSleeping
ProbePointArg< bool > * ppSleeping
ProbePoint that signals transitions of threadContexts sets.
Definition: base.hh:519
ArmISA::mask
Bitfield< 28, 24 > mask
Definition: miscregs_types.hh:711
CheckerCPU::getMMUPtr
BaseMMU * getMMUPtr()
Definition: cpu.hh:153
BaseCPU::GlobalStats::hostOpRate
::Stats::Formula hostOpRate
Definition: base.hh:156
BaseCPU::GlobalStats
Global CPU statistics that are merged into the Root object.
Definition: base.hh:149
BaseCPU::powerGatingOnIdle
const bool powerGatingOnIdle
Definition: base.hh:633

Generated on Tue Mar 23 2021 19:41:24 for gem5 by doxygen 1.8.17