Fix handling of a dynamically created event with an empty name - #168
Fix handling of a dynamically created event with an empty name#168atalii wants to merge 2 commits into
Conversation
|
What your patch does, is to make every event hierarchically named, including those created during simulation. This is allowed by the standard, see IEEE 1666-2023, 5.10.4:
So far, the reference implementation decided to NOT create hierarchically named events during simulation, which in turn results in:
According to the standard, this empty name is currently non-compliant:
To fix this, I would suggest to change inline const char*
sc_event::name() const
{
return SC_LIKELY_(!m_name.empty()) ? m_name.c_str() : "$$unnamed$$";
}The registration in the hierarchy still needs to be skipped during simulation to keep the original intent. |
|
Right, thanks a ton @pah - I assumed (wrongfully) that non-hierarchical events would still appear in Regarding your suggestion, I would prefer that |
6f1c5d9 to
a6e42e1
Compare
|
The latest commit counteracts the idea of keeping event generation during simulation lightweight to reduce the performance impact. Especially using My previous suggestion to return some non-unique string on demand is the minimal change required to make the implementation standards compliant again without any of the negative side effects in your proposal. Why did you change the tests? Explicit hierarchically named events are mandated by the standard and were supported before. |
Understandable - I didn't realize this was an important path for perf, nor that kernel event names were part of the public API.
I just misremembered and thought that these would also be implementation-defined when I saw the failing tests. Sorry about that. What would you think of the following? @@ -224,7 +224,10 @@ sc_event::register_event( const char* leaf_name, bool is_kernel_event /* = false
if( !leaf_name || !leaf_name[0] )
{
- if ( sc_is_running( m_simc ) ) return;
+ if ( sc_is_running( m_simc ) ) {
+ m_name = "$$unnamed$$";
+ return;
+ }
leaf_name = sc_gen_unique_name
( is_kernel_event ? SC_KERNEL_EVENT_PREFIX : "event" );
}I would prefer that m_name have the same meaning regardless of whether the event is hierarchical or not, but there may certainly be side effects to this change that I don't anticipate, as with my previous patch. Thanks for pointing these things out - I'm obviously not very familiar with all the stuff going on here, and I appreciate your guidance on what works and what doesn't :). |
|
@atalii, could you please rebase on main? |
The for (;;) construction is (more) clearly a while loop. Signed-off-by: Tali Auster <me@tali.network>
Per the LRM, an event created during simulation with an empty-name must end up with a non-empty name. Signed-off-by: Tali Auster <me@tali.network>
a6e42e1 to
54bf169
Compare
6f1c5d9 is the important commit; the message is copied below with some extra info following:
sc_event: support dynamic events with empty names
Per the LRM, an event created during or after initialization with an
empty name must still be initialized. It is implementation defined
whether or not this becomes a hierarchical event or a top-level event,
but in the first case, it must have a name that begins with "event".
Specifically, the GTest in the following module, instantiated in the
natural manner, fails prior to this commit:
My fix is to simply remove what I believe to be an errant refusal to
register a no-name event if the simulation is running.
Two additional points:
Thank you!