Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/12808

Change subject: systemc: Change how the scheduler orders processes.
......................................................................

systemc: Change how the scheduler orders processes.

The Accellera implementation looks like it does all the methods, then
all the threads, and then loops back and tries again, and there are
even comments in the code that suggests that. What it actually does,
however, is runs all the methods, then runs a single thread if one is
waiting, and then starts over. The effect is that the scheduler will
run any methods first, then run threads until a method might have
become ready, and then repeat.

This will actually result in more mixing of threads and methods, more
context switches, and worse performance, but it makes the regressions
pass more.

Change-Id: I7cb0485e26eed79204ff2a3c3ded27b973e0b7b0
---
M src/systemc/core/scheduler.cc
M src/systemc/core/scheduler.hh
2 files changed, 17 insertions(+), 22 deletions(-)



diff --git a/src/systemc/core/scheduler.cc b/src/systemc/core/scheduler.cc
index 8a796bb..9deb077 100644
--- a/src/systemc/core/scheduler.cc
+++ b/src/systemc/core/scheduler.cc
@@ -49,7 +49,7 @@
     _elaborationDone(false), _started(false), _stopNow(false),
     _status(StatusOther), maxTickEvent(this, false, MaxTickPriority),
     _numCycles(0), _changeStamp(0), _current(nullptr), initDone(false),
-    runOnce(false), readyList(nullptr)
+    runOnce(false)
 {}

 Scheduler::~Scheduler()
@@ -154,7 +154,7 @@
 Scheduler::yield()
 {
     // Pull a process from the active list.
-    _current = readyList->getNext();
+    _current = getNextReady();
     if (!_current) {
         // There are no more processes, so return control to evaluate.
         Fiber::primaryFiber()->run();
@@ -266,19 +266,8 @@

     // The evaluation phase.
     do {
-        // We run methods and threads in two seperate passes to emulate how
-        // Accellera orders things, but without having to scan through a
-        // unified list to find the next process of the correct type.
-        readyList = &readyListMethods;
-        while (!readyListMethods.empty())
-            yield();
-
-        readyList = &readyListThreads;
-        while (!readyListThreads.empty())
-            yield();
-
-        // We already know that readyListThreads is empty at this point.
-    } while (!readyListMethods.empty());
+        yield();
+    } while (getNextReady());

     if (!empty) {
         _numCycles++;
diff --git a/src/systemc/core/scheduler.hh b/src/systemc/core/scheduler.hh
index 33515ea..ad1467e 100644
--- a/src/systemc/core/scheduler.hh
+++ b/src/systemc/core/scheduler.hh
@@ -194,16 +194,16 @@
     void
     runNow(Process *p)
     {
- // This function may put a process on the wrong list, ie a method on
-        // the process list or vice versa. That's fine since that's just a
- // performance optimization, and the important thing here is how the
-        // processes are ordered.
+        // This function may put a process on the wrong list, ie a thread
+        // the method list. That's fine since that's just a performance
+ // optimization, and the important thing here is how the processes are
+        // ordered.

         // If a process is running, schedule it/us to run again.
         if (_current)
-            readyList->pushFirst(_current);
+            readyListMethods.pushFirst(_current);
         // Schedule p to run first.
-        readyList->pushFirst(p);
+        readyListMethods.pushFirst(p);
         yield();
     }

@@ -390,6 +390,13 @@
     ScEvents deltas;
     TimeSlots timeSlots;

+    Process *
+    getNextReady()
+    {
+        Process *p = readyListMethods.getNext();
+        return p ? p : readyListThreads.getNext();
+    }
+
     void runReady();
     EventWrapper<Scheduler, &Scheduler::runReady> readyEvent;
     void scheduleReadyEvent();
@@ -441,7 +448,6 @@

     ProcessList initList;

-    ProcessList *readyList;
     ProcessList readyListMethods;
     ProcessList readyListThreads;


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/12808
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: I7cb0485e26eed79204ff2a3c3ded27b973e0b7b0
Gerrit-Change-Number: 12808
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to