Replies: 3 comments 11 replies
-
Thank you for the writeup, @calebmkim! As some additional context for others, I asked @calebmkim to jot this down as a draft for a page we will add to the documentation to define the semantics of the The apparent need for two annotations came up in the context of #1042, which is further explained in #1039. Take a look at the latter for details but the high-level motivation is that sharing for |
Beta Was this translation helpful? Give feedback.
-
To formalize this bit:
The assertion here is that
A way to operationalize this is to say that the sharing pass is always allowed to treat a |
Beta Was this translation helpful? Give feedback.
-
One final thing: @calebmkim, I don't quite understand what this assertion means in the sufficient condition for
Namely, I'm not sure what "the values for the output ports" are, and I'm not sure what "die" means. With an eye toward writing this up as a documentation page, maybe some concrete examples of |
Beta Was this translation helpful? Give feedback.
-
A component is "state shareable" if:
For any Calyx program, given two instances of the component, c1 and c2: if the live ranges of c1 and c2 do not overlap at all, then we can replace every use of c2 with c1 and the behavior of the program will not change. (Live range of a component, meaning the groups in which the value assigned to the components could potentially be read before the component is written to next).
A rough draft for sufficient criteria for state shareability for a given comp that @sampsyo have thought have (subject to change):
A component comp is "shareable" if:
For any Calyx program, given two instances of comp, c1 and c2, if c1 and c2 are guaranteed never to be used at the same time as each other, then we can replace every use of c2 with c1 and the behavior of the program will not change.
Potential criteria for shareability (should be improved):
An interesting thought @sampsyo and I discussed was this: it seems that shareability requires that any time you want to read a shareable component, you must also write to it in the same group. If you don't do this, then the output the component gives could be anything. Then, If I wrote a program using what I thought was a shareable component, but it turns out it was actually state shareable component, then my program still should behave as I intended it to.
(edit to add examples):
Example of state_shareable:
Example of non-shareable:
Beta Was this translation helpful? Give feedback.
All reactions