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");
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",
271 DPRINTF(Loader,
"Loaded symbol: %s @ %#llx\n", symbol,
addr);
282 DPRINTF(PseudoInst,
"pseudo_inst::initParam() key:%s%s\n",
283 (
char *)&key_str1, (
char *)&key_str2);
288 const int len = 2 *
sizeof(uint64_t) + 1;
290 std::memset(key,
'\0',
len);
292 std::array<uint64_t, 2> key_regs = {{ key_str1, key_str2 }};
293 key_regs =
letoh(key_regs);
294 std::memcpy(key, key_regs.data(),
sizeof(key_regs));
297 const std::string key_str(key);
300 else if (key == DIST_RANK)
302 else if (key == DIST_SIZE)
305 panic(
"Unknown key for initparam pseudo instruction:\"%s\"", key_str);
312 DPRINTF(PseudoInst,
"pseudo_inst::resetstats(%i, %i)\n", delay, period);
326 DPRINTF(PseudoInst,
"pseudo_inst::dumpstats(%i, %i)\n", delay, period);
340 DPRINTF(PseudoInst,
"pseudo_inst::dumpresetstats(%i, %i)\n", delay,
355 DPRINTF(PseudoInst,
"pseudo_inst::m5checkpoint(%i, %i)\n", delay, period);
369 DPRINTF(PseudoInst,
"pseudo_inst::readfile(0x%x, 0x%x, 0x%x)\n",
379 int fd = ::open(file.c_str(), O_RDONLY, 0);
381 panic(
"could not open file %s\n", file);
383 if (::lseek(
fd,
offset, SEEK_SET) < 0)
384 panic(
"could not seek: %s", strerror(errno));
386 char *buf =
new char[
len];
389 int bytes = ::read(
fd,
p,
len);
412 DPRINTF(PseudoInst,
"pseudo_inst::writefile(0x%x, 0x%x, 0x%x, 0x%x)\n",
416 std::string filename;
421 virt_proxy.
readString(filename, filename_addr);
432 std::ios::in | std::ios::out | std::ios::binary,
true);
437 panic(
"could not open file %s\n", filename);
445 char *buf =
new char[
len];
449 if (
os->fail() ||
os->bad())
450 panic(
"Error while doing writefile!\n");
462 DPRINTF(PseudoInst,
"pseudo_inst::debugbreak()\n");
469 DPRINTF(PseudoInst,
"pseudo_inst::switchcpu()\n");
476 DPRINTF(PseudoInst,
"pseudo_inst::togglesync()\n");
483 DPRINTF(PseudoInst,
"pseudo_inst::triggerWorkloadEvent()\n");
495 DPRINTF(PseudoInst,
"pseudo_inst::workbegin(%i, %i)\n", workid, threadid);
499 if (params.exit_on_work_items) {
500 exitSimLoop(
"workbegin",
static_cast<int>(workid));
504 DPRINTF(WorkItems,
"Work Begin workid: %d, threadid %d\n", workid,
513 if (params.work_item_id == -1 || params.work_item_id == workid) {
518 if (params.work_cpus_ckpt_count != 0 &&
519 sys->
markWorkItem(cpuId) >= params.work_cpus_ckpt_count) {
526 if (systemWorkBeginCount == params.work_begin_ckpt_count) {
534 if (systemWorkBeginCount == params.work_begin_exit_count) {
541 if (cpuId == params.work_begin_cpu_id_exit) {
558 DPRINTF(PseudoInst,
"pseudo_inst::workend(%i, %i)\n", workid, threadid);
562 if (params.exit_on_work_items) {
567 DPRINTF(WorkItems,
"Work End workid: %d, threadid %d\n", workid, threadid);
575 if (params.work_item_id == -1 || params.work_item_id == workid) {
580 if (params.work_cpus_ckpt_count != 0 &&
581 sys->
markWorkItem(cpuId) >= params.work_cpus_ckpt_count) {
588 if (params.work_end_ckpt_count != 0 &&
589 systemWorkEndCount == params.work_end_ckpt_count) {
597 if (params.work_end_exit_count != 0 &&
598 systemWorkEndCount == params.work_end_exit_count) {
int cpuId() const
Reads this CPU's ID.
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...
Tick nextCycle() const
Based on the clock of the object, determine the start tick of the first cycle that is at least one cy...
Cycles is a wrapper class for representing cycle counts, i.e.
static uint64_t rankParam()
Getter for the dist rank param.
static bool readyToExit(Tick delay)
Initiate the exit from the simulation.
static void toggleSync(ThreadContext *tc)
Trigger the primary to start/stop synchronization.
static bool readyToCkpt(Tick delay, Tick period)
Initiate taking a checkpoint.
static uint64_t sizeParam()
Getter for the dist size param.
void close(OutputStream *file)
Closes an output file and free the corresponding OutputFile.
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).
OutputStream * create(const std::string &name, bool binary=false, bool no_gz=false)
Creates a file in this directory (optionally compressed).
std::ostream * stream() const
Get the output underlying output stream.
This object is a proxy for a port or other object which implements the functional response protocol,...
void writeBlob(Addr addr, const void *p, int size) const
Same as tryWriteBlob, but insists on success.
void readString(std::string &str, Addr addr) const
Same as tryReadString, but insists on success.
void readBlob(Addr addr, void *p, int size) const
Higher level interfaces based on the above.
int markWorkItem(int index)
Called by pseudo_inst to mark the cpus actively executing work items.
uint64_t incWorkItemsEnd()
Called by pseudo_inst to track the number of work items completed by this system.
uint64_t incWorkItemsBegin()
Called by pseudo_inst to track the number of work items started by this system.
void workItemEnd(uint32_t tid, uint32_t workid)
Workload * workload
OS kernel.
void workItemBegin(uint32_t tid, uint32_t workid)
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual void activate()=0
Set the status to Active.
virtual System * getSystemPtr()=0
virtual Tick readLastActivate()=0
void quiesceTick(Tick resume)
Quiesce, suspend, and schedule activate at resume.
virtual Tick readLastSuspend()=0
void quiesce()
Quiesce thread context.
@ Suspended
Temporarily inactive.
virtual BaseCPU * getCpuPtr()=0
virtual Status status() const =0
This proxy attempts to translate virtual addresses using the TLBs.
virtual void event(ThreadContext *tc)
virtual bool insertSymbol(const loader::Symbol &symbol)=0
bool insert(const Symbol &symbol)
Insert a new symbol in the table if it does not already exist.
#define panic(...)
This implements a cprintf based panic() function.
#define fatal(...)
This implements a cprintf based fatal() function.
const Params & params() const
SymbolTable debugSymbolTable
Global unified debugging symbol table (for target).
uint64_t m5sum(ThreadContext *tc, uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f)
uint64_t rpns(ThreadContext *tc)
void loadsymbol(ThreadContext *tc)
void quiesceCycles(ThreadContext *tc, uint64_t cycles)
void arm(ThreadContext *tc)
void debugbreak(ThreadContext *tc)
void m5fail(ThreadContext *tc, Tick delay, uint64_t code)
void quiesce(ThreadContext *tc)
void addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr)
uint64_t writefile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset, Addr filename_addr)
uint64_t readfile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset)
void quiesceNs(ThreadContext *tc, uint64_t ns)
void m5exit(ThreadContext *tc, Tick delay)
void quiesceSkip(ThreadContext *tc)
void togglesync(ThreadContext *tc)
void resetstats(ThreadContext *tc, Tick delay, Tick period)
void workend(ThreadContext *tc, uint64_t workid, uint64_t threadid)
uint64_t initParam(ThreadContext *tc, uint64_t key_str1, uint64_t key_str2)
void triggerWorkloadEvent(ThreadContext *tc)
uint64_t quiesceTime(ThreadContext *tc)
void wakeCPU(ThreadContext *tc, uint64_t cpuid)
void m5checkpoint(ThreadContext *tc, Tick delay, Tick period)
void workbegin(ThreadContext *tc, uint64_t workid, uint64_t threadid)
void switchcpu(ThreadContext *tc)
void dumpstats(ThreadContext *tc, Tick delay, Tick period)
void dumpresetstats(ThreadContext *tc, Tick delay, Tick period)
void schedStatEvent(bool dump, bool reset, Tick when, Tick repeat)
Schedule statistics dumping.
GEM5_DEPRECATED_NAMESPACE(Units, units)
Units for Stats.
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
bool to_number(const std::string &value, Pixel &retval)
Tick curTick()
The universal simulation clock.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
uint64_t Tick
Tick count type.
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 (...
void eat_white(std::string &s)