AMF-Placer
2.0
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
|
Go to the documentation of this file.
41 #include <semaphore.h>
86 void legalize(
bool exactLegalization =
false);
99 float tmpAverageDisplacement = 0.0;
102 tmpAverageDisplacement += std::fabs(PUSitePair.first->X() - PUSitePair.second->X()) +
103 std::fabs(PUSitePair.first->Y() - PUSitePair.second->Y());
107 return tmpAverageDisplacement;
133 if (_candidateFactor > 1)
146 void dumpMatching(
bool fixedColumn =
false,
bool enforce =
false);
175 std::vector<PlacementInfo::Location> &
cellLoc;
215 std::map<PlacementInfo::PlacementUnit *, std::vector<DeviceInfo::DeviceSite *>>
PU2Sites;
233 std::vector<std::vector<std::pair<int, float>>>
adjList;
257 std::vector<std::pair<PlacementInfo::PlacementUnit *, DeviceInfo::DeviceSite *>>
PULevelMatching;
374 std::map<PlacementInfo::PlacementUnit *, std::vector<DeviceInfo::DeviceSite *>>
PU2LegalSites;
380 std::map<PlacementInfo::PlacementUnit *, float>
PU2X;
385 std::map<PlacementInfo::PlacementUnit *, float>
PU2Y;
393 std::map<PlacementInfo::PlacementUnit *, int>
PU2SiteX;
402 std::map<PlacementInfo::PlacementUnit *, std::vector<int>>
PU2Columns;
408 std::set<PlacementInfo::PlacementUnit *>
MCLBPUs;
414 std::set<PlacementInfo::PlacementUnit *>
LCLBPUs;
543 float DPForMinHPWL(
int colNum, std::vector<std::vector<DeviceInfo::DeviceSite *>> &Column2Sites,
544 std::vector<std::deque<PlacementInfo::PlacementUnit *>> &Column2PUs);
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);
606 for (
int i = 0;
i < PUsNum;
i++)
611 #pragma omp parallel for
612 for (
int i = 0;
i < PUsNum;
i++)
618 curCell = unpackedCell->getCell();
622 assert(curMacro->getCells().size() > 0);
623 curCell = curMacro->getCells()[0];
639 for (
int i = 0;
i < PUsNum;
i++)
661 void sortPUsByPU2Y(std::deque<PlacementInfo::PlacementUnit *> &PUs);
667 return std::fabs(PULoc.
X - curSite->
X()) +
y2xRatio * std::fabs(PULoc.
Y - curSite->
Y());
672 return std::fabs(curPU->
X() - curSite->
X()) +
y2xRatio * std::fabs(curPU->
Y() - curSite->
Y());
691 float PUX = curSite->
X();
692 float PUY = curSite->
Y();
695 for (
auto curNet : nets)
697 if (curNet->getDesignNet()->getPins().size() > 10000)
699 oriHPWL += curNet->getHPWL(
y2xRatio);
700 newHPWL += curNet->getNewHPWLByTrying(curPU, PUX, PUY,
y2xRatio);
704 return (newHPWL - oriHPWL);
722 for (
auto curNet : nets)
724 if (curNet->getDesignNet()->getPins().size() > 10000)
726 oriHPWL += curNet->getHPWL(
y2xRatio);
727 newHPWL += curNet->getNewHPWLByTrying(tmpPU, PUX, PUY,
y2xRatio);
730 return (newHPWL - oriHPWL);
746 for (
i = low;
i < high;
i++)
765 pvt = (high + low) / 2;
790 inline int sortPartition(std::vector<PlacementInfo::PlacementUnit *> &PUs,
int low,
int high)
795 for (
i = low;
i < high;
i++)
800 if (PUs[
i]->
X() < PUs[pivot]->
X())
806 swapPUs(&PUs[pivot], &PUs[index]);
814 pvt = low + n % (high - low + 1);
815 swapPUs(&PUs[high], &PUs[pvt]);
void updateMatchingAndUnmatchedPUs()
record the matching in private list and update the list of PlacementUnits which are not matched by th...
float getHPWLChange(PlacementInfo::PlacementUnit *curPU, DeviceInfo::DeviceSite *curSite)
get the HPWL change when the given PlacementUnit moves to the given DeviceSite
std::vector< int > LCLBColumnUntilization
record the number of cells (Macro contains multiple cells) in each column of SLICEL
int MCLBRowNum
the number of SLICEM rows ocolumnsn the target device
bool enableLCLBLegalization
std::map< PlacementInfo::PlacementUnit *, float > PU2X
record the mapping from PlacementUnits to exact DeviceSite location X
void sortSitesBySiteY(std::vector< DeviceInfo::DeviceSite * > &sites)
std::map< PlacementInfo::PlacementUnit *, int > MCLB2Column
record the mapping from SLICEM CLB PlacementUnits to corresponding columns
float getDisplacement(PlacementInfo::PlacementUnit *curPU, DeviceInfo::DeviceSite *curSite)
std::vector< std::pair< PlacementInfo::PlacementUnit *, DeviceInfo::DeviceSite * > > PULevelMatching
record the binding between PlacementUnits and DeviceSites as a vector of pairs
std::map< PlacementInfo::PlacementUnit *, std::vector< DeviceInfo::DeviceSite * > > PU2Sites
record the mapping from PlacementUnits to the candidate sites which are NOT binded to PUs
std::map< std::string, std::vector< DeviceInfo::DeviceSite * > > siteType2Sites
a map record the potential sites of different site types
std::map< PlacementInfo::PlacementUnit *, std::vector< int > > PU2Columns
record the column id for the binded cells in involved PlacementUnits
MinCostBipartiteMatcher * minCostBipartiteMatcher
min-cost bipartite matching solver for the legalization
a fixed group of multiple standard cells with constraints of their relative locations
int getPUSiteNum(PlacementInfo::PlacementUnit *tmpPUUnit)
check how many sites are required by the given PlacementUnit
std::vector< std::vector< DeviceInfo::DeviceSite * > > MCLBColumn2Sites
record the sites in each column of SLICEM
a DesignCell in design netlist, DesignPin objects of which might connect to DesignNet objects
std::vector< PlacementInfo::Location > & cellLoc
a reference of the locations of cells (in cellId order)
int DumpCLBLegalizationCnt
std::vector< float > LCLBColumnXs
the floating-point X location of the SLICEL columns on the device
void resetPU2SitesInDistance()
clear the information of candidate sites for the PlacementUnits left to be matched
float getAverageDisplacementOfRoughLegalization()
Get the average displacement of rough legalization for the involved PlacementUnit.
std::vector< std::string > siteTypesToLegalize
a vector of Cell Type string indicating the target types handled by this CLBLegalizer
std::set< PlacementInfo::PlacementUnit * > matchedPUs
a set of PlacementUnits binded to corresponding DeviceSites
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
void finalLegalizeBasedOnDP()
finally dynamic programming to legalize the PlacementUnits which have been mapped to the columns.
PlacementInfo::CompatiblePlacementTable * compatiblePlacementTable
compatiblePlacementTable describes the type mapping from design to device, where a cell can be placed...
std::set< DeviceInfo::DeviceSite * > matchedSites
a set of DeviceSites binded to corresponding PlacementUnits
std::vector< std::vector< DeviceInfo::DeviceSite * > > LCLBColumn2Sites
record the sites in each column of SLICEL
std::map< DeviceInfo::DeviceSite *, int > rightSiteIds
map sites to temperary indexes for bipartite matching
int initialMaxNumCandidate
the maximum number of final candidate sites
int LCLBColumnNum
the number of SLICEL columns on the target device
std::vector< std::vector< std::pair< int, float > > > adjList
the adjacent list of the bipartite graph
void dumpMatching(bool fixedColumn=false, bool enforce=false)
void mapPUsToColumns()
map PlacementUnit to the columns according to the locations of the cells in it
std::vector< PlacementInfo::PlacementUnit * > initialPUsToLegalize
a vector storing the PlacementUnits which SHOULD be legalized
float getHPWLChange(PlacementInfo::PlacementUnit *tmpPU, float PUX, float PUY)
get the HPWL change when the given PlacementUnit moves to the given location
This header file contains the classes of data for a standalone design netlist.
std::set< PlacementInfo::PlacementUnit * > MCLBPUs
the PlacementUnits which shoudl be mapped to SLICEM
void createBipartiteGraph()
Create a bipartite graph between PlacementUnit and potential DeviceSites.
void swapSitePtr(DeviceInfo::DeviceSite **siteA, DeviceInfo::DeviceSite **siteB)
void sortPUsByPU2Y(std::deque< PlacementInfo::PlacementUnit * > &PUs)
std::vector< std::vector< PlacementNet * > > & getPlacementUnitId2Nets()
std::map< PlacementInfo::PlacementUnit *, int > PU2SiteX
record the exact site X (column id) of involved PlacementUnits
This header file contains the classes of data for a standalone device.
float displacementThreshold
displacement threshold to detect potential legal sites
void legalize(bool exactLegalization=false)
conduct legalization and map the PlacementUnit of one of the given types to sites
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
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
int RandomPivotPartition(PlacementInfo::PlacementUnit *curPU, std::vector< DeviceInfo::DeviceSite * > &sites, int low, int high)
std::map< PlacementInfo::PlacementUnit *, int > LCLB2Column
record the mapping from SLICEL CLB PlacementUnits to corresponding columns
float getAverageDisplacementOfExactLegalization()
Get the average displacement of exact legalization for the involved PlacementUnit.
Site class for site on device.
int candidateFactor
we are allowed to detect a excessive number (>candidateNum) of initial candidates....
void swapPU(PlacementInfo::PlacementUnit **A, PlacementInfo::PlacementUnit **B)
std::set< PlacementInfo::PlacementUnit * > LCLBPUs
the PlacementUnits which shoudl be mapped to SLICEL
int MCLBColumnNum
the number of SLICEM columns on the target device
std::vector< std::deque< PlacementInfo::PlacementUnit * > > LCLBColumn2PUs
record the PlacementUnits in each column of SLICEL
void swapPUs(PlacementInfo::PlacementUnit **siteA, PlacementInfo::PlacementUnit **siteB)
float getDisplacement(PlacementInfo::Location &PULoc, DeviceInfo::DeviceSite *curSite)
std::vector< int > MCLBColumnUntilization
record the number of cells (Macro contains multiple cells) in each column of SLICEM
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.
describes the type mapping from design to device, where a cell can be placed (which BEL in which site...
int nJobs
the number of the parallel multi-threading workers to handle the legalization problems
float fixedColumnAverageDisplacement
the average displacement of fixed column (but not exactly consective) legalization for the involved P...
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.
std::set< PlacementInfo::PlacementUnit * > PUsToLegalizeSet
a set storing the PlacementUnits which have NOT been legalized
float initialDisplacementThreshold
displacement threshold to detect potential legal sites
void setIntitialParameters(float displacementThr, int candidateNum, int _candidateFactor=-1)
Set the intitial parameters of the legalizer.
void findSiteType2AvailableSites()
find available sites for each specific type required by the constructor
int sortPartition(PlacementInfo::PlacementUnit *curPU, std::vector< DeviceInfo::DeviceSite * > &sites, int low, int high)
void findPU2SitesInDistance()
find candidate sites for the PlacementUnits left to be matched
a movement unit in placement with information of location and resource demand
std::vector< DeviceInfo::DeviceSite * > siteList
a vector for the candidate sites for bipartite matching
std::map< PlacementInfo::PlacementUnit *, float > PU2Y
record the mapping from PlacementUnits to exact DeviceSite location Y
int getCellId()
Get the Cell Id in the cell list.
std::map< PlacementInfo::PlacementUnit *, std::vector< DeviceInfo::DeviceSite * > > PU2LegalSites
record the mapping from PlacementUnits to exact DeviceSites
std::map< std::string, std::string > & JSONCfg
float finalAverageDisplacement
the average displacement of exact legalization for the involved PlacementUnit
std::vector< float > MCLBColumnXs
the floating-point X location of the SLICEM columns on the device
void resolveOverflowColumns()
resolve the overflow columns during fixed column legalization by spreading "outliers" to neighbor col...
bool enableMCLBLegalization
void updatePUMatchingLocation(bool isRoughLegalization=true, bool updateDisplacement=true)
update the locations of the legalization anchors for the PlacementUnits.
std::vector< std::deque< PlacementInfo::PlacementUnit * > > MCLBColumn2PUs
record the PlacementUnits in each column of SLICEM
void fixedColumnLegalize()
conduct fixed-column legalization as a step in exact legalization. During fixed-column legalization,...
void getPUsToLegalize()
get the PlacementUnits which SHOULD be legalized
void resetSettings()
clear the mapping information and reset the mapping parameters
Information class related to FPGA device, including the details of BEL/Site/Tile/ClockRegion.
void quick_sort_WLChange(PlacementInfo::PlacementUnit *curPU, std::vector< DeviceInfo::DeviceSite * > &sites, int p, int q)
the smallest, indivisible, representable component. It will include only one standard cell
PlacementInfo * placementInfo
float roughAverageDisplacement
the average displacement of rough legalization for the involved PlacementUnit
int RandomPivotPartition(std::vector< PlacementInfo::PlacementUnit * > &PUs, int low, int high)
This header file mainly contains the definition of class PlacementInfo, including information related...
int sortPartition(std::vector< PlacementInfo::PlacementUnit * > &PUs, int low, int high)
std::map< PlacementInfo::PlacementUnit *, std::vector< DeviceInfo::DeviceSite * > * > PU2SitesInDisplacementThreshold
a cache record the candidate sites within a given displacement threshold for each PlacementUnit
std::vector< PlacementInfo::PlacementUnit * > PUsToLegalize
a vector storing the PlacementUnits which have NOT been legalized
void quick_sort_locX(std::vector< PlacementInfo::PlacementUnit * > &PUs, int p, int q)
CLBLegalizer maps CLBs (each of which consists of one site) to legal location. e.g....
std::string legalizerName
void roughlyLegalize()
conduct rough legalization.
void setSitesMapped()
Set the sites which are binded as mapped so they will not be mapped to other elements in the netlist.
int maxNumCandidate
the maximum number of final candidate sites
int LCLBRowNum
the number of SLICEL rows on the target device
void resetSitesMapped()
reset the mapped flag of the involved sites.
Information related to FPGA placement (wirelength optimization, cell spreading, legalization,...
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
void findPossibleLegalLocation(bool fixedColumn=false)
find potential sites for each PlacementUnit