-
Notifications
You must be signed in to change notification settings - Fork 53
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
[semantics] Semantics of Empty
vs Seq
/Par(Empty)
#1526
Comments
😃 Always a fun kind of edge case to consider. My gut feeling says Option II (A terminates, B runs forever). The underlying semantic rules would be:
You're right that this is makes that An alternative would be for fully-structural components to be distinct from components with no control statements, i.e., |
One well formedness rule in calyx, that isn’t enforced, is that all components must take at least one cycle to execute (same as groups) so there are no components that terminate immediately |
In my eyes, both programs exhibit undefined behavior because they don’t have any internal signaling to force them to take at least one cucle |
Yeah, there's a strong argument for that as well. It would address the optimization problem: the However, we don't necessarily need to decide that Just for fun, I wanted to see what the compiler currently does, so I tried compiling this:
With this command (
And we produce:
i.e., we do the |
A decision about Also, |
Also, a related issue is #621 which also happens because we haven't really nailed down the timing restrictions for component |
Is there anything actionable for this issue? If we've decided on a particular semantics, let's document that in the docs page and close this issue? |
I think this is a good point. Think about a conditional with Empty in one branch. You have to interpret this Empty differently than you would interpret it at the top level, which is a sign of non-compositional weirdness. |
Closing since there's nothing actionable here right now |
Imagine a component like:
We'll call it version A (empty seq).
Imagine the same program but without the seq (empty control). Call that version B.
These programs are potentially a weird little semantic corner. To elaborate, there are three possible situations for each program:
My understanding of Calyx is that ver A (empty seq) falls into 1 (instant termination), while ver B (empty control) falls into one of the latter two options.
It seems "obvious" that the compiler should be able to turn
Seq([Empty])
intoEmpty
. This transformation may or may not be an actual optimization, but I'll call it such for the rest of this issue.Option I (both are invalid)
If this is true it suggests that a program must have exactly one of the following:
This also means our obvious optimization is valid.
Option II (A: terminates, B: runs forever)
This is consistent with my understanding of what a control program means and what a fully structural program means, however this means our optimization is invalid which seems off.
Option III (both run forever)
Optimization remains vaild, this however seems inconsistent with the my notional understanding of what a control program means.
Option IV (Both terminate instantly)
Optimization remains valid, this seems transparently incorrect with respect to the semantics of a control-free program.
All other options result in an invalid optimization and possibly clash with the generally understood behavior of Calyx programs.
The text was updated successfully, but these errors were encountered: