Gabe Black has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/52103 )

Change subject: sim: Create a StubWorkload for System.workload to default to.
......................................................................

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 <[email protected]>
Maintainer: Gabe Black <[email protected]>
Tested-by: kokoro <[email protected]>
---
M src/sim/workload.hh
M src/sim/system.cc
M src/sim/System.py
M configs/dram/low_power_sweep.py
M src/sim/Workload.py
5 files changed, 63 insertions(+), 13 deletions(-)

Approvals:
  Gabe Black: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/configs/dram/low_power_sweep.py b/configs/dram/low_power_sweep.py
index c21a180..db02a06 100644
--- a/configs/dram/low_power_sweep.py
+++ b/configs/dram/low_power_sweep.py
@@ -90,8 +90,6 @@
                                    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
diff --git a/src/sim/System.py b/src/sim/System.py
index d7b88b0..115fb94 100644
--- a/src/sim/System.py
+++ b/src/sim/System.py
@@ -44,6 +44,7 @@

 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 @@
     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")
diff --git a/src/sim/Workload.py b/src/sim/Workload.py
index 74d2306..8d63164 100644
--- a/src/sim/Workload.py
+++ b/src/sim/Workload.py
@@ -37,6 +37,13 @@
     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"
diff --git a/src/sim/system.cc b/src/sim/system.cc
index 14e6a78..86ba3be 100644
--- a/src/sim/system.cc
+++ b/src/sim/system.cc
@@ -96,9 +96,7 @@
 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 @@
                  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 @@
 {
     threads.insert(tc, assigned);

-    if (workload)
-        workload->registerThreadContext(tc);
+    workload->registerThreadContext(tc);

     for (auto *e: liveEvents)
         tc->schedule(e);
@@ -310,8 +308,7 @@
     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 @@
 bool
 System::trapToGdb(int signal, ContextID ctx_id) const
 {
-    return workload && workload->trapToGdb(signal, ctx_id);
+    return workload->trapToGdb(signal, ctx_id);
 }

 void
diff --git a/src/sim/workload.hh b/src/sim/workload.hh
index fa62555..c09c56c 100644
--- a/src/sim/workload.hh
+++ b/src/sim/workload.hh
@@ -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 StubWorkload : public Workload
+{
+  private:
+    PARAMS(StubWorkload);
+    loader::SymbolTable _symtab;
+
+  public:
+    StubWorkload(const StubWorkloadParams &params) : 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__

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/52103
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Idfc3e75c65318d75a3eae6a19944ae1f79a2d111
Gerrit-Change-Number: 52103
Gerrit-PatchSet: 10
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Earl Ou <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Matt Poremba <[email protected]>
Gerrit-Reviewer: Matt Sinclair <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-CC: Jason Lowe-Power <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to