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 <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
This commit is contained in:
Gabe Black
2018-09-05 19:28:44 -07:00
parent dee485ff67
commit 5ed90fffb6
6 changed files with 37 additions and 10 deletions

View File

@@ -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);
}

View File

@@ -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() >

View File

@@ -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;

View File

@@ -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();

View File

@@ -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)

View File

@@ -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()) {