AMF-Placer  2.0
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
GlobalPlacer.h
Go to the documentation of this file.
1 
26 #ifndef _GLOBALPLACER
27 #define _GLOBALPLACER
28 
29 #include "CLBLegalizer.h"
30 #include "ClusterPlacer.h"
31 #include "DesignInfo.h"
32 #include "DeviceInfo.h"
33 #include "Eigen/SparseCore"
34 #include "GeneralSpreader.h"
35 #include "MacroLegalizer.h"
36 #include "PlacementInfo.h"
38 #include "WirelengthOptimizer.h"
39 #include "dumpZip.h"
40 //#include "osqp++/osqp++.h"
41 #include <assert.h>
42 #include <fstream>
43 #include <iostream>
44 #include <map>
45 #include <mutex>
46 #include <semaphore.h>
47 #include <set>
48 #include <sstream>
49 #include <string>
50 #include <thread>
51 #include <vector>
52 
60 {
61  public:
69  GlobalPlacer(PlacementInfo *placementInfo, std::map<std::string, std::string> &JSONCfg,
70  bool resetLegalizationInfo = true);
72  {
73  if (clusterPlacer)
74  delete clusterPlacer;
75  if (WLOptimizer)
76  delete WLOptimizer;
77  if (generalSpreader)
78  delete generalSpreader;
79  if (BRAMDSPLegalizer)
80  delete BRAMDSPLegalizer;
82  delete CARRYMacroLegalizer;
83  if (mCLBLegalizer)
84  delete mCLBLegalizer;
85  if (lCLBLegalizer)
86  delete lCLBLegalizer;
87  }
88 
93  void clusterPlacement();
94 
106  void GlobalPlacement_CLBElements(int iterNum, bool continuePreviousIteration = false, int lowerBoundIterNum = 6,
107  bool enableMacroPseudoNet2Site = false, bool stopStrictly = false,
108  unsigned int spreadRegionBinNumLimit = 10000000,
109  PlacementTimingOptimizer *timingOptimizer = nullptr);
110 
118  void GlobalPlacement_fixedCLB(int iterNum, float pseudoNetWeight);
119 
127  inline void setPseudoNetWeight(float weight)
128  {
130  }
131 
139  inline float getPseudoNetWeight()
140  {
141  return oriPseudoNetWeight;
142  }
143 
152  {
154  }
155 
162  {
164  }
165 
172  inline void setMacroLegalizationParameters(int cnt, float macroLegalizationWeight)
173  {
174  WLOptimizer->setMacroLegalizationParameters(cnt, macroLegalizationWeight);
175  }
176 
182  {
183  macroLegalizationFixed = true;
184  }
185 
191  inline void setNeighborDisplacementUpperbound(float _threshold)
192  {
193  neighborDisplacementUpperbound = _threshold;
194  }
195 
205  void spreading(int currentIteration, int spreadRegionSizeLimit = 100000000, float displacementLimit = -10);
206 
208  {
209  assert(WLOptimizer);
210  return WLOptimizer;
211  }
212 
214 
215  private:
217 
218  // settings
219  std::map<std::string, std::string> &JSONCfg;
220  bool verbose = false;
221  bool dumpOptTrace = false;
222  float y2xRatio = 1.0;
223 
231 
240 
246 
253 
259 
265 
271 
277 
283 
290  void updatePseudoNetWeight(float &pseudoNetWeight, int curIter);
291 
298  void macroLegalize(int curIteration, bool timingDriven = false,
299  PlacementTimingOptimizer *timingOptimizer = nullptr);
300 
301  void printPlacedUnits(std::ostream &os);
302  void dumpLUTCoordinate();
303  void dumpDSPCoordinate(bool enforced = false);
304  void dumpBRAMCoordinate(bool enforced = false);
305  void dumpFFCoordinate();
306  void dumpLUTFFCoordinate(bool enforced = false);
307  void dumpAllCellsCoordinate();
308  void dumpCARRYCoordinate();
309  void dumpCoord();
310  inline float random_float(float min, float max)
311  {
312  return ((float)random() / RAND_MAX) * (max - min) + min;
313  }
314 
315  /*
316  * some counters indicating the numbers of the dumped log and naming them accordingly
317  *
318  */
319 
327 
333  float spreadingForgetRatio = 0.2;
334 
339  float progressRatio = 0.0;
340 
346 
352 
358 
363  std::deque<float> historyHPWLs;
364  float minHPWL;
365 
371 
377 
384 
389  bool HPWLChangeLittle = false;
390 
395  bool macrosBindedToSites = false;
396 
401  bool macroCloseToSite = false;
402 
407  bool macroLocked = false;
408 
414 
420  bool directMacroLegalize = false;
421 
422  bool dumpClockUtilization = false;
423 
424  bool DSPCritical = false;
425 
427  std::deque<float> historyAverageDisplacement;
428 
434  float oriPseudoNetWeight = -1.0;
435 
440  float pseudoNetWeight = 1.0;
441 
447 
450  bool timingOptEnabled = false;
451  bool printHPWL = false;
452 };
453 
454 #endif
GlobalPlacer::disableSpreadingForgetRatio
bool disableSpreadingForgetRatio
diable cell spreading forget ratio
Definition: GlobalPlacer.h:239
ClusterPlacer
ClusterPlacer will cluster nodes in the given netlist and place the clusters on the device based on s...
Definition: ClusterPlacer.h:54
GlobalPlacer::averageCarryLegalDisplacement
float averageCarryLegalDisplacement
record the legalization displacement of CARRY
Definition: GlobalPlacer.h:351
GlobalPlacer::getWirelengthOptimizer
WirelengthOptimizer * getWirelengthOptimizer()
Definition: GlobalPlacer.h:207
GlobalPlacer::LUTFFCoordinateDumpCnt
int LUTFFCoordinateDumpCnt
Definition: GlobalPlacer.h:324
paintPlacement.cnt
int cnt
Definition: paintPlacement.py:155
GlobalPlacer::CARRYCoordinateDumpCnt
int CARRYCoordinateDumpCnt
Definition: GlobalPlacer.h:325
GlobalPlacer::printPlacedUnits
void printPlacedUnits(std::ostream &os)
Definition: GlobalPlacer.cc:398
WirelengthOptimizer.h
This header file contains the definitions of GlobalPlacer class and its internal modules and APIs whi...
PlacementTimingOptimizer.h
GlobalPlacer::WLOptimizer
WirelengthOptimizer * WLOptimizer
wirelength optimizer is based on numerial model and used to reduce the overall wirelength with variou...
Definition: GlobalPlacer.h:252
GlobalPlacer::spreading
void spreading(int currentIteration, int spreadRegionSizeLimit=100000000, float displacementLimit=-10)
cell spreading for all types of elements
Definition: GlobalPlacer.cc:618
GlobalPlacer::printHPWL
bool printHPWL
Definition: GlobalPlacer.h:451
GlobalPlacer::macrosBindedToSites
bool macrosBindedToSites
macros are binded to sites and such binding will lead to pseudo nets between anchors and elements
Definition: GlobalPlacer.h:395
exportDeviceLocation.weight
weight
Definition: exportDeviceLocation.py:274
GlobalPlacer::dumpBRAMCoordinate
void dumpBRAMCoordinate(bool enforced=false)
Definition: GlobalPlacer.cc:1100
GlobalPlacer::historyHPWLs
std::deque< float > historyHPWLs
record the change history of HPWL
Definition: GlobalPlacer.h:363
GlobalPlacer::setPseudoNetWeight
void setPseudoNetWeight(float weight)
Set the initial pseudo net weight for the global placer.
Definition: GlobalPlacer.h:127
GlobalPlacer::directMacroLegalize
bool directMacroLegalize
directly legalize macros without the phase of rough legalization (each standard cell in a macro will ...
Definition: GlobalPlacer.h:420
MacroLegalizer
MacroLegalizer maps DSP/BRAM/CARRY macros to legal location.
Definition: MacroLegalizer.h:58
GlobalPlacer::averageMCLBLegalDisplacement
float averageMCLBLegalDisplacement
record the legalization displacement of SLICEM-Macro
Definition: GlobalPlacer.h:357
GlobalPlacer::dumpDSPCoordinate
void dumpDSPCoordinate(bool enforced=false)
Definition: GlobalPlacer.cc:1004
WirelengthOptimizer::getMacroPseudoNetEnhanceCnt
int getMacroPseudoNetEnhanceCnt()
Get the number of the conducted macro iterations.
Definition: WirelengthOptimizer.h:166
GlobalPlacer::clusterPlacer
ClusterPlacer * clusterPlacer
cluster placer is used for initial placement
Definition: GlobalPlacer.h:245
GlobalPlacer::spreadingForgetRatio
float spreadingForgetRatio
we use the forget ratio to control the sensitivity of cell spreading during the location updateing (n...
Definition: GlobalPlacer.h:333
WirelengthOptimizer::setMacroLegalizationParameters
void setMacroLegalizationParameters(int cnt, float macroLegalizationWeight)
Set the macro legalization parameters.
Definition: WirelengthOptimizer.h:155
GlobalPlacer::updateMinHPWLAfterLegalization
bool updateMinHPWLAfterLegalization
when legalization is started, the HPWL might have a significant change due to the legalization displa...
Definition: GlobalPlacer.h:383
GlobalPlacer::y2xRatio
float y2xRatio
Definition: GlobalPlacer.h:222
GlobalPlacer::macroLocked
bool macroLocked
lock the macro binding and bypass serveral legalizaiton iterations for wirelength stable convergence
Definition: GlobalPlacer.h:407
GlobalPlacer::BRAMDSPLegalizer
MacroLegalizer * BRAMDSPLegalizer
legalize multi-site BRAM/DSP elements
Definition: GlobalPlacer.h:264
GlobalPlacer::oriPseudoNetWeight
float oriPseudoNetWeight
record the pseudo net weight at the end of placement functions for later iterations....
Definition: GlobalPlacer.h:434
GlobalPlacer::enableClockRegionAware
bool enableClockRegionAware
Definition: GlobalPlacer.h:449
GlobalPlacer::HPWLChangeLittle
bool HPWLChangeLittle
the small change of minHPWL might imply that the optimization converges.
Definition: GlobalPlacer.h:389
PlacementTimingOptimizer
Definition: PlacementTimingOptimizer.h:46
DesignInfo.h
This header file contains the classes of data for a standalone design netlist.
GlobalPlacer::upperBoundHPWL
float upperBoundHPWL
upperbound HPWL is obtained just after cell spreading and legalization
Definition: GlobalPlacer.h:370
GlobalPlacer::dumpCARRYCoordinate
void dumpCARRYCoordinate()
Definition: GlobalPlacer.cc:768
GlobalPlacer::LUTCoordinateDumpCnt
int LUTCoordinateDumpCnt
Definition: GlobalPlacer.h:320
GlobalPlacer::updatePseudoNetWeight
void updatePseudoNetWeight(float &pseudoNetWeight, int curIter)
update pseudo net weight according to placement progress
Definition: GlobalPlacer.cc:668
dumpZip.h
DeviceInfo.h
This header file contains the classes of data for a standalone device.
GlobalPlacer::dumpLUTFFCoordinate
void dumpLUTFFCoordinate(bool enforced=false)
Definition: GlobalPlacer.cc:906
GlobalPlacer::averageMacroLegalDisplacement
float averageMacroLegalDisplacement
record the legalization displacement of DSP/BRAM
Definition: GlobalPlacer.h:345
GlobalPlacer::setNeighborDisplacementUpperbound
void setNeighborDisplacementUpperbound(float _threshold)
Set the distance upperbound of neighbor LUT/FF-like elements for area adjustion.
Definition: GlobalPlacer.h:191
GlobalPlacer::timingOptEnabled
bool timingOptEnabled
Definition: GlobalPlacer.h:450
GlobalPlacer::dumpOptTrace
bool dumpOptTrace
Definition: GlobalPlacer.h:221
GlobalPlacer::allCoordinateDumpCnt
int allCoordinateDumpCnt
Definition: GlobalPlacer.h:326
GlobalPlacer::~GlobalPlacer
~GlobalPlacer()
Definition: GlobalPlacer.h:71
GlobalPlacer::pseudoNetWeight
float pseudoNetWeight
the pseudo net weight in the iterations of placement functions
Definition: GlobalPlacer.h:440
GlobalPlacer::getMacroPseudoNetEnhanceCnt
int getMacroPseudoNetEnhanceCnt()
Get the number of macro pseudo net enhancements.
Definition: GlobalPlacer.h:151
GlobalPlacer::verbose
bool verbose
Definition: GlobalPlacer.h:220
CLBLegalizer.h
This header file contains the definitions of CLBLegalizer class and its internal modules and APIs whi...
GlobalPlacer::dumpFFCoordinate
void dumpFFCoordinate()
Definition: GlobalPlacer.cc:816
GeneralSpreader
GeneralSpreader accounts for the cell spreading, which controls the cell density of specific resource...
Definition: GeneralSpreader.h:50
GlobalPlacer::macroLegalizationFixed
bool macroLegalizationFixed
fix the macros to the exact legal location
Definition: GlobalPlacer.h:413
ClusterPlacer.h
This header file contains the definitions of ClusterPlacer class and its internal modules and APIs wh...
GlobalPlacer::DSPCritical
bool DSPCritical
Definition: GlobalPlacer.h:424
GlobalPlacer::BRAMCoordinateDumpCnt
int BRAMCoordinateDumpCnt
Definition: GlobalPlacer.h:322
GlobalPlacer::macroLegalize
void macroLegalize(int curIteration, bool timingDriven=false, PlacementTimingOptimizer *timingOptimizer=nullptr)
legalize specific types of macro to the target regions
Definition: GlobalPlacer.cc:458
MacroLegalizer.h
This header file contains the definitions of MacroLegalizer class and its internal modules and APIs w...
GlobalPlacer::timingDrivenDetailedPlacement_shortestPath_intermediate
int timingDrivenDetailedPlacement_shortestPath_intermediate(PlacementTimingOptimizer *timingOptimizer)
Definition: GlobalPlacer.cc:1196
GlobalPlacer::GlobalPlacement_CLBElements
void GlobalPlacement_CLBElements(int iterNum, bool continuePreviousIteration=false, int lowerBoundIterNum=6, bool enableMacroPseudoNet2Site=false, bool stopStrictly=false, unsigned int spreadRegionBinNumLimit=10000000, PlacementTimingOptimizer *timingOptimizer=nullptr)
wirelength optimization + cell spreading + legalization + area adjustion
Definition: GlobalPlacer.cc:128
GlobalPlacer::GlobalPlacement_fixedCLB
void GlobalPlacement_fixedCLB(int iterNum, float pseudoNetWeight)
fix the locations of CLB and let macros move without low pseudo net at initial stages,...
Definition: GlobalPlacer.cc:334
GeneralSpreader.h
This header file contains the definitions of GeneralSpreader class and its internal modules and APIs ...
GlobalPlacer::pseudoNetWeightConsiderNetNum
bool pseudoNetWeightConsiderNetNum
set adaptive pseudo net weight according to net density
Definition: GlobalPlacer.h:230
GlobalPlacer::JSONCfg
std::map< std::string, std::string > & JSONCfg
Definition: GlobalPlacer.h:219
GlobalPlacer::dumpLUTCoordinate
void dumpLUTCoordinate()
Definition: GlobalPlacer.cc:410
GlobalPlacer::lowerBoundHPWL
float lowerBoundHPWL
lowerbound HPWL is obtained just after wirelength optimization
Definition: GlobalPlacer.h:376
GlobalPlacer::hasUserDefinedClusterInfo
bool hasUserDefinedClusterInfo
Definition: GlobalPlacer.h:448
GlobalPlacer::dumpAllCellsCoordinate
void dumpAllCellsCoordinate()
Definition: GlobalPlacer.cc:864
GlobalPlacer
GlobalPlacer accounts for the general iterations in global placement.
Definition: GlobalPlacer.h:60
GlobalPlacer::macroLockedIterCnt
int macroLockedIterCnt
Definition: GlobalPlacer.h:426
GlobalPlacer::clusterPlacement
void clusterPlacement()
cluster elements and conduct initial placement at coarse-grained level
Definition: GlobalPlacer.cc:122
GlobalPlacer::minHPWL
float minHPWL
Definition: GlobalPlacer.h:364
GlobalPlacer::mCLBLegalizer
CLBLegalizer * mCLBLegalizer
legalize single-site SLICEM-CLB elements
Definition: GlobalPlacer.h:276
GlobalPlacer::setMacroLegalizationParameters
void setMacroLegalizationParameters(int cnt, float macroLegalizationWeight)
Set the macro legalization parameters (including legalization counter and pseudo net weight)
Definition: GlobalPlacer.h:172
GlobalPlacer::CARRYMacroLegalizer
MacroLegalizer * CARRYMacroLegalizer
legalize multi-site CARRY elements
Definition: GlobalPlacer.h:270
GlobalPlacer::setMacroLegalizationFixed
void setMacroLegalizationFixed()
fix the macro legalization result
Definition: GlobalPlacer.h:181
GlobalPlacer::FFCoordinateDumpCnt
int FFCoordinateDumpCnt
Definition: GlobalPlacer.h:323
GlobalPlacer::macroCloseToSite
bool macroCloseToSite
macros are located closely to their legalized locations
Definition: GlobalPlacer.h:401
WirelengthOptimizer::getMacroLegalizationWeight
float getMacroLegalizationWeight()
Get the net weight for macro legalization.
Definition: WirelengthOptimizer.h:176
GlobalPlacer::generalSpreader
GeneralSpreader * generalSpreader
a general spreading will spread cells to meet cell density requirements
Definition: GlobalPlacer.h:258
GlobalPlacer::lCLBLegalizer
CLBLegalizer * lCLBLegalizer
legalize single-site SLICEL-CLB elements
Definition: GlobalPlacer.h:282
GlobalPlacer::getPseudoNetWeight
float getPseudoNetWeight()
Get the current pseudo net weight.
Definition: GlobalPlacer.h:139
GlobalPlacer::neighborDisplacementUpperbound
float neighborDisplacementUpperbound
the distance threshold for the neighbor detection during area adjustion
Definition: GlobalPlacer.h:446
GlobalPlacer::getMacroLegalizationWeight
float getMacroLegalizationWeight()
Get the current macro legalization weight object.
Definition: GlobalPlacer.h:161
PlacementInfo.h
This header file mainly contains the definition of class PlacementInfo, including information related...
GlobalPlacer::DSPCoordinateDumpCnt
int DSPCoordinateDumpCnt
Definition: GlobalPlacer.h:321
GlobalPlacer::random_float
float random_float(float min, float max)
Definition: GlobalPlacer.h:310
GlobalPlacer::dumpClockUtilization
bool dumpClockUtilization
Definition: GlobalPlacer.h:422
GlobalPlacer::historyAverageDisplacement
std::deque< float > historyAverageDisplacement
Definition: GlobalPlacer.h:427
GlobalPlacer::progressRatio
float progressRatio
the similarity between upperbound wirelength and lowerbound wirelength
Definition: GlobalPlacer.h:339
CLBLegalizer
CLBLegalizer maps CLBs (each of which consists of one site) to legal location. e.g....
Definition: CLBLegalizer.h:62
WirelengthOptimizer
WirelengthOptimizer builds numerical models based on the element locations and calls solvers to find ...
Definition: WirelengthOptimizer.h:54
GlobalPlacer::GlobalPlacer
GlobalPlacer(PlacementInfo *placementInfo, std::map< std::string, std::string > &JSONCfg, bool resetLegalizationInfo=true)
Construct a new Global Placer object based on placement information.
Definition: GlobalPlacer.cc:31
GlobalPlacer::dumpCoord
void dumpCoord()
Definition: GlobalPlacer.cc:388
PlacementInfo
Information related to FPGA placement (wirelength optimization, cell spreading, legalization,...
Definition: PlacementInfo.h:59
GlobalPlacer::placementInfo
PlacementInfo * placementInfo
Definition: GlobalPlacer.h:216