Efficient RawInstGraph::neighbors_directed
#52
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When I implemented a disabler to disable all the Instantiation-nodes, I noticed that the code got stuck trying to find all outgoing enabled successors of a node (this was with heaps-simpler3.log). After a detailed analysis, I noticed that the code got stuck in
InstGraph::analyse
, more specifically, when callingself.raw.neighbors_directed
on the node=2
.I found out that the issue was that in a graph like the one in the screenshot, if all successors of the top-most (white) node
=2
are disabled, it will essentially iterate through all paths inRawInstGraph::neighbors_directed
. In cases like the one shown in the screenshot, this will result in an exponential number of paths searched through and hence it gets stuck.To fix this, I added an efficient pre-computation to find the next enabled nodes (in either direction) right before the analysis in
InstGraph::initialise_default
such that subsequently in the analysis, we only have to access this field. To this end, I re-used theTransferInitialiser
that iterates through the graph in a DP-manner (in topological order for parents and reverse topological order for children) to compute the next enabled children and parents of a node. The code should be rather self-explanatory.I have tested the code with assertions to see whether the computed neighbours match with the previous version and it did. One thing I'm not sure of is if
InstGraph::initialise_default
is the right place to call this function.