19#ifndef BF_P4C_MAU_MAU_POWER_H_
20#define BF_P4C_MAU_MAU_POWER_H_
28#include "bf-p4c/device.h"
30#include "ir/unique_id.h"
31#include "lib/dyn_vector.h"
32#include "power_schema.h"
38enum mau_dep_t { DEP_CONCURRENT = 0, DEP_ACTION = 1, DEP_MATCH = 2 };
48enum lut_t { NEXT_TABLE_LUT = 0, GLOB_EXEC_LUT = 1, LONG_BRANCH_LUT = 2 };
50std::ostream &operator<<(std::ostream &, mau_dep_t);
57std::string float2str(
double d);
66 static const int kNumberGress = GRESS_T_COUNT;
67 using PowerLogging = Logging::Power_Schema_Logger;
70 bitvec has_exact_[kNumberGress];
72 bitvec has_tcam_[kNumberGress];
73 bitvec has_meter_lpf_or_wred_[kNumberGress];
74 bitvec has_selector_[kNumberGress];
76 bitvec has_stateful_[kNumberGress];
77 bitvec has_stats_[kNumberGress];
82 std::map<UniqueId, bool> counter_runs_at_eop_;
83 std::map<UniqueId, bool> meter_runs_at_eop_;
85 std::map<UniqueId, bool> meter_is_lpf_or_wred_;
88 std::map<UniqueId, int> selector_group_size_;
93 std::map<UniqueId, int> table_to_stage_;
95 std::map<UniqueId, const IR::MAU::Table *> uid_to_table_;
100 std::map<int, mau_dep_t> stage_dep_to_previous_[kNumberGress];
124 void set_dependency_for_gress_stage(gress_t g,
int stage, mau_dep_t dep);
181 std::ostream &
emit_dep_asm(std::ostream &out, gress_t g,
int stage)
const;
203 const gress_t gress_;
213 int get_mpr_stage(
int stage)
const;
222 void set_or_mpr_next_table(
int stage,
int logical_id,
int id_vector);
223 int get_mpr_next_table(
int stage,
int logical_id)
const;
232 void set_or_mpr_global_exec(
int stage,
int exec_bit,
int id_vector);
233 int get_mpr_global_exec(
int stage,
int exec_bit)
const;
242 int get_mpr_long_branch(
int stage,
int tag_id)
const;
265 int get_mpr_always_run_for_stage(
int stage)
const;
279 void set_or_mpr_bus_dep_glob_exec(
int stage,
int id_vector);
280 int get_mpr_bus_dep_glob_exec(
int stage)
const;
294 void set_or_mpr_bus_dep_long_brch(
int stage,
int id_vector);
295 int get_mpr_bus_dep_long_brch(
int stage)
const;
297 friend std::ostream &operator<<(std::ostream &out,
const MprSettings &m);
305 std::ostream &emit_stage_asm(std::ostream &out,
int stage)
const;
375 void print_data(std::ostream &out,
int cols, std::string id_name, std::vector<int> data,
412 using PowerLogging = Logging::Power_Schema_Logger;
416 int map_ram_read = 0;
417 int map_ram_write = 0;
418 int deferred_ram_read = 0;
419 int deferred_ram_write = 0;
427 deferred_ram_read(0),
428 deferred_ram_write(0) {}
430 explicit PowerMemoryAccess(
int ram_read,
int ram_write,
int tcam_read,
int map_ram_read,
431 int map_ram_write,
int deferred_ram_read,
int deferred_ram_write)
432 : ram_read(ram_read),
433 ram_write(ram_write),
434 tcam_read(tcam_read),
435 map_ram_read(map_ram_read),
436 map_ram_write(map_ram_write),
437 deferred_ram_read(deferred_ram_read),
438 deferred_ram_write(deferred_ram_write) {}
441 out <<
"Memory access:" << std::endl;
442 out <<
" RAMs read " << p.ram_read << std::endl;
443 out <<
" RAMs write " << p.ram_write << std::endl;
444 out <<
" TCAMs read " << p.tcam_read << std::endl;
445 out <<
" MapRAMs read " << p.map_ram_read << std::endl;
446 out <<
" MapRAMs write " << p.map_ram_write << std::endl;
447 out <<
" Deferred RAMs read " << p.deferred_ram_read << std::endl;
448 out <<
" Deferred RAMs write " << p.deferred_ram_write << std::endl;
453 ram_read += p.ram_read;
454 ram_write += p.ram_write;
455 tcam_read += p.tcam_read;
456 map_ram_read += p.map_ram_read;
457 map_ram_write += p.map_ram_write;
458 deferred_ram_read += p.deferred_ram_read;
459 deferred_ram_write += p.deferred_ram_write;
500 void log_json_memories(PowerLogging::StageDetails *)
const;
Definition mau_power.h:64
int compute_stage_latency(gress_t gress, int stage) const
Definition mau_power.cpp:184
void log_json_stage_characteristics(gress_t g, PowerLogging *logger) const
Definition mau_power.cpp:374
bool stage_has_chained_feature(gress_t gress, int stage, stage_feature_t feature) const
Definition mau_power.cpp:207
std::ostream & emit_dep_asm(std::ostream &out, gress_t g, int stage) const
Definition mau_power.cpp:82
bool try_convert_to_match_dep()
Definition mau_power.cpp:110
int compute_pred_cycle(gress_t gress, int stage) const
Definition mau_power.cpp:169
bool requires_dep_asm(gress_t g, int stage) const
Definition mau_power.cpp:92
bool stage_has_feature(gress_t gress, int stage, stage_feature_t feature) const
Definition mau_power.cpp:60
void update_deps_for_device()
Definition mau_power.cpp:131
void print_features(std::ostream &out, gress_t gress) const
Definition mau_power.cpp:248
int compute_pipe_latency(gress_t gress) const
Definition mau_power.cpp:153
int get_max_selector_words(gress_t gress, int stage) const
Definition mau_power.cpp:56
void print_latency(std::ostream &out, gress_t gress) const
Definition mau_power.cpp:320
bool are_there_more_tables(gress_t gress, int start_stage) const
Definition mau_power.cpp:241
mau_dep_t get_dependency_for_gress_stage(gress_t g, int stage) const
Definition mau_power.cpp:103
Definition mau_power.h:201
void set_mpr_global_exec(int stage, int exec_bit, int id_vector)
Definition mau_power.cpp:510
void set_or_mpr_always_run(int stage, int id_vector)
Definition mau_power.cpp:487
void set_mpr_long_branch(int stage, int tag_id, int id_vector)
Definition mau_power.cpp:526
void set_mpr_always_run(int stage, int id_vector)
Definition mau_power.cpp:482
void set_or_mpr_long_branch(int stage, int tag_id, int id_vector)
Definition mau_power.cpp:536
void set_mpr_next_table(int stage, int logical_id, int id_vector)
Definition mau_power.cpp:494
void set_mpr_stage(int stage, int mpr_stage)
Definition mau_power.cpp:475
bool need_to_emit(lut_t type, int stage) const
Definition mau_power.cpp:418
void set_mpr_bus_dep_glob_exec(int stage, int id_vector)
Definition mau_power.cpp:542
void set_mpr_bus_dep_long_brch(int stage, int id_vector)
Definition mau_power.cpp:556
Definition dyn_vector.h:27
Definition mau/asm_output.h:39
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
Definition mau_power.h:411
double compute_table_weight(double computed_power, int num_pipes) const
Definition mau_power.cpp:738
double compute_table_power(int num_pipes) const
Definition mau_power.cpp:721