P4C
The P4 Compiler
Loading...
Searching...
No Matches
MauPower::PowerMemoryAccess Struct Reference

Public Types

using PowerLogging = Logging::Power_Schema_Logger
 

Public Member Functions

 PowerMemoryAccess (int ram_read, int ram_write, int tcam_read, int map_ram_read, int map_ram_write, int deferred_ram_read, int deferred_ram_write)
 
double compute_table_power (int num_pipes) const
 
double compute_table_weight (double computed_power, int num_pipes) const
 
void log_json_memories (PowerLogging::StageDetails *) const
 
PowerMemoryAccess operator+ (const PowerMemoryAccess &p) const
 
PowerMemoryAccessoperator+= (const PowerMemoryAccess &p)
 

Public Attributes

int deferred_ram_read = 0
 
int deferred_ram_write = 0
 
int map_ram_read = 0
 
int map_ram_write = 0
 
int ram_read = 0
 
int ram_write = 0
 
int tcam_read = 0
 

Friends

std::ostream & operator<< (std::ostream &out, const PowerMemoryAccess &p)
 

Member Function Documentation

◆ compute_table_power()

double MauPower::PowerMemoryAccess::compute_table_power ( int num_pipes) const

Computes the worst-case power consumed given parameters that indicate the number of different memory types read and written. This function is intended to be called per logical table in each stage, where the parameters include the sum of memories accessed by the match table and all its attached tables. For example, if an exact match table has a directly attached counter, the parameters should have non-zero values for rams_read, rams_write, map_rams_read, and map_rams_write. If the counter runs at EOP time, the deferred_rams_read and deferred_rams_write should have non-zero values as well. Note that the value this function returns should not be exposed to an end-user.

Parameters
num_pipesThe number of pipes to consider this table in.
Returns
The total power consumed (in Watts).

Computes the power consumed by a single table in the specified number of pipelines. Note that the result of this function should not be exposed to the user in logging. (Yes, it can experimentally derived fairly easily...)

Parameters
num_pipesThe number of pipelines to consider the table in.
Returns
An estimate for the power consumption (in Watts) based on the table's access pattern.

◆ compute_table_weight()

double MauPower::PowerMemoryAccess::compute_table_weight ( double computed_power,
int num_pipes ) const

Returns a normalized weight of a table's power contribution. We do not generally want to expose the raw Watts used by a table, as this is considered Barefoot secret.

Returns
The normalized weight of the power contribution of this table. Note that this is normalized to one pipeline.

Normalize power units to a unitless weight value. The result of this function is the one that can be exposed to the user.