AMF-Placer  2.0
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
WirelengthOptimizer Class Reference

WirelengthOptimizer builds numerical models based on the element locations and calls solvers to find an optimal solution of the placement. More...

#include <WirelengthOptimizer.h>

Collaboration diagram for WirelengthOptimizer:

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
 
PlacementInfoplacementInfo
 
QPSolverWrapperxSolver = nullptr
 
QPSolverWrapperySolver = 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
 

Detailed Description

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.

Member Typedef Documentation

◆ CellWithScore

◆ PUWithScore

◆ slackEnhanceTuple

Constructor & Destructor Documentation

◆ WirelengthOptimizer()

WirelengthOptimizer::WirelengthOptimizer ( PlacementInfo placementInfo,
std::map< std::string, std::string > &  JSONCfg,
bool  verbose = true 
)

Construct a new Wirelength Optimizer object.

Parameters
placementInfothe PlacementInfo for this placer to handle
JSONCfgthe user-defined placement configuration
verbosewhether the WirelengthOptimizer prints out more information or dumps log files

Definition at line 31 of file WirelengthOptimizer.cc.

Here is the call graph for this function:

◆ ~WirelengthOptimizer()

WirelengthOptimizer::~WirelengthOptimizer ( )
inline

Definition at line 64 of file WirelengthOptimizer.h.

Member Function Documentation

◆ addPseudoNet2LoctionForAllPUs()

void WirelengthOptimizer::addPseudoNet2LoctionForAllPUs ( float  pesudoNetWeight,
bool  considerNetNum 
)
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.

Parameters
pesudoNetWeightthe common weight factor for pseudo nets
considerNetNumwhether add the interconnection-density-aware factor to pseudo net weights

Definition at line 821 of file WirelengthOptimizer.cc.

Referenced by updateB2BNetWeight().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addPseudoNet_SlackBased()

void WirelengthOptimizer::addPseudoNet_SlackBased ( float  timingWeight,
double  slackPowFactor,
PlacementTimingOptimizer timingOptimizer,
bool  calculate = false 
)
private

add pseudo net for timing optimization based on the timing slack of each elements in the design netlist

Parameters
timingWeightthe common weight factor for pseudo nets for timing
slackPowFactora factor for the sensitivity of negative timing slack
timingOptimizerthe handler of timing-related analysis

Definition at line 434 of file WirelengthOptimizer.cc.

Referenced by GlobalPlacementQPSolve(), and updateB2BNetWeight().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addPseudoNetForMacros()

void WirelengthOptimizer::addPseudoNetForMacros ( float  pesudoNetWeight,
bool  considerNetNum 
)
private

add the legalization pseudo nets to force macros move to the legal sites

Parameters
pesudoNetWeightthe common weight factor for pseudo nets
considerNetNumwhether add the interconnection-density-aware factor to pseudo net weights

Definition at line 356 of file WirelengthOptimizer.cc.

Referenced by updateB2BNetWeight().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clearNetPinEnhanceRate()

void WirelengthOptimizer::clearNetPinEnhanceRate ( )
inline

Definition at line 181 of file WirelengthOptimizer.h.

◆ getCellDistance()

float WirelengthOptimizer::getCellDistance ( PlacementInfo::Location A,
PlacementInfo::Location B 
)
inlineprivate

Definition at line 305 of file WirelengthOptimizer.h.

Referenced by LUTLUTPairing_TimingDriven().

Here is the caller graph for this function:

◆ getMacroLegalizationWeight()

float WirelengthOptimizer::getMacroLegalizationWeight ( )
inline

Get the net weight for macro legalization.

Returns
float

Definition at line 176 of file WirelengthOptimizer.h.

Referenced by GlobalPlacer::getMacroLegalizationWeight(), and GlobalPlacer::GlobalPlacement_CLBElements().

Here is the caller graph for this function:

◆ getMacroPseudoNetEnhanceCnt()

int WirelengthOptimizer::getMacroPseudoNetEnhanceCnt ( )
inline

Get the number of the conducted macro iterations.

Returns
int

Definition at line 166 of file WirelengthOptimizer.h.

Referenced by GlobalPlacer::getMacroPseudoNetEnhanceCnt(), and GlobalPlacer::GlobalPlacement_CLBElements().

Here is the caller graph for this function:

◆ GlobalPlacementQPSolve()

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

Parameters
pesudoNetWeightthe common weight factor for pseudo nets
firstIterationindicates whether this is the first iteration of current round of WL optimization to control the data loading
forwardSolutionToNextIterationif this round of WL optimization includes multiple iterations, do we forward the location data obtained in last iteration for later processing?
enableMacroPseudoNet2Siteenable the legalization pseudo net to force macros move to the legal site
considerNetNumwhether add the interconnection-density-aware factor to pseudo net weights
enableUserDefinedClusterOptwhether check user-defined cluster information to add pseudo nets
timingOptwhether 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LUTLUTPairing_TimingDriven()

void WirelengthOptimizer::LUTLUTPairing_TimingDriven ( float  timingWeight,
float  disThreshold,
PlacementTimingOptimizer timingOptimizer 
)
private

Definition at line 666 of file WirelengthOptimizer.cc.

Referenced by updateB2BNetWeight().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ manhattanDis()

double WirelengthOptimizer::manhattanDis ( double  x0,
double  y0,
double  x1,
double  y1 
)
inlineprivate

evaluate the Mahattan distance between two locations

Parameters
x0
y0
x1
y1
Returns
double

Definition at line 301 of file WirelengthOptimizer.h.

◆ QPSolve()

static void WirelengthOptimizer::QPSolve ( QPSolverWrapper *&  curSolver)
staticprivate

call the cooresponding solver to solve the QP problem defined in the given QPSolverWrapper

Parameters
curSolvera given QPSolverWrapper

◆ reloadPlacementInfo()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setGeneralTimingNetWeight()

void WirelengthOptimizer::setGeneralTimingNetWeight ( float  _generalTimingNetWeight)
inline

Definition at line 186 of file WirelengthOptimizer.h.

◆ setMacroLegalizationParameters()

void WirelengthOptimizer::setMacroLegalizationParameters ( int  cnt,
float  macroLegalizationWeight 
)
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.

Parameters
cntthe number of the conducted macro iterations
macroLegalizationWeightthe net weight for macro legalization

Definition at line 155 of file WirelengthOptimizer.h.

Referenced by GlobalPlacer::setMacroLegalizationParameters().

Here is the caller graph for this function:

◆ setSlackPowerFactor()

void WirelengthOptimizer::setSlackPowerFactor ( double  _slackPowerFactor)
inline

Definition at line 191 of file WirelengthOptimizer.h.

◆ solverLoadData()

void WirelengthOptimizer::solverLoadData ( )
private

load to placement location from PlacementInfo to the solver

Definition at line 142 of file WirelengthOptimizer.cc.

Referenced by GlobalPlacementQPSolve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ solverLoadFixedData()

void WirelengthOptimizer::solverLoadFixedData ( )
private

load to placement location of fixed PlacementUnits from PlacementInfo to the solver

Definition at line 152 of file WirelengthOptimizer.cc.

Here is the call graph for this function:

◆ solverWriteBackData()

void WirelengthOptimizer::solverWriteBackData ( float  displacementLimit)
private

write placement location from the solver to the PlacementInfo

Definition at line 181 of file WirelengthOptimizer.cc.

Referenced by GlobalPlacementQPSolve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateB2BNetWeight()

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.

Parameters
pesudoNetWeightthe common weight factor for pseudo nets
enableMacroPseudoNet2Siteenable the legalization pseudo net to force macros move to the legal site
considerNetNumwhether add the interconnection-density-aware factor to pseudo net weights
enableUserDefinedClusterOptwhether check user-defined cluster information to add pseudo nets
timingOptwhether turn on the timing-oriented optimizations

Definition at line 268 of file WirelengthOptimizer.cc.

Referenced by GlobalPlacementQPSolve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateB2BNetWeightWorker()

void WirelengthOptimizer::updateB2BNetWeightWorker ( PlacementInfo placementInfo,
std::vector< Eigen::Triplet< float >> &  objectiveMatrixTripletList,
std::vector< float > &  objectiveMatrixDiag,
Eigen::VectorXd &  objectiveVector,
float  generalNetWeight,
float  y2xRatio,
bool  updateX,
bool  updateY 
)
static

a worker funtion for multi-threading net weight updating

min_x 0.5 * x'Px + q'x s.t. l <= Ax <= u

Parameters
placementInfothe PlacementInfo for this placer to handle
objectiveMatrixTripletLista list of Eigen::Triplet used to describe the sparse matrix P of QP model
objectiveMatrixDiaga vector used to store the diagonal values in the sparse matrix P of QP model
objectiveVectora vector (i.e., Eigen::VectorXd) used to store the linear factors q' of QP model
generalNetWeighta common factor indicate the overall strength of the nets in the QP model from external setting
y2xRatioa factor to tune the weights of the net spanning in Y-coordinate relative to the net spanning in X-coordinate
updateXupdate the X-coordinate term in the quadratic problem
updateYupdate the X-coordinate term in the quadratic problem

Definition at line 334 of file WirelengthOptimizer.cc.

Referenced by updateB2BNetWeight().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updatePseudoNetForClockRegion()

void WirelengthOptimizer::updatePseudoNetForClockRegion ( float  pesudoNetWeight)
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.

Parameters
pesudoNetWeightthe common weight factor for pseudo nets

Definition at line 1043 of file WirelengthOptimizer.cc.

Referenced by updateB2BNetWeight().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updatePseudoNetForUserDefinedClusters()

void WirelengthOptimizer::updatePseudoNetForUserDefinedClusters ( float  pesudoNetWeight)
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

Parameters
pesudoNetWeightthe common weight factor for pseudo nets

Definition at line 955 of file WirelengthOptimizer.cc.

Referenced by updateB2BNetWeight().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ directMacroLegalize

bool WirelengthOptimizer::directMacroLegalize = false
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().

◆ DSPCritical

bool WirelengthOptimizer::DSPCritical = false
private

Definition at line 376 of file WirelengthOptimizer.h.

Referenced by updatePseudoNetForClockRegion(), and WirelengthOptimizer().

◆ generalNetWeight

float WirelengthOptimizer::generalNetWeight = 1.0
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().

◆ generalTimingNetWeight

float WirelengthOptimizer::generalTimingNetWeight = 1.0
private

◆ JSONCfg

std::map<std::string, std::string>& WirelengthOptimizer::JSONCfg
private

Definition at line 333 of file WirelengthOptimizer.h.

Referenced by updateB2BNetWeight(), and WirelengthOptimizer().

◆ macroPseudoNetCnt

int WirelengthOptimizer::macroPseudoNetCnt = 0
private

the number of the conducted macro iterations

Definition at line 399 of file WirelengthOptimizer.h.

Referenced by addPseudoNetForMacros(), getMacroPseudoNetEnhanceCnt(), and setMacroLegalizationParameters().

◆ MKLorNot

bool WirelengthOptimizer::MKLorNot = false
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().

◆ netPinEnhanceRate

std::map<DesignInfo::DesignNet *, std::vector<float> > WirelengthOptimizer::netPinEnhanceRate
private

◆ oriMacroLegalizationWeight

float WirelengthOptimizer::oriMacroLegalizationWeight = 1.0
private

the net weight for macro legalization

Definition at line 393 of file WirelengthOptimizer.h.

Referenced by addPseudoNetForMacros(), getMacroLegalizationWeight(), and setMacroLegalizationParameters().

◆ pin2pinEnhance

float WirelengthOptimizer::pin2pinEnhance = 5.0
private

Definition at line 378 of file WirelengthOptimizer.h.

Referenced by updateB2BNetWeight(), and WirelengthOptimizer().

◆ placementInfo

◆ PNetId2SlackEnhanceTuples

std::vector<std::vector<slackEnhanceTuple> *> WirelengthOptimizer::PNetId2SlackEnhanceTuples
private

Definition at line 267 of file WirelengthOptimizer.h.

Referenced by addPseudoNet_SlackBased(), and ~WirelengthOptimizer().

◆ slackPowerFactor

double WirelengthOptimizer::slackPowerFactor = 1.1
private

◆ slackThr

float WirelengthOptimizer::slackThr = 0
private

Definition at line 403 of file WirelengthOptimizer.h.

Referenced by addPseudoNet_SlackBased(), and GlobalPlacementQPSolve().

◆ targetCellId

int WirelengthOptimizer::targetCellId = -1
private

◆ targetCellName

std::string WirelengthOptimizer::targetCellName = "design_1_i/DigitRec_0/inst/ap_phi_reg_pp2_iter31_knn_set_392_1_reg_27413_reg[20]"
private

Definition at line 406 of file WirelengthOptimizer.h.

Referenced by addPseudoNet_SlackBased(), and reloadPlacementInfo().

◆ userDefinedClusterFadeOutFactor

float WirelengthOptimizer::userDefinedClusterFadeOutFactor = 1.0
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().

◆ useUnconstrainedCG

bool WirelengthOptimizer::useUnconstrainedCG = true
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().

◆ verbose

bool WirelengthOptimizer::verbose
private

◆ xSolver

◆ y2xRatio

float WirelengthOptimizer::y2xRatio = 1.0
private

◆ ySolver


The documentation for this class was generated from the following files: