Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/12599
Change subject: systemc: Warn if a process is dont_initialize with no
static sensitivieis.
......................................................................
systemc: Warn if a process is dont_initialize with no static sensitivieis.
Change-Id: I4db64f42872a6fb459faa401abdad3f168297347
---
M src/systemc/channel/sc_clock.cc
M src/systemc/core/process.cc
M src/systemc/core/process.hh
M src/systemc/core/process_types.hh
M src/systemc/core/sc_spawn.cc
M src/systemc/core/scheduler.cc
6 files changed, 37 insertions(+), 10 deletions(-)
diff --git a/src/systemc/channel/sc_clock.cc
b/src/systemc/channel/sc_clock.cc
index 7cdd1c1..25c07b3 100644
--- a/src/systemc/channel/sc_clock.cc
+++ b/src/systemc/channel/sc_clock.cc
@@ -61,7 +61,7 @@
{
_name += (to ? ".up_tick" : ".down_tick");
_procName = _name + ".p";
- p = new Method(_procName.c_str(), &funcWrapper);
+ p = new Method(_procName.c_str(), &funcWrapper, true);
scheduler.reg(p);
scheduler.dontInitialize(p);
}
diff --git a/src/systemc/core/process.cc b/src/systemc/core/process.cc
index b8eab3c..317e8c3 100644
--- a/src/systemc/core/process.cc
+++ b/src/systemc/core/process.cc
@@ -396,11 +396,12 @@
::sc_core::sc_report *Process::lastReport() const { return
_lastReport.get(); }
-Process::Process(const char *name, ProcessFuncWrapper *func) :
+Process::Process(const char *name, ProcessFuncWrapper *func, bool
internal) :
::sc_core::sc_process_b(name), excWrapper(nullptr), func(func),
- _needsStart(true), _isUnwinding(false), _terminated(false),
- _suspended(false), _disabled(false), _syncReset(false), refCount(0),
- stackSize(::Fiber::DefaultStackSize), dynamicSensitivity(nullptr)
+ _internal(internal), _needsStart(true), _isUnwinding(false),
+ _terminated(false), _suspended(false), _disabled(false),
_syncReset(false),
+ refCount(0), stackSize(::Fiber::DefaultStackSize),
+ dynamicSensitivity(nullptr)
{
_dynamic =
(::sc_core::sc_get_status() >
diff --git a/src/systemc/core/process.hh b/src/systemc/core/process.hh
index d28d463..4b43e1b 100644
--- a/src/systemc/core/process.hh
+++ b/src/systemc/core/process.hh
@@ -336,8 +336,11 @@
void lastReport(::sc_core::sc_report *report);
::sc_core::sc_report *lastReport() const;
+ bool hasStaticSensitivities() { return !staticSensitivities.empty(); }
+ bool internal() { return _internal; }
+
protected:
- Process(const char *name, ProcessFuncWrapper *func);
+ Process(const char *name, ProcessFuncWrapper *func, bool
internal=false);
static Process *_newest;
@@ -354,6 +357,9 @@
ProcessFuncWrapper *func;
sc_core::sc_curr_proc_kind _procKind;
+
+ bool _internal;
+
bool _needsStart;
bool _dynamic;
bool _isUnwinding;
diff --git a/src/systemc/core/process_types.hh
b/src/systemc/core/process_types.hh
index 5fbab80..6f603e7 100644
--- a/src/systemc/core/process_types.hh
+++ b/src/systemc/core/process_types.hh
@@ -39,7 +39,9 @@
class Method : public Process
{
public:
- Method(const char *name, ProcessFuncWrapper *func) : Process(name,
func) {}
+ Method(const char *name, ProcessFuncWrapper *func, bool
internal=false) :
+ Process(name, func, internal)
+ {}
const char *kind() const override { return "sc_method_process"; }
@@ -53,8 +55,8 @@
class Thread : public Process
{
public:
- Thread(const char *name, ProcessFuncWrapper *func) :
- Process(name, func), ctx(nullptr)
+ Thread(const char *name, ProcessFuncWrapper *func, bool
internal=false) :
+ Process(name, func, internal), ctx(nullptr)
{}
~Thread() { delete ctx; }
@@ -103,7 +105,8 @@
class CThread : public Thread
{
public:
- CThread(const char *name, ProcessFuncWrapper *func) : Thread(name,
func)
+ CThread(const char *name, ProcessFuncWrapper *func, bool
internal=false) :
+ Thread(name, func, internal)
{
// We'll be in the initialization list now, but we shouldn't be.
popListNode();
diff --git a/src/systemc/core/sc_spawn.cc b/src/systemc/core/sc_spawn.cc
index b0570a6..5356a18 100644
--- a/src/systemc/core/sc_spawn.cc
+++ b/src/systemc/core/sc_spawn.cc
@@ -83,6 +83,16 @@
proc->addStatic(new PendingSensitivityFinder(proc, f));
}
+ if (opts && opts->_dontInitialize &&
+ opts->_events.empty() && opts->_ports.empty() &&
+ opts->_exports.empty() && opts->_interfaces.empty() &&
+ opts->_finders.empty()) {
+ SC_REPORT_WARNING(
+ "(W558) disable() or dont_initialize() called on process "
+ "with no static sensitivity, it will be orphaned",
+ name);
+ }
+
scheduler.reg(proc);
if (dontInitialize)
diff --git a/src/systemc/core/scheduler.cc b/src/systemc/core/scheduler.cc
index 78b47cd..4c98b68 100644
--- a/src/systemc/core/scheduler.cc
+++ b/src/systemc/core/scheduler.cc
@@ -106,6 +106,13 @@
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()) {
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/12599
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: I4db64f42872a6fb459faa401abdad3f168297347
Gerrit-Change-Number: 12599
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