AMF-Placer
2.0
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
|
WirelengthOptimizer builds numerical models based on the element locations and calls solvers to find an optimal solution of the placement. More...
#include <WirelengthOptimizer.h>
Classes | |
struct | _CellWithScore |
struct | _PUWithScore |
struct | _slackEnhanceTuple |
Public Member Functions | |
WirelengthOptimizer (PlacementInfo *placementInfo, std::map< std::string, std::string > &JSONCfg, bool verbose=true) | |
Construct a new Wirelength Optimizer object. More... | |
~WirelengthOptimizer () | |
void | GlobalPlacementQPSolve (float pesudoNetWeight, bool firstIteration=true, bool forwardSolutionToNextIteration=false, bool enableMacroPseudoNet2Site=false, bool considerNetNum=true, bool enableUserDefinedClusterOpt=false, float displacementLimit=-10, PlacementTimingOptimizer *timingOptimizer=nullptr) |
use quadratic model to estimate the HPWL and some timing/user-defined pseudo nets are involved for specific optimization More... | |
void | updateB2BNetWeight (float pesudoNetWeight, bool enableMacroPseudoNet2Site=false, bool considerNetNum=true, bool enableUserDefinedClusterOpt=false, PlacementTimingOptimizer *timingOptimizer=nullptr) |
update the net weights in the quadratic model according to B2B net HPWL model. More... | |
void | reloadPlacementInfo () |
re-initialize some parameters and optimizer configuration according to the PlacementInfo More... | |
void | setMacroLegalizationParameters (int cnt, float macroLegalizationWeight) |
Set the macro legalization parameters. More... | |
int | getMacroPseudoNetEnhanceCnt () |
Get the number of the conducted macro iterations. More... | |
float | getMacroLegalizationWeight () |
Get the net weight for macro legalization. More... | |
void | clearNetPinEnhanceRate () |
void | setGeneralTimingNetWeight (float _generalTimingNetWeight) |
void | setSlackPowerFactor (double _slackPowerFactor) |
Static Public Member Functions | |
static void | updateB2BNetWeightWorker (PlacementInfo *placementInfo, std::vector< Eigen::Triplet< float >> &objectiveMatrixTripletList, std::vector< float > &objectiveMatrixDiag, Eigen::VectorXd &objectiveVector, float generalNetWeight, float y2xRatio, bool updateX, bool updateY) |
a worker funtion for multi-threading net weight updating More... | |
Private Types | |
typedef struct WirelengthOptimizer::_slackEnhanceTuple | slackEnhanceTuple |
typedef struct WirelengthOptimizer::_PUWithScore | PUWithScore |
typedef struct WirelengthOptimizer::_CellWithScore | CellWithScore |
Private Member Functions | |
void | solverLoadData () |
load to placement location from PlacementInfo to the solver More... | |
void | solverLoadFixedData () |
load to placement location of fixed PlacementUnits from PlacementInfo to the solver More... | |
void | solverWriteBackData (float displacementLimit) |
write placement location from the solver to the PlacementInfo More... | |
void | addPseudoNetForMacros (float pesudoNetWeight, bool considerNetNum) |
add the legalization pseudo nets to force macros move to the legal sites More... | |
void | addPseudoNet2LoctionForAllPUs (float pesudoNetWeight, bool considerNetNum) |
as convential QP placers do, we add pseudo nets between anchors and PlacementUnit to constrain the movement of PlacementUnit for WL optimization. More... | |
void | updatePseudoNetForUserDefinedClusters (float pesudoNetWeight) |
add pseudo net for user-defined clusters More... | |
void | addPseudoNet_SlackBased (float timingWeight, double slackPowFactor, PlacementTimingOptimizer *timingOptimizer, bool calculate=false) |
add pseudo net for timing optimization based on the timing slack of each elements in the design netlist More... | |
void | LUTLUTPairing_TimingDriven (float timingWeight, float disThreshold, PlacementTimingOptimizer *timingOptimizer) |
void | updatePseudoNetForClockRegion (float pesudoNetWeight) |
add pseudo nets for clock region More... | |
double | manhattanDis (double x0, double y0, double x1, double y1) |
evaluate the Mahattan distance between two locations More... | |
float | getCellDistance (PlacementInfo::Location &A, PlacementInfo::Location &B) |
Static Private Member Functions | |
static void | QPSolve (QPSolverWrapper *&curSolver) |
call the cooresponding solver to solve the QP problem defined in the given QPSolverWrapper More... | |
Private Attributes | |
std::vector< std::vector< slackEnhanceTuple > * > | PNetId2SlackEnhanceTuples |
PlacementInfo * | placementInfo |
QPSolverWrapper * | xSolver = nullptr |
QPSolverWrapper * | ySolver = nullptr |
std::map< std::string, std::string > & | JSONCfg |
bool | verbose |
float | generalNetWeight = 1.0 |
a common factor indicate the overall strength of the nets in the QP model from external setting More... | |
float | generalTimingNetWeight = 1.0 |
double | slackPowerFactor = 1.1 |
float | y2xRatio = 1.0 |
a factor to tune the weights of the net spanning in Y-coordinate relative to the net spanning in X-coordinate More... | |
bool | useUnconstrainedCG = true |
indicate whether wirelength optimizer uses Eigen3, which cannot solve QP problem with constraints. If false, OSQP solver which can set constraints for the quadratic model, will be involved to replace Eigen3. More... | |
bool | MKLorNot = false |
indicate whether wirelength optimizer is based on MKL library when using OSQP placer, which can set constraints for the quadratic model More... | |
bool | directMacroLegalize = false |
indicate whether we use direct macro legalization instread of the progressive legalization (2-phase legalization) More... | |
bool | DSPCritical = false |
float | pin2pinEnhance = 5.0 |
float | userDefinedClusterFadeOutFactor = 1.0 |
the fade-out factor for the user-defined clusters More... | |
float | oriMacroLegalizationWeight = 1.0 |
the net weight for macro legalization More... | |
int | macroPseudoNetCnt = 0 |
the number of the conducted macro iterations More... | |
std::map< DesignInfo::DesignNet *, std::vector< float > > | netPinEnhanceRate |
float | slackThr = 0 |
std::string | targetCellName = "design_1_i/DigitRec_0/inst/ap_phi_reg_pp2_iter31_knn_set_392_1_reg_27413_reg[20]" |
int | targetCellId = -1 |
WirelengthOptimizer builds numerical models based on the element locations and calls solvers to find an optimal solution of the placement.
Definition at line 53 of file WirelengthOptimizer.h.
|
private |
|
private |
|
private |
WirelengthOptimizer::WirelengthOptimizer | ( | PlacementInfo * | placementInfo, |
std::map< std::string, std::string > & | JSONCfg, | ||
bool | verbose = true |
||
) |
Construct a new Wirelength Optimizer object.
placementInfo | the PlacementInfo for this placer to handle |
JSONCfg | the user-defined placement configuration |
verbose | whether the WirelengthOptimizer prints out more information or dumps log files |
Definition at line 31 of file WirelengthOptimizer.cc.
|
inline |
Definition at line 64 of file WirelengthOptimizer.h.
|
private |
as convential QP placers do, we add pseudo nets between anchors and PlacementUnit to constrain the movement of PlacementUnit for WL optimization.
Please note that we can add the interconnect-aware factor into the pseudo nets so the macros can move slower compared to the fine-grained elements.
pesudoNetWeight | the common weight factor for pseudo nets |
considerNetNum | whether add the interconnection-density-aware factor to pseudo net weights |
Definition at line 821 of file WirelengthOptimizer.cc.
Referenced by updateB2BNetWeight().
|
private |
add pseudo net for timing optimization based on the timing slack of each elements in the design netlist
timingWeight | the common weight factor for pseudo nets for timing |
slackPowFactor | a factor for the sensitivity of negative timing slack |
timingOptimizer | the handler of timing-related analysis |
Definition at line 434 of file WirelengthOptimizer.cc.
Referenced by GlobalPlacementQPSolve(), and updateB2BNetWeight().
|
private |
add the legalization pseudo nets to force macros move to the legal sites
pesudoNetWeight | the common weight factor for pseudo nets |
considerNetNum | whether add the interconnection-density-aware factor to pseudo net weights |
Definition at line 356 of file WirelengthOptimizer.cc.
Referenced by updateB2BNetWeight().
|
inline |
Definition at line 181 of file WirelengthOptimizer.h.
|
inlineprivate |
Definition at line 305 of file WirelengthOptimizer.h.
Referenced by LUTLUTPairing_TimingDriven().
|
inline |
Get the net weight for macro legalization.
Definition at line 176 of file WirelengthOptimizer.h.
Referenced by GlobalPlacer::getMacroLegalizationWeight(), and GlobalPlacer::GlobalPlacement_CLBElements().
|
inline |
Get the number of the conducted macro iterations.
Definition at line 166 of file WirelengthOptimizer.h.
Referenced by GlobalPlacer::getMacroPseudoNetEnhanceCnt(), and GlobalPlacer::GlobalPlacement_CLBElements().
void WirelengthOptimizer::GlobalPlacementQPSolve | ( | float | pesudoNetWeight, |
bool | firstIteration = true , |
||
bool | forwardSolutionToNextIteration = false , |
||
bool | enableMacroPseudoNet2Site = false , |
||
bool | considerNetNum = true , |
||
bool | enableUserDefinedClusterOpt = false , |
||
float | displacementLimit = -10 , |
||
PlacementTimingOptimizer * | timingOptimizer = nullptr |
||
) |
use quadratic model to estimate the HPWL and some timing/user-defined pseudo nets are involved for specific optimization
pesudoNetWeight | the common weight factor for pseudo nets |
firstIteration | indicates whether this is the first iteration of current round of WL optimization to control the data loading |
forwardSolutionToNextIteration | if this round of WL optimization includes multiple iterations, do we forward the location data obtained in last iteration for later processing? |
enableMacroPseudoNet2Site | enable the legalization pseudo net to force macros move to the legal site |
considerNetNum | whether add the interconnection-density-aware factor to pseudo net weights |
enableUserDefinedClusterOpt | whether check user-defined cluster information to add pseudo nets |
timingOpt | whether turn on the timing-oriented optimizations |
Definition at line 100 of file WirelengthOptimizer.cc.
Referenced by GlobalPlacer::GlobalPlacement_CLBElements(), GlobalPlacer::GlobalPlacement_fixedCLB(), and ParallelCLBPacker::packCLBs().
|
private |
Definition at line 666 of file WirelengthOptimizer.cc.
Referenced by updateB2BNetWeight().
|
inlineprivate |
evaluate the Mahattan distance between two locations
x0 | |
y0 | |
x1 | |
y1 |
Definition at line 301 of file WirelengthOptimizer.h.
|
staticprivate |
call the cooresponding solver to solve the QP problem defined in the given QPSolverWrapper
curSolver | a given QPSolverWrapper |
void WirelengthOptimizer::reloadPlacementInfo | ( | ) |
re-initialize some parameters and optimizer configuration according to the PlacementInfo
PlacementInfo might change due to the loading of checkpoint or re-initialization of bin grid. Therefore, we need to let the WL optimizer to know the changes.
Definition at line 69 of file WirelengthOptimizer.cc.
Referenced by GlobalPlacer::GlobalPlacement_CLBElements(), and GlobalPlacer::GlobalPlacement_fixedCLB().
|
inline |
Definition at line 186 of file WirelengthOptimizer.h.
|
inline |
Set the macro legalization parameters.
The convergence of the placement is determined by some parameters and when we load the checkpoint from files, we also need to load the corresponding parameters for the optimizers.
cnt | the number of the conducted macro iterations |
macroLegalizationWeight | the net weight for macro legalization |
Definition at line 155 of file WirelengthOptimizer.h.
Referenced by GlobalPlacer::setMacroLegalizationParameters().
|
inline |
Definition at line 191 of file WirelengthOptimizer.h.
|
private |
load to placement location from PlacementInfo to the solver
Definition at line 142 of file WirelengthOptimizer.cc.
Referenced by GlobalPlacementQPSolve().
|
private |
load to placement location of fixed PlacementUnits from PlacementInfo to the solver
Definition at line 152 of file WirelengthOptimizer.cc.
|
private |
write placement location from the solver to the PlacementInfo
Definition at line 181 of file WirelengthOptimizer.cc.
Referenced by GlobalPlacementQPSolve().
void WirelengthOptimizer::updateB2BNetWeight | ( | float | pesudoNetWeight, |
bool | enableMacroPseudoNet2Site = false , |
||
bool | considerNetNum = true , |
||
bool | enableUserDefinedClusterOpt = false , |
||
PlacementTimingOptimizer * | timingOptimizer = nullptr |
||
) |
update the net weights in the quadratic model according to B2B net HPWL model.
In this procedure, we will not only consider the conventional nets/pseudonets in previous QP placer, but also include the legalization pseudo nets and timing-oriented pseudo nets to comprehensively optimize the placement in this part. Meanwhile, we allow users to define some clusters and let the WL optimizer take them into consideration during optimization.
pesudoNetWeight | the common weight factor for pseudo nets |
enableMacroPseudoNet2Site | enable the legalization pseudo net to force macros move to the legal site |
considerNetNum | whether add the interconnection-density-aware factor to pseudo net weights |
enableUserDefinedClusterOpt | whether check user-defined cluster information to add pseudo nets |
timingOpt | whether turn on the timing-oriented optimizations |
Definition at line 268 of file WirelengthOptimizer.cc.
Referenced by GlobalPlacementQPSolve().
|
static |
a worker funtion for multi-threading net weight updating
min_x 0.5 * x'Px + q'x s.t. l <= Ax <= u
placementInfo | the PlacementInfo for this placer to handle |
objectiveMatrixTripletList | a list of Eigen::Triplet used to describe the sparse matrix P of QP model |
objectiveMatrixDiag | a vector used to store the diagonal values in the sparse matrix P of QP model |
objectiveVector | a vector (i.e., Eigen::VectorXd) used to store the linear factors q' of QP model |
generalNetWeight | a common factor indicate the overall strength of the nets in the QP model from external setting |
y2xRatio | a factor to tune the weights of the net spanning in Y-coordinate relative to the net spanning in X-coordinate |
updateX | update the X-coordinate term in the quadratic problem |
updateY | update the X-coordinate term in the quadratic problem |
Definition at line 334 of file WirelengthOptimizer.cc.
Referenced by updateB2BNetWeight().
|
private |
add pseudo nets for clock region
we find that when the nets route across the boundaries of clock regions will lead to high delay, therefore, we will try to force the long path located in the same clock regions for the timing optimization.
pesudoNetWeight | the common weight factor for pseudo nets |
Definition at line 1043 of file WirelengthOptimizer.cc.
Referenced by updateB2BNetWeight().
|
private |
add pseudo net for user-defined clusters
We allow users to specify some clusters in the design and WL optimizer will try to push them togather during solving the QP problem
pesudoNetWeight | the common weight factor for pseudo nets |
Definition at line 955 of file WirelengthOptimizer.cc.
Referenced by updateB2BNetWeight().
|
private |
indicate whether we use direct macro legalization instread of the progressive legalization (2-phase legalization)
If we conduct direct macro legalization, pseudo net for legalization will be removed and macro will be placed to the cooresponding location according to the legalization result.
Definition at line 374 of file WirelengthOptimizer.h.
Referenced by updateB2BNetWeight(), and WirelengthOptimizer().
|
private |
Definition at line 376 of file WirelengthOptimizer.h.
Referenced by updatePseudoNetForClockRegion(), and WirelengthOptimizer().
|
private |
a common factor indicate the overall strength of the nets in the QP model from external setting
Definition at line 341 of file WirelengthOptimizer.h.
Referenced by updateB2BNetWeight(), and updateB2BNetWeightWorker().
|
private |
Definition at line 342 of file WirelengthOptimizer.h.
Referenced by GlobalPlacementQPSolve(), setGeneralTimingNetWeight(), and updateB2BNetWeight().
|
private |
Definition at line 333 of file WirelengthOptimizer.h.
Referenced by updateB2BNetWeight(), and WirelengthOptimizer().
|
private |
the number of the conducted macro iterations
Definition at line 399 of file WirelengthOptimizer.h.
Referenced by addPseudoNetForMacros(), getMacroPseudoNetEnhanceCnt(), and setMacroLegalizationParameters().
|
private |
indicate whether wirelength optimizer is based on MKL library when using OSQP placer, which can set constraints for the quadratic model
Definition at line 364 of file WirelengthOptimizer.h.
Referenced by reloadPlacementInfo(), and WirelengthOptimizer().
|
private |
Definition at line 401 of file WirelengthOptimizer.h.
Referenced by addPseudoNet_SlackBased(), clearNetPinEnhanceRate(), and reloadPlacementInfo().
|
private |
the net weight for macro legalization
Definition at line 393 of file WirelengthOptimizer.h.
Referenced by addPseudoNetForMacros(), getMacroLegalizationWeight(), and setMacroLegalizationParameters().
|
private |
Definition at line 378 of file WirelengthOptimizer.h.
Referenced by updateB2BNetWeight(), and WirelengthOptimizer().
|
private |
Definition at line 329 of file WirelengthOptimizer.h.
Referenced by addPseudoNet2LoctionForAllPUs(), addPseudoNet_SlackBased(), addPseudoNetForMacros(), LUTLUTPairing_TimingDriven(), reloadPlacementInfo(), solverLoadData(), solverLoadFixedData(), solverWriteBackData(), updateB2BNetWeight(), updateB2BNetWeightWorker(), updatePseudoNetForClockRegion(), updatePseudoNetForUserDefinedClusters(), and WirelengthOptimizer().
|
private |
Definition at line 267 of file WirelengthOptimizer.h.
Referenced by addPseudoNet_SlackBased(), and ~WirelengthOptimizer().
|
private |
Definition at line 343 of file WirelengthOptimizer.h.
Referenced by GlobalPlacementQPSolve(), LUTLUTPairing_TimingDriven(), setSlackPowerFactor(), and updateB2BNetWeight().
|
private |
Definition at line 403 of file WirelengthOptimizer.h.
Referenced by addPseudoNet_SlackBased(), and GlobalPlacementQPSolve().
|
private |
Definition at line 407 of file WirelengthOptimizer.h.
Referenced by addPseudoNet_SlackBased(), LUTLUTPairing_TimingDriven(), and reloadPlacementInfo().
|
private |
Definition at line 406 of file WirelengthOptimizer.h.
Referenced by addPseudoNet_SlackBased(), and reloadPlacementInfo().
|
private |
the fade-out factor for the user-defined clusters
The user-defined clusters might not be perfect so we might need to gradually reduce their terms in the QP problem by this factor
Definition at line 387 of file WirelengthOptimizer.h.
Referenced by updatePseudoNetForUserDefinedClusters().
|
private |
indicate whether wirelength optimizer uses Eigen3, which cannot solve QP problem with constraints. If false, OSQP solver which can set constraints for the quadratic model, will be involved to replace Eigen3.
Definition at line 357 of file WirelengthOptimizer.h.
Referenced by reloadPlacementInfo(), and WirelengthOptimizer().
|
private |
Definition at line 334 of file WirelengthOptimizer.h.
Referenced by GlobalPlacementQPSolve(), reloadPlacementInfo(), updateB2BNetWeight(), and WirelengthOptimizer().
|
private |
Definition at line 331 of file WirelengthOptimizer.h.
Referenced by addPseudoNet2LoctionForAllPUs(), addPseudoNet_SlackBased(), addPseudoNetForMacros(), GlobalPlacementQPSolve(), LUTLUTPairing_TimingDriven(), reloadPlacementInfo(), solverLoadData(), solverLoadFixedData(), solverWriteBackData(), updateB2BNetWeight(), updatePseudoNetForClockRegion(), updatePseudoNetForUserDefinedClusters(), WirelengthOptimizer(), and ~WirelengthOptimizer().
|
private |
a factor to tune the weights of the net spanning in Y-coordinate relative to the net spanning in X-coordinate
Definition at line 350 of file WirelengthOptimizer.h.
Referenced by addPseudoNet2LoctionForAllPUs(), addPseudoNet_SlackBased(), addPseudoNetForMacros(), getCellDistance(), LUTLUTPairing_TimingDriven(), manhattanDis(), updateB2BNetWeight(), updateB2BNetWeightWorker(), updatePseudoNetForClockRegion(), updatePseudoNetForUserDefinedClusters(), and WirelengthOptimizer().
|
private |
Definition at line 332 of file WirelengthOptimizer.h.
Referenced by addPseudoNet2LoctionForAllPUs(), addPseudoNet_SlackBased(), addPseudoNetForMacros(), GlobalPlacementQPSolve(), LUTLUTPairing_TimingDriven(), reloadPlacementInfo(), solverLoadData(), solverLoadFixedData(), solverWriteBackData(), updateB2BNetWeight(), updatePseudoNetForUserDefinedClusters(), WirelengthOptimizer(), and ~WirelengthOptimizer().