19#ifndef BF_P4C_PHV_SLICING_PHV_SLICING_DFS_ITERATOR_H_
20#define BF_P4C_PHV_SLICING_PHV_SLICING_DFS_ITERATOR_H_
24#include "backends/tofino/bf-p4c/lib/assoc.h"
25#include "backends/tofino/bf-p4c/parde/check_parser_multi_write.h"
26#include "backends/tofino/bf-p4c/phv/slicing/phv_slicing_iterator.h"
27#include "backends/tofino/bf-p4c/phv/slicing/phv_slicing_split.h"
28#include "backends/tofino/bf-p4c/phv/slicing/types.h"
29#include "backends/tofino/bf-p4c/phv/utils/utils.h"
30#include "lib/ordered_set.h"
36using SliceListLoc = std::pair<SuperCluster *, SuperCluster::SliceList *>;
41 static const bitvec all_container_sizes;
44 enum class ConstraintType {
61 ConstraintType type()
const;
64 int min()
const {
return *sizes.begin(); }
74 bool ok(
const int n)
const;
83enum class SplitChoice {
100 const PackConflictChecker has_pack_conflict_i;
101 const IsReferencedChecker is_used_i;
120 std::vector<const SuperCluster::SliceList *> slicelist_on_stack_i;
131 bool has_itr_i =
false;
140 int n_steps_since_last_solution = 0;
143 std::set<SplitChoice> reject_sizes;
147 const SuperCluster::SliceList *to_invalidate =
nullptr;
162 static constexpr int to_invalidate_max_ignore = 8;
171 const PackConflictChecker &pack_conflict,
const IsReferencedChecker is_used)
175 action_packing_validator_i(action_packing_validator),
176 parser_packing_validator_i(parser_packing_validator),
177 has_pack_conflict_i(pack_conflict),
179 config_i(
false,
false,
true,
true,
false, (1 << 25), (1 << 19)),
180 check_write_mode_consistency_i(phv, field_to_states, parser_info) {}
183 void iterate(
const IterateCb &cb)
override;
189 void invalidate(
const SuperCluster::SliceList *sl)
override;
233 std::vector<SplitChoice>
make_choices(
const SliceListLoc &target)
const;
246 bool dfs_prune_invalid_parser_packing(
const SuperCluster *sc)
const;
313 const SuperCluster::SliceList *just_split_target,
314 const int n_just_split_bits,
SplitSchema *schema)
const;
319 SuperCluster *sc, SuperCluster::SliceList *sl,
int first_n_bits)
const;
367 void need_to_check_duplicate();
373 int check_duplicate = -1;
375 const int duplicate_check_supercluster_size = 5;
Definition ordered_map.h:32
Definition ordered_set.h:32
Definition action_packing_validator_interface.h:33
Definition parser_packing_validator_interface.h:26
Definition phv_slicing_dfs_iterator.h:92
void propagate_8bit_exact_container_split(SuperCluster *sc, SuperCluster::SliceList *target, SplitSchema *schema, SplitDecision *decisions) const
Definition phv_slicing_dfs_iterator.cpp:615
void iterate(const IterateCb &cb) override
iterate will pass valid slicing results to cb. Stop when cb returns false.
Definition phv_slicing_dfs_iterator.cpp:1187
bool dfs_prune_unsat_slicelist_max_size(const SplitDecision &constraints, const SuperCluster *sc) const
return true if exists constraint unsat due to the limit of slice list size.
Definition phv_slicing_dfs_iterator.cpp:1687
void invalidate(const SuperCluster::SliceList *sl) override
Definition phv_slicing_dfs_iterator.cpp:2183
std::vector< SplitChoice > make_choices(const SliceListLoc &target) const
Definition phv_slicing_dfs_iterator.cpp:433
std::optional< std::list< SuperCluster * > > split_by_deparsed_bottom_bits(SuperCluster *sc) const
split_by_deparsed_bottom_bits will split at the beginning of deparsed_bottom_bits field.
Definition phv_slicing_dfs_iterator.cpp:942
bool dfs_prune_unsat_exact_list_size_mismatch(const SplitDecision &decided_sz, const SuperCluster *sc) const
Definition phv_slicing_dfs_iterator.cpp:1846
std::optional< std::list< SuperCluster * > > split_by_pa_container_size(const SuperCluster *sc, const PHVContainerSizeLayout &pa)
split_by_pa_container_size will split sc by pa container size.
Definition phv_slicing_dfs_iterator.cpp:1053
std::optional< std::pair< SplitSchema, SplitDecision > > make_split_meta(SuperCluster *sc, SuperCluster::SliceList *sl, int first_n_bits) const
Definition phv_slicing_dfs_iterator.cpp:794
bool dfs_prune_unsat_slicelist_constraints(const SplitDecision &constraints, const SuperCluster *sc) const
Definition phv_slicing_dfs_iterator.cpp:1719
std::optional< std::list< SuperCluster * > > split_by_valid_container_range(SuperCluster *sc) const
Definition phv_slicing_dfs_iterator.cpp:965
bool need_further_split(const SuperCluster::SliceList *sl) const
return true if the slicelist needs to be further split.
Definition phv_slicing_dfs_iterator.cpp:1331
std::optional< std::list< SuperCluster * > > split_by_long_fieldslices(SuperCluster *sc) const
Definition phv_slicing_dfs_iterator.cpp:987
bool propagate_tail_split(SuperCluster *sc, const SplitDecision &constraints, const SplitDecision *decisions, const SuperCluster::SliceList *just_split_target, const int n_just_split_bits, SplitSchema *schema) const
Definition phv_slicing_dfs_iterator.cpp:697
std::optional< std::list< SuperCluster * > > split_by_adjacent_deparsed_and_non_deparsed(SuperCluster *sc) const
Definition phv_slicing_dfs_iterator.cpp:914
bool dfs(const IterateCb &yield, const ordered_set< SuperCluster * > &unchecked)
Definition phv_slicing_dfs_iterator.cpp:2036
std::optional< SliceListLoc > dfs_pick_next() const
Definition phv_slicing_dfs_iterator.cpp:564
std::optional< SplitDecision > collect_aftersplit_constraints(const SuperCluster *sc) const
Definition phv_slicing_dfs_iterator.cpp:1489
bool collect_implicit_container_sz_constraint(SplitDecision *decided_sz, const SuperCluster *sc) const
Definition phv_slicing_dfs_iterator.cpp:1612
bool check_pack_conflict(const SuperCluster::SliceList *sl) const
return true if there are pack_conflicts in sl.
Definition phv_slicing_dfs_iterator.cpp:1394
void set_config(const IteratorConfig &cfg) override
set configs.
Definition phv_slicing_dfs_iterator.h:192
std::optional< std::list< SuperCluster * > > split_by_adjacent_no_pack(SuperCluster *sc) const
Definition phv_slicing_dfs_iterator.cpp:872
std::vector< SuperCluster * > get_well_formed_no_more_split() const
Definition phv_slicing_dfs_iterator.cpp:1965
bool dfs_prune_invalid_packing(const SuperCluster *sc)
Definition phv_slicing_dfs_iterator.cpp:1883
bool dfs_prune_unwell_formed(const SuperCluster *sc) const
Definition phv_slicing_dfs_iterator.cpp:1424
bool dfs_prune(const ordered_set< SuperCluster * > &unchecked)
Definition phv_slicing_dfs_iterator.cpp:1917
std::optional< std::list< SuperCluster * > > split_by_parser_write_mode(SuperCluster *sc)
split_by_parser_write_mode will split based on incompatible parser write modes
Definition phv_slicing_dfs_iterator.cpp:1016
The interface that the iterator must satisfy.
Definition slicing/types.h:108
Definition phv/utils/utils.h:1049
Definition phv_fields.h:1095
The namespace encapsulating PHV-related stuff.
Definition gateway.h:32
Definition check_parser_multi_write.h:47
Map field to the parser states in which they are extracted or assigned from checksums.
Definition phv_fields.h:1755
constraints introduced on fieldslices of container sizes after splitting a slice list.
Definition phv_slicing_dfs_iterator.h:39
Definition slicing/types.h:52