From: Gabe Black Date: Thu, 6 Sep 2018 02:28:44 +0000 (-0700) Subject: systemc: Warn if a process is dont_initialize with no static sensitivieis. X-Git-Tag: v19.0.0.0~1639 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5ed90fffb6bdbbd5fe2316687faff05f641d6692;p=gem5.git systemc: Warn if a process is dont_initialize with no static sensitivieis. Change-Id: I4db64f42872a6fb459faa401abdad3f168297347 Reviewed-on: https://gem5-review.googlesource.com/c/12599 Reviewed-by: Gabe Black Maintainer: Gabe Black --- diff --git a/src/systemc/channel/sc_clock.cc b/src/systemc/channel/sc_clock.cc index 7cdd1c1d1..25c07b3b2 100644 --- a/src/systemc/channel/sc_clock.cc +++ b/src/systemc/channel/sc_clock.cc @@ -61,7 +61,7 @@ class ClockTick : public ScEvent { _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 b8eab3cde..317e8c3a2 100644 --- a/src/systemc/core/process.cc +++ b/src/systemc/core/process.cc @@ -396,11 +396,12 @@ Process::lastReport(::sc_core::sc_report *report) ::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 d28d46396..4b43e1b7b 100644 --- a/src/systemc/core/process.hh +++ b/src/systemc/core/process.hh @@ -336,8 +336,11 @@ class Process : public ::sc_core::sc_process_b, public ListNode 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 @@ class Process : public ::sc_core::sc_process_b, public ListNode 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 5fbab8038..6f603e73f 100644 --- a/src/systemc/core/process_types.hh +++ b/src/systemc/core/process_types.hh @@ -39,7 +39,9 @@ namespace sc_gem5 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 Method : public Process 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 Thread : public Process 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 b0570a663..00fe502e6 100644 --- a/src/systemc/core/sc_spawn.cc +++ b/src/systemc/core/sc_spawn.cc @@ -83,6 +83,16 @@ spawnWork(ProcessFuncWrapper *func, const char *name, 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", + proc->name()); + } + scheduler.reg(proc); if (dontInitialize) diff --git a/src/systemc/core/scheduler.cc b/src/systemc/core/scheduler.cc index 78b47cd4d..4c98b68aa 100644 --- a/src/systemc/core/scheduler.cc +++ b/src/systemc/core/scheduler.cc @@ -106,6 +106,13 @@ 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()) {