Go to the documentation of this file.
56 #include "config/the_isa.hh"
59 #include "debug/Loader.hh"
60 #include "debug/Quiesce.hh"
61 #include "debug/WorkItems.hh"
63 #include "params/BaseCPU.hh"
72 using namespace Stats;
83 namespace InitParamKey
162 warn(
"PseudoInst::wakeCPU(%i), cpuid greater than number of contexts"
178 exitSimLoop(
"m5_exit instruction encountered", 0, when, 0,
true);
185 uint64_t
d, uint64_t
e, uint64_t
f)
189 return a +
b +
c +
d +
e +
f;
197 exitSimLoop(
"m5_fail instruction encountered", code, when, 0,
true);
206 if (filename.empty()) {
211 std::ifstream file(filename.c_str());
214 fatal(
"file error: Can't open symbol table file %s\n", filename);
216 while (!file.eof()) {
217 getline(file, buffer);
223 if (idx == std::string::npos)
226 std::string address =
"0x" + buffer.substr(0, idx);
232 std::string symbol = buffer.substr(idx + 3);
242 { Loader::Symbol::Binding::Global, symbol, addr })) {
278 const int len = 2 *
sizeof(uint64_t) + 1;
280 std::memset(key,
'\0',
len);
282 std::array<uint64_t, 2> key_regs = {{ key_str1, key_str2 }};
283 key_regs =
letoh(key_regs);
284 std::memcpy(key, key_regs.data(),
sizeof(key_regs));
287 const std::string key_str(key);
295 panic(
"Unknown key for initparam pseudo instruction:\"%s\"", key_str);
368 int fd = ::open(file.c_str(), O_RDONLY, 0);
370 panic(
"could not open file %s\n", file);
372 if (::lseek(
fd,
offset, SEEK_SET) < 0)
373 panic(
"could not seek: %s", strerror(errno));
375 char *buf =
new char[
len];
378 int bytes = ::read(
fd,
p,
len);
401 std::string filename;
413 std::ios::in | std::ios::out | std::ios::binary,
true);
418 panic(
"could not open file %s\n", filename);
426 char *buf =
new char[
len];
429 if (
os->fail() ||
os->bad())
430 panic(
"Error while doing writefile!\n");
479 if (params.exit_on_work_items) {
480 exitSimLoop(
"workbegin",
static_cast<int>(workid));
484 DPRINTF(WorkItems,
"Work Begin workid: %d, threadid %d\n", workid,
493 if (params.work_item_id == -1 || params.work_item_id == workid) {
498 if (params.work_cpus_ckpt_count != 0 &&
499 sys->
markWorkItem(cpuId) >= params.work_cpus_ckpt_count) {
506 if (systemWorkBeginCount == params.work_begin_ckpt_count) {
514 if (systemWorkBeginCount == params.work_begin_exit_count) {
521 if (cpuId == params.work_begin_cpu_id_exit) {
542 if (params.exit_on_work_items) {
547 DPRINTF(WorkItems,
"Work End workid: %d, threadid %d\n", workid, threadid);
555 if (params.work_item_id == -1 || params.work_item_id == workid) {
560 if (params.work_cpus_ckpt_count != 0 &&
561 sys->
markWorkItem(cpuId) >= params.work_cpus_ckpt_count) {
568 if (params.work_end_ckpt_count != 0 &&
569 systemWorkEndCount == params.work_end_ckpt_count) {
577 if (params.work_end_exit_count != 0 &&
578 systemWorkEndCount == params.work_end_exit_count) {
#define fatal(...)
This implements a cprintf based fatal() function.
void debugbreak(ThreadContext *tc)
void workbegin(ThreadContext *tc, uint64_t workid, uint64_t threadid)
virtual void activate()=0
Set the status to Active.
void quiesce()
Quiesce thread context.
void workItemEnd(uint32_t tid, uint32_t workid)
const std::string DIST_RANK
Unique key for "rank" param (distributed gem5 runs)
void m5exit(ThreadContext *tc, Tick delay)
uint64_t Tick
Tick count type.
uint64_t rpns(ThreadContext *tc)
OutputStream * create(const std::string &name, bool binary=false, bool no_gz=false)
Creates a file in this directory (optionally compressed).
static void toggleSync(ThreadContext *tc)
Trigger the primary to start/stop synchronization.
int markWorkItem(int index)
Called by pseudo_inst to mark the cpus actively executing work items.
void workItemBegin(uint32_t tid, uint32_t workid)
uint64_t quiesceTime(ThreadContext *tc)
uint64_t incWorkItemsEnd()
Called by pseudo_inst to track the number of work items completed by this system.
void writeBlob(Addr addr, const void *p, int size) const
Same as tryWriteBlob, but insists on success.
void dumpstats(ThreadContext *tc, Tick delay, Tick period)
virtual Tick readLastSuspend()=0
bool to_number(const std::string &value, VecPredRegContainer< NumBits, Packed > &p)
Helper functions used for serialization/de-serialization.
uint64_t readfile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset)
virtual Tick readLastActivate()=0
void switchcpu(ThreadContext *tc)
SymbolTable debugSymbolTable
Global unified debugging symbol table (for target).
void togglesync(ThreadContext *tc)
const std::string DIST_SIZE
Unique key for "size" param (distributed gem5 runs)
static uint64_t rankParam()
Getter for the dist rank param.
Workload * workload
OS kernel.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
void readString(std::string &str, Addr addr) const
Same as tryReadString, but insists on success.
std::ostream * stream() const
Get the output underlying output stream.
uint64_t initParam(ThreadContext *tc, uint64_t key_str1, uint64_t key_str2)
void workend(ThreadContext *tc, uint64_t workid, uint64_t threadid)
void dumpresetstats(ThreadContext *tc, Tick delay, Tick period)
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...
void quiesceSkip(ThreadContext *tc)
void close(OutputStream *file)
Closes an output file and free the corresponding OutputFile.
virtual bool insertSymbol(const Loader::Symbol &symbol)=0
void triggerWorkloadEvent(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 (...
uint64_t incWorkItemsBegin()
Called by pseudo_inst to track the number of work items started by this system.
uint64_t m5sum(ThreadContext *tc, uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f)
virtual Status status() const =0
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.
uint64_t writefile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset, Addr filename_addr)
void quiesceTick(Tick resume)
Quiesce, suspend, and schedule activate at resume.
static bool readyToExit(Tick delay)
Initiate the exit from the simulation.
void eat_white(std::string &s)
void schedStatEvent(bool dump, bool reset, Tick when, Tick repeat)
Schedule statistics dumping.
virtual PortProxy & getVirtProxy()=0
@ Suspended
Temporarily inactive.
void quiesce(ThreadContext *tc)
void quiesceCycles(ThreadContext *tc, uint64_t cycles)
const std::string DEFAULT
The default key (empty string)
void wakeCPU(ThreadContext *tc, uint64_t cpuid)
static bool readyToCkpt(Tick delay, Tick period)
Initiate taking a checkpoint.
Cycles is a wrapper class for representing cycle counts, i.e.
Tick nextCycle() const
Based on the clock of the object, determine the start tick of the first cycle that is at least one cy...
void arm(ThreadContext *tc)
void m5checkpoint(ThreadContext *tc, Tick delay, Tick period)
Tick curTick()
The universal simulation clock.
void quiesceNs(ThreadContext *tc, uint64_t ns)
void addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr)
bool insert(const Symbol &symbol)
void loadsymbol(ThreadContext *tc)
const Params & params() const
void resetstats(ThreadContext *tc, Tick delay, Tick period)
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).
void readBlob(Addr addr, void *p, int size) const
Higher level interfaces based on the above.
virtual BaseCPU * getCpuPtr()=0
static uint64_t sizeParam()
Getter for the dist size param.
#define ULL(N)
uint64_t constant
int cpuId() const
Reads this CPU's ID.
virtual System * getSystemPtr()=0
#define panic(...)
This implements a cprintf based panic() function.
virtual void event(ThreadContext *tc)
Generated on Tue Mar 23 2021 19:41:28 for gem5 by doxygen 1.8.17