AMF-Placer  2.0
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
CLBLegalizer.h
Go to the documentation of this file.
1 
26 #ifndef _CLBLEGALIZER
27 #define _CLBLEGALIZER
28 
29 #include "DesignInfo.h"
30 #include "DeviceInfo.h"
32 #include "PlacementInfo.h"
33 #include "dumpZip.h"
34 #include "sysInfo.h"
35 #include <assert.h>
36 #include <fstream>
37 #include <iostream>
38 #include <map>
39 #include <mutex>
40 #include <omp.h>
41 #include <semaphore.h>
42 #include <set>
43 #include <sstream>
44 #include <string>
45 #include <thread>
46 #include <vector>
47 
62 {
63  public:
74  std::vector<std::string> &siteTypesToLegalize, std::map<std::string, std::string> &JSONCfg);
76  {
79  }
80 
86  void legalize(bool exactLegalization = false);
87 
96  {
97  if (finalAverageDisplacement > 1000)
99  float tmpAverageDisplacement = 0.0;
100  for (auto PUSitePair : PULevelMatching)
101  {
102  tmpAverageDisplacement += std::fabs(PUSitePair.first->X() - PUSitePair.second->X()) +
103  std::fabs(PUSitePair.first->Y() - PUSitePair.second->Y());
104  }
105  tmpAverageDisplacement /= PULevelMatching.size();
106 
107  return tmpAverageDisplacement;
108  }
109 
118  {
120  }
121 
129  void setIntitialParameters(float displacementThr, int candidateNum, int _candidateFactor = -1)
130  {
131  initialDisplacementThreshold = displacementThr;
132  initialMaxNumCandidate = candidateNum;
133  if (_candidateFactor > 1)
134  {
135  candidateFactor = _candidateFactor;
136  }
137  }
138 
145  void resetSitesMapped();
146  void dumpMatching(bool fixedColumn = false, bool enforce = false);
147 
148  inline bool hasNoTarget()
149  {
150  return noTarget;
151  }
152 
153  private:
154  std::string legalizerName;
157 
164 
169  std::vector<std::string> siteTypesToLegalize;
170 
175  std::vector<PlacementInfo::Location> &cellLoc;
176 
177  std::map<std::string, std::string> &JSONCfg;
178 
184 
189  std::vector<PlacementInfo::PlacementUnit *> PUsToLegalize;
190 
195  std::vector<PlacementInfo::PlacementUnit *> initialPUsToLegalize;
196 
201  std::set<PlacementInfo::PlacementUnit *> PUsToLegalizeSet;
202 
207  std::map<std::string, std::vector<DeviceInfo::DeviceSite *>> siteType2Sites;
208 
215  std::map<PlacementInfo::PlacementUnit *, std::vector<DeviceInfo::DeviceSite *>> PU2Sites;
216 
221  std::map<DeviceInfo::DeviceSite *, int> rightSiteIds;
222 
227  std::vector<DeviceInfo::DeviceSite *> siteList;
228 
233  std::vector<std::vector<std::pair<int, float>>> adjList;
234 
239  std::map<PlacementInfo::PlacementUnit *, std::map<DeviceInfo::DeviceSite *, float>> PU2Site2HPWLIncrease;
240 
245  std::set<PlacementInfo::PlacementUnit *> matchedPUs;
246 
251  std::set<DeviceInfo::DeviceSite *> matchedSites;
252 
257  std::vector<std::pair<PlacementInfo::PlacementUnit *, DeviceInfo::DeviceSite *>> PULevelMatching;
258 
260 
266 
271  int maxNumCandidate = 20;
272 
279 
284  int nJobs = 1;
285 
290  int MCLBColumnNum = -1;
291 
296  int LCLBColumnNum = -1;
297 
302  int MCLBRowNum = -1;
303 
308  int LCLBRowNum = -1;
309 
314  std::vector<float> MCLBColumnXs;
315 
320  std::vector<float> LCLBColumnXs;
321 
326  std::vector<std::vector<DeviceInfo::DeviceSite *>> MCLBColumn2Sites;
327 
332  std::vector<std::vector<DeviceInfo::DeviceSite *>> LCLBColumn2Sites;
333 
338  std::vector<std::deque<PlacementInfo::PlacementUnit *>> MCLBColumn2PUs;
339 
344  std::vector<std::deque<PlacementInfo::PlacementUnit *>> LCLBColumn2PUs;
345 
350  std::vector<int> MCLBColumnUntilization;
351 
356  std::vector<int> LCLBColumnUntilization;
357 
362  std::map<PlacementInfo::PlacementUnit *, int> MCLB2Column;
363 
368  std::map<PlacementInfo::PlacementUnit *, int> LCLB2Column;
369 
374  std::map<PlacementInfo::PlacementUnit *, std::vector<DeviceInfo::DeviceSite *>> PU2LegalSites;
375 
380  std::map<PlacementInfo::PlacementUnit *, float> PU2X;
385  std::map<PlacementInfo::PlacementUnit *, float> PU2Y;
386 
393  std::map<PlacementInfo::PlacementUnit *, int> PU2SiteX;
394 
402  std::map<PlacementInfo::PlacementUnit *, std::vector<int>> PU2Columns;
403 
408  std::set<PlacementInfo::PlacementUnit *> MCLBPUs;
409 
414  std::set<PlacementInfo::PlacementUnit *> LCLBPUs;
415 
420  std::map<PlacementInfo::PlacementUnit *, std::vector<DeviceInfo::DeviceSite *> *> PU2SitesInDisplacementThreshold;
421 
424  bool verbose = false;
425  float y2xRatio = 1.0;
426 
431  float finalAverageDisplacement = 10000.0;
432 
441 
446  float roughAverageDisplacement = 10000.0;
447 
448  bool noTarget = false;
449 
455 
461 
466  void getPUsToLegalize();
467 
473 
478  void resolveOverflowColumns();
479 
485  void findPossibleLegalLocation(bool fixedColumn = false);
486 
491  void mapPUsToColumns();
492 
497  void createBipartiteGraph();
498 
507  void roughlyLegalize();
508 
514  void fixedColumnLegalize();
515 
525  void updatePUMatchingLocation(bool isRoughLegalization = true, bool updateDisplacement = true);
526 
533  void finalLegalizeBasedOnDP();
534 
543  float DPForMinHPWL(int colNum, std::vector<std::vector<DeviceInfo::DeviceSite *>> &Column2Sites,
544  std::vector<std::deque<PlacementInfo::PlacementUnit *>> &Column2PUs);
545 
552 
562  void spreadPUs(int columnNum, std::vector<int> &columnUntilization,
563  std::vector<std::vector<DeviceInfo::DeviceSite *>> &column2Sites,
564  std::vector<std::deque<PlacementInfo::PlacementUnit *>> &column2PUs,
565  std::map<PlacementInfo::PlacementUnit *, int> &cell2Column);
566 
575  int findIdMaxWithRecurence(int minId, int maxId, std::vector<int> &ids);
576 
581  void setSitesMapped();
582 
587  inline void resetSettings()
588  {
591  matchedPUs.clear();
592  matchedSites.clear();
593  PULevelMatching.clear();
594  }
595 
601  {
603 
604  int PUsNum = PUsToLegalize.size();
605 
606  for (int i = 0; i < PUsNum; i++)
607  {
609  }
610 
611 #pragma omp parallel for
612  for (int i = 0; i < PUsNum; i++)
613  {
615  DesignInfo::DesignCell *curCell = nullptr;
616  if (auto unpackedCell = dynamic_cast<PlacementInfo::PlacementUnpackedCell *>(curPU))
617  {
618  curCell = unpackedCell->getCell();
619  }
620  else if (auto curMacro = dynamic_cast<PlacementInfo::PlacementMacro *>(curPU))
621  {
622  assert(curMacro->getCells().size() > 0);
623  curCell = curMacro->getCells()[0];
624  }
625  assert(curCell);
627  curCell, cellLoc[curCell->getCellId()].X, cellLoc[curCell->getCellId()].Y, displacementThreshold,
629  }
630  }
631 
637  {
638  int PUsNum = PUsToLegalize.size();
639  for (int i = 0; i < PUsNum; i++)
640  {
642  delete PU2SitesInDisplacementThreshold[curPU];
643  }
644  }
645 
653 
655  {
657  *A = *B;
658  *B = C;
659  }
660 
661  void sortPUsByPU2Y(std::deque<PlacementInfo::PlacementUnit *> &PUs);
662 
663  void sortSitesBySiteY(std::vector<DeviceInfo::DeviceSite *> &sites);
664 
666  {
667  return std::fabs(PULoc.X - curSite->X()) + y2xRatio * std::fabs(PULoc.Y - curSite->Y());
668  }
669 
671  {
672  return std::fabs(curPU->X() - curSite->X()) + y2xRatio * std::fabs(curPU->Y() - curSite->Y());
673  }
674 
683  {
684  assert(PU2Site2HPWLIncrease.find(curPU) != PU2Site2HPWLIncrease.end());
685  if (PU2Site2HPWLIncrease[curPU].find(curSite) != PU2Site2HPWLIncrease[curPU].end())
686  {
687  return PU2Site2HPWLIncrease[curPU][curSite];
688  }
689  float oriHPWL = 0.0;
690  float newHPWL = 0.0;
691  float PUX = curSite->X();
692  float PUY = curSite->Y();
693  auto nets = placementInfo->getPlacementUnitId2Nets()[curPU->getId()];
694 
695  for (auto curNet : nets)
696  {
697  if (curNet->getDesignNet()->getPins().size() > 10000) // it could be clock
698  continue;
699  oriHPWL += curNet->getHPWL(y2xRatio);
700  newHPWL += curNet->getNewHPWLByTrying(curPU, PUX, PUY, y2xRatio);
701  }
702 
703  PU2Site2HPWLIncrease[curPU][curSite] = (newHPWL - oriHPWL);
704  return (newHPWL - oriHPWL);
705  }
706 
715  inline float getHPWLChange(PlacementInfo::PlacementUnit *tmpPU, float PUX, float PUY)
716  {
717 
718  float oriHPWL = 0.0;
719  float newHPWL = 0.0;
720  auto nets = placementInfo->getPlacementUnitId2Nets()[tmpPU->getId()];
721 
722  for (auto curNet : nets)
723  {
724  if (curNet->getDesignNet()->getPins().size() > 10000) // it could be clock
725  continue;
726  oriHPWL += curNet->getHPWL(y2xRatio);
727  newHPWL += curNet->getNewHPWLByTrying(tmpPU, PUX, PUY, y2xRatio);
728  }
729 
730  return (newHPWL - oriHPWL);
731  }
732 
734  {
735  DeviceInfo::DeviceSite *tmp = *siteA;
736  *siteA = *siteB;
737  *siteB = tmp;
738  }
739 
740  inline int sortPartition(PlacementInfo::PlacementUnit *curPU, std::vector<DeviceInfo::DeviceSite *> &sites, int low,
741  int high)
742  {
743  int pivot, index, i;
744  index = low;
745  pivot = high;
746  for (i = low; i < high; i++)
747  {
748  // finding index of pivot.
749  // if (a[i] < a[pivot])
750  // if (getDisplacement(PULoc, sites[i]) < getDisplacement(PULoc, sites[pivot]))
751  if (getHPWLChange(curPU, sites[i]) < getHPWLChange(curPU, sites[pivot]))
752  {
753  swapSitePtr(&sites[i], &sites[index]);
754  index++;
755  }
756  }
757  swapSitePtr(&sites[pivot], &sites[index]);
758  return index;
759  }
760  inline int RandomPivotPartition(PlacementInfo::PlacementUnit *curPU, std::vector<DeviceInfo::DeviceSite *> &sites,
761  int low, int high)
762  {
763  // Random selection of pivot.
764  int pvt;
765  pvt = (high + low) / 2; // Randomizing the pivot value from sub-array.
766  swapSitePtr(&sites[high], &sites[pvt]);
767  return sortPartition(curPU, sites, low, high);
768  }
769  void quick_sort_WLChange(PlacementInfo::PlacementUnit *curPU, std::vector<DeviceInfo::DeviceSite *> &sites, int p,
770  int q)
771  {
772  // recursively sort the list
773  int pindex;
774  if (p < q)
775  {
776  pindex = RandomPivotPartition(curPU, sites, p, q); // randomly choose pivot
777  // Recursively implementing QuickSort.
778  quick_sort_WLChange(curPU, sites, p, pindex - 1);
779  quick_sort_WLChange(curPU, sites, pindex + 1, q);
780  }
781  }
782 
784  {
785  PlacementInfo::PlacementUnit *tmp = *siteA;
786  *siteA = *siteB;
787  *siteB = tmp;
788  }
789 
790  inline int sortPartition(std::vector<PlacementInfo::PlacementUnit *> &PUs, int low, int high)
791  {
792  int pivot, index, i;
793  index = low;
794  pivot = high;
795  for (i = low; i < high; i++)
796  {
797  // finding index of pivot.
798  // if (a[i] < a[pivot])
799  // if (getDisplacement(PULoc, PUs[i]) < getDisplacement(PULoc, PUs[pivot]))
800  if (PUs[i]->X() < PUs[pivot]->X())
801  {
802  swapPUs(&PUs[i], &PUs[index]);
803  index++;
804  }
805  }
806  swapPUs(&PUs[pivot], &PUs[index]);
807  return index;
808  }
809  inline int RandomPivotPartition(std::vector<PlacementInfo::PlacementUnit *> &PUs, int low, int high)
810  {
811  // Random selection of pivot.
812  int pvt, n;
813  n = random();
814  pvt = low + n % (high - low + 1); // Randomizing the pivot value from sub-array.
815  swapPUs(&PUs[high], &PUs[pvt]);
816  return sortPartition(PUs, low, high);
817  }
818  void quick_sort_locX(std::vector<PlacementInfo::PlacementUnit *> &PUs, int p, int q)
819  {
820  // recursively sort the list
821  int pindex;
822  if (p < q)
823  {
824  pindex = RandomPivotPartition(PUs, p, q); // randomly choose pivot
825  // Recursively implementing QuickSort.
826  quick_sort_locX(PUs, p, pindex - 1);
827  quick_sort_locX(PUs, pindex + 1, q);
828  }
829  }
830 };
831 
832 #endif
CLBLegalizer::updateMatchingAndUnmatchedPUs
void updateMatchingAndUnmatchedPUs()
record the matching in private list and update the list of PlacementUnits which are not matched by th...
Definition: CLBLegalizer.cc:600
PlacementInfo::Location
Definition: PlacementInfo.h:3595
MinCostBipartiteMatcher
Definition: MinCostBipartiteMatcher.h:44
CLBLegalizer::getHPWLChange
float getHPWLChange(PlacementInfo::PlacementUnit *curPU, DeviceInfo::DeviceSite *curSite)
get the HPWL change when the given PlacementUnit moves to the given DeviceSite
Definition: CLBLegalizer.h:682
CLBLegalizer::LCLBColumnUntilization
std::vector< int > LCLBColumnUntilization
record the number of cells (Macro contains multiple cells) in each column of SLICEL
Definition: CLBLegalizer.h:356
CLBLegalizer::MCLBRowNum
int MCLBRowNum
the number of SLICEM rows ocolumnsn the target device
Definition: CLBLegalizer.h:302
CLBLegalizer::enableLCLBLegalization
bool enableLCLBLegalization
Definition: CLBLegalizer.h:423
CLBLegalizer::PU2X
std::map< PlacementInfo::PlacementUnit *, float > PU2X
record the mapping from PlacementUnits to exact DeviceSite location X
Definition: CLBLegalizer.h:380
CLBLegalizer::sortSitesBySiteY
void sortSitesBySiteY(std::vector< DeviceInfo::DeviceSite * > &sites)
Definition: CLBLegalizer.cc:699
exportDeviceLocation.sites
list sites
Definition: exportDeviceLocation.py:216
CLBLegalizer::MCLB2Column
std::map< PlacementInfo::PlacementUnit *, int > MCLB2Column
record the mapping from SLICEM CLB PlacementUnits to corresponding columns
Definition: CLBLegalizer.h:362
CLBLegalizer::getDisplacement
float getDisplacement(PlacementInfo::PlacementUnit *curPU, DeviceInfo::DeviceSite *curSite)
Definition: CLBLegalizer.h:670
CLBLegalizer::PULevelMatching
std::vector< std::pair< PlacementInfo::PlacementUnit *, DeviceInfo::DeviceSite * > > PULevelMatching
record the binding between PlacementUnits and DeviceSites as a vector of pairs
Definition: CLBLegalizer.h:257
CLBLegalizer::PU2Sites
std::map< PlacementInfo::PlacementUnit *, std::vector< DeviceInfo::DeviceSite * > > PU2Sites
record the mapping from PlacementUnits to the candidate sites which are NOT binded to PUs
Definition: CLBLegalizer.h:215
CLBLegalizer::siteType2Sites
std::map< std::string, std::vector< DeviceInfo::DeviceSite * > > siteType2Sites
a map record the potential sites of different site types
Definition: CLBLegalizer.h:207
CLBLegalizer::PU2Columns
std::map< PlacementInfo::PlacementUnit *, std::vector< int > > PU2Columns
record the column id for the binded cells in involved PlacementUnits
Definition: CLBLegalizer.h:402
CLBLegalizer::minCostBipartiteMatcher
MinCostBipartiteMatcher * minCostBipartiteMatcher
min-cost bipartite matching solver for the legalization
Definition: CLBLegalizer.h:183
PlacementInfo::PlacementMacro
a fixed group of multiple standard cells with constraints of their relative locations
Definition: PlacementInfo.h:1525
CLBLegalizer::getPUSiteNum
int getPUSiteNum(PlacementInfo::PlacementUnit *tmpPUUnit)
check how many sites are required by the given PlacementUnit
Definition: CLBLegalizer.cc:685
CLBLegalizer::MCLBColumn2Sites
std::vector< std::vector< DeviceInfo::DeviceSite * > > MCLBColumn2Sites
record the sites in each column of SLICEM
Definition: CLBLegalizer.h:326
DesignInfo::DesignCell
a DesignCell in design netlist, DesignPin objects of which might connect to DesignNet objects
Definition: DesignInfo.h:782
CLBLegalizer::cellLoc
std::vector< PlacementInfo::Location > & cellLoc
a reference of the locations of cells (in cellId order)
Definition: CLBLegalizer.h:175
CLBLegalizer::DumpCLBLegalizationCnt
int DumpCLBLegalizationCnt
Definition: CLBLegalizer.h:259
CLBLegalizer::LCLBColumnXs
std::vector< float > LCLBColumnXs
the floating-point X location of the SLICEL columns on the device
Definition: CLBLegalizer.h:320
CLBLegalizer::resetPU2SitesInDistance
void resetPU2SitesInDistance()
clear the information of candidate sites for the PlacementUnits left to be matched
Definition: CLBLegalizer.h:636
CLBLegalizer::getAverageDisplacementOfRoughLegalization
float getAverageDisplacementOfRoughLegalization()
Get the average displacement of rough legalization for the involved PlacementUnit.
Definition: CLBLegalizer.h:117
CLBLegalizer::siteTypesToLegalize
std::vector< std::string > siteTypesToLegalize
a vector of Cell Type string indicating the target types handled by this CLBLegalizer
Definition: CLBLegalizer.h:169
CLBLegalizer::matchedPUs
std::set< PlacementInfo::PlacementUnit * > matchedPUs
a set of PlacementUnits binded to corresponding DeviceSites
Definition: CLBLegalizer.h:245
MinCostBipartiteMatcher.h
CLBLegalizer::spreadPUs
void spreadPUs(int columnNum, std::vector< int > &columnUntilization, std::vector< std::vector< DeviceInfo::DeviceSite * >> &column2Sites, std::vector< std::deque< PlacementInfo::PlacementUnit * >> &column2PUs, std::map< PlacementInfo::PlacementUnit *, int > &cell2Column)
spread PlacementUnits accross columns to resolve resource overflow
Definition: CLBLegalizer.cc:810
CLBLegalizer::finalLegalizeBasedOnDP
void finalLegalizeBasedOnDP()
finally dynamic programming to legalize the PlacementUnits which have been mapped to the columns.
Definition: CLBLegalizer.cc:168
CLBLegalizer::compatiblePlacementTable
PlacementInfo::CompatiblePlacementTable * compatiblePlacementTable
compatiblePlacementTable describes the type mapping from design to device, where a cell can be placed...
Definition: CLBLegalizer.h:163
CLBLegalizer::matchedSites
std::set< DeviceInfo::DeviceSite * > matchedSites
a set of DeviceSites binded to corresponding PlacementUnits
Definition: CLBLegalizer.h:251
CLBLegalizer::LCLBColumn2Sites
std::vector< std::vector< DeviceInfo::DeviceSite * > > LCLBColumn2Sites
record the sites in each column of SLICEL
Definition: CLBLegalizer.h:332
CLBLegalizer::rightSiteIds
std::map< DeviceInfo::DeviceSite *, int > rightSiteIds
map sites to temperary indexes for bipartite matching
Definition: CLBLegalizer.h:221
CLBLegalizer::initialMaxNumCandidate
int initialMaxNumCandidate
the maximum number of final candidate sites
Definition: CLBLegalizer.h:460
CLBLegalizer::LCLBColumnNum
int LCLBColumnNum
the number of SLICEL columns on the target device
Definition: CLBLegalizer.h:296
PlacementInfo::PlacementUnit::Y
float Y()
Definition: PlacementInfo.h:1029
CLBLegalizer::hasNoTarget
bool hasNoTarget()
Definition: CLBLegalizer.h:148
CLBLegalizer::adjList
std::vector< std::vector< std::pair< int, float > > > adjList
the adjacent list of the bipartite graph
Definition: CLBLegalizer.h:233
CLBLegalizer::dumpMatching
void dumpMatching(bool fixedColumn=false, bool enforce=false)
Definition: CLBLegalizer.cc:628
CLBLegalizer::mapPUsToColumns
void mapPUsToColumns()
map PlacementUnit to the columns according to the locations of the cells in it
Definition: CLBLegalizer.cc:939
CLBLegalizer::initialPUsToLegalize
std::vector< PlacementInfo::PlacementUnit * > initialPUsToLegalize
a vector storing the PlacementUnits which SHOULD be legalized
Definition: CLBLegalizer.h:195
CLBLegalizer::getHPWLChange
float getHPWLChange(PlacementInfo::PlacementUnit *tmpPU, float PUX, float PUY)
get the HPWL change when the given PlacementUnit moves to the given location
Definition: CLBLegalizer.h:715
DesignInfo.h
This header file contains the classes of data for a standalone design netlist.
CLBLegalizer::MCLBPUs
std::set< PlacementInfo::PlacementUnit * > MCLBPUs
the PlacementUnits which shoudl be mapped to SLICEM
Definition: CLBLegalizer.h:408
PlacementInfo::PlacementUnit::X
float X()
Definition: PlacementInfo.h:1024
CLBLegalizer::noTarget
bool noTarget
Definition: CLBLegalizer.h:448
CLBLegalizer::createBipartiteGraph
void createBipartiteGraph()
Create a bipartite graph between PlacementUnit and potential DeviceSites.
Definition: CLBLegalizer.cc:556
CLBLegalizer::swapSitePtr
void swapSitePtr(DeviceInfo::DeviceSite **siteA, DeviceInfo::DeviceSite **siteB)
Definition: CLBLegalizer.h:733
CLBLegalizer::sortPUsByPU2Y
void sortPUsByPU2Y(std::deque< PlacementInfo::PlacementUnit * > &PUs)
Definition: CLBLegalizer.cc:690
dumpZip.h
PlacementInfo::getPlacementUnitId2Nets
std::vector< std::vector< PlacementNet * > > & getPlacementUnitId2Nets()
Definition: PlacementInfo.h:3903
CLBLegalizer::PU2SiteX
std::map< PlacementInfo::PlacementUnit *, int > PU2SiteX
record the exact site X (column id) of involved PlacementUnits
Definition: CLBLegalizer.h:393
DeviceInfo.h
This header file contains the classes of data for a standalone device.
PlacementInfo::Location::X
float X
Definition: PlacementInfo.h:3596
CLBLegalizer::displacementThreshold
float displacementThreshold
displacement threshold to detect potential legal sites
Definition: CLBLegalizer.h:265
delayVisualization.X
X
Definition: delayVisualization.py:80
CLBLegalizer::legalize
void legalize(bool exactLegalization=false)
conduct legalization and map the PlacementUnit of one of the given types to sites
Definition: CLBLegalizer.cc:78
CLBLegalizer::findIdMaxWithRecurence
int findIdMaxWithRecurence(int minId, int maxId, std::vector< int > &ids)
find the column which contains the most of cells in a macro in a specific range of columns
Definition: CLBLegalizer.cc:916
PlacementInfo::findNeiborSiteFromBinGrid
std::vector< DeviceInfo::DeviceSite * > * findNeiborSiteFromBinGrid(DesignInfo::DesignCell *curCell, float targetX, float targetY, float displacementThreshold, int siteNumThreshold, bool checkClockRegion=false)
find neibor device sites of a given cell from bin grid
Definition: PlacementInfo.h:3799
DSE.end
end
Definition: DSE.py:18
CLBLegalizer::RandomPivotPartition
int RandomPivotPartition(PlacementInfo::PlacementUnit *curPU, std::vector< DeviceInfo::DeviceSite * > &sites, int low, int high)
Definition: CLBLegalizer.h:760
CLBLegalizer::LCLB2Column
std::map< PlacementInfo::PlacementUnit *, int > LCLB2Column
record the mapping from SLICEL CLB PlacementUnits to corresponding columns
Definition: CLBLegalizer.h:368
CLBLegalizer::getAverageDisplacementOfExactLegalization
float getAverageDisplacementOfExactLegalization()
Get the average displacement of exact legalization for the involved PlacementUnit.
Definition: CLBLegalizer.h:95
delayVisualization.C
C
Definition: delayVisualization.py:86
DeviceInfo::DeviceSite
Site class for site on device.
Definition: DeviceInfo.h:163
CLBLegalizer::candidateFactor
int candidateFactor
we are allowed to detect a excessive number (>candidateNum) of initial candidates....
Definition: CLBLegalizer.h:278
CLBLegalizer::y2xRatio
float y2xRatio
Definition: CLBLegalizer.h:425
CLBLegalizer::swapPU
void swapPU(PlacementInfo::PlacementUnit **A, PlacementInfo::PlacementUnit **B)
Definition: CLBLegalizer.h:654
delayVisualization.A
A
Definition: delayVisualization.py:85
CLBLegalizer::LCLBPUs
std::set< PlacementInfo::PlacementUnit * > LCLBPUs
the PlacementUnits which shoudl be mapped to SLICEL
Definition: CLBLegalizer.h:414
CLBLegalizer::MCLBColumnNum
int MCLBColumnNum
the number of SLICEM columns on the target device
Definition: CLBLegalizer.h:290
CLBLegalizer::LCLBColumn2PUs
std::vector< std::deque< PlacementInfo::PlacementUnit * > > LCLBColumn2PUs
record the PlacementUnits in each column of SLICEL
Definition: CLBLegalizer.h:344
CLBLegalizer::swapPUs
void swapPUs(PlacementInfo::PlacementUnit **siteA, PlacementInfo::PlacementUnit **siteB)
Definition: CLBLegalizer.h:783
CLBLegalizer::getDisplacement
float getDisplacement(PlacementInfo::Location &PULoc, DeviceInfo::DeviceSite *curSite)
Definition: CLBLegalizer.h:665
CLBLegalizer::MCLBColumnUntilization
std::vector< int > MCLBColumnUntilization
record the number of cells (Macro contains multiple cells) in each column of SLICEM
Definition: CLBLegalizer.h:350
CLBLegalizer::DPForMinHPWL
float DPForMinHPWL(int colNum, std::vector< std::vector< DeviceInfo::DeviceSite * >> &Column2Sites, std::vector< std::deque< PlacementInfo::PlacementUnit * >> &Column2PUs)
DP function for the legalization of a specific type of PlacementUnits in the same column.
Definition: CLBLegalizer.cc:187
sysInfo.h
PlacementInfo::CompatiblePlacementTable
describes the type mapping from design to device, where a cell can be placed (which BEL in which site...
Definition: PlacementInfo.h:94
CLBLegalizer::nJobs
int nJobs
the number of the parallel multi-threading workers to handle the legalization problems
Definition: CLBLegalizer.h:284
CLBLegalizer::fixedColumnAverageDisplacement
float fixedColumnAverageDisplacement
the average displacement of fixed column (but not exactly consective) legalization for the involved P...
Definition: CLBLegalizer.h:440
CLBLegalizer::CLBLegalizer
CLBLegalizer(std::string legalizerName, PlacementInfo *placementInfo, DeviceInfo *deviceInfo, std::vector< std::string > &siteTypesToLegalize, std::map< std::string, std::string > &JSONCfg)
Construct a new CLBLegalizer object.
Definition: CLBLegalizer.cc:33
CLBLegalizer::PUsToLegalizeSet
std::set< PlacementInfo::PlacementUnit * > PUsToLegalizeSet
a set storing the PlacementUnits which have NOT been legalized
Definition: CLBLegalizer.h:201
CLBLegalizer::initialDisplacementThreshold
float initialDisplacementThreshold
displacement threshold to detect potential legal sites
Definition: CLBLegalizer.h:454
CLBLegalizer::setIntitialParameters
void setIntitialParameters(float displacementThr, int candidateNum, int _candidateFactor=-1)
Set the intitial parameters of the legalizer.
Definition: CLBLegalizer.h:129
CLBLegalizer::findSiteType2AvailableSites
void findSiteType2AvailableSites()
find available sites for each specific type required by the constructor
Definition: CLBLegalizer.cc:374
CLBLegalizer::sortPartition
int sortPartition(PlacementInfo::PlacementUnit *curPU, std::vector< DeviceInfo::DeviceSite * > &sites, int low, int high)
Definition: CLBLegalizer.h:740
CLBLegalizer::findPU2SitesInDistance
void findPU2SitesInDistance()
find candidate sites for the PlacementUnits left to be matched
Definition: CLBLegalizer.h:600
PlacementInfo::PlacementUnit
a movement unit in placement with information of location and resource demand
Definition: PlacementInfo.h:1010
CLBLegalizer::siteList
std::vector< DeviceInfo::DeviceSite * > siteList
a vector for the candidate sites for bipartite matching
Definition: CLBLegalizer.h:227
CLBLegalizer::PU2Y
std::map< PlacementInfo::PlacementUnit *, float > PU2Y
record the mapping from PlacementUnits to exact DeviceSite location Y
Definition: CLBLegalizer.h:385
DesignInfo::DesignCell::getCellId
int getCellId()
Get the Cell Id in the cell list.
Definition: DesignInfo.h:1037
PlacementInfo::PlacementUnit::getId
unsigned int getId()
Definition: PlacementInfo.h:1206
CLBLegalizer::PU2LegalSites
std::map< PlacementInfo::PlacementUnit *, std::vector< DeviceInfo::DeviceSite * > > PU2LegalSites
record the mapping from PlacementUnits to exact DeviceSites
Definition: CLBLegalizer.h:374
CLBLegalizer::JSONCfg
std::map< std::string, std::string > & JSONCfg
Definition: CLBLegalizer.h:177
CLBLegalizer::finalAverageDisplacement
float finalAverageDisplacement
the average displacement of exact legalization for the involved PlacementUnit
Definition: CLBLegalizer.h:431
CLBLegalizer::MCLBColumnXs
std::vector< float > MCLBColumnXs
the floating-point X location of the SLICEM columns on the device
Definition: CLBLegalizer.h:314
CLBLegalizer::resolveOverflowColumns
void resolveOverflowColumns()
resolve the overflow columns during fixed column legalization by spreading "outliers" to neighbor col...
Definition: CLBLegalizer.cc:904
CLBLegalizer::enableMCLBLegalization
bool enableMCLBLegalization
Definition: CLBLegalizer.h:422
CLBLegalizer::updatePUMatchingLocation
void updatePUMatchingLocation(bool isRoughLegalization=true, bool updateDisplacement=true)
update the locations of the legalization anchors for the PlacementUnits.
Definition: CLBLegalizer.cc:719
CLBLegalizer::verbose
bool verbose
Definition: CLBLegalizer.h:424
CLBLegalizer::MCLBColumn2PUs
std::vector< std::deque< PlacementInfo::PlacementUnit * > > MCLBColumn2PUs
record the PlacementUnits in each column of SLICEM
Definition: CLBLegalizer.h:338
CLBLegalizer::fixedColumnLegalize
void fixedColumnLegalize()
conduct fixed-column legalization as a step in exact legalization. During fixed-column legalization,...
Definition: CLBLegalizer.cc:139
CLBLegalizer::getPUsToLegalize
void getPUsToLegalize()
get the PlacementUnits which SHOULD be legalized
Definition: CLBLegalizer.cc:336
CLBLegalizer::resetSettings
void resetSettings()
clear the mapping information and reset the mapping parameters
Definition: CLBLegalizer.h:587
DeviceInfo
Information class related to FPGA device, including the details of BEL/Site/Tile/ClockRegion.
Definition: DeviceInfo.h:43
CLBLegalizer::quick_sort_WLChange
void quick_sort_WLChange(PlacementInfo::PlacementUnit *curPU, std::vector< DeviceInfo::DeviceSite * > &sites, int p, int q)
Definition: CLBLegalizer.h:769
DeviceInfo::DeviceSite::X
float X()
Definition: DeviceInfo.h:288
PlacementInfo::PlacementUnpackedCell
the smallest, indivisible, representable component. It will include only one standard cell
Definition: PlacementInfo.h:1447
CLBLegalizer::placementInfo
PlacementInfo * placementInfo
Definition: CLBLegalizer.h:155
checkHalfColumn.i
int i
Definition: checkHalfColumn.py:5
CLBLegalizer::roughAverageDisplacement
float roughAverageDisplacement
the average displacement of rough legalization for the involved PlacementUnit
Definition: CLBLegalizer.h:446
CLBLegalizer::RandomPivotPartition
int RandomPivotPartition(std::vector< PlacementInfo::PlacementUnit * > &PUs, int low, int high)
Definition: CLBLegalizer.h:809
PlacementInfo.h
This header file mainly contains the definition of class PlacementInfo, including information related...
CLBLegalizer::sortPartition
int sortPartition(std::vector< PlacementInfo::PlacementUnit * > &PUs, int low, int high)
Definition: CLBLegalizer.h:790
CLBLegalizer::PU2SitesInDisplacementThreshold
std::map< PlacementInfo::PlacementUnit *, std::vector< DeviceInfo::DeviceSite * > * > PU2SitesInDisplacementThreshold
a cache record the candidate sites within a given displacement threshold for each PlacementUnit
Definition: CLBLegalizer.h:420
CLBLegalizer::PUsToLegalize
std::vector< PlacementInfo::PlacementUnit * > PUsToLegalize
a vector storing the PlacementUnits which have NOT been legalized
Definition: CLBLegalizer.h:189
CLBLegalizer::deviceInfo
DeviceInfo * deviceInfo
Definition: CLBLegalizer.h:156
CLBLegalizer::quick_sort_locX
void quick_sort_locX(std::vector< PlacementInfo::PlacementUnit * > &PUs, int p, int q)
Definition: CLBLegalizer.h:818
CLBLegalizer
CLBLegalizer maps CLBs (each of which consists of one site) to legal location. e.g....
Definition: CLBLegalizer.h:62
CLBLegalizer::legalizerName
std::string legalizerName
Definition: CLBLegalizer.h:154
CLBLegalizer::roughlyLegalize
void roughlyLegalize()
conduct rough legalization.
Definition: CLBLegalizer.cc:114
CLBLegalizer::setSitesMapped
void setSitesMapped()
Set the sites which are binded as mapped so they will not be mapped to other elements in the netlist.
Definition: CLBLegalizer.cc:989
CLBLegalizer::maxNumCandidate
int maxNumCandidate
the maximum number of final candidate sites
Definition: CLBLegalizer.h:271
CLBLegalizer::LCLBRowNum
int LCLBRowNum
the number of SLICEL rows on the target device
Definition: CLBLegalizer.h:308
PlacementInfo::Location::Y
float Y
Definition: PlacementInfo.h:3597
CLBLegalizer::resetSitesMapped
void resetSitesMapped()
reset the mapped flag of the involved sites.
Definition: CLBLegalizer.cc:1002
DeviceInfo::DeviceSite::Y
float Y()
Definition: DeviceInfo.h:292
PlacementInfo
Information related to FPGA placement (wirelength optimization, cell spreading, legalization,...
Definition: PlacementInfo.h:59
CLBLegalizer::PU2Site2HPWLIncrease
std::map< PlacementInfo::PlacementUnit *, std::map< DeviceInfo::DeviceSite *, float > > PU2Site2HPWLIncrease
a map of map recording the HPWL overhead when binding a PlacementUnit to a specific site
Definition: CLBLegalizer.h:239
CLBLegalizer::findPossibleLegalLocation
void findPossibleLegalLocation(bool fixedColumn=false)
find potential sites for each PlacementUnit
Definition: CLBLegalizer.cc:472
CLBLegalizer::~CLBLegalizer
~CLBLegalizer()
Definition: CLBLegalizer.h:75