gem5  v19.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 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  * Authors: Steve Reinhardt
44  * Nathan Binkert
45  * Rick Strong
46  */
47 
48 #include "cpu/base.hh"
49 
50 #include <iostream>
51 #include <sstream>
52 #include <string>
53 
54 #include "arch/generic/tlb.hh"
55 #include "base/cprintf.hh"
56 #include "base/loader/symtab.hh"
57 #include "base/logging.hh"
58 #include "base/output.hh"
59 #include "base/trace.hh"
60 #include "cpu/checker/cpu.hh"
61 #include "cpu/cpuevent.hh"
62 #include "cpu/profile.hh"
63 #include "cpu/thread_context.hh"
64 #include "debug/Mwait.hh"
65 #include "debug/SyscallVerbose.hh"
66 #include "debug/Thread.hh"
67 #include "mem/page_table.hh"
68 #include "params/BaseCPU.hh"
69 #include "sim/clocked_object.hh"
70 #include "sim/full_system.hh"
71 #include "sim/process.hh"
72 #include "sim/sim_events.hh"
73 #include "sim/sim_exit.hh"
74 #include "sim/system.hh"
75 
76 // Hack
77 #include "sim/stat_control.hh"
78 
79 using namespace std;
80 
82 
83 // This variable reflects the max number of threads in any CPU. Be
84 // careful to only use it once all the CPUs that you care about have
85 // been initialized
87 
89  : Event(Event::Progress_Event_Pri), _interval(ival), lastNumInst(0),
90  cpu(_cpu), _repeatEvent(true)
91 {
92  if (_interval)
93  cpu->schedule(this, curTick() + _interval);
94 }
95 
96 void
98 {
99  Counter temp = cpu->totalOps();
100 
101  if (_repeatEvent)
102  cpu->schedule(this, curTick() + _interval);
103 
104  if (cpu->switchedOut()) {
105  return;
106  }
107 
108 #ifndef NDEBUG
109  double ipc = double(temp - lastNumInst) / (_interval / cpu->clockPeriod());
110 
111  DPRINTFN("%s progress event, total committed:%i, progress insts committed: "
112  "%lli, IPC: %0.8d\n", cpu->name(), temp, temp - lastNumInst,
113  ipc);
114  ipc = 0.0;
115 #else
116  cprintf("%lli: %s progress event, total committed:%i, progress insts "
117  "committed: %lli\n", curTick(), cpu->name(), temp,
118  temp - lastNumInst);
119 #endif
120  lastNumInst = temp;
121 }
122 
123 const char *
125 {
126  return "CPU Progress";
127 }
128 
129 BaseCPU::BaseCPU(Params *p, bool is_checker)
130  : ClockedObject(p), instCnt(0), _cpuId(p->cpu_id), _socketId(p->socket_id),
131  _instMasterId(p->system->getMasterId(this, "inst")),
132  _dataMasterId(p->system->getMasterId(this, "data")),
133  _taskId(ContextSwitchTaskId::Unknown), _pid(invldPid),
134  _switchedOut(p->switched_out), _cacheLineSize(p->system->cacheLineSize()),
135  interrupts(p->interrupts), profileEvent(NULL),
136  numThreads(p->numThreads), system(p->system),
137  previousCycle(0), previousState(CPU_STATE_SLEEP),
138  functionTraceStream(nullptr), currentFunctionStart(0),
139  currentFunctionEnd(0), functionEntryTick(0),
140  addressMonitor(p->numThreads),
141  syscallRetryLatency(p->syscallRetryLatency),
142  pwrGatingLatency(p->pwr_gating_latency),
143  powerGatingOnIdle(p->power_gating_on_idle),
144  enterPwrGatingEvent([this]{ enterPwrGating(); }, name())
145 {
146  // if Python did not provide a valid ID, do it here
147  if (_cpuId == -1 ) {
148  _cpuId = cpuList.size();
149  }
150 
151  // add self to global list of CPUs
152  cpuList.push_back(this);
153 
154  DPRINTF(SyscallVerbose, "Constructing CPU with id %d, socket id %d\n",
155  _cpuId, _socketId);
156 
159 
160  functionTracingEnabled = false;
161  if (p->function_trace) {
162  const string fname = csprintf("ftrace.%s", name());
164 
166  functionEntryTick = p->function_trace_start;
167 
168  if (p->function_trace_start == 0) {
169  functionTracingEnabled = true;
170  } else {
171  Event *event = new EventFunctionWrapper(
172  [this]{ enableFunctionTrace(); }, name(), true);
173  schedule(event, p->function_trace_start);
174  }
175  }
176 
177  // The interrupts should always be present unless this CPU is
178  // switched in later or in case it is a checker CPU
179  if (!params()->switched_out && !is_checker) {
180  fatal_if(interrupts.size() != numThreads,
181  "CPU %s has %i interrupt controllers, but is expecting one "
182  "per thread (%i)\n",
183  name(), interrupts.size(), numThreads);
184  for (ThreadID tid = 0; tid < numThreads; tid++)
185  interrupts[tid]->setCPU(this);
186  }
187 
188  if (FullSystem) {
189  if (params()->profile)
191  [this]{ processProfileEvent(); },
192  name());
193  }
194  tracer = params()->tracer;
195 
196  if (params()->isa.size() != numThreads) {
197  fatal("Number of ISAs (%i) assigned to the CPU does not equal number "
198  "of threads (%i).\n", params()->isa.size(), numThreads);
199  }
200 }
201 
202 void
204 {
205  functionTracingEnabled = true;
206 }
207 
209 {
210  delete profileEvent;
211 }
212 
213 void
215 {
216  assert(tid < numThreads);
217  AddressMonitor &monitor = addressMonitor[tid];
218 
219  monitor.armed = true;
220  monitor.vAddr = address;
221  monitor.pAddr = 0x0;
222  DPRINTF(Mwait,"[tid:%d] Armed monitor (vAddr=0x%lx)\n", tid, address);
223 }
224 
225 bool
227 {
228  assert(tid < numThreads);
229  AddressMonitor &monitor = addressMonitor[tid];
230 
231  if (!monitor.gotWakeup) {
232  int block_size = cacheLineSize();
233  uint64_t mask = ~((uint64_t)(block_size - 1));
234 
235  assert(pkt->req->hasPaddr());
236  monitor.pAddr = pkt->getAddr() & mask;
237  monitor.waiting = true;
238 
239  DPRINTF(Mwait,"[tid:%d] mwait called (vAddr=0x%lx, "
240  "line's paddr=0x%lx)\n", tid, monitor.vAddr, monitor.pAddr);
241  return true;
242  } else {
243  monitor.gotWakeup = false;
244  return false;
245  }
246 }
247 
248 void
250 {
251  assert(tid < numThreads);
252  AddressMonitor &monitor = addressMonitor[tid];
253 
254  RequestPtr req = std::make_shared<Request>();
255 
256  Addr addr = monitor.vAddr;
257  int block_size = cacheLineSize();
258  uint64_t mask = ~((uint64_t)(block_size - 1));
259  int size = block_size;
260 
261  //The address of the next line if it crosses a cache line boundary.
262  Addr secondAddr = roundDown(addr + size - 1, block_size);
263 
264  if (secondAddr > addr)
265  size = secondAddr - addr;
266 
267  req->setVirt(0, addr, size, 0x0, dataMasterId(), tc->instAddr());
268 
269  // translate to physical address
270  Fault fault = dtb->translateAtomic(req, tc, BaseTLB::Read);
271  assert(fault == NoFault);
272 
273  monitor.pAddr = req->getPaddr() & mask;
274  monitor.waiting = true;
275 
276  DPRINTF(Mwait,"[tid:%d] mwait called (vAddr=0x%lx, line's paddr=0x%lx)\n",
277  tid, monitor.vAddr, monitor.pAddr);
278 }
279 
280 void
282 {
283  // Set up instruction-count-based termination events, if any. This needs
284  // to happen after threadContexts has been constructed.
285  if (params()->max_insts_any_thread != 0) {
286  const char *cause = "a thread reached the max instruction count";
287  for (ThreadID tid = 0; tid < numThreads; ++tid)
288  scheduleInstStop(tid, params()->max_insts_any_thread, cause);
289  }
290 
291  // Set up instruction-count-based termination events for SimPoints
292  // Typically, there are more than one action points.
293  // Simulation.py is responsible to take the necessary actions upon
294  // exitting the simulation loop.
295  if (!params()->simpoint_start_insts.empty()) {
296  const char *cause = "simpoint starting point found";
297  for (size_t i = 0; i < params()->simpoint_start_insts.size(); ++i)
298  scheduleInstStop(0, params()->simpoint_start_insts[i], cause);
299  }
300 
301  if (params()->max_insts_all_threads != 0) {
302  const char *cause = "all threads reached the max instruction count";
303 
304  // allocate & initialize shared downcounter: each event will
305  // decrement this when triggered; simulation will terminate
306  // when counter reaches 0
307  int *counter = new int;
308  *counter = numThreads;
309  for (ThreadID tid = 0; tid < numThreads; ++tid) {
310  Event *event = new CountedExitEvent(cause, *counter);
311  threadContexts[tid]->scheduleInstCountEvent(
312  event, params()->max_insts_all_threads);
313  }
314  }
315 
316  if (!params()->switched_out) {
318 
320  }
321 }
322 
323 void
325 {
326  if (FullSystem) {
327  if (!params()->switched_out && profileEvent)
329  }
330 
331  if (params()->progress_interval) {
332  new CPUProgressEvent(this, params()->progress_interval);
333  }
334 
335  if (_switchedOut)
336  ClockedObject::pwrState(Enums::PwrState::OFF);
337 
338  // Assumption CPU start to operate instantaneously without any latency
339  if (ClockedObject::pwrState() == Enums::PwrState::UNDEFINED)
340  ClockedObject::pwrState(Enums::PwrState::ON);
341 
342 }
343 
346 {
348  ptr.reset(new ProbePoints::PMU(getProbeManager(), name));
349 
350  return ptr;
351 }
352 
353 void
355 {
356  ppAllCycles = pmuProbePoint("Cycles");
357  ppActiveCycles = pmuProbePoint("ActiveCycles");
358 
359  ppRetiredInsts = pmuProbePoint("RetiredInsts");
360  ppRetiredInstsPC = pmuProbePoint("RetiredInstsPC");
361  ppRetiredLoads = pmuProbePoint("RetiredLoads");
362  ppRetiredStores = pmuProbePoint("RetiredStores");
363  ppRetiredBranches = pmuProbePoint("RetiredBranches");
364 
366  "Sleeping");
367 }
368 
369 void
371 {
372  if (!inst->isMicroop() || inst->isLastMicroop()) {
373  ppRetiredInsts->notify(1);
374  ppRetiredInstsPC->notify(pc);
375  }
376 
377  if (inst->isLoad())
378  ppRetiredLoads->notify(1);
379 
380  if (inst->isStore() || inst->isAtomic())
381  ppRetiredStores->notify(1);
382 
383  if (inst->isControl())
384  ppRetiredBranches->notify(1);
385 }
386 
387 void
389 {
391 
392  using namespace Stats;
393 
394  numCycles
395  .name(name() + ".numCycles")
396  .desc("number of cpu cycles simulated")
397  ;
398 
400  .name(name() + ".numWorkItemsStarted")
401  .desc("number of work items this cpu started")
402  ;
403 
405  .name(name() + ".numWorkItemsCompleted")
406  .desc("number of work items this cpu completed")
407  ;
408 
409  int size = threadContexts.size();
410  if (size > 1) {
411  for (int i = 0; i < size; ++i) {
412  stringstream namestr;
413  ccprintf(namestr, "%s.ctx%d", name(), i);
414  threadContexts[i]->regStats(namestr.str());
415  }
416  } else if (size == 1)
417  threadContexts[0]->regStats(name());
418 }
419 
420 Port &
421 BaseCPU::getPort(const string &if_name, PortID idx)
422 {
423  // Get the right port based on name. This applies to all the
424  // subclasses of the base CPU and relies on their implementation
425  // of getDataPort and getInstPort.
426  if (if_name == "dcache_port")
427  return getDataPort();
428  else if (if_name == "icache_port")
429  return getInstPort();
430  else
431  return ClockedObject::getPort(if_name, idx);
432 }
433 
434 void
436 {
437  assert(system->multiThread || numThreads == 1);
438 
439  ThreadID size = threadContexts.size();
440  for (ThreadID tid = 0; tid < size; ++tid) {
441  ThreadContext *tc = threadContexts[tid];
442 
443  if (system->multiThread) {
445  } else {
447  }
448 
449  if (!FullSystem)
451  }
452 }
453 
454 void
456 {
459  }
460 }
461 
462 void
464 {
465  for (auto tc : threadContexts) {
466  if (tc->status() == ThreadContext::Active)
467  return;
468  }
469 
470  if (ClockedObject::pwrState() == Enums::PwrState::CLK_GATED &&
472  assert(!enterPwrGatingEvent.scheduled());
473  // Schedule a power gating event when clock gated for the specified
474  // amount of time
476  }
477 }
478 
479 int
481 {
482  ThreadID size = threadContexts.size();
483  for (ThreadID tid = 0; tid < size; ++tid) {
484  if (tc == threadContexts[tid])
485  return tid;
486  }
487  return 0;
488 }
489 
490 void
492 {
493  DPRINTF(Thread, "activate contextId %d\n",
494  threadContexts[thread_num]->contextId());
495  // Squash enter power gating event while cpu gets activated
498  // For any active thread running, update CPU power state to active (ON)
499  ClockedObject::pwrState(Enums::PwrState::ON);
500 
502 }
503 
504 void
506 {
507  DPRINTF(Thread, "suspend contextId %d\n",
508  threadContexts[thread_num]->contextId());
509  // Check if all threads are suspended
510  for (auto t : threadContexts) {
511  if (t->status() != ThreadContext::Suspended) {
512  return;
513  }
514  }
515 
516  // All CPU thread are suspended, update cycle count
518 
519  // All CPU threads suspended, enter lower power state for the CPU
520  ClockedObject::pwrState(Enums::PwrState::CLK_GATED);
521 
522  // If pwrGatingLatency is set to 0 then this mechanism is disabled
523  if (powerGatingOnIdle) {
524  // Schedule power gating event when clock gated for pwrGatingLatency
525  // cycles
527  }
528 }
529 
530 void
532 {
534 }
535 
536 void
538 {
539  ClockedObject::pwrState(Enums::PwrState::OFF);
540 }
541 
542 void
544 {
545  assert(!_switchedOut);
546  _switchedOut = true;
549 
550  // Flush all TLBs in the CPU to avoid having stale translations if
551  // it gets switched in later.
552  flushTLBs();
553 
554  // Go to the power gating state
555  ClockedObject::pwrState(Enums::PwrState::OFF);
556 }
557 
558 void
560 {
561  assert(threadContexts.size() == oldCPU->threadContexts.size());
562  assert(_cpuId == oldCPU->cpuId());
563  assert(_switchedOut);
564  assert(oldCPU != this);
565  _pid = oldCPU->getPid();
566  _taskId = oldCPU->taskId();
567  // Take over the power state of the switchedOut CPU
569 
570  previousState = oldCPU->previousState;
571  previousCycle = oldCPU->previousCycle;
572 
573  _switchedOut = false;
574 
575  ThreadID size = threadContexts.size();
576  for (ThreadID i = 0; i < size; ++i) {
577  ThreadContext *newTC = threadContexts[i];
578  ThreadContext *oldTC = oldCPU->threadContexts[i];
579 
580  newTC->takeOverFrom(oldTC);
581 
582  CpuEvent::replaceThreadContext(oldTC, newTC);
583 
584  assert(newTC->contextId() == oldTC->contextId());
585  assert(newTC->threadId() == oldTC->threadId());
586  system->replaceThreadContext(newTC, newTC->contextId());
587 
588  /* This code no longer works since the zero register (e.g.,
589  * r31 on Alpha) doesn't necessarily contain zero at this
590  * point.
591  if (DTRACE(Context))
592  ThreadContext::compare(oldTC, newTC);
593  */
594 
595  Port *old_itb_port = oldTC->getITBPtr()->getTableWalkerPort();
596  Port *old_dtb_port = oldTC->getDTBPtr()->getTableWalkerPort();
597  Port *new_itb_port = newTC->getITBPtr()->getTableWalkerPort();
598  Port *new_dtb_port = newTC->getDTBPtr()->getTableWalkerPort();
599 
600  // Move over any table walker ports if they exist
601  if (new_itb_port)
602  new_itb_port->takeOverFrom(old_itb_port);
603  if (new_dtb_port)
604  new_dtb_port->takeOverFrom(old_dtb_port);
605  newTC->getITBPtr()->takeOverFrom(oldTC->getITBPtr());
606  newTC->getDTBPtr()->takeOverFrom(oldTC->getDTBPtr());
607 
608  // Checker whether or not we have to transfer CheckerCPU
609  // objects over in the switch
610  CheckerCPU *oldChecker = oldTC->getCheckerCpuPtr();
611  CheckerCPU *newChecker = newTC->getCheckerCpuPtr();
612  if (oldChecker && newChecker) {
613  Port *old_checker_itb_port =
614  oldChecker->getITBPtr()->getTableWalkerPort();
615  Port *old_checker_dtb_port =
616  oldChecker->getDTBPtr()->getTableWalkerPort();
617  Port *new_checker_itb_port =
618  newChecker->getITBPtr()->getTableWalkerPort();
619  Port *new_checker_dtb_port =
620  newChecker->getDTBPtr()->getTableWalkerPort();
621 
622  newChecker->getITBPtr()->takeOverFrom(oldChecker->getITBPtr());
623  newChecker->getDTBPtr()->takeOverFrom(oldChecker->getDTBPtr());
624 
625  // Move over any table walker ports if they exist for checker
626  if (new_checker_itb_port)
627  new_checker_itb_port->takeOverFrom(old_checker_itb_port);
628  if (new_checker_dtb_port)
629  new_checker_dtb_port->takeOverFrom(old_checker_dtb_port);
630  }
631  }
632 
633  interrupts = oldCPU->interrupts;
634  for (ThreadID tid = 0; tid < numThreads; tid++) {
635  interrupts[tid]->setCPU(this);
636  }
637  oldCPU->interrupts.clear();
638 
639  if (FullSystem) {
640  for (ThreadID i = 0; i < size; ++i)
641  threadContexts[i]->profileClear();
642 
643  if (profileEvent)
645  }
646 
647  // All CPUs have an instruction and a data port, and the new CPU's
648  // ports are dangling while the old CPU has its ports connected
649  // already. Unbind the old CPU and then bind the ports of the one
650  // we are switching to.
651  getInstPort().takeOverFrom(&oldCPU->getInstPort());
652  getDataPort().takeOverFrom(&oldCPU->getDataPort());
653 }
654 
655 void
657 {
658  for (ThreadID i = 0; i < threadContexts.size(); ++i) {
660  CheckerCPU *checker(tc.getCheckerCpuPtr());
661 
662  tc.getITBPtr()->flushAll();
663  tc.getDTBPtr()->flushAll();
664  if (checker) {
665  checker->getITBPtr()->flushAll();
666  checker->getDTBPtr()->flushAll();
667  }
668  }
669 }
670 
671 void
673 {
674  ThreadID size = threadContexts.size();
675 
676  for (ThreadID i = 0; i < size; ++i)
677  threadContexts[i]->profileSample();
678 
679  schedule(profileEvent, curTick() + params()->profile);
680 }
681 
682 void
684 {
686 
687  if (!_switchedOut) {
688  /* Unlike _pid, _taskId is not serialized, as they are dynamically
689  * assigned unique ids that are only meaningful for the duration of
690  * a specific run. We will need to serialize the entire taskMap in
691  * system. */
693 
694  // Serialize the threads, this is done by the CPU implementation.
695  for (ThreadID i = 0; i < numThreads; ++i) {
696  ScopedCheckpointSection sec(cp, csprintf("xc.%i", i));
697  interrupts[i]->serialize(cp);
698  serializeThread(cp, i);
699  }
700  }
701 }
702 
703 void
705 {
707 
708  if (!_switchedOut) {
710 
711  // Unserialize the threads, this is done by the CPU implementation.
712  for (ThreadID i = 0; i < numThreads; ++i) {
713  ScopedCheckpointSection sec(cp, csprintf("xc.%i", i));
714  interrupts[i]->unserialize(cp);
715  unserializeThread(cp, i);
716  }
717  }
718 }
719 
720 void
721 BaseCPU::scheduleInstStop(ThreadID tid, Counter insts, const char *cause)
722 {
723  const Tick now(getCurrentInstCount(tid));
724  Event *event(new LocalSimLoopExitEvent(cause, 0));
725 
726  threadContexts[tid]->scheduleInstCountEvent(event, now + insts);
727 }
728 
729 Tick
731 {
732  return threadContexts[tid]->getCurrentInstCount();
733 }
734 
736  armed = false;
737  waiting = false;
738  gotWakeup = false;
739 }
740 
742  assert(pkt->req->hasPaddr());
743  if (armed && waiting) {
744  if (pAddr == pkt->getAddr()) {
745  DPRINTF(Mwait,"pAddr=0x%lx invalidated: waking up core\n",
746  pkt->getAddr());
747  waiting = false;
748  return true;
749  }
750  }
751  return false;
752 }
753 
754 
755 void
757 {
758  if (!debugSymbolTable)
759  return;
760 
761  // if pc enters different function, print new function symbol and
762  // update saved range. Otherwise do nothing.
763  if (pc < currentFunctionStart || pc >= currentFunctionEnd) {
764  string sym_str;
765  bool found = debugSymbolTable->findNearestSymbol(pc, sym_str,
768 
769  if (!found) {
770  // no symbol found: use addr as label
771  sym_str = csprintf("0x%x", pc);
773  currentFunctionEnd = pc + 1;
774  }
775 
776  ccprintf(*functionTraceStream, " (%d)\n%d: %s",
777  curTick() - functionEntryTick, curTick(), sym_str);
779  }
780 }
781 
782 bool
784 {
785  return params()->wait_for_remote_gdb;
786 }
uint32_t taskId() const
Get cpu task id.
Definition: base.hh:207
void ccprintf(cp::Print &print)
Definition: cprintf.hh:131
#define DPRINTF(x,...)
Definition: trace.hh:229
virtual const char * description() const
Return a C string describing the event.
Definition: base.cc:124
virtual void unserializeThread(CheckpointIn &cp, ThreadID tid)
Unserialize one thread.
Definition: base.hh:431
bool isStore() const
Definition: static_inst.hh:160
virtual void flushAll()=0
Remove all entries from the TLB.
Counter lastNumInst
Definition: base.hh:92
Ports are used to interface objects to each other.
Definition: port.hh:60
OutputDirectory simout
Definition: output.cc:65
BaseCPUParams Params
Definition: base.hh:310
virtual Port & getPort(const std::string &if_name, PortID idx=InvalidPortID)
Get a port with a given name and index.
Definition: sim_object.cc:126
virtual void probeInstCommit(const StaticInstPtr &inst, Addr pc)
Helper method to trigger PMU probes for a committed instruction.
Definition: base.cc:370
bool waiting
Definition: base.hh:84
Tick functionEntryTick
Definition: base.hh:564
static void replaceThreadContext(ThreadContext *oldTc, ThreadContext *newTc)
Update all events switching old tc to new tc.
Definition: cpuevent.cc:51
decltype(nullptr) constexpr NoFault
Definition: types.hh:245
int findContext(ThreadContext *tc)
Given a Thread Context pointer return the thread num.
Definition: base.cc:480
#define fatal(...)
This implements a cprintf based fatal() function.
Definition: logging.hh:175
ProbePoints::PMUUPtr ppRetiredStores
Retired store instructions.
Definition: base.hh:500
CheckerCPU class.
Definition: cpu.hh:87
Bitfield< 7 > i
ContextID registerThreadContext(ThreadContext *tc, ContextID assigned=InvalidContextID)
Definition: system.cc:259
ThreadID numThreads
Number of threads we&#39;re actually simulating (<= SMT_MAX_THREADS).
Definition: base.hh:378
virtual BaseTLB * getDTBPtr()=0
void registerThreadContexts()
Definition: base.cc:435
Tick instCnt
Instruction count used for SPARC misc register.
Definition: base.hh:115
void process()
Definition: base.cc:97
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:721
std::vector< BaseInterrupts * > interrupts
Definition: base.hh:222
bool isLoad() const
Definition: static_inst.hh:159
std::shared_ptr< Request > RequestPtr
Definition: request.hh:83
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port on this CPU.
Definition: base.cc:421
Stats::Scalar numWorkItemsCompleted
Definition: base.hh:605
EventFunctionWrapper enterPwrGatingEvent
Definition: base.hh:630
BaseCPU(Params *params, bool is_checker=false)
Definition: base.cc:129
bool armed
Definition: base.hh:80
ip6_addr_t addr
Definition: inet.hh:335
Addr pAddr
Definition: base.hh:82
uint64_t getCurrentInstCount(ThreadID tid)
Get the number of instructions executed by the specified thread on this CPU.
Definition: base.cc:730
virtual void activateContext(ThreadID thread_num)
Notify the CPU that the indicated context is now active.
Definition: base.cc:491
Cycles previousCycle
Definition: base.hh:528
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
Definition: root.cc:136
bool isAtomic() const
Definition: static_inst.hh:161
BaseCPU * cpu
Definition: base.hh:93
virtual Process * getProcessPtr()=0
bool switchedOut() const
Determine if the CPU is switched out.
Definition: base.hh:367
bool _switchedOut
Is the CPU switched out or active?
Definition: base.hh:148
virtual void regStats()
Callback to set stat parameters.
Definition: group.cc:66
SymbolTable * debugSymbolTable
Global unified debugging symbol table (for target).
Definition: symtab.cc:45
void unserialize(CheckpointIn &cp) override
Reconstruct the state of this object from a checkpoint.
Definition: base.cc:704
Overload hash function for BasicBlockRange type.
Definition: vec_reg.hh:586
const bool multiThread
Definition: system.hh:199
System * system
Definition: base.hh:386
Definition: cprintf.cc:42
virtual ~BaseCPU()
Definition: base.cc:208
bool gotWakeup
Definition: base.hh:85
int cpuId() const
Reads this CPU&#39;s ID.
Definition: base.hh:183
Tick clockPeriod() const
ThreadContext is the external interface to all thread state for anything outside of the CPU...
#define DPRINTFN(...)
Definition: trace.hh:233
STL vector class.
Definition: stl.hh:40
void deschedule(Event &event)
Definition: eventq.hh:750
void armMonitor(ThreadID tid, Addr address)
Definition: base.cc:214
std::ostream * stream() const
Get the output underlying output stream.
Definition: output.hh:64
const uint32_t _socketId
Each cpu will have a socket ID that corresponds to its physical location in the system.
Definition: base.hh:128
RequestPtr req
A pointer to the original request.
Definition: packet.hh:327
void regStats() override
Callback to set stat parameters.
Definition: base.cc:388
virtual void serializeThread(CheckpointOut &cp, ThreadID tid) const
Serialize a single thread.
Definition: base.hh:423
ProbePoints::PMUUPtr ppActiveCycles
CPU cycle counter, only counts if any thread contexts is active.
Definition: base.hh:509
std::vector< ThreadContext * > threadContexts
Definition: base.hh:267
Definition: tlb.hh:52
#define UNSERIALIZE_SCALAR(scalar)
Definition: serialize.hh:645
virtual void setContextId(ContextID id)=0
Tick curTick()
The current simulated tick.
Definition: core.hh:47
Bitfield< 4 > pc
virtual Port & getInstPort()=0
Purely virtual method that returns a reference to the instruction port.
Tick _interval
Definition: base.hh:91
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:162
void schedulePowerGatingEvent()
Definition: base.cc:463
bool scheduled() const
Determine if the current event is scheduled.
Definition: eventq.hh:385
void assignThreadContext(ContextID context_id)
Definition: process.hh:127
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:559
std::unique_ptr< PMU > PMUUPtr
Definition: pmu.hh:57
MasterID dataMasterId() const
Reads this CPU&#39;s unique data requestor ID.
Definition: base.hh:189
uint64_t Tick
Tick count type.
Definition: types.hh:63
void updateCycleCounters(CPUState state)
base method keeping track of cycle progression
Definition: base.hh:532
ProbePointArg< bool > * ppSleeping
ProbePoint that signals transitions of threadContexts sets.
Definition: base.hh:519
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
EventFunctionWrapper * profileEvent
Definition: base.hh:264
void startup() override
startup() is the final initialization call before simulation.
Definition: base.cc:324
ClockedObject declaration and implementation.
bool findNearestSymbol(Addr addr, std::string &symbol, Addr &symaddr, 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:116
bool doMonitor(PacketPtr pkt)
Definition: base.cc:741
ProbePoints::PMUUPtr ppRetiredInstsPC
Definition: base.hh:495
virtual BaseTLB * getITBPtr()=0
void enterPwrGating()
Definition: base.cc:537
int _cpuId
Definition: base.hh:121
Addr getAddr() const
Definition: packet.hh:726
std::vector< AddressMonitor > addressMonitor
Definition: base.hh:608
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Definition: logging.hh:203
void flushTLBs()
Flush all TLBs in the CPU.
Definition: base.cc:656
bool functionTracingEnabled
Definition: base.hh:560
void mwaitAtomic(ThreadID tid, ThreadContext *tc, BaseTLB *dtb)
Definition: base.cc:249
T roundDown(const T &val, const U &align)
This function is used to align addresses in memory.
Definition: intmath.hh:185
virtual void verifyMemoryMode() const
Verify that the system is in a memory mode supported by the CPU.
Definition: base.hh:378
BaseTLB * getDTBPtr()
Definition: cpu.hh:161
virtual Addr instAddr() const =0
virtual Counter totalOps() const =0
virtual void takeOverFrom(BaseTLB *otlb)=0
Take over from an old tlb context.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
uint32_t _pid
The current OS process ID that is executing on this processor.
Definition: base.hh:145
virtual const std::string name() const
Definition: sim_object.hh:120
int64_t Counter
Statistics counter type.
Definition: types.hh:58
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
int maxThreadsPerCPU
The maximum number of active threads across all cpus.
Definition: base.cc:86
Addr vAddr
Definition: base.hh:81
bool waitForRemoteGDB() const
Definition: base.cc:783
Bitfield< 10, 5 > event
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...
Special TaskIds that are used for per-context-switch stats dumps and Cache Occupancy.
Definition: request.hh:73
Bitfield< 15 > system
Definition: misc.hh:999
void processProfileEvent()
Definition: base.cc:672
virtual void switchOut()
Prepare for another CPU to take over execution.
Definition: base.cc:543
ProbePoints::PMUUPtr ppAllCycles
CPU cycle counter even if any thread Context is suspended.
Definition: base.hh:506
#define SERIALIZE_SCALAR(scalar)
Definition: serialize.hh:643
const bool powerGatingOnIdle
Definition: base.hh:629
ProbePoints::PMUUPtr pmuProbePoint(const char *name)
Helper method to instantiate probe points belonging to this object.
Definition: base.cc:345
Derived & name(const std::string &name)
Set the name and marks this stat to print at the end of simulation.
Definition: statistics.hh:279
Enums::PwrState pwrState() const
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:227
OutputStream * findOrCreate(const std::string &name, bool binary=false)
Definition: output.cc:258
bool mwait(ThreadID tid, PacketPtr pkt)
Definition: base.cc:226
unsigned int cacheLineSize() const
Get the cache line size of the system.
Definition: base.hh:391
virtual Port * getTableWalkerPort()
Get the table walker port if present.
Definition: tlb.hh:139
virtual CheckerCPU * getCheckerCpuPtr()=0
ProbePointArg generates a point for the class of Arg.
static std::vector< BaseCPU * > cpuList
Static global cpu list.
Definition: base.hh:569
void regProbePoints() override
Register probe points for this object.
Definition: base.cc:354
Declarations of a non-full system Page Table.
std::ostream CheckpointOut
Definition: serialize.hh:68
bool isControl() const
Definition: static_inst.hh:173
virtual void takeOverFrom(ThreadContext *old_context)=0
void deschedulePowerGatingEvent()
Definition: base.cc:455
Definition: eventq.hh:189
CPUState previousState
Definition: base.hh:529
void takeOverFrom(Port *old)
A utility function to make it easier to swap out ports.
Definition: port.hh:132
ProbePoints::PMUUPtr ppRetiredBranches
Retired branches (any type)
Definition: base.hh:503
virtual int threadId() const =0
void traceFunctionsInternal(Addr pc)
Definition: base.cc:756
ProbeManager * getProbeManager()
Get the probe manager for this object.
Definition: sim_object.cc:120
ProbePoints::PMUUPtr ppRetiredLoads
Retired load instructions.
Definition: base.hh:498
Stats::Scalar numCycles
Definition: base.hh:603
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: base.cc:281
virtual ContextID contextId() const =0
virtual Port & getDataPort()=0
Purely virtual method that returns a reference to the data port.
void replaceThreadContext(ThreadContext *tc, ContextID context_id)
Definition: system.cc:393
void schedule(Event &event, Tick when)
Definition: eventq.hh:744
uint32_t _taskId
An intrenal representation of a task identifier within gem5.
Definition: base.hh:141
Trace::InstTracer * tracer
Definition: base.hh:269
void serialize(CheckpointOut &cp) const override
Serialize this object to the given output stream.
Definition: base.cc:683
AddressMonitor()
Definition: base.cc:735
Addr currentFunctionEnd
Definition: base.hh:563
Bitfield< 3, 0 > mask
Definition: types.hh:64
Derived & desc(const std::string &_desc)
Set the description and marks this stat to print at the end of simulation.
Definition: statistics.hh:312
const Cycles pwrGatingLatency
Definition: base.hh:628
Temporarily inactive.
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:237
virtual void haltContext(ThreadID thread_num)
Notify the CPU that the indicated context is now halted.
Definition: base.cc:531
Bitfield< 5 > t
BaseTLB * getITBPtr()
Definition: cpu.hh:160
Scoped checkpoint section helper class.
Definition: serialize.hh:173
Bitfield< 0 > p
void enableFunctionTrace()
Definition: base.cc:203
std::shared_ptr< FaultBase > Fault
Definition: types.hh:240
const Params * params() const
Definition: base.hh:311
bool isMicroop() const
Definition: static_inst.hh:197
ProbePoints::PMUUPtr ppRetiredInsts
Instruction commit probe point.
Definition: base.hh:494
std::ostream * functionTraceStream
Definition: base.hh:561
uint32_t getPid() const
Definition: base.hh:211
virtual Fault translateAtomic(const RequestPtr &req, ThreadContext *tc, Mode mode)=0
virtual void suspendContext(ThreadID thread_num)
Notify the CPU that the indicated context is now suspended.
Definition: base.cc:505
bool isLastMicroop() const
Definition: static_inst.hh:199
void cprintf(const char *format, const Args &...args)
Definition: cprintf.hh:156
Stats::Scalar numWorkItemsStarted
Definition: base.hh:604
CPUProgressEvent(BaseCPU *_cpu, Tick ival=0)
Definition: base.cc:88
Addr currentFunctionStart
Definition: base.hh:562
bool _repeatEvent
Definition: base.hh:94

Generated on Fri Feb 28 2020 16:26:58 for gem5 by doxygen 1.8.13