P4C
The P4 Compiler
Loading...
Searching...
No Matches
TablePlacement Class Reference
Inheritance diagram for TablePlacement:
[legend]

Classes

struct  FinalRerunTablePlacementTrigger
 
struct  Placed
 
struct  RejectReason
 
struct  RewriteForSplitAttached
 
class  SetupInfo
 
struct  TableInfo
 
struct  TableSeqInfo
 

Public Types

enum  choice_t {
  CALC_STAGE , PROV_STAGE , NEED_MORE , SHARED_TABLES ,
  PRIORITY , DOWNWARD_PROP_DSC , LOCAL_DSC , LOCAL_DS ,
  LOCAL_TD , DOWNWARD_DOM_FRONTIER , DOWNWARD_TD , NEXT_TABLE_OPEN ,
  CDS_PLACEABLE , CDS_PLACE_COUNT , AVERAGE_CDS_CHAIN , DEFAULT
}
 
using GatewayMergeChoices = ordered_map<const IR::MAU::Table *, cstring>
 
- Public Types inherited from P4::Visitor
typedef Visitor_Context Context
 

Public Member Functions

 TablePlacement (const BFN_Options &, DependencyGraph &, const TablesMutuallyExclusive &, PhvInfo &, LayoutChoices &, const SharedIndirectAttachedAnalysis &, SplitAttachedInfo &, TableSummary &, MauBacktracker &)
 
const Placedadd_starter_pistols (const Placed *done, const Placed **best, const StageUseEstimate &current)
 
bool backtrack (trigger &) override
 
bool can_split (const IR::MAU::Table *, const IR::MAU::AttachedMemory *)
 Check if an indirect attached table can be split acorss stages.
 
bool disable_split_layout (const IR::MAU::Table *tbl)
 
void end_apply () override
 
template<class... Args>
void error (Args... args)
 
int errorCount () const
 
void filter_layout_options (Placed *pl)
 
void find_dependency_stages (const IR::MAU::Table *tbl, std::map< int, ordered_map< const Placed *, DependencyGraph::dependencies_t > > &) const
 
std::multimap< cstring, constPlaced * >::const_iterator find_placed (cstring name) const
 
GatewayMergeChoices gateway_merge_choices (const IR::MAU::Table *table)
 
const IR::MAU::Table * getTblByName (cstring t)
 
profile_t init_apply (const IR::Node *root) override
 
bool initial_stage_and_entries (TablePlacement::Placed *rv, int &furthest_stage)
 
bool pick_layout_option (Placed *next, std::vector< Placed * > allocated_layout)
 
void reject_placement (const Placed *of, choice_t reason, const Placed *better)
 
void setup_detached_gateway (IR::MAU::Table *tbl, const Placed *placed)
 
bool shrink_attached_tbl (Placed *next, bool first_time, bool &done_shrink)
 
bool shrink_estimate (Placed *next, int &srams_left, int &tcams_left, int min_entries)
 
bool shrink_preferred_lo (Placed *next)
 
bool try_alloc_adb (const gress_t &gress, std::vector< Placed * > tables_to_allocate, std::vector< Placed * > tables_placed)
 
TableSummary::PlacementResult try_alloc_all (Placed *next, std::vector< Placed * > whole_stage, const char *what, bool no_memory=false)
 
bool try_alloc_format (Placed *next, bool gw_linked)
 
bool try_alloc_imem (const gress_t &gress, std::vector< Placed * > tables_to_allocate, std::vector< Placed * > tables_placed)
 
bool try_alloc_ixbar (Placed *next, std::vector< Placed * > allocated_layout)
 
bool try_alloc_mem (Placed *next, std::vector< Placed * > whole_stage)
 
bool try_pick_layout (const gress_t &gress, std::vector< Placed * > tables_to_allocate, std::vector< Placed * > tables_placed)
 
safe_vector< Placed * > try_place_table (const IR::MAU::Table *t, const Placed *done, const StageUseEstimate &current, GatewayMergeChoices &gmc, const TableSummary::PlacedTable *pt=nullptr)
 
Placedtry_place_table (Placed *rv, const StageUseEstimate &current, const TableSummary::PlacedTable *pt=nullptr)
 
int uid (const IR::MAU::Table *t)
 
int uid (const IR::MAU::TableSeq *t)
 
int uid (cstring t)
 
- Public Member Functions inherited from P4::PassManager
 PassManager (const PassManager &)=default
 
 PassManager (const std::initializer_list< VisitorRef > &init)
 
 PassManager (PassManager &&)=default
 
void addDebugHook (DebugHook h, bool recursive=false)
 
void addDebugHooks (std::vector< DebugHook > hooks, bool recursive=false)
 
void addPasses (const std::initializer_list< VisitorRef > &init)
 
const IR::Nodeapply_visitor (const IR::Node *, const char *=0) override
 
PassManagerclone () const override
 
void early_exit ()
 
void listPasses (std::ostream &, cstring sep) const
 
bool never_backtracks () override
 
void removePasses (const std::vector< cstring > &exclude)
 
void setStopOnError (bool stop)
 
- Public Member Functions inherited from P4::Visitor
virtual bool check_clone (const Visitor *a)
 
virtual bool check_global (cstring)
 
virtual void clear_globals ()
 
virtual ControlFlowVisitorcontrolFlowVisitor ()
 
virtual void end_apply (const IR::Node *root)
 
virtual void erase_global (cstring)
 
template<class T >
const T * findContext () const
 
template<class T >
const T * findContext (const Context *&c) const
 
template<class T >
const T * findOrigCtxt () const
 
template<class T >
const T * findOrigCtxt (const Context *&c) const
 
virtual Visitorflow_clone ()
 
virtual void flow_merge (Visitor &)
 
virtual bool flow_merge_closure (Visitor &)
 
virtual void flow_merge_global_from (cstring)
 
virtual void flow_merge_global_to (cstring)
 
const ContextgetChildContext () const
 
int getChildrenVisited () const
 
const ContextgetContext () const
 
int getContextDepth () const
 
const IR::NodegetCurrentNode () const
 
template<class T >
const T * getCurrentNode () const
 
const IR::NodegetOriginal () const
 
template<class T >
const T * getOriginal () const
 
template<class T >
const T * getParent () const
 
virtual bool has_flow_joins () const
 
profile_t init_apply (const IR::Node *root, const Context *parent_context)
 
bool isInContext (const IR::Node *n) const
 
virtual const char * name () const
 
template<class T >
void parallel_visit (const IR::Vector< T > &v, const char *name, int cidx)
 
template<class T >
void parallel_visit (const IR::Vector< T > &v, const char *name=0)
 
template<class T >
void parallel_visit (IR::Vector< T > &v, const char *name, int cidx)
 
template<class T >
void parallel_visit (IR::Vector< T > &v, const char *name=0)
 
void print_context () const
 
const VisitorsetCalledBy (const Visitor *visitor)
 
void setName (const char *name)
 
void visit (const IR::Node &n, const char *name, int cidx)
 
void visit (const IR::Node &n, const char *name=0)
 
void visit (const IR::Node *&n, const char *name, int cidx)
 
void visit (const IR::Node *&n, const char *name=0)
 
void visit (const IR::Node *const &n, const char *name, int cidx)
 
void visit (const IR::Node *const &n, const char *name=0)
 
void visit (IR::Node &n, const char *name, int cidx)
 
void visit (IR::Node &n, const char *name=0)
 
void visit (IR::Node *&, const char *=0, int=0)
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T> && !std::is_pointer_v<T>>, class... Args>
void warn (const int kind, const char *format, const T &node, Args &&...args)
 The const ref variant of the above.
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T>>, class... Args>
void warn (const int kind, const char *format, const T *node, Args &&...args)
 
bool warning_enabled (int warning_kind) const
 
- Public Member Functions inherited from P4::Backtrack

Static Public Member Functions

static bool can_duplicate (const IR::MAU::AttachedMemory *)
 
- Static Public Member Functions inherited from P4::Visitor
static cstring demangle (const char *)
 
static bool warning_enabled (const Visitor *visitor, int warning_kind)
 

Public Attributes

bool alloc_done = false
 
SplitAttachedInfoatt_info
 
std::map< const IR::MAU::AttachedMemory *, ordered_set< const IR::MAU::Table * > > attached_to
 
ControlPathwaysToTable con_paths
 
DynamicDependencyMetrics ddm
 
DependencyGraphdeps
 
cstring error_message
 
bool ignoreContainerConflicts = false
 
LayoutChoiceslc
 
bool limit_tmp_creation = false
 
MauBacktrackermau_backtracker
 
const TablesMutuallyExclusivemutex
 
std::set< const IR::MAU::Table * > not_eligible
 
CalculateNextTableProp ntp
 
const BFN_Optionsoptions
 
PhvInfophv
 
const TablePlacement::Placedplacement = nullptr
 
std::map< cstring, std::map< cstring, RejectReason > > rejected_placements
 
std::map< const IR::MAU::TableSeq *, struct TableSeqInfoseqInfo
 
const SharedIndirectAttachedAnalysissiaa
 
std::array< const IR::MAU::Table *, 2 > starter_pistol = {{nullptr, nullptr}}
 
bool success = false
 
TableSummarysummary
 
std::array< bool, 3 > table_in_gress = {{false, false, false}}
 
std::multimap< cstring, const Placed * > table_placed
 
std::map< cstring, struct TableInfo * > tblByName
 
std::vector< struct TableInfo * > tblByUid
 
std::map< const IR::MAU::Table *, struct TableInfotblInfo
 
- Public Attributes inherited from P4::Visitor
const Visitorcalled_by = nullptr
 
cstring internalName
 
SplitFlowVisit_base *& split_link
 
SplitFlowVisit_basesplit_link_mem = nullptr
 

Static Public Attributes

static int placement_round = 1
 

Friends

std::ostream & operator<< (std::ostream &out, TablePlacement::choice_t choice)
 

Additional Inherited Members

- Protected Member Functions inherited from P4::PassManager
profile_t init_apply (const IR::Node *root) override
 
void runDebugHooks (const char *visitorName, const IR::Node *node)
 
- Protected Member Functions inherited from P4::Visitor
virtual void init_join_flows (const IR::Node *)
 
virtual bool join_flows (const IR::Node *)
 
virtual void post_join_flows (const IR::Node *, const IR::Node *)
 
void visit_children (const IR::Node *, std::function< void()> fn)
 
virtual void visitAgain () const
 
virtual void visitOnce () const
 
- Protected Attributes inherited from P4::PassManager
safe_vector< DebugHookdebugHooks
 
safe_vector< Visitor * > passes
 
bool running = false
 
unsigned seqNo = 0
 
bool stop_on_error = true
 
- Protected Attributes inherited from P4::Visitor
bool dontForwardChildrenBeforePreorder = false
 
bool joinFlows = false
 
bool visitDagOnce = true
 

Class Documentation

◆ TablePlacement::RejectReason

struct TablePlacement::RejectReason
Class Members
attached_entries_t attached_entries
int entries
choice_t reason
int stage

◆ TablePlacement::TableInfo

struct TablePlacement::TableInfo
Class Members
bitvec parents
ordered_set< const TableSeq * > refs
const Table * table
bitvec tables
int uid = -1

◆ TablePlacement::TableSeqInfo

struct TablePlacement::TableSeqInfo
Class Members
bitvec immed_tables
bitvec parents
ordered_set< const Table * > refs
bool root = false
bitvec tables
int uid = -1

Member Function Documentation

◆ add_starter_pistols()

const TablePlacement::Placed * TablePlacement::add_starter_pistols ( const Placed * done,
const Placed ** best,
const StageUseEstimate & current )

In Tofino specifically, if a table is in ingress or egress, then a table for that pipeline must be placed within stage 0. The parser requires a pathway into the first stage.

Thus, this checks if no table can longer be placed in stage 0, and if a table from a particular gress has not yet been placed, the create a starting table for that pipe in stage 0.

◆ backtrack()

bool TablePlacement::backtrack ( trigger & trig)
overridevirtual

Reimplemented from P4::PassManager.

◆ can_duplicate()

bool TablePlacement::can_duplicate ( const IR::MAU::AttachedMemory * att)
static

Check an indirect attached table to see if it can be duplicated across stages, or if there must be only a single copy of (each element of) the table. This does not consider whether it is a good idea to duplicate the table (not a good idea for large tables and pointless if it won't fit in a single stage anyways).

◆ end_apply()

void TablePlacement::end_apply ( )
inlineoverridevirtual

Reimplemented from P4::Visitor.

◆ try_place_table()

safe_vector< TablePlacement::Placed * > TablePlacement::try_place_table ( const IR::MAU::Table * t,
const Placed * done,
const StageUseEstimate & current,
GatewayMergeChoices & gmc,
const TableSummary::PlacedTable * pt = nullptr )

When placing a gateway table, the gateway can potential be combined with a match table to build one logical table. The gateway_merge function picks a legal table to place with this table. This loops through all possible tables to be merged, and will return a vector of these possible choices to the is_better function to choose