P4C
The P4 Compiler
|
#include <optimize_phv.h>
Public Member Functions | |
BruteForceOptimizationStrategy (BruteForceAllocationStrategy &alloc_strategy_i, const std::list< PHV::ContainerGroup * > &container_groups, const ScoreContext &score_ctx) | |
void | addTransaction (PHV::Transaction &transaction, PHV::SuperCluster &sc, int tr_id=-1) |
std::list< PHV::SuperCluster * > | optimize (std::list< PHV::SuperCluster * > &unallocated_sc, PHV::Transaction &rst) |
void | printContDependency () |
Optimization Strategy called when PHV Allocation fail to place all the SuperClusters
The Brute Force Strategy add a Transaction for each SuperClusters being assigned. This Transaction list can be used to replay back the PHV Allocation found by the greedy algorithm. It can also be used as a baseline to try replacing some of these transactions with others and ultimately increase the whole solution score. The solution is optimized until we are either able to fit all of the unassigned SuperClusters or it went over the entire transaction list for MAX_OPT_PASS times.
This is an overview of what this optimization strategy is doing:
1 - Take the first Transaction (a) in the list 2 - Create a Transaction list (b) that excludes this Transaction (a) and all of the Transaction that was dependant (c) on that one as well 3 - Play back this Transaction list (b) 4 - Try to re-assign the removed Transaction (a) and all of the dependant one (c) 5 - If that succeed, Try to assign the unassigned SuperClusters 6 - Take the next Transaction from the list and go back to (1)
void BruteForceOptimizationStrategy::addTransaction | ( | PHV::Transaction & | transaction, |
PHV::SuperCluster & | sc, | ||
int | tr_id = -1 ) |
Copyright (C) 2024 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0 Insert a Transaction/SuperCluster to the optimization strategy.
[in] | transaction | Transaction to keep track |
[in] | sc | SuperCluster binded to this Transaction |
[in] | tr_id | Optional Transaction ID. When unset, the Transaction ID will be the next integer value. Removed Transaction ID are not re-used. |
std::list< PHV::SuperCluster * > BruteForceOptimizationStrategy::optimize | ( | std::list< PHV::SuperCluster * > & | unallocated_sc, |
PHV::Transaction & | rst ) |
Start the optimization process.
[in,out] | unallocated_sc | Unallocated SuperClusters list to place. The list is updated during the process and ideally is returned empty on success. |
[in,out] | rst | Base Transaction to commit the best result on. |
unallocated_sc
list. void BruteForceOptimizationStrategy::printContDependency | ( | ) |
Print the Container to Transaction Dependencies.