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

#include <mau_power.h>

Public Types

using PowerLogging = Logging::Power_Schema_Logger
 

Public Member Functions

bool are_there_more_tables (gress_t gress, int start_stage) const
 
int compute_pipe_latency (gress_t gress) const
 
int compute_pred_cycle (gress_t gress, int stage) const
 
int compute_stage_latency (gress_t gress, int stage) const
 
std::ostream & emit_dep_asm (std::ostream &out, gress_t g, int stage) const
 
mau_dep_t get_dependency_for_gress_stage (gress_t g, int stage) const
 
int get_max_selector_words (gress_t gress, int stage) const
 
void log_json_stage_characteristics (gress_t g, PowerLogging *logger) const
 
void print_features (std::ostream &out, gress_t gress) const
 
void print_latency (std::ostream &out, gress_t gress) const
 
bool requires_dep_asm (gress_t g, int stage) const
 
void set_dependency_for_gress_stage (gress_t g, int stage, mau_dep_t dep)
 
bool stage_has_chained_feature (gress_t gress, int stage, stage_feature_t feature) const
 
bool stage_has_feature (gress_t gress, int stage, stage_feature_t feature) const
 
bool try_convert_to_match_dep ()
 
void update_deps_for_device ()
 

Public Attributes

std::map< UniqueId, bool > counter_runs_at_eop_
 
bitvec has_exact_ [kNumberGress]
 
bitvec has_meter_lpf_or_wred_ [kNumberGress]
 
bitvec has_selector_ [kNumberGress]
 
bitvec has_stateful_ [kNumberGress]
 
bitvec has_stats_ [kNumberGress]
 
bitvec has_tcam_ [kNumberGress]
 
dyn_vector< int > max_selector_words_ [kNumberGress]
 
std::map< UniqueId, bool > meter_is_lpf_or_wred_
 
std::map< UniqueId, bool > meter_runs_at_eop_
 
std::map< UniqueId, int > selector_group_size_
 
dyn_vector< std::vector< const IR::MAU::Table * > > stage_to_tables_ [kNumberGress]
 
std::map< UniqueId, int > table_to_stage_
 
std::map< UniqueId, const IR::MAU::Table * > uid_to_table_
 

Static Public Attributes

static const int kNumberGress = GRESS_T_COUNT
 

Detailed Description

A class to represent MAU stage characteristics, such as:

  • what features are in use in each MAU stage in each gress
  • the dependency to the previous stage for each MAU stage in each gress

Member Function Documentation

◆ are_there_more_tables()

bool MauPower::MauFeatures::are_there_more_tables ( gress_t gress,
int start_stage ) const

Returns true if there are tables remaining in a particular gress in the start stage until the last MAU stage.

◆ compute_pipe_latency()

int MauPower::MauFeatures::compute_pipe_latency ( gress_t gress) const
Parameters
gressThe thread of compute.
Returns
A specific pipeline latency (in clock cycles).

◆ compute_pred_cycle()

int MauPower::MauFeatures::compute_pred_cycle ( gress_t gress,
int stage ) const
Parameters
gressThe thread of compute.
stageThe MAU stage number, running 0 to n-1.
Returns
The predication cycle of a specific MAU gress-stage (in clock cycles)

◆ compute_stage_latency()

int MauPower::MauFeatures::compute_stage_latency ( gress_t gress,
int stage ) const
Parameters
gressThe thread of compute.
stageThe MAU stage number, running 0 to n-1.
Returns
The stage latency of a specific MAU gress-stage (in clock cycles).

◆ emit_dep_asm()

std::ostream & MauPower::MauFeatures::emit_dep_asm ( std::ostream & out,
gress_t g,
int stage ) const

Emits information that needs to be communicated to assembly for register configuration. Currently, this is the MAU stage dependencies.

◆ get_dependency_for_gress_stage()

mau_dep_t MauPower::MauFeatures::get_dependency_for_gress_stage ( gress_t g,
int stage ) const
Parameters
gThe thread of compute.
stageThe MAU stage number, running 0 to n-1.
Returns
Stage dependency type to the previous MAU stage.

◆ get_max_selector_words()

int MauPower::MauFeatures::get_max_selector_words ( gress_t gress,
int stage ) const
Parameters
gressThe thread of compute.
stageThe MAU stage number, running 0 to n-1.
Returns
The maximum number of RAM words required to hold the largest selector group. For example, a group size of 120 results in 1 being returned. A group size of 121 results in 2 being returned.

◆ log_json_stage_characteristics()

void MauPower::MauFeatures::log_json_stage_characteristics ( gress_t g,
PowerLogging * logger ) const

Produces the power.json output.

◆ print_features()

void MauPower::MauFeatures::print_features ( std::ostream & out,
gress_t gress ) const

Produces lovely text tables showing features and dependencies.

◆ print_latency()

void MauPower::MauFeatures::print_latency ( std::ostream & out,
gress_t gress ) const

Produces lovely text tables showing latencies and dependencies.

◆ requires_dep_asm()

bool MauPower::MauFeatures::requires_dep_asm ( gress_t g,
int stage ) const

Return true if some asm code is required for the stage for correct behavior, even if no tables are present

◆ stage_has_chained_feature()

bool MauPower::MauFeatures::stage_has_chained_feature ( gress_t gress,
int stage,
stage_feature_t feature ) const
Parameters
gressThe thread of compute.
stageThe MAU stage number, running 0 to n-1.
featureThe MAU feature.
Returns
Boolean indicating if a particular stage should be considered as having a particular feature for timing balance reasons. This is only applicable when the stage is not separated by match dependencies with its adjacent stages.

◆ stage_has_feature()

bool MauPower::MauFeatures::stage_has_feature ( gress_t gress,
int stage,
stage_feature_t feature ) const
Parameters
gressThe thread of compute.
stageThe MAU stage number, running 0 to n-1.
featureThe MAU feature.
Returns
Boolean indicating if a particular stage has a given feature.

◆ try_convert_to_match_dep()

bool MauPower::MauFeatures::try_convert_to_match_dep ( )

Attempts to convert a MAU stage dependency to match dependent. If a stage can be changed, the change is performed and this function returns true. Otherwise, it returns false.

Returns
Boolean indicating if a MAU stage in any thread was converted to match dependent.

◆ update_deps_for_device()

void MauPower::MauFeatures::update_deps_for_device ( )

Removes concurrent dependency type if dealing with Tofino2 or later.