160 static constexpr int NUM_LOGICAL_TABLES_PER_STAGE = 16;
161 static constexpr int FIRST_ALT_RETRY_ENHANCED_TP_INVOCATION = 2;
180 int entries_req = -1;
187 bool gateway_only =
false;
194 void add(
const IR::MAU::Table *t, State::state_t state);
196 friend std::ostream &operator<<(std::ostream &out,
const PlacedTable &pl);
204 friend std::ostream &operator<<(std::ostream &out, PlacementResult result) {
207 else if (result == FAIL)
209 else if (result == FAIL_ON_ADB)
210 out <<
"FAIL_ON_ADB";
211 else if (result == FAIL_ON_MEM)
212 out <<
"FAIL_ON_MEM";
214 out <<
"FAIL_ON_IXBAR";
219 static constexpr int CRITICAL_PATH_THRESHOLD = 2;
220 static constexpr int ALT_PHV_ALLOC_TABLE_FIX_THRESHOLD = 3;
223 bool firstRoundFit =
false;
226 State::state_t prev_state = State::INITIAL;
231 bool ingressDone =
false;
232 bool egressDone =
false;
239 bool no_errors_before_summary =
true;
241 int alt_phv_alloc_table_fixed = 0;
246 State::state_t &state;
265 std::map<int, PlacedTable *> placedTables;
276 std::map<int, PlacedTable *> trivial_placedTables;
280 PlacementResult table_replay_result = FAIL;
284 std::map<int, const IR::MAU::Table *> order;
286 std::map<int, std::set<const IR::MAU::Table *>> tables;
302 std::map<cstring, std::map<le_bitrange, std::map<int, int>>> ixbarBytes;
306 std::map<int, std::unique_ptr<IXBar>> ixbar[2];
308 std::map<int, std::unique_ptr<Memories>> memory[2];
310 std::map<int, std::unique_ptr<ActionDataBus>> action_data_bus[2];
312 std::map<int, std::unique_ptr<InstructionMemory>> imems[2];
314 std::map<cstring, unsigned> logical_ids;
322 const IR::MAU::Table *table_replay_problematic_table =
nullptr;
324 profile_t init_apply(
const IR::Node *root)
override;
325 bool preorder(
const IR::MAU::Table *t)
override;
326 void postorder(
const IR::BFN::Pipe *pipe)
override;
327 void end_apply()
override;
330 void printTablePlacement();
336 void generateIxbarBytesInfo();
341 bool find_problematic_table();
347 State::state_t &state);
365 static void addTablePtr(
const IR::MAU::Table *ptr);
373 int maxStages(gress_t gress)
const {
return max_stages[gress]; }
378 void addPlacementError(
cstring msg) { tablePlacementErrors[msg] =
true; }
379 void addPlacementWarnError(
cstring msg) { tablePlacementErrors[msg] |=
false; }
380 void clearPlacementErrors() { tablePlacementErrors.clear(); }
381 int placementErrorCount() {
return tablePlacementErrors.size(); }
388 State::state_t getActualState()
const {
return state; }
389 void setPrevState() { state = prev_state; }
390 cstring getActualStateStr()
const;
391 void setAllStagesResources(
const StageUseEstimate &use) { allStages = use; }
394 std::map<int, PlacedTable *> &getPlacedTables() {
return placedTables; }
396 const IR::MAU::Table *get_table_replay_problematic_table()
const {
397 return table_replay_problematic_table;
399 int getNumInvoked()
const {
return numInvoked; }
416 std::map<int, int> findBytesOnIxbar(
const PHV::FieldSlice &slice)
const;
418 void printPlacedTables()
const;
419 void set_table_replay_result(PlacementResult result) { table_replay_result = result; }
421 PlacementResult get_table_replay_result()
const {
return table_replay_result; }
423 friend std::ostream &operator<<(std::ostream &out,
const TableSummary &ts);
424 friend std::ostream &operator<<(std::ostream &out,
428 void stop_table_replay_fitting()
const {
429 BUG_CHECK(state == State::ALT_FINALIZE_TABLE_SAME_ORDER_TABLE_FIXED,
430 "state is not intened for table replay fitting");
432 trivial_mergedGateways, firstRoundFit,
false,
false,
true);
436 void clear_table_alloc_info() {
438 internalTableAlloc.clear();
439 placedTables.clear();
442 bool is_table_replay() {
443 return state == State::ALT_FINALIZE_TABLE_SAME_ORDER ||
444 state == State::ALT_FINALIZE_TABLE_SAME_ORDER_TABLE_FIXED;