sim: Create a StubWorkload for System.workload to default to.
This way there will always be a workload object, even if nothing needs to be set up. This default can also be used in low_power_sweep.py, where the workload object was just a placeholder. This will allow required functionality like determining endianness of a system into the workload, rather than (for instance) in the more generic System object. This also makes accessing less essential functionality simpler, because we don't have to detect whether the workload is there, and can just return default, placeholder values from the StubWorkload. Change-Id: Idfc3e75c65318d75a3eae6a19944ae1f79a2d111 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/52103 Reviewed-by: Gabe Black <gabe.black@gmail.com> Maintainer: Gabe Black <gabe.black@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -90,8 +90,6 @@ system.clk_domain = SrcClockDomain(clock = '2.0GHz',
|
||||
voltage_domain =
|
||||
VoltageDomain(voltage = '1V'))
|
||||
|
||||
system.workload = SEWorkload()
|
||||
|
||||
# We are fine with 256 MB memory for now.
|
||||
mem_range = AddrRange('256MB')
|
||||
# Start address is 0
|
||||
|
||||
@@ -44,6 +44,7 @@ from m5.proxy import *
|
||||
|
||||
from m5.objects.DVFSHandler import *
|
||||
from m5.objects.SimpleMemory import *
|
||||
from m5.objects.Workload import StubWorkload
|
||||
|
||||
class MemoryMode(Enum): vals = ['invalid', 'atomic', 'timing',
|
||||
'atomic_noncaching']
|
||||
@@ -117,7 +118,7 @@ class System(SimObject):
|
||||
work_cpus_ckpt_count = Param.Counter(0,
|
||||
"create checkpoint when active cpu count value is reached")
|
||||
|
||||
workload = Param.Workload(NULL, "Workload to run on this system")
|
||||
workload = Param.Workload(StubWorkload(), "Workload to run on this system")
|
||||
init_param = Param.UInt64(0, "numerical value to pass into simulator")
|
||||
readfile = Param.String("", "file to read startup script from")
|
||||
symbolfile = Param.String("", "file to get the symbols from")
|
||||
|
||||
@@ -37,6 +37,13 @@ class Workload(SimObject):
|
||||
wait_for_remote_gdb = Param.Bool(False,
|
||||
"Wait for a remote GDB connection");
|
||||
|
||||
class StubWorkload(Workload):
|
||||
type = 'StubWorkload'
|
||||
cxx_header = "sim/workload.hh"
|
||||
cxx_class = 'gem5::StubWorkload'
|
||||
|
||||
entry = Param.Addr(0, 'Dummy entry point for this workload.')
|
||||
|
||||
class KernelWorkload(Workload):
|
||||
type = 'KernelWorkload'
|
||||
cxx_header = "sim/kernel_workload.hh"
|
||||
|
||||
@@ -96,9 +96,7 @@ void
|
||||
System::Threads::Thread::quiesce() const
|
||||
{
|
||||
context->suspend();
|
||||
auto *workload = context->getSystemPtr()->workload;
|
||||
if (workload)
|
||||
workload->recordQuiesce();
|
||||
context->getSystemPtr()->workload->recordQuiesce();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -217,8 +215,9 @@ System::System(const Params &p)
|
||||
AddrRange(1, 0)), // Create an empty range if disabled
|
||||
redirectPaths(p.redirect_paths)
|
||||
{
|
||||
if (workload)
|
||||
workload->setSystem(this);
|
||||
panic_if(!workload, "No workload set for system %s "
|
||||
"(could use StubWorkload?).", name());
|
||||
workload->setSystem(this);
|
||||
|
||||
// add self to global system list
|
||||
systemList.push_back(this);
|
||||
@@ -277,8 +276,7 @@ System::registerThreadContext(ThreadContext *tc, ContextID assigned)
|
||||
{
|
||||
threads.insert(tc, assigned);
|
||||
|
||||
if (workload)
|
||||
workload->registerThreadContext(tc);
|
||||
workload->registerThreadContext(tc);
|
||||
|
||||
for (auto *e: liveEvents)
|
||||
tc->schedule(e);
|
||||
@@ -310,8 +308,7 @@ System::replaceThreadContext(ThreadContext *tc, ContextID context_id)
|
||||
auto *otc = threads[context_id];
|
||||
threads.replace(tc, context_id);
|
||||
|
||||
if (workload)
|
||||
workload->replaceThreadContext(tc);
|
||||
workload->replaceThreadContext(tc);
|
||||
|
||||
for (auto *e: liveEvents) {
|
||||
otc->remove(e);
|
||||
@@ -454,7 +451,7 @@ System::workItemEnd(uint32_t tid, uint32_t workid)
|
||||
bool
|
||||
System::trapToGdb(int signal, ContextID ctx_id) const
|
||||
{
|
||||
return workload && workload->trapToGdb(signal, ctx_id);
|
||||
return workload->trapToGdb(signal, ctx_id);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
|
||||
#include "base/loader/object_file.hh"
|
||||
#include "base/loader/symtab.hh"
|
||||
#include "params/StubWorkload.hh"
|
||||
#include "params/Workload.hh"
|
||||
#include "sim/sim_object.hh"
|
||||
#include "sim/stats.hh"
|
||||
@@ -159,6 +160,29 @@ class Workload : public SimObject
|
||||
/** @} */
|
||||
};
|
||||
|
||||
class StubWorkload : public Workload
|
||||
{
|
||||
private:
|
||||
PARAMS(StubWorkload);
|
||||
loader::SymbolTable _symtab;
|
||||
|
||||
public:
|
||||
StubWorkload(const StubWorkloadParams ¶ms) : Workload(params) {}
|
||||
|
||||
Addr getEntry() const override { return params().entry; }
|
||||
loader::Arch getArch() const override { return loader::UnknownArch; }
|
||||
const loader::SymbolTable &
|
||||
symtab(ThreadContext *tc) override
|
||||
{
|
||||
return _symtab;
|
||||
}
|
||||
bool
|
||||
insertSymbol(const loader::Symbol &symbol) override
|
||||
{
|
||||
return _symtab.insert(symbol);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace gem5
|
||||
|
||||
#endif // __SIM_WORKLOAD_HH__
|
||||
|
||||
Reference in New Issue
Block a user