Go to the documentation of this file.
58 #include "debug/Loader.hh"
59 #include "debug/Quiesce.hh"
60 #include "debug/WorkItems.hh"
64 #include "params/BaseCPU.hh"
77 using namespace statistics;
95 const std::string DEFAULT =
"";
99 const std::string DIST_RANK =
"dist-rank";
103 const std::string DIST_SIZE =
"dist-size";
110 DPRINTF(PseudoInst,
"pseudo_inst::arm()\n");
120 DPRINTF(PseudoInst,
"pseudo_inst::quiesce()\n");
127 DPRINTF(PseudoInst,
"pseudo_inst::quiesceSkip()\n");
134 DPRINTF(PseudoInst,
"pseudo_inst::quiesceNs(%i)\n",
ns);
141 DPRINTF(PseudoInst,
"pseudo_inst::quiesceCycles(%i)\n", cycles);
148 DPRINTF(PseudoInst,
"pseudo_inst::quiesceTime()\n");
157 DPRINTF(PseudoInst,
"pseudo_inst::rpns()\n");
164 DPRINTF(PseudoInst,
"pseudo_inst::wakeCPU(%i)\n",
cpuid);
168 warn(
"pseudo_inst::wakeCPU(%i), cpuid greater than number of contexts"
181 DPRINTF(PseudoInst,
"pseudo_inst::m5exit(%i)\n", delay);
184 exitSimLoop(
"m5_exit instruction encountered", 0, when, 0,
true);
191 uint64_t
d, uint64_t
e, uint64_t
f)
193 DPRINTF(PseudoInst,
"pseudo_inst::m5sum(%#x, %#x, %#x, %#x, %#x, %#x)\n",
195 return a +
b +
c +
d +
e +
f;
201 DPRINTF(PseudoInst,
"pseudo_inst::m5fail(%i, %i)\n", delay, code);
203 exitSimLoop(
"m5_fail instruction encountered", code, when, 0,
true);
209 DPRINTF(PseudoInst,
"pseudo_inst::loadsymbol()\n");
211 const std::string &filename = tc->
getCpuPtr()->system->params().symbolfile;
212 if (filename.empty()) {
217 std::ifstream file(filename.c_str());
220 fatal(
"file error: Can't open symbol table file %s\n", filename);
222 while (!file.eof()) {
223 getline(file, buffer);
229 if (idx == std::string::npos)
232 std::string address =
"0x" + buffer.substr(0, idx);
238 std::string symbol = buffer.substr(idx + 3);
248 { loader::Symbol::Binding::Global, symbol, addr })) {
253 DPRINTF(Loader,
"Loaded symbol: %s @ %#llx\n", symbol,
addr);
261 DPRINTF(PseudoInst,
"pseudo_inst::addsymbol(0x%x, 0x%x)\n",
266 readString(symbol, symbolAddr);
268 DPRINTF(Loader,
"Loaded symbol: %s @ %#llx\n", symbol,
addr);
279 DPRINTF(PseudoInst,
"pseudo_inst::initParam() key:%s%s\n",
280 (
char *)&key_str1, (
char *)&key_str2);
285 const int len = 2 *
sizeof(uint64_t) + 1;
287 std::memset(key,
'\0',
len);
289 std::array<uint64_t, 2> key_regs = {{ key_str1, key_str2 }};
290 key_regs =
letoh(key_regs);
291 std::memcpy(key, key_regs.data(),
sizeof(key_regs));
294 const std::string key_str(key);
296 return tc->
getCpuPtr()->system->init_param;
297 else if (key == DIST_RANK)
299 else if (key == DIST_SIZE)
302 panic(
"Unknown key for initparam pseudo instruction:\"%s\"", key_str);
309 DPRINTF(PseudoInst,
"pseudo_inst::resetstats(%i, %i)\n", delay, period);
310 if (!tc->
getCpuPtr()->params().do_statistics_insts)
323 DPRINTF(PseudoInst,
"pseudo_inst::dumpstats(%i, %i)\n", delay, period);
324 if (!tc->
getCpuPtr()->params().do_statistics_insts)
337 DPRINTF(PseudoInst,
"pseudo_inst::dumpresetstats(%i, %i)\n", delay,
339 if (!tc->
getCpuPtr()->params().do_statistics_insts)
352 DPRINTF(PseudoInst,
"pseudo_inst::m5checkpoint(%i, %i)\n", delay, period);
353 if (!tc->
getCpuPtr()->params().do_checkpoint_insts)
366 DPRINTF(PseudoInst,
"pseudo_inst::readfile(0x%x, 0x%x, 0x%x)\n",
376 int fd = ::open(file.c_str(), O_RDONLY, 0);
378 panic(
"could not open file %s\n", file);
380 if (::lseek(
fd,
offset, SEEK_SET) < 0)
381 panic(
"could not seek: %s", strerror(errno));
383 char *buf =
new char[
len];
386 int bytes = ::read(
fd,
p,
len);
397 writeBlob(
vaddr, buf, result);
406 DPRINTF(PseudoInst,
"pseudo_inst::writefile(0x%x, 0x%x, 0x%x, 0x%x)\n",
410 std::string filename;
412 readString(filename, filename_addr);
423 std::ios::in | std::ios::out | std::ios::binary,
true);
428 panic(
"could not open file %s\n", filename);
436 char *buf =
new char[
len];
440 if (
os->fail() ||
os->bad())
441 panic(
"Error while doing writefile!\n");
453 DPRINTF(PseudoInst,
"pseudo_inst::debugbreak()\n");
460 DPRINTF(PseudoInst,
"pseudo_inst::switchcpu()\n");
467 DPRINTF(PseudoInst,
"pseudo_inst::togglesync()\n");
474 DPRINTF(PseudoInst,
"pseudo_inst::triggerWorkloadEvent()\n");
486 DPRINTF(PseudoInst,
"pseudo_inst::workbegin(%i, %i)\n", workid, threadid);
490 if (params.exit_on_work_items) {
491 exitSimLoop(
"workbegin",
static_cast<int>(workid));
495 DPRINTF(WorkItems,
"Work Begin workid: %d, threadid %d\n", workid,
504 if (params.work_item_id == -1 || params.work_item_id == workid) {
509 if (params.work_cpus_ckpt_count != 0 &&
510 sys->
markWorkItem(cpuId) >= params.work_cpus_ckpt_count) {
517 if (systemWorkBeginCount == params.work_begin_ckpt_count) {
525 if (systemWorkBeginCount == params.work_begin_exit_count) {
532 if (cpuId == params.work_begin_cpu_id_exit) {
549 DPRINTF(PseudoInst,
"pseudo_inst::workend(%i, %i)\n", workid, threadid);
553 if (params.exit_on_work_items) {
558 DPRINTF(WorkItems,
"Work End workid: %d, threadid %d\n", workid, threadid);
566 if (params.work_item_id == -1 || params.work_item_id == workid) {
571 if (params.work_cpus_ckpt_count != 0 &&
572 sys->
markWorkItem(cpuId) >= params.work_cpus_ckpt_count) {
579 if (params.work_end_ckpt_count != 0 &&
580 systemWorkEndCount == params.work_end_ckpt_count) {
588 if (params.work_end_exit_count != 0 &&
589 systemWorkEndCount == params.work_end_exit_count) {
Tick curTick()
The universal simulation clock.
#define fatal(...)
This implements a cprintf based fatal() function.
static bool readyToExit(Tick delay)
Initiate the exit from the simulation.
GEM5_DEPRECATED_NAMESPACE(Units, units)
Units for Stats.
virtual System * getSystemPtr()=0
virtual Tick readLastSuspend()=0
void workItemEnd(uint32_t tid, uint32_t workid)
void workend(ThreadContext *tc, uint64_t workid, uint64_t threadid)
void quiesceNs(ThreadContext *tc, uint64_t ns)
uint64_t quiesceTime(ThreadContext *tc)
void debugbreak(ThreadContext *tc)
void switchcpu(ThreadContext *tc)
uint64_t incWorkItemsEnd()
Called by pseudo_inst to track the number of work items completed by this system.
Workload * workload
OS kernel.
void eat_white(std::string &s)
bool to_number(const std::string &value, Pixel &retval)
virtual void activate()=0
Set the status to Active.
OutputStream * create(const std::string &name, bool binary=false, bool no_gz=false)
Creates a file in this directory (optionally compressed).
void quiesce(ThreadContext *tc)
void exitSimLoop(const std::string &message, int exit_code, Tick when, Tick repeat, bool serialize)
Schedule an event to exit the simulation loop (returning to Python) at the end of the current cycle (...
virtual Status status() const =0
This proxy attempts to translate virtual addresses using the TLBs.
Cycles is a wrapper class for representing cycle counts, i.e.
uint64_t rpns(ThreadContext *tc)
void triggerWorkloadEvent(ThreadContext *tc)
std::ostream * stream() const
Get the output underlying output stream.
void close(OutputStream *file)
Closes an output file and free the corresponding OutputFile.
uint64_t incWorkItemsBegin()
Called by pseudo_inst to track the number of work items started by this system.
void loadsymbol(ThreadContext *tc)
void quiesceTick(Tick resume)
Quiesce, suspend, and schedule activate at resume.
uint64_t writefile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset, Addr filename_addr)
void wakeCPU(ThreadContext *tc, uint64_t cpuid)
ThreadContext is the external interface to all thread state for anything outside of the CPU.
void quiesce()
Quiesce thread context.
virtual void event(ThreadContext *tc)
const Params & params() const
@ Suspended
Temporarily inactive.
uint64_t Tick
Tick count type.
void m5checkpoint(ThreadContext *tc, Tick delay, Tick period)
virtual Tick readLastActivate()=0
OutputStream * open(const std::string &name, std::ios_base::openmode mode, bool recreateable=true, bool no_gz=false)
Open a file in this directory (optionally compressed).
uint64_t readfile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset)
void m5fail(ThreadContext *tc, Tick delay, uint64_t code)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
void quiesceSkip(ThreadContext *tc)
void resetstats(ThreadContext *tc, Tick delay, Tick period)
void arm(ThreadContext *tc)
void dumpresetstats(ThreadContext *tc, Tick delay, Tick period)
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
void workbegin(ThreadContext *tc, uint64_t workid, uint64_t threadid)
bool insert(const Symbol &symbol)
Insert a new symbol in the table if it does not already exist.
static uint64_t sizeParam()
Getter for the dist size param.
void addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr)
void quiesceCycles(ThreadContext *tc, uint64_t cycles)
void m5exit(ThreadContext *tc, Tick delay)
static bool readyToCkpt(Tick delay, Tick period)
Initiate taking a checkpoint.
int markWorkItem(int index)
Called by pseudo_inst to mark the cpus actively executing work items.
uint64_t m5sum(ThreadContext *tc, uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f)
virtual BaseCPU * getCpuPtr()=0
static void toggleSync(ThreadContext *tc)
Trigger the primary to start/stop synchronization.
void togglesync(ThreadContext *tc)
SymbolTable debugSymbolTable
Global unified debugging symbol table (for target).
static uint64_t rankParam()
Getter for the dist rank param.
void workItemBegin(uint32_t tid, uint32_t workid)
uint64_t initParam(ThreadContext *tc, uint64_t key_str1, uint64_t key_str2)
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
void dumpstats(ThreadContext *tc, Tick delay, Tick period)
virtual bool insertSymbol(const loader::Symbol &symbol)=0
void schedStatEvent(bool dump, bool reset, Tick when, Tick repeat)
Schedule statistics dumping.
#define panic(...)
This implements a cprintf based panic() function.
Generated on Wed Jul 13 2022 10:39:27 for gem5 by doxygen 1.8.17