P4C
The P4 Compiler
Loading...
Searching...
No Matches
PHV::SuperCluster Class Reference

#include <utils.h>

Inheritance diagram for PHV::SuperCluster:
[legend]

Public Types

using SliceList = std::list<PHV::FieldSlice>
 

Public Member Functions

 SuperCluster (ordered_set< const PHV::RotationalCluster * > clusters, ordered_set< SliceList * > slice_lists)
 
size_t aggregate_size () const override
 
const AlignedClusteraligned_cluster (const PHV::FieldSlice &slice) const
 
bool all_of_fieldslices (const std::function< bool(const PHV::FieldSlice &)> func) const
 Apply func on all field slices in this super cluster.
 
bool any_of_fieldslices (const std::function< bool(const PHV::FieldSlice &)> func) const
 
void calc_pack_conflicts ()
 calculates the value of num_pack_conflicts_i (to be performed after PackConflicts analysis)
 
const RotationalClustercluster (const PHV::FieldSlice &slice) const
 
const ordered_set< const RotationalCluster * > & clusters () const
 
bool contains (const PHV::Field *f) const override
 
bool contains (const PHV::FieldSlice &slice) const override
 
bool deparsed () const override
 
int exact_containers () const override
 
SuperCluster::SliceList * findLinkedWideArithSliceList (const SuperCluster::SliceList *sl) const
 
void forall_fieldslices (const std::function< void(const PHV::FieldSlice &)> func) const
 Apply func on all field slices in this super cluster.
 
gress_t gress () const override
 
bool is_deparser_zero_candidate () const
 
int max_width () const override
 
SuperClustermerge (const SuperCluster *sc1)
 
SuperClustermerge (const SuperCluster *sc1) const
 return the merged supercluster.
 
SuperClustermergeAndSortBasedOnWideArith (const SuperCluster *sc1) const
 
bool needsStridedAlloc () const
 
void needsStridedAlloc (bool val)
 
bool needToMergeForWideArith (const SuperCluster *sc) const
 
int num_constraints () const override
 
size_t num_pack_conflicts () const
 
bool okIn (PHV::Kind kind) const override
 
bool operator== (const SuperCluster &other) const
 Semantic equality.
 
const ordered_set< const SliceList * > & slice_list (const PHV::FieldSlice &slice) const
 
const ordered_set< SliceList * > & slice_lists () const
 
ordered_set< PHV::FieldSliceslices () const
 
- Public Member Functions inherited from PHV::ClusterStats

Static Public Member Functions

static bool is_well_formed (const SuperCluster *sc, PHV::Error *err=new PHV::Error())
 
static std::vector< le_bitrangeslice_list_exact_containers (const SliceList &list)
 
static bool slice_list_has_exact_containers (const SliceList &list)
 
static std::vector< SuperCluster::SliceList * > slice_list_split_by_byte (const SuperCluster::SliceList &sl)
 
static int slice_list_total_bits (const SliceList &list)
 

Additional Inherited Members

- Public Attributes inherited from PHV::ClusterStats
int uid = nextId++
 

Detailed Description

A group of rotational clusters that must be placed in the same MAU group of PHV containers.

Invariants on membership:

  • every field slice in each slice list exists in exactly one aligned cluster, although the same slice may appear in multiple slice lists.
  • every aligned cluster exists in exactly one rotational cluster.
  • every rotational cluster exists in exactly one super cluster.

Any attempt to place a SuperCluster into a container group will fail if:

  • any slice is wider than the container size.
  • the aggregate width of any slice list is wider than the container size.

Slicing a SuperCluster can fail if:

  • a field slice would be split but has the no_split property.
  • two adjacent slices of the same field in a slice list would be split into different slice lists, but the field has the no_split property.

Note that slice lists are formed from lists of header fields (among other things). In this case, the order of slices in the slice list is in little Endian, but headers are often written in big Endian order, and so the order in the slice list will appear reversed.

See also
PHV::MakeSuperClusters in make_clusters.h for more details.

Member Function Documentation

◆ aggregate_size()

size_t PHV::SuperCluster::aggregate_size ( ) const
inlineoverridevirtual
Returns
the aggregate size of all slices in all clusters in this group.

Implements PHV::ClusterStats.

◆ aligned_cluster()

const AlignedCluster & PHV::SuperCluster::aligned_cluster ( const PHV::FieldSlice & slice) const
inline
Returns
the aligned cluster containing slice.
Warning
fails catastrophicaly if slice is not in any cluster in this group; all slices in every slice list are guaranteed to be present in exactly one cluster.

◆ any_of_fieldslices()

bool PHV::SuperCluster::any_of_fieldslices ( const std::function< bool(const PHV::FieldSlice &)> func) const
inline
Returns
true if any_of func is true on a fieldslice.

◆ cluster()

const RotationalCluster & PHV::SuperCluster::cluster ( const PHV::FieldSlice & slice) const
inline
Returns
the rotational cluster containing slice.
Warning
fails catastrophicaly if slice is not in any cluster in this group; all slices in every slice list are guaranteed to be present in exactly one cluster.

◆ clusters()

const ordered_set< const RotationalCluster * > & PHV::SuperCluster::clusters ( ) const
inline
Returns
the aligned clusters in this group.

◆ contains() [1/2]

bool PHV::SuperCluster::contains ( const PHV::Field * f) const
overridevirtual
Returns
true if this cluster contains f.

Implements PHV::ClusterStats.

◆ contains() [2/2]

bool PHV::SuperCluster::contains ( const PHV::FieldSlice & slice) const
overridevirtual
Returns
true if this cluster contains slice.

Implements PHV::ClusterStats.

◆ deparsed()

bool PHV::SuperCluster::deparsed ( ) const
inlineoverridevirtual
Returns
true if any slice in the cluster is deparsed (either to the wire or the TM).

Implements PHV::ClusterStats.

◆ exact_containers()

int PHV::SuperCluster::exact_containers ( ) const
inlineoverridevirtual
Returns
the number of clusters in this group with the exact_containers constraint.

Implements PHV::ClusterStats.

◆ findLinkedWideArithSliceList()

PHV::SuperCluster::SliceList * PHV::SuperCluster::findLinkedWideArithSliceList ( const SuperCluster::SliceList * sl) const

Given a SliceList within a SuperCluster, find its linked wide arithmetic SliceList.

◆ gress()

gress_t PHV::SuperCluster::gress ( ) const
inlineoverridevirtual
Returns
the gress requirement of this cluster.

Implements PHV::ClusterStats.

◆ is_deparser_zero_candidate()

bool PHV::SuperCluster::is_deparser_zero_candidate ( ) const
Returns
true if all field slices are deparser_zero_candidate.

◆ is_well_formed()

bool PHV::SuperCluster::is_well_formed ( const SuperCluster * sc,
PHV::Error * err = new PHV::Error() )
static
Returns
true if no structural constraints prevent this super cluster from fitting.
true if all slices lists and slices are smaller than 32b and no slice list contains more than one slice per aligned cluster. TODO: Also check that slice lists with exact_container requirements are all the same size. We should check this ahead of time, though. TODO: Also check that deparsed bottom bits fields are at the front of their slice lists.

◆ max_width()

int PHV::SuperCluster::max_width ( ) const
inlineoverridevirtual
Returns
the width of the maximum slice in any cluster in this group.

Implements PHV::ClusterStats.

◆ merge()

SuperCluster * PHV::SuperCluster::merge ( const SuperCluster * sc1)
inline
Returns
a new SuperCluster object that is the union of the provided SuperCluster inputs.

◆ mergeAndSortBasedOnWideArith()

PHV::SuperCluster * PHV::SuperCluster::mergeAndSortBasedOnWideArith ( const SuperCluster * sc1) const

Merge this SuperCluster with the input SuperCluster, and return a new SuperCluster. This function is only intended to be called when the two SuperClusters are linked by wide arithmetic allocation requirements. This function merges the slice lists such that slice lists that are paired by wide arithmetic requirements are adjacent in the list, and the slice list destined for an even container (the lo slice) appears before the slice list destined for an odd container (the hi slice).

◆ needsStridedAlloc()

bool PHV::SuperCluster::needsStridedAlloc ( ) const
inline
Returns
true if this super cluster needs strided allocation

◆ needToMergeForWideArith()

bool PHV::SuperCluster::needToMergeForWideArith ( const SuperCluster * sc) const
Returns
true if two SuperClusters need to be merged, because they container hi/lo field slices that participate in a wide arithmetic operation.

◆ num_constraints()

int PHV::SuperCluster::num_constraints ( ) const
inlineoverridevirtual
Returns
the sum of constraints of all clusters in this group.

Implements PHV::ClusterStats.

◆ num_pack_conflicts()

size_t PHV::SuperCluster::num_pack_conflicts ( ) const
inline
Returns
the number of pack conflicts of all slices in all clusters in this group. A pack conflict indicates that the field of a given slice cannot be packed with some other field referenced in the program.

◆ okIn()

bool PHV::SuperCluster::okIn ( PHV::Kind kind) const
overridevirtual
Returns
true if this cluster can be assigned to containers of kind kind.

Implements PHV::ClusterStats.

◆ slice_list()

const ordered_set< const PHV::SuperCluster::SliceList * > & PHV::SuperCluster::slice_list ( const PHV::FieldSlice & slice) const
Returns
the slice lists holding slice.

◆ slice_list_exact_containers()

std::vector< le_bitrange > PHV::SuperCluster::slice_list_exact_containers ( const SliceList & list)
static
Returns
the vector of le_bitrange instances identified for each PHV::FieldSlice

◆ slice_list_has_exact_containers()

bool PHV::SuperCluster::slice_list_has_exact_containers ( const SliceList & list)
static
Returns
true iff the slice list has any exact container inside

◆ slice_list_split_by_byte()

std::vector< PHV::SuperCluster::SliceList * > PHV::SuperCluster::slice_list_split_by_byte ( const SuperCluster::SliceList & sl)
static
Returns
a vector of slice list split by bytes with prepending alignment considered.

◆ slice_list_total_bits()

int PHV::SuperCluster::slice_list_total_bits ( const SliceList & list)
static
Returns
the total bits in a list paramter

◆ slice_lists()

const ordered_set< SliceList * > & PHV::SuperCluster::slice_lists ( ) const
inline
Returns
the slice lists that induced this grouping.

◆ slices()

ordered_set< PHV::FieldSlice > PHV::SuperCluster::slices ( ) const
Returns
all field slices in this cluster