-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Immediate start of federates with STP offset under decentralized coordination & fix target code STP_offset #2368
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change only works for the C target, and it relies on inspection of target code. The LF compiler does not understand C and interpreting target code should be left to the target compiler.
time
is a type in LF, and we need to make valid time literals part of the language. There are two ways to achieve this:
- Make all target code expressions valid time values and leave the type checking to the target compiler. Coincidently, Ability to use of target code expressions for time values in C++ #2369 implemented this recently for the C++ target. We could also enable this for C, but it would come at the cost of loosing static analyzability.
- Introduce a time literal in the LF syntax that represents the C value
FOREVER
. Since this would be a change in the language, I think it should go through the RFC process. It would also need to be implemented for all targets.
Could you explain what your PR is trying to achieve? Dataflow like behavior is quite vague.
Without this change, setting Regarding the dataflow-like behavior, in some cases the user wishes to use LF as dataflow reactions, as shown in the test file |
This is a bug in the LF compiler (more precisely, the Python code generator).
This is brittle as the LF compiler is neither a C compiler nor a Python interpreter. If a user places It is also brittle, because now the LF compiler defines what
We have many such "temporary fixes" in the code base, which accumulate to a significant amount of technical debt. To avoid more accumulation of technical debt, we made a commitment to evaluate PRs based on relevance and soundness (see CONTRIBUTING) and I do not consider the proposed solution to be sound for the reasons stated.
I do not understand how setting the STP offset to Also note that if you use microsteps in this way, you have to be careful, as you will eventually run out of microstep values. |
Thanks for the comment -- I implemented your proposed fix by inserting the expression verbatim if the expression is a code implementation. This implementation indeed fixes the bug for
I've updated the test. The previous test was setting
Microstep overflow is a concern in this dataflow fashion. If the application runs at 120 loops per second, a 32-bit unsigned integer would overflow in ~400 days. This could be resolved with changing the microstep to a 64-bit unsigned integer. |
I've created a GitHub issue #2374 for parsing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adjusting the PR. I will dismiss my request for changes, but I will leave approving to Edward as I cannot say I understand the meaning of setting the STP offset to forever. For me, this indicates that federates should wait forever before processing an event. If the idea is to avoid waiting, why not set the offset to 0? Either way, this should be documented appropriately and explained to users.
I think a more accurate description of this PR that reflects code change is immediate start of federates with STP offset under decentralized coordination & a fix that allows target code as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I edited the description to clarify why it is useful to set the STP_offset
to {= FOREVER =}
.
In decentralized coordination, the behavior used to be to wait for
STP_offset
before starting the worker threads. With this change, the federates start immediately without waiting forSTP_offset
. A test has been added for this change.When the user sets
STP_offset
toFOREVER
, it enables dataflow-like behavior, where a federate will wait until all network input ports have received a message with tag g or greater before advancing its tag to g.This PR is linked to this reactor-c PR.
This PR also includes a fix to
lfc
federated target that allows target language expressions such as{= FOREVER =}
asSTP_offset
. Without this fix,lfc
would throw an error whenSTP_offset
is any{= ... =}
expression: