P4C
The P4 Compiler
Loading...
Searching...
No Matches
BruteForceAllocationStrategy Class Reference
Inheritance diagram for BruteForceAllocationStrategy:
[legend]

Public Member Functions

 BruteForceAllocationStrategy (const cstring name, const PHV::AllocUtils &utils, const CoreAllocation &core, const PHV::Allocation &empty_alloc, const BruteForceStrategyConfig &config, int pipeId, PhvInfo &phv)
 
std::optional< const PHV::SuperCluster::SliceList * > get_unallocatable_list () const
 
int getPipeId () const
 
AllocResult tryAllocation (const PHV::Allocation &alloc, const std::list< PHV::SuperCluster * > &cluster_groups_input, const std::list< PHV::ContainerGroup * > &container_groups) override
 
- Public Member Functions inherited from AllocationStrategy
 AllocationStrategy (cstring name, const PHV::AllocUtils &utils, const CoreAllocation &core)
 

Protected Member Functions

std::list< PHV::SuperCluster * > allocDeparserZeroSuperclusters (PHV::Transaction &rst, std::list< PHV::SuperCluster * > &cluster_groups)
 
std::list< PHV::SuperCluster * > allocLoop (PHV::Transaction &rst, std::list< PHV::SuperCluster * > &cluster_groups, const std::list< PHV::ContainerGroup * > &container_groups, const ScoreContext &score_ctx)
 
ordered_set< bitveccalc_slicing_schemas (const PHV::SuperCluster *sc, const std::set< PHV::Allocation::AvailableSpot > &spots)
 
std::list< PHV::SuperCluster * > crush_clusters (const std::list< PHV::SuperCluster * > &cluster_groups)
 
std::optional< const PHV::SuperCluster::SliceList * > diagnose_slicing (const std::list< PHV::SuperCluster * > &slicing, const std::list< PHV::ContainerGroup * > &container_groups) const
 
std::list< PHV::SuperCluster * > pounderRoundAllocLoop (PHV::Transaction &rst, std::list< PHV::SuperCluster * > &cluster_groups, const std::list< PHV::ContainerGroup * > &container_groups)
 
std::list< PHV::SuperCluster * > preslice_clusters (const std::list< PHV::SuperCluster * > &cluster_groups, const std::list< PHV::ContainerGroup * > &container_groups, std::list< const PHV::SuperCluster * > &unsliceable)
 slice clusters into clusters with container-sized chunks.
 
std::optional< const PHV::SuperCluster::SliceList * > preslice_validation (const std::list< PHV::SuperCluster * > &sliced, const std::list< PHV::ContainerGroup * > &container_groups) const
 
void sortClusters (std::list< PHV::SuperCluster * > &cluster_groups)
 Sort list of superclusters into the order in which they should be allocated.
 
AllocResult tryAllocationFailuresFirst (const PHV::Allocation &alloc, const std::list< PHV::SuperCluster * > &cluster_groups_input, const std::list< PHV::ContainerGroup * > &container_groups, const ordered_set< const PHV::Field * > &failures)
 
bool tryAllocSlicing (const std::list< PHV::SuperCluster * > &slicing, const std::list< PHV::ContainerGroup * > &container_groups, PHV::Transaction &slicing_alloc, const ScoreContext &score_ctx)
 
bool tryAllocSlicingStrided (unsigned num_strides, const std::list< PHV::SuperCluster * > &slicing, const std::list< PHV::ContainerGroup * > &container_groups, PHV::Transaction &slicing_alloc, const ScoreContext &score_ctx)
 
bool tryAllocStride (const std::list< PHV::SuperCluster * > &stride, const std::list< PHV::ContainerGroup * > &container_groups, PHV::Transaction &stride_alloc, const ScoreContext &score_ctx)
 
bool tryAllocStrideWithLeaderAllocated (const std::list< PHV::SuperCluster * > &stride, PHV::Transaction &leader_alloc, const ScoreContext &score_ctx)
 
std::optional< PHV::TransactiontryVariousSlicing (PHV::Transaction &rst, PHV::SuperCluster *cluster_group, const std::list< PHV::ContainerGroup * > &container_groups, const ScoreContext &score_ctx, std::stringstream &alloc_history)
 

Friends

class BruteForceOptimizationStrategy
 

Additional Inherited Members

- Protected Attributes inherited from AllocationStrategy
const CoreAllocationcore_alloc_i
 
const cstring name
 
const PHV::AllocUtilsutils_i
 

Member Function Documentation

◆ allocDeparserZeroSuperclusters()

std::list< PHV::SuperCluster * > BruteForceAllocationStrategy::allocDeparserZeroSuperclusters ( PHV::Transaction & rst,
std::list< PHV::SuperCluster * > & cluster_groups )
protected

Allocate deparser zero fields to zero-initialized containers. B0 for ingress and B16 for egress.

◆ calc_slicing_schemas()

ordered_set< bitvec > BruteForceAllocationStrategy::calc_slicing_schemas ( const PHV::SuperCluster * sc,
const std::set< PHV::Allocation::AvailableSpot > & spots )
protected

Return a vector of slicing schemas for sc, that

  1. Slicing by the available spots on containers.
  2. Slicing by 7, 6, 5...1-bit chunks.

◆ pounderRoundAllocLoop()

std::list< PHV::SuperCluster * > BruteForceAllocationStrategy::pounderRoundAllocLoop ( PHV::Transaction & rst,
std::list< PHV::SuperCluster * > & cluster_groups,
const std::list< PHV::ContainerGroup * > & container_groups )
protected

Slice cluster_groups to small chunks and try allocate them.

After execution, rst will be updated with allocated clusters. Unallocated superclusters will be stored in cluster_groups, without being sliced.

Returns
allocated clusters.

Try to slice and allocate each cluster by trying the slicing schemas returned from calc_slicing_schema, in order.

◆ tryAllocation()

AllocResult BruteForceAllocationStrategy::tryAllocation ( const PHV::Allocation & alloc,
const std::list< PHV::SuperCluster * > & cluster_groups_input,
const std::list< PHV::ContainerGroup * > & container_groups )
overridevirtual

Run this strategy Returns: a AllocResult that

  1. status: the result of this strategy.
  2. transaction: allocations had been made.
  3. remaining_clusters: the remaining cluster; Strategies should not changed container_groups, except for sorting it.

Implements AllocationStrategy.

◆ tryVariousSlicing()

std::optional< PHV::Transaction > BruteForceAllocationStrategy::tryVariousSlicing ( PHV::Transaction & rst,
PHV::SuperCluster * cluster_group,
const std::list< PHV::ContainerGroup * > & container_groups,
const ScoreContext & score_ctx,
std::stringstream & alloc_history )
protected

TODO strided cluster can have many slices in the supercluster and the number of slicing can blow up (need a better way to stop than this crude heuristic).