-
Notifications
You must be signed in to change notification settings - Fork 274
DOC-56: An overview of grapht and dependence_grapht in corresponding README.md. #4095
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
Conversation
dde98e0
to
1da964c
Compare
src/analyses/README.md
Outdated
### Dependence graph | ||
|
||
Implemented in `src/analyses/dependence_graph.h(cpp)`. It is a graph and an | ||
abstract interpreter in the same time. The abstract interpretation nature |
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.
at the same time
nature of abstract interpretation?
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.
The sentence says "nature of the dependence graph being (also) AI analyser" rather than "nature of abstract interpretation".
src/analyses/README.md
Outdated
|
||
Implemented in `src/analyses/dependence_graph.h(cpp)`. It is a graph and an | ||
abstract interpreter in the same time. The abstract interpretation nature | ||
allows a dependence graph to build itself (the graph) from a given GOTO program. |
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.
what does it mean for a graph to build itself?
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.
For a graph in general it would perhaps mean nothing. However, here we speak about a special graph - the dependence graph in our code base. It is not just a graph representing control/data-dependencies is some GOTO program. It is also AI analyser. You do not build it by calling its graph-interface methods for adding nodes and edges. You instead pass it GOTO program and it will run its AI-interface methods on it to perform the data- and control- dependency analyses (i.e. it uses its "AI" nature of being also an AI analyser) and then it runs its finalize
method to actually build the graph by calling graph-interface methods (to add control/data-dependency edges) from the results of the analyses.
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 think the wording here ("build itself") is just a bit weird, below you very nicely explain what is going on and it may be worth having a forward reference to that.
src/analyses/README.md
Outdated
A dependence graph extends the class `grapht` with `dep_nodet` as the type of | ||
nodes (see `src/util/graph.h` for more details about | ||
[graph representation](../util/README.md)). | ||
The `dep_nodet` extends `graph_nodet<dep_edget>` by an iterator to a GOTO |
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.
with an iterator?
nodes (see `src/util/graph.h` for more details about | ||
[graph representation](../util/README.md)). | ||
The `dep_nodet` extends `graph_nodet<dep_edget>` by an iterator to a GOTO | ||
program instruction. It means that each graph node corresponds to a particular |
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.
what is "It" here?
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.
The information of the previous sentence - the fact that each node stores an iterator to a GOTO instruction.
src/analyses/README.md
Outdated
program instruction. It means that each graph node corresponds to a particular | ||
program instruction. A labelled edge `(u, v)` of a dependence graph expresses | ||
a dependency of the program instruction corresponding to node `u` on the program | ||
instruction corresponding to node `v`. The label of the edge (i.e. data of the |
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.
writing style guide recommends no latin (i.e.)
Implemented in `src/util/graph.h` as `grapht` class. The class natively defines | ||
only a directional graph. However, an undirected graph can be emulated by | ||
inserting for each edge (u, v) also (v, u). A multi-graph is not supported | ||
though, because parallel edges are not allowed between vertices. |
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 believe this can be simplified to "The grapht class represents a directed graph"; I don't think there's normally an expectation that any graph representation can also represent a multi graph directly, and a multi graph can be embedded in a directed graph in a similar way to how undirected graphs can be represented, so I don't necessarily think it's worth calling this out as a deficiency.
src/util/README.md
Outdated
|
||
#### Data representation | ||
|
||
A graph is defined by a template class `grapht<N>`, where the type `N` defines |
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.
where N
is the type of the nodes of the graph?
- It must be default constructible; the common way how to insert a node to the | ||
graph is to call method `add_node` which pushes a new default-constructed | ||
instance of `N` to the end of the vector and returns its index. | ||
- It must define a type `edget`, representing type of data attached to any edge |
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 wonder why we do it this way; I can't see any obvious reason why the edge type necessarily follows from the node type. It seems the type parameter here doesn't specify the node type, but actually both the node type and the edge type? Maybe it would be worth refactoring the graph to work like this grapht<graph_configt> { using node_t = typename graph_configt::node_t; using edge_t = graph_configt::edge_t; // ... }
? Just a thought
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.
Indeed we just define edges and node types at the same time. But of course this can be improved upon, and improvements are always welcome :-)
of that node, then `(v, u)` (resp. `(u, v)`) represent an edge in the graph, | ||
with attached data `in[v]` (resp. `out[v]`). | ||
- It must define methods `add_in`, `erase_in`, and `add_out`, `erase_out` for | ||
insertion and removal of values to and from the maps `in` and `out`. |
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 wonder why we bother having this stuff on the node type at all if all nodes are required to implement them in the same way anyway
insertion and removal of values to and from the maps `in` and `out`. | ||
- It must define a method `pretty` converting the node to a "pretty" string. | ||
|
||
One can use a predefined template class `graph_nodet<E>` as the template |
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.
What is E
here?
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.
Fixed.
Requested updates are available. |
src/analyses/README.md
Outdated
|
||
Implemented in `src/analyses/dependence_graph.h(cpp)`. It is a graph and an | ||
abstract interpreter in the same time. The abstract interpretation nature | ||
allows a dependence graph to build itself (the graph) from a given GOTO program. |
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 think the wording here ("build itself") is just a bit weird, below you very nicely explain what is going on and it may be worth having a forward reference to that.
Updates requested in the review are available: Added forward link from "build itself" to the |
@marek-trtik This requires a rebase to pick up the Windows CI fix. And |
85524de
to
a17a64a
Compare
Thanks Michael! Issue fixed, commits squashed, and rebased to latest |
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.
✔️
Passed Diffblue compatibility checks (cbmc commit: a17a64a).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/100445165
Besides an overview of
dependence_graph
I've also added a brief (and incomplete) overview of thegrapht
class, because it might be useful to understand how to use a dependence graph.