[WIP] Added region aware testing#50
Conversation
@kc611 I see there is code to go from YAML to SCFG -- is this what this bullet refers to? |
esc
left a comment
There was a problem hiding this comment.
It looks mostly fine. I left some comments about code that needs to be cleaned up.
|
@kc611 also, The synthetic assignments need to save, which variable is being assigned. Also the synthetic branches and such need to store their table of variable -> destination. This is part of the graph and semantics so needs to be stores inside the |
Yes, it refers to updating the |
OK, can you tick that checkbox, or is there still stuff missing? |
|
It is still missing support for building region blocks. I have updated the description to include the final goal of this PR i.e. to get an automated test for transformed SCFGs which in our case is fig3 and fig4. |
Ah, so you can't get a graph back from YAML that contains region blocks?
Yes, and |
esc
left a comment
There was a problem hiding this comment.
One additional question, is the backedges is empty anyway, can we add code to omit that in input YAML?
| edges = {} | ||
| backedges = {} | ||
|
|
||
| def reverse_lookup(value): |
There was a problem hiding this comment.
The values are class constructors, not sure what type that is.
There was a problem hiding this comment.
I think the correct signature for this would be type[BasicBlock]
| "0": ["1", "2"], | ||
| "1": ["5"], | ||
| "2": ["1", "5"], | ||
| "3": ["1"], |
There was a problem hiding this comment.
Can you explain this case, it goes from 0 to 1 in the diff?
There was a problem hiding this comment.
Same as #50 (comment) except in this case since graphs are random it doesn't matter where they point.
| '2': ['1', '4'] | ||
| '3': ['0'] | ||
| '4': [] | ||
| backedges: |
There was a problem hiding this comment.
I think this is wrong. The original should never have any backedges. They are just edges to begin with. Part of the SCFG loop restructure is to go through and make the distinction between edges and backedges.
There was a problem hiding this comment.
The issue is, if there's an edge (that is not a back edge) pointing towards the head of the graph, then we have no way of automatically detecting which node is the head of the graph from YAML.
Since our code logic behaves as follows:
The head of the graph is the node towards which no edge is pointing towards.
To resolve this issue for this example we can simply have a placeholder head with no edges pointing towards it that in turn points towards the actual graph we need, that'll remove the need for back edges.
There was a problem hiding this comment.
This is also an offshoot variant of the issue faced by @sklam downstream in Numba, wherein he circumvented it by having a separate placeholder head and tail for every RegionBlock. Seems like that could be upstreamed here to fix it in the long run.
There was a problem hiding this comment.
I am not convinced that this is a good implementation. I think it should be possible to specify a cyclic graph in YAML and read it in. I think I can see a way to eliminate the need to detect a head. In general, I think cyclic, but reducible graphs should be supported.
|
@kc611 thank you for submitting this. I made two reviews with some sugggestions. Also, please don't forget #50 (comment) |
|
Also, I am not sure that the values of the control variables are being tested. Using the following diff, I was expecting the tests to fail: But they do seem to pass? |
Co-authored-by: esc <esc@users.noreply.github.com>
…nching properties
|
Seems like testing for equality assertions for synthetic assignments and synthetic branches has exposed a flaky failure in SCFG loop restructuring. (This can be tested by running the figure 3 test multiple times until you get a failure.) |
I think there are some fixes for this exact issue in: #57 -- I will investigate porting those fixes to this PR. |
This patch "seems" to fix things. I've run it several times now and I was unable to reproduce the error: Looking again at the patch in #57 -- there are only three changes that are not related to rendering. The above is one of them. Perhaps this is sufficient to fix the instability of the current loop restructure implementation. |
This removes non-determinism from the insertion order of the SYNTH_ASSIGN blocks such that the resulting SCFG output is stable and can be tested appropriately.
I pushed this change with 42434fd |
|
|
||
| seen = set() | ||
|
|
||
| def make_scfg(curr_heads: set, exiting: str = None): |
There was a problem hiding this comment.
I think this should not be a closure, unless it really needs to be.
There was a problem hiding this comment.
I managed to write this such that it isn't a closure.
There was a problem hiding this comment.
I investigated this a bit more and I think this function will need some significant changes so as to make it more readable and that it becomes clearer what goes on. I think the make_scfg shouldn't be a closure and I also think that some stuff can be decomposed into smaller functions too.
There was a problem hiding this comment.
I left a few comments, but I think there is some more work to do on this:
- Refactor
make_scfgso that it complies more closely with general software engineering best practices (low-coupling, high cohesion) - Refactor the need for having a graph with a pre-determined "head-node" to support cyclic graphs as YAML input.
esc
left a comment
There was a problem hiding this comment.
I would suggest to add some docstrings to the auxilliary methods and also place those into a class SCFGIO alongside make_scfg. Then, forward the methods from_yaml/to_yaml and from_dict/to_dictto the static methods of SCFGIO class. Make sure you also update the documentation to reflect this. The methods remaining in the original SCFG class can simply have a see also: in the NumPy style.
| SCFGRenderer(self).view(name) | ||
|
|
||
|
|
||
| def find_outer_graph(graph_dict: dict): |
| return outer_blocks | ||
|
|
||
|
|
||
| def extract_block_info(blocks, current_name, block_ref_dict, edges, backedges): |
As titled, this PR adds region-aware testing by modifying the
from_yamlandto_yamlmethods ofSCFG.Following is the task list for this PR:
from_yamlandto_yamlto new format.fig3andfig4