AMF-Placer  2.0
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
GeneralSpreader.h
Go to the documentation of this file.
1 
27 #ifndef _GENERALSPREADER
28 #define _GENERALSPREADER
29 
30 #include "DesignInfo.h"
31 #include "DeviceInfo.h"
32 #include "PlacementInfo.h"
33 #include "const.h"
34 #include "dumpZip.h"
35 #include <assert.h>
36 #include <fstream>
37 #include <iostream>
38 #include <map>
39 #include <set>
40 #include <sstream>
41 #include <string>
42 #include <vector>
43 
50 {
51  public:
62  GeneralSpreader(PlacementInfo *placementInfo, std::map<std::string, std::string> &JSONCfg,
63  std::string &sharedCellType, int currentIteration, float capacityShrinkRatio, bool verbose = true);
65  {
66  }
67 
76  void spreadPlacementUnits(float forgetRatio, bool enableClockRegionAware = false, float displacementLimit = -10,
77  unsigned int spreadRegionBinSizeLimit = 1000000);
78  void dumpLUTFFCoordinate();
79 
86  {
87  public:
98  std::vector<std::vector<PlacementInfo::PlacementBinInfo *>> &binGrid, float capacityShrinkRatio)
100  {
101  topBinY = bottomBinY = curBin->Y();
102  leftBinX = rightBinX = curBin->X();
103  cellsInRegion.clear();
104  binsInRegion.clear();
105  cellsInRegionVec.clear();
106  binSetInRegion.clear();
107  binsInRegion.push_back(curBin);
108  binSetInRegion.insert(curBin);
109  for (auto curCell : curBin->getCells())
110  {
111  cellsInRegion.insert(curCell);
112  cellsInRegionVec.push_back(curCell);
113  }
114  totalCapacity = curBin->getCapacity();
115  totalUtilization = curBin->getUtilization();
117  }
119  {
120  }
121 
132  inline bool isRegionOverlap(int tmpRegionTopBinY, int tmpRegionBottomBinY, int tmpRegionLeftBinX,
133  int tmpRegionRightBinX)
134  {
135  if (leftBinX > tmpRegionRightBinX || tmpRegionLeftBinX > rightBinX)
136  return false;
137  if (topBinY < tmpRegionBottomBinY || tmpRegionTopBinY < bottomBinY)
138  return false;
139  return true;
140  }
141 
149  inline bool isRegionOverlap(SpreadRegion *anotherRegion)
150  {
151  if (leftBinX > anotherRegion->right() || anotherRegion->left() > rightBinX)
152  return false;
153  if (topBinY < anotherRegion->bottom() || anotherRegion->top() < bottomBinY)
154  return false;
155  return true;
156  }
157 
168  void addBinRegion(int newRegionTopBinY, int newRegionBottomBinY, int newRegionLeftBinX, int newRegionRightBinX,
169  std::set<PlacementInfo::PlacementBinInfo *> &coveredBinSet);
170 
176  inline std::vector<PlacementInfo::PlacementBinInfo *> &getBinsInRegion()
177  {
178  return binsInRegion;
179  }
180 
187  inline bool isOverflow()
188  {
189  return overflowRatio > 1.0;
190  }
191 
196  enum dirType
197  {
201  expandDown
202  };
203 
208  struct expandOp
209  {
211 
213  {
214  }
215 
218  {
219  }
220 
221  inline expandOp &operator=(const expandOp &a)
222  {
223  topYOp = a.topYOp;
224  bottomYOp = a.bottomYOp;
225  leftXOp = a.leftXOp;
226  rightXOp = a.rightXOp;
227  return *this;
228  }
229 
236  inline expandOp operator+(int x) const
237  {
238  assert(x == 1);
239  if (topYOp)
240  return expandOp(topYOp + 1, bottomYOp, leftXOp, rightXOp);
241  if (bottomYOp)
242  return expandOp(topYOp, bottomYOp - 1, leftXOp, rightXOp);
243  if (leftXOp)
244  return expandOp(topYOp, bottomYOp, leftXOp - 1, rightXOp);
245  if (rightXOp)
246  return expandOp(topYOp, bottomYOp, leftXOp, rightXOp + 1);
247  assert(false && "should not reach here");
248  return expandOp(topYOp * x, bottomYOp * x, leftXOp * x, rightXOp * x);
249  }
250  };
251 
252  // topBinY, bottomBinY, leftBinX, rightBinX;
253  expandOp expandOps[4] = {{0, 0, -1, 0}, {0, 0, 0, 1}, {1, 0, 0, 0}, {0, -1, 0, 0}};
255 
269  inline bool isCovered(int newTopBinY, int newBottomBinY, int newLeftBinX, int newRightBinX, dirType tmpDir,
270  std::set<PlacementInfo::PlacementBinInfo *> &coveredBinSet)
271  {
272  if (tmpDir == expandUp)
273  {
274  for (int binX = newLeftBinX; binX <= newRightBinX; binX++)
275  {
276  if (coveredBinSet.find(binGrid[newTopBinY][binX]) != coveredBinSet.end())
277  return true;
278  }
279  }
280  else if (tmpDir == expandDown)
281  {
282  for (int binX = newLeftBinX; binX <= newRightBinX; binX++)
283  {
284  if (coveredBinSet.find(binGrid[newBottomBinY][binX]) != coveredBinSet.end())
285  return true;
286  }
287  }
288  else if (tmpDir == expandLeft)
289  {
290  for (int binY = newBottomBinY; binY <= newTopBinY; binY++)
291  {
292  if (coveredBinSet.find(binGrid[binY][newLeftBinX]) != coveredBinSet.end())
293  return true;
294  }
295  }
296  else if (tmpDir == expandRight)
297  {
298  for (int binY = newBottomBinY; binY <= newTopBinY; binY++)
299  {
300  if (coveredBinSet.find(binGrid[binY][newRightBinX]) != coveredBinSet.end())
301  return true;
302  }
303  }
304  return false;
305  }
306 
319  inline void getDirCapacityAndUtilization(int newTopBinY, int newBottomBinY, int newLeftBinX, int newRightBinX,
320  dirType tmpDir, float &tmpUtilization, float &tmpCapacity)
321  {
322  // tmpCapacity = 0.0;
323  // tmpUtilization = 0.0;
324  if (tmpDir == expandUp)
325  {
326  // for (int binY = newBottomBinY; binY <= newTopBinY; binY++)
327  for (int binX = newLeftBinX; binX <= newRightBinX; binX++)
328  {
329  tmpCapacity += binGrid[newTopBinY][binX]->getCapacity();
330  tmpUtilization += binGrid[newTopBinY][binX]->getUtilization();
331  }
332  }
333  else if (tmpDir == expandDown)
334  {
335  // for (int binY = newBottomBinY; binY <= newTopBinY; binY++)
336  for (int binX = newLeftBinX; binX <= newRightBinX; binX++)
337  {
338  tmpCapacity += binGrid[newBottomBinY][binX]->getCapacity();
339  tmpUtilization += binGrid[newBottomBinY][binX]->getUtilization();
340  }
341  }
342  else if (tmpDir == expandLeft)
343  {
344  for (int binY = newBottomBinY; binY <= newTopBinY; binY++)
345  // for (int binX = newLeftBinX; binX <= newRightBinX; binX++)
346  {
347  tmpCapacity += binGrid[binY][newLeftBinX]->getCapacity();
348  tmpUtilization += binGrid[binY][newLeftBinX]->getUtilization();
349  }
350  }
351  else if (tmpDir == expandRight)
352  {
353  for (int binY = newBottomBinY; binY <= newTopBinY; binY++)
354  // for (int binX = newLeftBinX; binX <= newRightBinX; binX++)
355  {
356  tmpCapacity += binGrid[binY][newRightBinX]->getCapacity();
357  tmpUtilization += binGrid[binY][newRightBinX]->getUtilization();
358  }
359  }
360  if (tmpCapacity < 1e-5)
361  tmpCapacity = 1e-5;
362  if (tmpUtilization < 1e-5)
363  tmpUtilization = 2e-5;
364  }
365 
375  inline bool smartFindExpandDirection(std::set<PlacementInfo::PlacementBinInfo *> &coveredBinSet)
376  {
377  int possibleCnt = 0;
378 
379  // iterate the 4 direction
380  for (int tmpDir = 0; tmpDir < 4; tmpDir++)
381  {
382  // initialize the expansion result (boundary, utlization, capacity, legal or not)
383  unsigned int newTopBinY = topBinY + expandOps[tmpDir].topYOp;
384  int newBottomBinY = bottomBinY + expandOps[tmpDir].bottomYOp;
385  int newLeftBinX = leftBinX + expandOps[tmpDir].leftXOp;
386  unsigned int newRightBinX = rightBinX + expandOps[tmpDir].rightXOp;
387  dir2utilization[tmpDir] = 1e-1;
388  dir2capacity[tmpDir] = 1e-5;
389  legalDir[tmpDir] = false;
390  if (newTopBinY < binGrid.size() && newBottomBinY >= 0)
391  {
392  if (newRightBinX < binGrid[newTopBinY].size() && newLeftBinX >= 0)
393  {
394  // don't include the bins in other existing SpreadRegion
395  if (!isCovered(newTopBinY, newBottomBinY, newLeftBinX, newRightBinX,
396  static_cast<dirType>(tmpDir), coveredBinSet))
397  {
398  // evaluate the utilization and capacity
399  getDirCapacityAndUtilization(newTopBinY, newBottomBinY, newLeftBinX, newRightBinX,
400  static_cast<dirType>(tmpDir), dir2utilization[tmpDir],
401  dir2capacity[tmpDir]);
402 
403  // capacity greater than 0 => legal direction
404  if (dir2capacity[tmpDir] > 2e-5)
405  {
406  actualExpandOps[tmpDir] = expandOps[tmpDir];
407  legalDir[tmpDir] = true;
408  possibleCnt++;
409  }
410 
411  // if the capacity is legal, then try to further expand 1 more bin step in this direction
412  if (!legalDir[tmpDir])
413  {
414  actualExpandOps[tmpDir] = expandOps[tmpDir] + 1; // <== further expand
415  unsigned int newTopBinY = topBinY + actualExpandOps[tmpDir].topYOp;
416  int newBottomBinY = bottomBinY + actualExpandOps[tmpDir].bottomYOp;
417  int newLeftBinX = leftBinX + actualExpandOps[tmpDir].leftXOp;
418  unsigned int newRightBinX = rightBinX + actualExpandOps[tmpDir].rightXOp;
419  if (newTopBinY < binGrid.size() && newBottomBinY >= 0)
420  {
421  if (newRightBinX < binGrid[newTopBinY].size() && newLeftBinX >= 0)
422  {
423  if (!isCovered(newTopBinY, newBottomBinY, newLeftBinX, newRightBinX,
424  static_cast<dirType>(tmpDir), coveredBinSet))
425  {
426  getDirCapacityAndUtilization(newTopBinY, newBottomBinY, newLeftBinX,
427  newRightBinX, static_cast<dirType>(tmpDir),
428  dir2utilization[tmpDir], dir2capacity[tmpDir]);
429  if (dir2capacity[tmpDir] > 2e-5)
430  {
431  legalDir[tmpDir] = true;
432  possibleCnt++;
433  }
434 
435  // if the capacity is legal, then try to further expand 1 more bin step in
436  // this direction
437  if (!legalDir[tmpDir])
438  {
439  actualExpandOps[tmpDir] =
440  (expandOps[tmpDir] + 1) + 1; // <== further expand
441  unsigned int newTopBinY = topBinY + actualExpandOps[tmpDir].topYOp;
442  int newBottomBinY = bottomBinY + actualExpandOps[tmpDir].bottomYOp;
443  int newLeftBinX = leftBinX + actualExpandOps[tmpDir].leftXOp;
444  unsigned int newRightBinX =
446  if (newTopBinY < binGrid.size() && newBottomBinY >= 0)
447  {
448  if (newRightBinX < binGrid[newTopBinY].size() && newLeftBinX >= 0)
449  {
450  if (!isCovered(newTopBinY, newBottomBinY, newLeftBinX,
451  newRightBinX, static_cast<dirType>(tmpDir),
452  coveredBinSet))
453  {
455  newTopBinY, newBottomBinY, newLeftBinX, newRightBinX,
456  static_cast<dirType>(tmpDir), dir2utilization[tmpDir],
457  dir2capacity[tmpDir]);
458  if (dir2capacity[tmpDir] > 2e-5)
459  {
460  legalDir[tmpDir] = true;
461  possibleCnt++;
462  }
463  }
464  }
465  }
466  }
467  }
468  }
469  }
470  }
471  }
472  }
473  }
474  }
475  return possibleCnt;
476  }
477 
478  inline bool expandable(int tmpDir)
479  {
480  return legalDir[tmpDir];
481  }
482 
491  inline void smartExpand(std::set<PlacementInfo::PlacementBinInfo *> &coveredBinSet)
492  {
493  float hCapacity = dir2capacity[0] + dir2capacity[1];
494  float vCapacity = dir2capacity[2] + dir2capacity[3];
495  float hUtilization = dir2utilization[0] + dir2utilization[1];
496  float vUtilization = dir2utilization[2] + dir2utilization[3];
497  bool expanded = false;
498 
499  // try to expand in horizontal direction when horizontal utilization ratio is lower than vertical
500  // utilization ratio
501  if ((expandable(0) || expandable(1)) &&
502  ((hUtilization / hCapacity < 0.9 * vUtilization / vCapacity) ||
503  (std::fabs(hUtilization + vUtilization) < 1e-4 && hCapacity > vCapacity)))
504  {
505  if (random() % 2)
506  {
507  if (expandable(0))
508  {
511  {
512  // if expanding left can solve the overflow, then only expand to left direction
513  unsigned int newTopBinY = topBinY + actualExpandOps[0].topYOp;
514  int newBottomBinY = bottomBinY + actualExpandOps[0].bottomYOp;
515  int newLeftBinX = leftBinX + actualExpandOps[0].leftXOp;
516  addBinRegion(newTopBinY, newBottomBinY, newLeftBinX, leftBinX - 1, coveredBinSet);
517  return;
518  }
519  }
520  if (expandable(1))
521  {
524  {
525  // if expanding right can solve the overflow, then only expand to right direction
526  unsigned int newTopBinY = topBinY + actualExpandOps[1].topYOp;
527  int newBottomBinY = bottomBinY + actualExpandOps[1].bottomYOp;
528  unsigned int newRightBinX = rightBinX + actualExpandOps[1].rightXOp;
529  addBinRegion(newTopBinY, newBottomBinY, rightBinX + 1, newRightBinX, coveredBinSet);
530  return;
531  }
532  }
533  }
534  else
535  {
536  if (expandable(1))
537  {
540  {
541  // if expanding right can solve the overflow, then only expand to right direction
542  unsigned int newTopBinY = topBinY + actualExpandOps[1].topYOp;
543  int newBottomBinY = bottomBinY + actualExpandOps[1].bottomYOp;
544  unsigned int newRightBinX = rightBinX + actualExpandOps[1].rightXOp;
545  addBinRegion(newTopBinY, newBottomBinY, rightBinX + 1, newRightBinX, coveredBinSet);
546  return;
547  }
548  }
549  if (expandable(0))
550  {
553  {
554  // if expanding left can solve the overflow, then only expand to left direction
555  unsigned int newTopBinY = topBinY + actualExpandOps[0].topYOp;
556  int newBottomBinY = bottomBinY + actualExpandOps[0].bottomYOp;
557  int newLeftBinX = leftBinX + actualExpandOps[0].leftXOp;
558  addBinRegion(newTopBinY, newBottomBinY, newLeftBinX, leftBinX - 1, coveredBinSet);
559  return;
560  }
561  }
562  }
563 
564  // left and right
565  unsigned int newTopBinY = topBinY + actualExpandOps[0].topYOp;
566  int newBottomBinY = bottomBinY + actualExpandOps[0].bottomYOp;
567  int newLeftBinX = leftBinX + actualExpandOps[0].leftXOp;
568  unsigned int newRightBinX = rightBinX + actualExpandOps[0].rightXOp;
569  if (expandable(0))
570  {
571  addBinRegion(newTopBinY, newBottomBinY, newLeftBinX, leftBinX - 1, coveredBinSet);
572  expanded = true;
573  }
574  newTopBinY = topBinY + actualExpandOps[1].topYOp;
575  newBottomBinY = bottomBinY + actualExpandOps[1].bottomYOp;
576  newLeftBinX = leftBinX + actualExpandOps[1].leftXOp;
577  newRightBinX = rightBinX + actualExpandOps[1].rightXOp;
578  if (expandable(1))
579  {
580  addBinRegion(newTopBinY, newBottomBinY, rightBinX + 1, newRightBinX, coveredBinSet);
581  expanded = true;
582  }
583  }
584  else
585  {
586  if (random() % 2)
587  {
588  if (expandable(2))
589  {
592  {
593  // if expanding upward can solve the overflow, then only expand to upward direction
594  unsigned int newTopBinY = topBinY + actualExpandOps[2].topYOp;
595  int newLeftBinX = leftBinX + actualExpandOps[2].leftXOp;
596  unsigned int newRightBinX = rightBinX + actualExpandOps[2].rightXOp;
597  addBinRegion(newTopBinY, topBinY + 1, newLeftBinX, newRightBinX, coveredBinSet);
598  return;
599  }
600  }
601  if (expandable(3))
602  {
605  {
606  // if expanding downward can solve the overflow, then only expand to downward direction
607  int newBottomBinY = bottomBinY + actualExpandOps[3].bottomYOp;
608  int newLeftBinX = leftBinX + actualExpandOps[3].leftXOp;
609  unsigned int newRightBinX = rightBinX + actualExpandOps[3].rightXOp;
610  addBinRegion(bottomBinY - 1, newBottomBinY, newLeftBinX, newRightBinX, coveredBinSet);
611  return;
612  }
613  }
614  }
615  else
616  {
617  if (expandable(3))
618  {
621  {
622  // if expanding downward can solve the overflow, then only expand to downward direction
623  int newBottomBinY = bottomBinY + actualExpandOps[3].bottomYOp;
624  int newLeftBinX = leftBinX + actualExpandOps[3].leftXOp;
625  unsigned int newRightBinX = rightBinX + actualExpandOps[3].rightXOp;
626  addBinRegion(bottomBinY - 1, newBottomBinY, newLeftBinX, newRightBinX, coveredBinSet);
627  return;
628  }
629  }
630  if (expandable(2))
631  {
634  {
635  // if expanding upward can solve the overflow, then only expand to upward direction
636  unsigned int newTopBinY = topBinY + actualExpandOps[2].topYOp;
637  int newLeftBinX = leftBinX + actualExpandOps[2].leftXOp;
638  unsigned int newRightBinX = rightBinX + actualExpandOps[2].rightXOp;
639  addBinRegion(newTopBinY, topBinY + 1, newLeftBinX, newRightBinX, coveredBinSet);
640  return;
641  }
642  }
643  }
644 
645  // up and down
646  unsigned int newTopBinY = topBinY + actualExpandOps[2].topYOp;
647  int newBottomBinY = bottomBinY + actualExpandOps[2].bottomYOp;
648  int newLeftBinX = leftBinX + actualExpandOps[2].leftXOp;
649  unsigned int newRightBinX = rightBinX + actualExpandOps[2].rightXOp;
650  if (expandable(2))
651  {
652  addBinRegion(newTopBinY, topBinY + 1, newLeftBinX, newRightBinX, coveredBinSet);
653  expanded = true;
654  }
655  newTopBinY = topBinY + actualExpandOps[3].topYOp;
656  newBottomBinY = bottomBinY + actualExpandOps[3].bottomYOp;
657  newLeftBinX = leftBinX + actualExpandOps[3].leftXOp;
658  newRightBinX = rightBinX + actualExpandOps[3].rightXOp;
659  if (expandable(3))
660  {
661  addBinRegion(bottomBinY - 1, newBottomBinY, newLeftBinX, newRightBinX, coveredBinSet);
662  expanded = true;
663  }
664  }
665 
666  if (!expanded)
667  {
668  std::cout << "expandable(0,1,2,3):" << expandable(0) << expandable(1) << expandable(2) << expandable(3)
669  << "\ndir2capacity[0]:" << dir2capacity[0] << " dir2capacity[1]:" << dir2capacity[1]
670  << " dir2capacity[2]:" << dir2capacity[2] << " dir2capacity[3]:" << dir2capacity[3]
671  << "\ndir2utilization[0]:" << dir2utilization[0]
672  << " dir2utilization[1]:" << dir2utilization[1]
673  << " dir2utilization[2]:" << dir2utilization[2]
674  << " dir2utilization[3]:" << dir2utilization[3] << "\n"
675  << " hUtilization / hCapacity < vUtilization / vCapacity:"
676  << (hUtilization / hCapacity < vUtilization / vCapacity) << "\n";
677  std::cout.flush();
678  assert(false && "should not be unexpandable");
679  }
680  }
681 
689  inline bool simpleFindExpandDirection(std::set<PlacementInfo::PlacementBinInfo *> &coveredBinSet)
690  {
691  char failureCnt = 0;
692  curDirectionIndex = random() % 4;
693  while (failureCnt < 4)
694  {
695 
696  unsigned int newTopBinY = topBinY + expandOps[curDirectionIndex].topYOp;
697  int newBottomBinY = bottomBinY + expandOps[curDirectionIndex].bottomYOp;
698  int newLeftBinX = leftBinX + expandOps[curDirectionIndex].leftXOp;
699  unsigned int newRightBinX = rightBinX + expandOps[curDirectionIndex].rightXOp;
700  if (newTopBinY < binGrid.size() && newBottomBinY >= 0)
701  {
702  if (newRightBinX < binGrid[newTopBinY].size() && newLeftBinX >= 0)
703  {
704  if (!isCovered(newTopBinY, newBottomBinY, newLeftBinX, newRightBinX,
705  static_cast<dirType>(curDirectionIndex), coveredBinSet))
706  {
707  curDirection = static_cast<dirType>(curDirectionIndex);
709  return true;
710  }
711  }
712  }
714  failureCnt++;
715  }
716  return false;
717  }
718 
724  inline void simpleExpand(std::set<PlacementInfo::PlacementBinInfo *> &coveredBinSet)
725  {
726  unsigned int newTopBinY = topBinY + expandOps[curDirection].topYOp;
727  int newBottomBinY = bottomBinY + expandOps[curDirection].bottomYOp;
728  int newLeftBinX = leftBinX + expandOps[curDirection].leftXOp;
729  unsigned int newRightBinX = rightBinX + expandOps[curDirection].rightXOp;
730  if (curDirection == expandUp)
731  addBinRegion(newTopBinY, newTopBinY, newLeftBinX, newRightBinX, coveredBinSet);
732  else if (curDirection == expandDown)
733  addBinRegion(newBottomBinY, newBottomBinY, newLeftBinX, newRightBinX, coveredBinSet);
734  else if (curDirection == expandLeft)
735  addBinRegion(newTopBinY, newBottomBinY, newLeftBinX, newLeftBinX, coveredBinSet);
736  else if (curDirection == expandRight)
737  addBinRegion(newTopBinY, newBottomBinY, newRightBinX, newRightBinX, coveredBinSet);
738  }
739 
748  {
749  return binSetInRegion.find(curBin) != binSetInRegion.end();
750  }
751 
759  inline std::vector<DesignInfo::DesignCell *> &getCells()
760  {
761  return cellsInRegionVec;
762  }
763 
769  inline int top()
770  {
771  return topBinY;
772  }
773 
779  inline int bottom()
780  {
781  return bottomBinY;
782  }
783 
789  inline int left()
790  {
791  return leftBinX;
792  }
793 
799  inline int right()
800  {
801  return rightBinX;
802  }
803 
809  inline float getOverflowRatio()
810  {
811  return overflowRatio;
812  }
813 
821  class SubBox
822  {
823  public:
835  std::vector<std::vector<PlacementInfo::PlacementBinInfo *>> &binGrid,
836  float capacityShrinkRatio = 1.0, int level = 100, bool dirIsH = true)
838  topBinY(curRegion->top()), bottomBinY(curRegion->bottom()), leftBinX(curRegion->left()),
839  rightBinX(curRegion->right()), level(level), dirIsH(dirIsH)
840  {
841  cellIds.clear();
842  std::vector<DesignInfo::DesignCell *> tmpCells;
843  tmpCells.clear();
844  for (auto curCell : curRegion->getCells())
845  {
846  tmpCells.push_back(curCell);
847  }
848  std::sort(tmpCells.begin(), tmpCells.end(),
850  return a->getCellId() > b->getCellId();
851  });
852  for (auto curCell : tmpCells)
853  {
854  cellIds.push_back(curCell->getCellId());
855  }
856  }
857 
869  SubBox(SubBox *parentBox, int topBinY, int bottomBinY, int leftBinX, int rightBinX, int cellRangeBegin,
870  int cellRangeEnd)
871  : placementInfo(parentBox->placementInfo), binGrid(parentBox->binGrid),
873  leftBinX(leftBinX), rightBinX(rightBinX), level(parentBox->getLevel() - 1), dirIsH(!parentBox->dirIsH)
874  {
875  if (cellRangeBegin <= cellRangeEnd)
876  cellIds = std::vector<int>(
877  {parentBox->cellIds.begin() + cellRangeBegin, parentBox->cellIds.begin() + cellRangeEnd + 1});
878  else
879  cellIds.clear();
880  }
881 
883  {
884  }
885 
887  std::vector<std::vector<PlacementInfo::PlacementBinInfo *>> &binGrid;
888  float capacityShrinkRatio = 1.0;
889 
890  inline void addCellId(int cellId)
891  {
892  cellIds.push_back(cellId);
893  }
894 
899  void spreadAndPartition();
900 
910  inline int Partition(std::vector<int> &cellIds, int low, int high, bool Xsort)
911  {
912  if (Xsort)
913  {
914  int pivot, index, i;
915  index = low;
916  pivot = high;
917  for (i = low; i < high; i++)
918  {
919  // finding index of pivot.
920  // if (a[i] < a[pivot])
923  {
924  std::swap(cellIds[i], cellIds[index]);
925  index++;
926  }
927  }
928  std::swap(cellIds[pivot], cellIds[index]);
929  return index;
930  }
931  else
932  {
933  int pivot, index, i;
934  index = low;
935  pivot = high;
936  for (i = low; i < high; i++)
937  {
938  // finding index of pivot.
939  // if (a[i] < a[pivot])
942  {
943  std::swap(cellIds[i], cellIds[index]);
944  index++;
945  }
946  }
947  std::swap(cellIds[pivot], cellIds[index]);
948  return index;
949  }
950  }
951 
961  inline int RandomPivotPartition(std::vector<int> &cellIds, int low, int high, bool Xsort)
962  {
963  // Random selection of pivot.
964  int pvt, n;
965  n = HiFPlacer_hashprimes[low & 0xff];
966  pvt = low + n % (high - low + 1); // Randomizing the pivot value from sub-array.
967  std::swap(cellIds[high], cellIds[pvt]);
968  return Partition(cellIds, low, high, Xsort);
969  }
970 
979  void quick_sort(std::vector<int> &cellIds, int p, int q, bool Xsort)
980  {
981  // recursively sort the list
982  int pindex;
983  if (p < q)
984  {
985  pindex = RandomPivotPartition(cellIds, p, q, Xsort); // randomly choose pivot
986  // Recursively implementing QuickSort.
987  quick_sort(cellIds, p, pindex - 1, Xsort);
988  quick_sort(cellIds, pindex + 1, q, Xsort);
989  }
990  }
991 
992  inline int getLevel()
993  {
994  return level;
995  }
996 
1003  void spreadCellsH(SubBox **boxA, SubBox **boxB);
1004 
1011  void spreadCellsV(SubBox **boxA, SubBox **boxB);
1012 
1018  inline int top()
1019  {
1020  return topBinY;
1021  }
1022 
1028  inline int bottom()
1029  {
1030  return bottomBinY;
1031  }
1032 
1038  inline int left()
1039  {
1040  return leftBinX;
1041  }
1042 
1048  inline int right()
1049  {
1050  return rightBinX;
1051  }
1052 
1053  private:
1055 
1060  std::vector<int> cellIds;
1061  int level;
1062 
1063  public:
1064  bool dirIsH;
1065 
1070  int minExpandSize = 2;
1071  };
1072 
1073  static constexpr float eps = 1e-4;
1074 
1075  private:
1082 
1088 
1094 
1099  std::vector<std::vector<PlacementInfo::PlacementBinInfo *>> &binGrid;
1100 
1106 
1111  float dir2capacity[4];
1112 
1119  bool legalDir[4];
1120  float capacityShrinkRatio = 1.0;
1121 
1126  std::set<DesignInfo::DesignCell *> cellsInRegion;
1127 
1133  std::vector<DesignInfo::DesignCell *> cellsInRegionVec;
1134 
1140  std::vector<PlacementInfo::PlacementBinInfo *> binsInRegion;
1141 
1146  std::set<PlacementInfo::PlacementBinInfo *> binSetInRegion;
1147  };
1148 
1162  void updatePlacementUnitsWithSpreadedCellLocations(std::set<PlacementInfo::PlacementUnit *> &involvedPUs,
1163  std::set<DesignInfo::DesignCell *> &involvedCells,
1164  std::vector<PlacementInfo::PlacementUnit *> &involvedPUVec,
1165  float forgetRatio, bool enableClockRegionAware,
1166  float displacementLimit);
1167 
1181  PlacementInfo *placementInfo, std::set<PlacementInfo::PlacementUnit *> &involvedPUs,
1182  std::set<DesignInfo::DesignCell *> &involvedCells, std::vector<PlacementInfo::PlacementUnit *> &involvedPUVec,
1183  float forgetRatio, float displacementLimit, int startId, int endId);
1184 
1192  static void makeCellInLegalArea(PlacementInfo *placementInfo, float &cellX, float &cellY)
1193  {
1194  float eps = 1e-4;
1195  if (cellX < placementInfo->getGlobalMinX())
1196  {
1197  cellX = placementInfo->getGlobalMinX() + eps;
1198  }
1199  if (cellY < placementInfo->getGlobalMinY())
1200  {
1201  cellY = placementInfo->getGlobalMinY() + eps;
1202  }
1203  if (cellX > placementInfo->getGlobalMaxX())
1204  {
1205  cellX = placementInfo->getGlobalMaxX() - eps;
1206  }
1207  if (cellY > placementInfo->getGlobalMaxY())
1208  {
1209  cellY = placementInfo->getGlobalMaxY() - eps;
1210  }
1211  }
1212 
1218 
1219  void DumpCellsCoordinate(std::string dumpFileName, GeneralSpreader::SpreadRegion *curRegion);
1220  void DumpPUCoordinate(std::string dumpFileName, std::vector<PlacementInfo::PlacementUnit *> &involvedPUVec);
1221 
1222  private:
1224  std::map<std::string, std::string> &JSONCfg;
1225  std::string sharedCellType;
1227  float capacityShrinkRatio = 1.0;
1228  bool verbose;
1229 
1234  std::vector<std::vector<PlacementInfo::PlacementBinInfo *>> &binGrid;
1235 
1238  int nJobs = 1;
1239 
1246  bool useSimpleExpland = false;
1247  bool enforceSimpleExpland = false;
1248  int dumpCnt = 0;
1249 
1254  std::vector<PlacementInfo::PlacementBinInfo *> overflowBins;
1255 
1260  std::set<PlacementInfo::PlacementBinInfo *> overflowBinSet;
1261 
1266  std::set<PlacementInfo::PlacementBinInfo *> coveredBinSet;
1267 
1268  void dumpSiteGridDensity(std::string dumpFileName);
1269 
1275  void findOverflowBins(float overflowThreshold);
1276 
1286  unsigned int numBinThr = 1000000);
1287 
1292  std::vector<GeneralSpreader::SpreadRegion *> expandedRegions;
1293 };
1294 
1295 std::ostream &operator<<(std::ostream &os, GeneralSpreader::SpreadRegion::SubBox *curBox);
1296 #endif
GeneralSpreader::SpreadRegion::bottom
int bottom()
get the bottom bin coordinate Y of the SpreadRegion in bin grid
Definition: GeneralSpreader.h:779
PlacementInfo::PlacementBinInfo::X
int X()
return the column of the bin in the grid
Definition: PlacementInfo.h:683
GeneralSpreader::SpreadRegion::SubBox::getLevel
int getLevel()
Definition: GeneralSpreader.h:992
GeneralSpreader::SpreadRegion::cellsInRegion
std::set< DesignInfo::DesignCell * > cellsInRegion
a set of cells in the SpreadRegion
Definition: GeneralSpreader.h:1126
GeneralSpreader::SpreadRegion::cellsInRegionVec
std::vector< DesignInfo::DesignCell * > cellsInRegionVec
a vector of cells in the SpreadRegion
Definition: GeneralSpreader.h:1133
GeneralSpreader::dumpSiteGridDensityCnt
int dumpSiteGridDensityCnt
Definition: GeneralSpreader.h:1236
GeneralSpreader::SpreadRegion::expandable
bool expandable(int tmpDir)
Definition: GeneralSpreader.h:478
GeneralSpreader::currentIteration
int currentIteration
Definition: GeneralSpreader.h:1226
GeneralSpreader::DumpPUCoordinate
void DumpPUCoordinate(std::string dumpFileName, std::vector< PlacementInfo::PlacementUnit * > &involvedPUVec)
Definition: GeneralSpreader.cc:1353
GeneralSpreader::SpreadRegion::capacityShrinkRatio
float capacityShrinkRatio
Definition: GeneralSpreader.h:1120
GeneralSpreader::expandedRegions
std::vector< GeneralSpreader::SpreadRegion * > expandedRegions
the obtained SpreadRegion s which can be processed in parallel.
Definition: GeneralSpreader.h:1292
GeneralSpreader::SpreadRegion::expandLeft
@ expandLeft
Definition: GeneralSpreader.h:198
GeneralSpreader::SpreadRegion::curDirection
dirType curDirection
make the direction into enum type for clearer identification
Definition: GeneralSpreader.h:1093
PlacementInfo::PlacementBinInfo
BEL bin for global placement for a specific shared BEL type.
Definition: PlacementInfo.h:372
GeneralSpreader::SpreadRegion::getOverflowRatio
float getOverflowRatio()
Get the resource overflow ratio.
Definition: GeneralSpreader.h:809
GeneralSpreader::SpreadRegion::expandOp
a struct to describe the expanding operation for the SpreadRegion
Definition: GeneralSpreader.h:209
GeneralSpreader::SpreadRegion::SubBox::top
int top()
get the top bin coordinate Y of the SubBox in bin grid
Definition: GeneralSpreader.h:1018
PlacementInfo::PlacementBinInfo::getCells
std::set< DesignInfo::DesignCell * > & getCells()
Get the reference of the set of cells in the bin.
Definition: PlacementInfo.h:563
GeneralSpreader::SpreadRegion::dir2capacity
float dir2capacity[4]
the capacity of the four directions (absolute value)
Definition: GeneralSpreader.h:1111
GeneralSpreader::SpreadRegion::SubBox::SubBox
SubBox(SubBox *parentBox, int topBinY, int bottomBinY, int leftBinX, int rightBinX, int cellRangeBegin, int cellRangeEnd)
Construct a new Sub Box object.
Definition: GeneralSpreader.h:869
DesignInfo::DesignCell
a DesignCell in design netlist, DesignPin objects of which might connect to DesignNet objects
Definition: DesignInfo.h:782
GeneralSpreader::SpreadRegion::smartFindExpandDirection
bool smartFindExpandDirection(std::set< PlacementInfo::PlacementBinInfo * > &coveredBinSet)
find the legal expansion direction
Definition: GeneralSpreader.h:375
GeneralSpreader::SpreadRegion::expandDown
@ expandDown
Definition: GeneralSpreader.h:201
GeneralSpreader::SpreadRegion::dir2utilization
float dir2utilization[4]
the utilization of the four directions (absolute value)
Definition: GeneralSpreader.h:1105
HiFPlacer_hashprimes
const int HiFPlacer_hashprimes[300]
Definition: const.h:28
GeneralSpreader::SpreadRegion::isRegionOverlap
bool isRegionOverlap(SpreadRegion *anotherRegion)
check whether overlapped with another SpreadRegion
Definition: GeneralSpreader.h:149
GeneralSpreader::SpreadRegion::legalDir
bool legalDir[4]
a boolean array to record legal directions to expand the SpreadRegion
Definition: GeneralSpreader.h:1119
GeneralSpreader::SpreadRegion::SubBox::placementInfo
PlacementInfo * placementInfo
Definition: GeneralSpreader.h:886
GeneralSpreader::dumpLUTFFCoordinate
void dumpLUTFFCoordinate()
Definition: GeneralSpreader.cc:1279
GeneralSpreader::SpreadRegion::dirType
dirType
four direction options to expand the SpreadRegion
Definition: GeneralSpreader.h:197
GeneralSpreader::SpreadRegion::expandOp::operator+
expandOp operator+(int x) const
overload operator+ to expand the SpreadRegion by given steps in the pre-set direction
Definition: GeneralSpreader.h:236
GeneralSpreader::GeneralSpreader
GeneralSpreader(PlacementInfo *placementInfo, std::map< std::string, std::string > &JSONCfg, std::string &sharedCellType, int currentIteration, float capacityShrinkRatio, bool verbose=true)
Construct a new General Spreader object.
Definition: GeneralSpreader.cc:34
GeneralSpreader::binGrid
std::vector< std::vector< PlacementInfo::PlacementBinInfo * > > & binGrid
a reference of the global bin grid for data accessing and updating of cell density
Definition: GeneralSpreader.h:1234
PlacementInfo::getGlobalMinY
float getGlobalMinY()
Get the Global Min Y (bottom boundary of the device)
Definition: PlacementInfo.h:2882
GeneralSpreader::SpreadRegion::isCovered
bool isCovered(int newTopBinY, int newBottomBinY, int newLeftBinX, int newRightBinX, dirType tmpDir, std::set< PlacementInfo::PlacementBinInfo * > &coveredBinSet)
check whether an expansion in a given direction will make the SpreadRegion overlapped with some bins ...
Definition: GeneralSpreader.h:269
GeneralSpreader::SpreadRegion::SubBox::addCellId
void addCellId(int cellId)
Definition: GeneralSpreader.h:890
GeneralSpreader::updatePlacementUnitsWithSpreadedCellLocationsWorker
static void updatePlacementUnitsWithSpreadedCellLocationsWorker(PlacementInfo *placementInfo, std::set< PlacementInfo::PlacementUnit * > &involvedPUs, std::set< DesignInfo::DesignCell * > &involvedCells, std::vector< PlacementInfo::PlacementUnit * > &involvedPUVec, float forgetRatio, float displacementLimit, int startId, int endId)
multi-threading workers for updating the information of the involved PlacementUnit(s)
Definition: GeneralSpreader.cc:307
GeneralSpreader::nJobs
int nJobs
Definition: GeneralSpreader.h:1238
PlacementInfo::getCellId2location
std::vector< Location > & getCellId2location()
Definition: PlacementInfo.h:3600
GeneralSpreader::SpreadRegion::expandOp::expandOp
expandOp(int topYOp, int bottomYOp, int leftXOp, int rightXOp)
Definition: GeneralSpreader.h:216
GeneralSpreader::SpreadRegion::top
int top()
get the top bin coordinate Y of the SpreadRegion in bin grid
Definition: GeneralSpreader.h:769
GeneralSpreader::SpreadRegion::SpreadRegion
SpreadRegion(PlacementInfo::PlacementBinInfo *curBin, PlacementInfo *placementInfo, std::vector< std::vector< PlacementInfo::PlacementBinInfo * >> &binGrid, float capacityShrinkRatio)
Construct a new Spread Region object.
Definition: GeneralSpreader.h:97
GeneralSpreader::verbose
bool verbose
Definition: GeneralSpreader.h:1228
paintPlacement.x
list x
Definition: paintPlacement.py:152
GeneralSpreader::SpreadRegion::left
int left()
get the left bin coordinate X of the SpreadRegion in bin grid
Definition: GeneralSpreader.h:789
GeneralSpreader::SpreadRegion::SubBox
SubBox is the exact container which is the object for bi-partitioning-based cell spreading.
Definition: GeneralSpreader.h:822
GeneralSpreader::SpreadRegion::SubBox::bottom
int bottom()
get the bottom bin coordinate Y of the SubBox in bin grid
Definition: GeneralSpreader.h:1028
GeneralSpreader::SpreadRegion::SubBox::spreadAndPartition
void spreadAndPartition()
spread cells and partition the SubBox into smaller SubBoxes
Definition: GeneralSpreader.cc:706
GeneralSpreader::SpreadRegion::topBinY
int topBinY
Definition: GeneralSpreader.h:1080
GeneralSpreader::overflowBins
std::vector< PlacementInfo::PlacementBinInfo * > overflowBins
a vector of the found overflow bins in the current placement
Definition: GeneralSpreader.h:1254
DesignInfo.h
This header file contains the classes of data for a standalone design netlist.
GeneralSpreader::SpreadRegion::SubBox::rightBinX
int rightBinX
Definition: GeneralSpreader.h:1054
GeneralSpreader::SpreadRegion::SubBox::level
int level
Definition: GeneralSpreader.h:1061
PlacementInfo::getGlobalMaxX
float getGlobalMaxX()
Get the Global Max X (right boundary of the device)
Definition: PlacementInfo.h:2852
GeneralSpreader::capacityShrinkRatio
float capacityShrinkRatio
Definition: GeneralSpreader.h:1227
GeneralSpreader::dumpSiteGridDensity
void dumpSiteGridDensity(std::string dumpFileName)
Definition: GeneralSpreader.cc:1256
GeneralSpreader::DumpCellsCoordinate
void DumpCellsCoordinate(std::string dumpFileName, GeneralSpreader::SpreadRegion *curRegion)
Definition: GeneralSpreader.cc:1335
GeneralSpreader::SpreadRegion::binGrid
std::vector< std::vector< PlacementInfo::PlacementBinInfo * > > & binGrid
a reference of the global bin grid for data accessing and updating of cell density
Definition: GeneralSpreader.h:1099
dumpZip.h
GeneralSpreader::SpreadRegion::rightBinX
int rightBinX
Definition: GeneralSpreader.h:1081
DeviceInfo.h
This header file contains the classes of data for a standalone device.
GeneralSpreader::SpreadRegion::SubBox::minExpandSize
int minExpandSize
the minimum length of boundary
Definition: GeneralSpreader.h:1070
GeneralSpreader::SpreadRegion::totalUtilization
float totalUtilization
Definition: GeneralSpreader.h:1078
GeneralSpreader::SpreadRegion::expandOp::expandOp
expandOp()
Definition: GeneralSpreader.h:212
GeneralSpreader::enforceSimpleExpland
bool enforceSimpleExpland
Definition: GeneralSpreader.h:1247
GeneralSpreader::recordSpreadedCellLocations
void recordSpreadedCellLocations()
record the spreaded location in PlacementInfo for later forget-ratio-based location updating
Definition: GeneralSpreader.cc:698
GeneralSpreader::SpreadRegion::totalCapacity
float totalCapacity
Definition: GeneralSpreader.h:1077
GeneralSpreader::SpreadRegion::expandOp::operator=
expandOp & operator=(const expandOp &a)
Definition: GeneralSpreader.h:221
GeneralSpreader::SpreadRegion::SubBox::leftBinX
int leftBinX
Definition: GeneralSpreader.h:1054
GeneralSpreader::SpreadRegion::simpleFindExpandDirection
bool simpleFindExpandDirection(std::set< PlacementInfo::PlacementBinInfo * > &coveredBinSet)
find the expansion direction iteratively in pre-defined order
Definition: GeneralSpreader.h:689
GeneralSpreader::SpreadRegion::SubBox::capacityShrinkRatio
float capacityShrinkRatio
Definition: GeneralSpreader.h:888
GeneralSpreader::SpreadRegion::expandOp::leftXOp
int leftXOp
Definition: GeneralSpreader.h:210
GeneralSpreader::SpreadRegion
SpreadRegion is an object that record cell spreading region information, including boundaries,...
Definition: GeneralSpreader.h:86
operator<<
std::ostream & operator<<(std::ostream &os, GeneralSpreader::SpreadRegion::SubBox *curBox)
Definition: GeneralSpreader.cc:1328
GeneralSpreader::~GeneralSpreader
~GeneralSpreader()
Definition: GeneralSpreader.h:64
GeneralSpreader::useSimpleExpland
bool useSimpleExpland
simple expansion will iteratively try 4 directions to expand the SpreadRegion
Definition: GeneralSpreader.h:1246
GeneralSpreader::SpreadRegion::SubBox::SubBox
SubBox(PlacementInfo *placementInfo, SpreadRegion *curRegion, std::vector< std::vector< PlacementInfo::PlacementBinInfo * >> &binGrid, float capacityShrinkRatio=1.0, int level=100, bool dirIsH=true)
Construct a new Sub Box object.
Definition: GeneralSpreader.h:834
const.h
GeneralSpreader::SpreadRegion::overflowRatio
float overflowRatio
Definition: GeneralSpreader.h:1079
GeneralSpreader::SpreadRegion::expandOps
expandOp expandOps[4]
Definition: GeneralSpreader.h:253
GeneralSpreader::SpreadRegion::SubBox::quick_sort
void quick_sort(std::vector< int > &cellIds, int p, int q, bool Xsort)
recursive implementation of quick sort for cell ids by X/Y location
Definition: GeneralSpreader.h:979
PlacementInfo::getGlobalMinX
float getGlobalMinX()
Get the Global Min X (left boundary of the device)
Definition: PlacementInfo.h:2872
GeneralSpreader::SpreadRegion::SubBox::spreadCellsH
void spreadCellsH(SubBox **boxA, SubBox **boxB)
split horizontally the SubBox into smaller ones and assign cells to them
Definition: GeneralSpreader.cc:752
GeneralSpreader
GeneralSpreader accounts for the cell spreading, which controls the cell density of specific resource...
Definition: GeneralSpreader.h:50
GeneralSpreader::SpreadRegion::expandRight
@ expandRight
Definition: GeneralSpreader.h:199
GeneralSpreader::expandFromABin
GeneralSpreader::SpreadRegion * expandFromABin(PlacementInfo::PlacementBinInfo *curBin, float capacityShrinkRatio, unsigned int numBinThr=1000000)
obtain a SpreadRegion by expanding a cell spreading window from an overflow bin
Definition: GeneralSpreader.cc:613
GeneralSpreader::SpreadRegion::SubBox::bottomBinY
int bottomBinY
Definition: GeneralSpreader.h:1054
GeneralSpreader::SpreadRegion::simpleExpand
void simpleExpand(std::set< PlacementInfo::PlacementBinInfo * > &coveredBinSet)
select the the expansion direction which is found in a pre-defined order
Definition: GeneralSpreader.h:724
GeneralSpreader::placementInfo
PlacementInfo * placementInfo
Definition: GeneralSpreader.h:1223
GeneralSpreader::coveredBinSet
std::set< PlacementInfo::PlacementBinInfo * > coveredBinSet
a set of the bins covered by existing SpreadRegion(s)
Definition: GeneralSpreader.h:1266
GeneralSpreader::SpreadRegion::placementInfo
PlacementInfo * placementInfo
Definition: GeneralSpreader.h:1076
GeneralSpreader::SpreadRegion::getCells
std::vector< DesignInfo::DesignCell * > & getCells()
Get the cells in the SpreadRegion.
Definition: GeneralSpreader.h:759
GeneralSpreader::SpreadRegion::SubBox::left
int left()
get the left bin coordinate X of the SubBox in bin grid
Definition: GeneralSpreader.h:1038
GeneralSpreader::SpreadRegion::SubBox::RandomPivotPartition
int RandomPivotPartition(std::vector< int > &cellIds, int low, int high, bool Xsort)
the partition/sort function for quick sorting by cell location (X or Y)
Definition: GeneralSpreader.h:961
GeneralSpreader::SpreadRegion::leftBinX
int leftBinX
Definition: GeneralSpreader.h:1081
GeneralSpreader::SpreadRegion::eps
static constexpr float eps
Definition: GeneralSpreader.h:1073
GeneralSpreader::SpreadRegion::curDirectionIndex
int curDirectionIndex
record the last selection of expansion direction for later expansion
Definition: GeneralSpreader.h:1087
GeneralSpreader::SpreadRegion::binSetInRegion
std::set< PlacementInfo::PlacementBinInfo * > binSetInRegion
a set of bins in the SpreadRegion
Definition: GeneralSpreader.h:1146
GeneralSpreader::SpreadRegion::isRegionOverlap
bool isRegionOverlap(int tmpRegionTopBinY, int tmpRegionBottomBinY, int tmpRegionLeftBinX, int tmpRegionRightBinX)
check whether the SpreadRegion is overlapped with a given boundary
Definition: GeneralSpreader.h:132
GeneralSpreader::makeCellInLegalArea
static void makeCellInLegalArea(PlacementInfo *placementInfo, float &cellX, float &cellY)
ensure the X/Y is in the legal range of the target device
Definition: GeneralSpreader.h:1192
GeneralSpreader::SpreadRegion::SubBox::binGrid
std::vector< std::vector< PlacementInfo::PlacementBinInfo * > > & binGrid
Definition: GeneralSpreader.h:887
GeneralSpreader::SpreadRegion::expandOp::bottomYOp
int bottomYOp
Definition: GeneralSpreader.h:210
GeneralSpreader::LUTFFCoordinateDumpCnt
int LUTFFCoordinateDumpCnt
Definition: GeneralSpreader.h:1237
GeneralSpreader::SpreadRegion::SubBox::Partition
int Partition(std::vector< int > &cellIds, int low, int high, bool Xsort)
the partition/sort function for quick sorting by cell location (X or Y)
Definition: GeneralSpreader.h:910
GeneralSpreader::updatePlacementUnitsWithSpreadedCellLocations
void updatePlacementUnitsWithSpreadedCellLocations(std::set< PlacementInfo::PlacementUnit * > &involvedPUs, std::set< DesignInfo::DesignCell * > &involvedCells, std::vector< PlacementInfo::PlacementUnit * > &involvedPUVec, float forgetRatio, bool enableClockRegionAware, float displacementLimit)
update the information of the involved PlacementUnit(s)
Definition: GeneralSpreader.cc:414
PlacementInfo::PlacementBinInfo::Y
int Y()
return the row of the bin in the grid
Definition: PlacementInfo.h:673
GeneralSpreader::JSONCfg
std::map< std::string, std::string > & JSONCfg
Definition: GeneralSpreader.h:1224
PlacementInfo::PlacementBinInfo::getCapacity
float getCapacity()
Definition: PlacementInfo.h:627
GeneralSpreader::SpreadRegion::actualExpandOps
expandOp actualExpandOps[4]
Definition: GeneralSpreader.h:254
GeneralSpreader::SpreadRegion::addBinRegion
void addBinRegion(int newRegionTopBinY, int newRegionBottomBinY, int newRegionLeftBinX, int newRegionRightBinX, std::set< PlacementInfo::PlacementBinInfo * > &coveredBinSet)
add cell bins into SpreadRegion with a new boundary and update region information including boundary ...
Definition: GeneralSpreader.cc:656
GeneralSpreader::SpreadRegion::SubBox::right
int right()
get the right bin coordinate X of the SubBox in bin grid
Definition: GeneralSpreader.h:1048
GeneralSpreader::dumpCnt
int dumpCnt
Definition: GeneralSpreader.h:1248
PlacementInfo::PlacementBinInfo::getUtilization
float getUtilization()
Definition: PlacementInfo.h:622
GeneralSpreader::SpreadRegion::isOverflow
bool isOverflow()
check whether the resource in this region is less than the requirement
Definition: GeneralSpreader.h:187
GeneralSpreader::SpreadRegion::~SpreadRegion
~SpreadRegion()
Definition: GeneralSpreader.h:118
GeneralSpreader::SpreadRegion::expandUp
@ expandUp
Definition: GeneralSpreader.h:200
GeneralSpreader::sharedCellType
std::string sharedCellType
Definition: GeneralSpreader.h:1225
GeneralSpreader::SpreadRegion::expandOp::rightXOp
int rightXOp
Definition: GeneralSpreader.h:210
GeneralSpreader::SpreadRegion::getDirCapacityAndUtilization
void getDirCapacityAndUtilization(int newTopBinY, int newBottomBinY, int newLeftBinX, int newRightBinX, dirType tmpDir, float &tmpUtilization, float &tmpCapacity)
evaluation the utilization and capacity of the incoming bins which will be included in the SpreadRegi...
Definition: GeneralSpreader.h:319
checkHalfColumn.i
int i
Definition: checkHalfColumn.py:5
GeneralSpreader::overflowBinSet
std::set< PlacementInfo::PlacementBinInfo * > overflowBinSet
a set of the found overflow bins in the current placement
Definition: GeneralSpreader.h:1260
GeneralSpreader::SpreadRegion::SubBox::topBinY
int topBinY
Definition: GeneralSpreader.h:1054
GeneralSpreader::SpreadRegion::smartExpand
void smartExpand(std::set< PlacementInfo::PlacementBinInfo * > &coveredBinSet)
select the expansion direction greedily
Definition: GeneralSpreader.h:491
PlacementInfo.h
This header file mainly contains the definition of class PlacementInfo, including information related...
GeneralSpreader::SpreadRegion::bottomBinY
int bottomBinY
Definition: GeneralSpreader.h:1080
GeneralSpreader::SpreadRegion::expandOp::topYOp
int topYOp
Definition: GeneralSpreader.h:210
GeneralSpreader::findOverflowBins
void findOverflowBins(float overflowThreshold)
find the overflow bins in the placement accoridng to a given threshold
Definition: GeneralSpreader.cc:267
GeneralSpreader::SpreadRegion::binsInRegion
std::vector< PlacementInfo::PlacementBinInfo * > binsInRegion
a vector of bins in the SpreadRegion
Definition: GeneralSpreader.h:1140
GeneralSpreader::SpreadRegion::getBinsInRegion
std::vector< PlacementInfo::PlacementBinInfo * > & getBinsInRegion()
Get the bins in the SpreadRegion.
Definition: GeneralSpreader.h:176
GeneralSpreader::SpreadRegion::right
int right()
get the right bin coordinate X of the SpreadRegion in bin grid
Definition: GeneralSpreader.h:799
GeneralSpreader::SpreadRegion::contains
bool contains(PlacementInfo::PlacementBinInfo *curBin)
check whether SpreadRegion contains the given bin
Definition: GeneralSpreader.h:747
PlacementInfo::getGlobalMaxY
float getGlobalMaxY()
Get the Global Max Y (top boundary of the device)
Definition: PlacementInfo.h:2862
GeneralSpreader::SpreadRegion::SubBox::spreadCellsV
void spreadCellsV(SubBox **boxA, SubBox **boxB)
split vertically the SubBox into smaller ones and assign cells to them
Definition: GeneralSpreader.cc:986
GeneralSpreader::SpreadRegion::SubBox::cellIds
std::vector< int > cellIds
the cells in this SubBox
Definition: GeneralSpreader.h:1060
PlacementInfo
Information related to FPGA placement (wirelength optimization, cell spreading, legalization,...
Definition: PlacementInfo.h:59
GeneralSpreader::spreadPlacementUnits
void spreadPlacementUnits(float forgetRatio, bool enableClockRegionAware=false, float displacementLimit=-10, unsigned int spreadRegionBinSizeLimit=1000000)
spread cells with a given forgetting ratio
Definition: GeneralSpreader.cc:52
GeneralSpreader::SpreadRegion::SubBox::~SubBox
~SubBox()
Definition: GeneralSpreader.h:882
GeneralSpreader::SpreadRegion::SubBox::dirIsH
bool dirIsH
Definition: GeneralSpreader.h:1064