P4C
The P4 Compiler
|
#include <simple_power_graph.h>
Public Member Functions | |
SimplePowerGraph (cstring gress) | |
bool | active_simultaneously (UniqueId parent, UniqueId child) |
void | add_connection (UniqueId parent, ordered_set< UniqueId > activated, cstring edge_name) |
bool | can_reach (UniqueId parent, UniqueId child) |
void | dbprint (std::ostream &out) const |
void | dbprint (std::ostream &out, NodeAndEdgeSet *seen) const |
void | get_leaves (UniqueId n, std::vector< UniqueId > &leaves) |
Node * | get_root () const |
double | get_tables_on_worst_path (const std::map< UniqueId, PowerMemoryAccess > &table_memory_access, std::set< Node * > &rv) |
const std::set< UniqueId > & | predecessors (UniqueId child) const |
void | to_dot (cstring filename) |
std::vector< Node * > | topo_sort () |
Public Member Functions inherited from P4::IHasDbPrint | |
void | print () const |
Public Attributes | |
const cstring | name_ |
This class represents the final placed MAU table control flow graph for a given thread of execution: ingress, egress, or ghost. It consists of Nodes that represent logical tables and Edges that represent the flow from one logical table to one or more subsequent logical tables. For Tofino2 and beyond, an Edge is allowed to be a one-to-many relationship, since Tofino2+ allows initiation of multiple parallel threads of execution via local_exec, global_exec, and long branching.
* Returns true if these tables can be active at the same time. * For Tofino, this function will return identical results to can_reach. * For Tofino2 and beyond, this takes into account parallel sub-graphs. * e.g. * ---> C ----> D * / \ * ---> A E ---> F * \ / * ---> B ---— * If A activates both B and C, then even though B cannot reach D, * we have to consider B and D as activate at the same time for * dependency analysis.
void MauPower::SimplePowerGraph::add_connection | ( | UniqueId | parent, |
ordered_set< UniqueId > | activated, | ||
cstring | edge_name ) |
Connects a parent Node to one or more child nodes via an Edge. This function creates Node and Edge objects, if they do not already exist.
parent | The unique representation of a parent logical table. |
activated | The set of unique IDs for what children this parent may activate next in the control flow. |
edge_name | A debug name to give the edge, to be used in dot display. |
Returns true if there a 'downward' connection from parent to child.
|
inlinevirtual |
Implements P4::IHasDbPrint.
Returns a vector of reachable leaf nodes in the graph from the provided Node for the given UniqueId.
double MauPower::SimplePowerGraph::get_tables_on_worst_path | ( | const std::map< UniqueId, PowerMemoryAccess > & | table_memory_access, |
std::set< Node * > & | rv ) |
For power estimation, returns a set of the Nodes that are found on the worst-case table control flow. A mapping form UniqueId to estimated power consumption is provided as the "cost" for each Node.
|
inline |
Returns the predecessors of a node – the tables that can invoke this node
void MauPower::SimplePowerGraph::to_dot | ( | cstring | filename | ) |
Output this graph to the dot file, as specified by the filename.
Outputs the final placed table control flow graphs to a .dot file.
std::vector< Node * > MauPower::SimplePowerGraph::topo_sort | ( | ) |
Returns a topological sort of the Nodes in this graph.
Returns a topological sorting of the graph.