P4C
The P4 Compiler
Loading...
Searching...
No Matches
MauPower::SimplePowerGraph Class Reference

#include <simple_power_graph.h>

Inheritance diagram for MauPower::SimplePowerGraph:
[legend]

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)
 
Nodeget_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_
 

Detailed Description

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.

Member Function Documentation

◆ active_simultaneously()

bool MauPower::SimplePowerGraph::active_simultaneously ( UniqueId parent,
UniqueId child )

    * 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.    

◆ add_connection()

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.

Parameters
parentThe unique representation of a parent logical table.
activatedThe set of unique IDs for what children this parent may activate next in the control flow.
edge_nameA debug name to give the edge, to be used in dot display.

◆ can_reach()

bool MauPower::SimplePowerGraph::can_reach ( UniqueId parent,
UniqueId child )

Returns true if there a 'downward' connection from parent to child.

◆ dbprint()

void MauPower::SimplePowerGraph::dbprint ( std::ostream & out) const
inlinevirtual

Implements P4::IHasDbPrint.

◆ get_leaves()

void MauPower::SimplePowerGraph::get_leaves ( UniqueId n,
std::vector< UniqueId > & leaves )

Returns a vector of reachable leaf nodes in the graph from the provided Node for the given UniqueId.

◆ get_tables_on_worst_path()

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.

◆ predecessors()

const std::set< UniqueId > & MauPower::SimplePowerGraph::predecessors ( UniqueId child) const
inline

Returns the predecessors of a node – the tables that can invoke this node

◆ to_dot()

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.

◆ topo_sort()

std::vector< Node * > MauPower::SimplePowerGraph::topo_sort ( )

Returns a topological sort of the Nodes in this graph.

Returns a topological sorting of the graph.