Gabe Black has submitted this change and it was merged. ( https://gem5-review.googlesource.com/c/public/gem5/+/12613 )

Change subject: systemc: Keep all pre-init processes on a single list.
......................................................................

systemc: Keep all pre-init processes on a single list.

We were keeping track of processes which should be initialized and
those which shouldn't on two different lists, and then processing
each list one after the other. This could reorder processes from the
order they were created, and so cause spurious differences which cause
the Accellera tests to fail.

This does make the scheduler slightly simpler, so it's not all bad.

Change-Id: I63306a41ce7bea91fa9ff2f6774ce9150134ce48
Reviewed-on: https://gem5-review.googlesource.com/c/12613
Reviewed-by: Gabe Black <[email protected]>
Maintainer: Gabe Black <[email protected]>
---
M src/systemc/channel/sc_clock.cc
M src/systemc/core/process.cc
M src/systemc/core/process.hh
M src/systemc/core/sc_module.cc
M src/systemc/core/sc_spawn.cc
M src/systemc/core/scheduler.cc
M src/systemc/core/scheduler.hh
7 files changed, 30 insertions(+), 59 deletions(-)

Approvals:
  Gabe Black: Looks good to me, approved; Looks good to me, approved



diff --git a/src/systemc/channel/sc_clock.cc b/src/systemc/channel/sc_clock.cc
index 2a41235..332604f 100644
--- a/src/systemc/channel/sc_clock.cc
+++ b/src/systemc/channel/sc_clock.cc
@@ -66,8 +66,8 @@
     createProcess()
     {
         p = new Method(name.c_str(), &funcWrapper, true);
+        p->dontInitialize(true);
         scheduler.reg(p);
-        scheduler.dontInitialize(p);
     }

     ~ClockTick()
diff --git a/src/systemc/core/process.cc b/src/systemc/core/process.cc
index e4d213b..553f332 100644
--- a/src/systemc/core/process.cc
+++ b/src/systemc/core/process.cc
@@ -314,12 +314,6 @@
 }

 void
-Process::dontInitialize()
-{
-    scheduler.dontInitialize(this);
-}
-
-void
 Process::finalize()
 {
     for (auto &s: pendingStaticSensitivities) {
@@ -400,9 +394,9 @@

Process::Process(const char *name, ProcessFuncWrapper *func, bool internal) :
     ::sc_core::sc_process_b(name), excWrapper(nullptr), func(func),
-    _internal(internal), _timedOut(false), _needsStart(true),
-    _isUnwinding(false), _terminated(false), _suspended(false),
-    _disabled(false), _syncReset(false), refCount(0),
+    _internal(internal), _timedOut(false), _dontInitialize(false),
+    _needsStart(true), _isUnwinding(false), _terminated(false),
+    _suspended(false), _disabled(false), _syncReset(false), refCount(0),
     stackSize(::Fiber::DefaultStackSize), dynamicSensitivity(nullptr)
 {
     _dynamic =
diff --git a/src/systemc/core/process.hh b/src/systemc/core/process.hh
index 1ea5997..4d88e27 100644
--- a/src/systemc/core/process.hh
+++ b/src/systemc/core/process.hh
@@ -319,9 +319,6 @@
     const ::sc_core::sc_event &resetEvent() { return _resetEvent; }
const ::sc_core::sc_event &terminatedEvent() { return _terminatedEvent; }

-    // This should only be called before initialization.
-    void dontInitialize();
-
     void setStackSize(size_t size) { stackSize = size; }

     void finalize();
@@ -347,6 +344,9 @@
     bool timedOut() { return _timedOut; }
     void timedOut(bool to) { _timedOut = to; }

+    bool dontInitialize() { return _dontInitialize; }
+    void dontInitialize(bool di) { _dontInitialize = di; }
+
   protected:
Process(const char *name, ProcessFuncWrapper *func, bool internal=false);

@@ -371,6 +371,8 @@
     // Needed to support the deprecated "timed_out" function.
     bool _timedOut;

+    bool _dontInitialize;
+
     bool _needsStart;
     bool _dynamic;
     bool _isUnwinding;
diff --git a/src/systemc/core/sc_module.cc b/src/systemc/core/sc_module.cc
index 2fc6e8c..e695f76 100644
--- a/src/systemc/core/sc_module.cc
+++ b/src/systemc/core/sc_module.cc
@@ -86,7 +86,7 @@
         return nullptr;
     }
     scheduler.reg(p);
-    p->dontInitialize();
+    p->dontInitialize(true);
     return p;
 }

@@ -296,7 +296,7 @@
 void
 sc_module::dont_initialize()
 {
-    ::sc_gem5::Process::newest()->dontInitialize();
+    ::sc_gem5::Process::newest()->dontInitialize(true);
 }

 void
diff --git a/src/systemc/core/sc_spawn.cc b/src/systemc/core/sc_spawn.cc
index 00fe502..9e2b4c8 100644
--- a/src/systemc/core/sc_spawn.cc
+++ b/src/systemc/core/sc_spawn.cc
@@ -66,6 +66,8 @@
     else
         proc = new Thread(name, func);

+    proc->dontInitialize(dontInitialize);
+
     if (opts) {
         for (auto e: opts->_events)
             proc->addStatic(new PendingSensitivityEvent(proc, e));
@@ -95,9 +97,6 @@

     scheduler.reg(proc);

-    if (dontInitialize)
-        scheduler.dontInitialize(proc);
-
     return proc;
 }

diff --git a/src/systemc/core/scheduler.cc b/src/systemc/core/scheduler.cc
index 8015809..fe00ac0 100644
--- a/src/systemc/core/scheduler.cc
+++ b/src/systemc/core/scheduler.cc
@@ -88,8 +88,6 @@
         deschedule(&maxTickEvent);

     Process *p;
-    while ((p = toFinalize.getNext()))
-        p->popListNode();
     while ((p = initList.getNext()))
         p->popListNode();
     while ((p = readyListMethods.getNext()))
@@ -105,22 +103,20 @@
 void
 Scheduler::initPhase()
 {
-    for (Process *p = toFinalize.getNext(); p; p = toFinalize.getNext()) {
-        p->finalize();
-        p->popListNode();
-
-        if (!p->hasStaticSensitivities() && !p->internal()) {
-            SC_REPORT_WARNING(
- "(W558) disable() or dont_initialize() called on process "
-                    "with no static sensitivity, it will be orphaned",
-                    p->name());
-        }
-    }
-
     for (Process *p = initList.getNext(); p; p = initList.getNext()) {
         p->finalize();
         p->popListNode();
-        p->ready();
+
+        if (p->dontInitialize()) {
+            if (!p->hasStaticSensitivities() && !p->internal()) {
+                SC_REPORT_WARNING(
+                        "(W558) disable() or dont_initialize() called on "
+                        "process with no static sensitivity, it will be "
+                        "orphaned", p->name());
+            }
+        } else {
+            p->ready();
+        }
     }

     runUpdate();
@@ -147,8 +143,9 @@
     if (initDone) {
         // If we're past initialization, finalize static sensitivity.
         p->finalize();
-        // Mark the process as ready.
-        p->ready();
+        // If not marked as dontInitialize, mark as ready.
+        if (!p->dontInitialize())
+            p->ready();
     } else {
// Otherwise, record that this process should be initialized once we
         // get there.
@@ -157,20 +154,6 @@
 }

 void
-Scheduler::dontInitialize(Process *p)
-{
-    if (initDone) {
-        // Pop this process off of the ready list.
-        p->popListNode();
-    } else {
-        // Push this process onto the list of processes which still need
- // their static sensitivity to be finalized. That implicitly pops it
-        // off the list of processes to be initialized/marked ready.
-        toFinalize.pushLast(p);
-    }
-}
-
-void
 Scheduler::yield()
 {
     // Pull a process from the active list.
@@ -240,15 +223,12 @@
 {
     bool was_ready;
     if (initDone) {
- // After initialization, the only list we can be on is the ready list.
+        // After initialization, check if we're on a ready list.
         was_ready = (p->nextListNode != nullptr);
         p->popListNode();
     } else {
-        // Check the ready lists to see if we find this process.
-        was_ready = listContains(&readyListMethods, p) ||
-            listContains(&readyListThreads, p);
-        if (was_ready)
-            toFinalize.pushLast(p);
+        // Nothing is ready before init.
+        was_ready = false;
     }
     return was_ready;
 }
diff --git a/src/systemc/core/scheduler.hh b/src/systemc/core/scheduler.hh
index 052be08..0bbc3da 100644
--- a/src/systemc/core/scheduler.hh
+++ b/src/systemc/core/scheduler.hh
@@ -173,9 +173,6 @@
     // Register a process with the scheduler.
     void reg(Process *p);

-    // Tell the scheduler not to initialize a process.
-    void dontInitialize(Process *p);
-
     // Run the next process, if there is one.
     void yield();

@@ -439,7 +436,6 @@
     bool runOnce;

     ProcessList initList;
-    ProcessList toFinalize;

     ProcessList *readyList;
     ProcessList readyListMethods;

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

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I63306a41ce7bea91fa9ff2f6774ce9150134ce48
Gerrit-Change-Number: 12613
Gerrit-PatchSet: 8
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Matthias Jung <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to