![]() |
P4C
The P4 Compiler
|
#include <allocate_phv.h>
Public Member Functions | |
CoreAllocation (const PHV::AllocUtils &utils, bool disable_metainit) | |
bool | can_physical_liverange_overlay (const PHV::AllocSlice &slice, const ordered_set< PHV::AllocSlice > &allocated) const |
bool | checkDarkOverlay (const std::vector< PHV::AllocSlice > &candidate_slices, const PHV::Transaction &alloc) const |
bool | checkParserExtractions (const std::vector< PHV::AllocSlice > &candidate_slices, const PHV::Transaction &alloc) const |
std::optional< const PHV::SuperCluster::SliceList * > | find_first_unallocated_slicelist (const PHV::Allocation &alloc, const std::list< PHV::ContainerGroup * > &container_groups, const PHV::SuperCluster &cluster) const |
bool | generateNewAllocSlices (const PHV::AllocSlice &origSlice, const ordered_set< PHV::AllocSlice > &alloced_slices, PHV::DarkInitMap &slices, ordered_set< PHV::AllocSlice > &new_candidate_slices, PHV::Transaction &alloc_attempt, const PHV::Allocation::MutuallyLiveSlices &container_state) const |
bool | get_prioririze_ARA_inits () |
bool | get_single_gress_parser_group () |
bool | hasARAinits (ordered_set< PHV::AllocSlice > slices) const |
@look for ARA inits in set of slices | |
bool | hasCrossingLiveranges (std::vector< PHV::AllocSlice > candidate_slices, ordered_set< PHV::AllocSlice > alloc_slices) const |
PHV::Transaction | make_speculated_alloc (const PHV::Transaction &alloc, const PHV::SuperCluster &sc, const std::vector< PHV::AllocSlice > &candidates, const PHV::Container &c) const |
bool | rangesOverlap (const PHV::AllocSlice &slice, const IR::BFN::ParserPrimitive *prim) const |
Do the slice and prim have overlapping field ranges. | |
bool | satisfies_constraints (const PHV::Allocation &alloc, const PHV::AllocSlice &slice, ordered_set< PHV::AllocSlice > &initFields, std::vector< PHV::AllocSlice > &candidate_slices) const |
bool | satisfies_constraints (const PHV::ContainerGroup &group, const PHV::Field *f) const |
bool | satisfies_constraints (const PHV::ContainerGroup &group, const PHV::FieldSlice &slice) const |
bool | satisfies_constraints (std::vector< PHV::AllocSlice > slices, const PHV::Allocation &alloc) const |
void | set_prioritize_ARA_inits () |
void | set_single_gress_parser_group () |
std::optional< PHV::Transaction > | try_alloc (const PHV::Allocation &alloc, const PHV::ContainerGroup &group, PHV::SuperCluster &cluster, int max_alignment_tries, const ScoreContext &score_ctx) const |
std::optional< PHV::Transaction > | try_deparser_zero_alloc (const PHV::Allocation &alloc, PHV::SuperCluster &cluster, PhvInfo &phv) const |
std::optional< PHV::Transaction > | tryAllocSliceList (const PHV::Allocation &alloc, const PHV::ContainerGroup &group, const PHV::SuperCluster &super_cluster, const PHV::Allocation::ConditionalConstraint &start_positions, const ScoreContext &score_ctx) const |
std::optional< PHV::Transaction > | tryAllocSliceList (const PHV::Allocation &alloc, const PHV::ContainerGroup &group, const PHV::SuperCluster &super_cluster, const PHV::SuperCluster::SliceList &slice_list, const ordered_map< PHV::FieldSlice, int > &start_positions, const ScoreContext &score_ctx) const |
Static Public Member Functions | |
static bool | can_overlay (const SymBitMatrix &mutually_exclusive_field_ids, const PHV::Field *f, const ordered_set< PHV::AllocSlice > &slices) |
static bool | satisfies_constraints (const PHV::ContainerGroup &container_group, const PHV::SuperCluster &cluster_group) |
static bool | some_overlay (const SymBitMatrix &mutually_exclusive_field_ids, const PHV::Field *f, const ordered_set< PHV::AllocSlice > &slices) |
A set of functions used in PHV allocation.
|
static |
f
can overlay all fields in slices
. bool CoreAllocation::can_physical_liverange_overlay | ( | const PHV::AllocSlice & | slice, |
const ordered_set< PHV::AllocSlice > & | allocated ) const |
slice
can overlay all fields in allocated
in terms of physical liveranges. bool CoreAllocation::checkParserExtractions | ( | const std::vector< PHV::AllocSlice > & | candidate_slices, |
const PHV::Transaction & | alloc ) const |
Verify whether the candidate_slices
will produce parser extractions that will lead to data corruption
PHV::Transaction CoreAllocation::make_speculated_alloc | ( | const PHV::Transaction & | alloc, |
const PHV::SuperCluster & | sc, | ||
const std::vector< PHV::AllocSlice > & | candidates, | ||
const PHV::Container & | c ) const |
Generate pseudo AllocSlices for field slices that have not been allocated, but their allocation can be speculated upfront: when there is only one valid starting position.
alloc
. bool CoreAllocation::satisfies_constraints | ( | const PHV::Allocation & | alloc, |
const PHV::AllocSlice & | slice, | ||
ordered_set< PHV::AllocSlice > & | initFields, | ||
std::vector< PHV::AllocSlice > & | candidate_slices ) const |
slice
is a valid allocation move given the allocation status in alloc
. initFields
contains a list of fields in this container that will be initialized via metadata initialization.
|
static |
container_group
and cluster_group
satisfy constraints. TODO: figure out what, if any, constraints should go here. bool CoreAllocation::satisfies_constraints | ( | const PHV::ContainerGroup & | group, |
const PHV::Field * | f ) const |
bool CoreAllocation::satisfies_constraints | ( | const PHV::ContainerGroup & | group, |
const PHV::FieldSlice & | slice ) const |
bool CoreAllocation::satisfies_constraints | ( | std::vector< PHV::AllocSlice > | slices, |
const PHV::Allocation & | alloc ) const |
FIXME(vstill): the mutex check seems to be needed also in cases where the data are not comming from the packet
|
static |
f
can overlay at least one field in slices
. std::optional< PHV::Transaction > CoreAllocation::try_alloc | ( | const PHV::Allocation & | alloc, |
const PHV::ContainerGroup & | group, | ||
PHV::SuperCluster & | cluster, | ||
int | max_alignment_tries, | ||
const ScoreContext & | score_ctx ) const |
Try to allocate all fields in cluster
to containers in group
, using the following techniques (when permissible by constraints), assuming alloc
is the allocation so far, possibly including allocations to containers in group:
cluster
to group
or std::nullopt if no allocation could be found.Caveats and TODOs:
Uses mutex_i and uses_i.
std::optional< PHV::Transaction > CoreAllocation::try_deparser_zero_alloc | ( | const PHV::Allocation & | alloc, |
PHV::SuperCluster & | cluster, | ||
PhvInfo & | phv ) const |
Helper function that tries to allocate all fields in the deparser zero supercluster cluster
to containers B0 (for ingress) and B16 (for egress). The DeparserZero analysis earlier in PHV allocation already ensures that these fields can be safely allocated to the zero-ed containers.
std::optional< PHV::Transaction > CoreAllocation::tryAllocSliceList | ( | const PHV::Allocation & | alloc, |
const PHV::ContainerGroup & | group, | ||
const PHV::SuperCluster & | super_cluster, | ||
const PHV::Allocation::ConditionalConstraint & | start_positions, | ||
const ScoreContext & | score_ctx ) const |
Helper function for tryAlloc that tries to allocate all fields in start_positions
simultaneously. Deparsed fields in particular need to be placed simultaneously with their neighbors; otherwise, the deparsed
constraint cannot be satisfied.
For example, consider a header with two 8-bit fields:
header h { bit<4> f1; bit<4> f2; }
Fields f1 and f2 are deparsed, meaning that each must be placed in a container alone or with other deparsed fields (in order) such that no container bits are unallocated. However, if we check this constraint one field at a time, then neither field can be placed—one must be placed first, but it only occupies half the container, violating the constraint.
Additionally, start_positions
also includes the conditional constraints generated by ActionPhvConstraints.
Uses mutex_i and uses_i.
alloc | the allocation computed so far. |
group | the container group to which the slice list is to be allocated. |
super_cluster | ??? |
start_positions | a map. Keys are the field slices to be allocated. Values are the corresponding conditional constraint on the field slice. |
score_ctx | TODO TODO: there is an assumption that only fieldslice of the slice list, shows up in the start_positions map (as there is no slice list passed as args). Better to remove this. |
std::optional< PHV::Transaction > CoreAllocation::tryAllocSliceList | ( | const PHV::Allocation & | alloc, |
const PHV::ContainerGroup & | group, | ||
const PHV::SuperCluster & | super_cluster, | ||
const PHV::SuperCluster::SliceList & | slice_list, | ||
const ordered_map< PHV::FieldSlice, int > & | start_positions, | ||
const ScoreContext & | score_ctx ) const |
Convenience method that transforms start_positions
map into a map of ConditionalConstraint, which is passed to tryAllocSliceList
above.