abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
place_gordian.c
Go to the documentation of this file.
1 /*===================================================================*/
2 //
3 // place_gordian.c
4 //
5 // Aaron P. Hurst, 2003-2007
6 // ahurst@eecs.berkeley.edu
7 //
8 /*===================================================================*/
9 
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <math.h>
13 #include <assert.h>
14 #include <limits.h>
15 
16 #include "place_gordian.h"
17 #include "place_base.h"
18 
20 
21 
22 
23 // --------------------------------------------------------------------
24 // Global variables
25 //
26 // --------------------------------------------------------------------
27 
29 
30 
31 // --------------------------------------------------------------------
32 // globalPlace()
33 //
34 /// \brief Performs analytic placement using a GORDIAN-like algorithm.
35 //
36 /// Updates the positions of all non-fixed non-pad cells.
37 ///
38 // --------------------------------------------------------------------
39 void globalPlace() {
40  bool completionFlag = false;
41  int iteration = 0;
42 
43  printf("PLAC-10 : Global placement (wirelength-driven Gordian)\n");
44 
46 
47  // build matrices representing interconnections
48  printf("QMAN-00 : \tconstructing initial quadratic problem...\n");
50 
51  // iterate placement until termination condition is met
52  while(!completionFlag) {
53  printf("QMAN-01 : \titeration %d numPartitions = %d\n",iteration,g_place_numPartitions);
54 
55  // do the global optimization in each direction
56  printf("QMAN-01 : \t\tglobal optimization\n");
58 
59  // -------- PARTITIONING BASED CELL SPREADING ------
60 
61  // bisection
62  printf("QMAN-01 : \t\tpartition refinement\n");
64  completionFlag |= refinePartitions();
65 
66  printf("QMAN-01 : \t\twirelength = %e\n", getTotalWirelength());
67 
68  iteration++;
69  }
70 
71  // final global optimization
72  printf("QMAN-02 : \t\tfinal pass\n");
75  printf("QMAN-01 : \t\twirelength = %e\n", getTotalWirelength());
76 
77  // clean up
79  printf("QMAN-01 : \t\twirelength = %e\n", getTotalWirelength());
81  printf("QMAN-01 : \t\twirelength = %e\n", getTotalWirelength());
82 }
83 
84 
85 // --------------------------------------------------------------------
86 // globalIncremental()
87 //
88 /// \brief Performs analytic placement using a GORDIAN-like algorithm.
89 //
90 /// Requires a valid set of partitions.
91 ///
92 // --------------------------------------------------------------------
93 
95  if (!g_place_rootPartition) {
96  printf("WARNING: Can not perform incremental placement\n");
97  globalPlace();
98  return;
99  }
100 
101  printf("PLAC-10 : Incremental global placement\n");
102 
104 
105  printf("QMAN-00 : \tconstructing initial quadratic problem...\n");
107 
109  printf("QMAN-01 : \t\twirelength = %e\n", getTotalWirelength());
110 
111  // clean up
113  printf("QMAN-01 : \t\twirelength = %e\n", getTotalWirelength());
115  printf("QMAN-01 : \t\twirelength = %e\n", getTotalWirelength());
116 }
117 
118 
119 // --------------------------------------------------------------------
120 // sanitizePlacement()
121 //
122 /// \brief Moves any cells that are outside of the core bounds to the nearest location within.
123 //
124 // --------------------------------------------------------------------
126  int c;
127  float order_width = g_place_rowHeight;
128  float x, y, edge, w, h;
129 
130  printf("QCLN-10 : \tsanitizing placement\n");
131 
132  for(c=0; c<g_place_numCells; c++) if (g_place_concreteCells[c]) {
134  if (cell->m_fixed || cell->m_parent->m_pad) {
135  continue;
136  }
137  // the new locations of the cells will be distributed within
138  // a small margin inside the border so that ordering is preserved
139  order_width = g_place_rowHeight;
140 
141  x = cell->m_x, y = cell->m_y,
142  w = cell->m_parent->m_width, h = cell->m_parent->m_height;
143 
144  if ((edge=x-w*0.5) < g_place_coreBounds.x) {
145  x = g_place_coreBounds.x+w*0.5 +
146  order_width/(1.0+g_place_coreBounds.x-edge);
147  }
148  else if ((edge=x+w*0.5) > g_place_coreBounds.x+g_place_coreBounds.w) {
150  order_width/(1.0+edge-g_place_coreBounds.x-g_place_coreBounds.w);
151  }
152  if ((edge=y-h*0.5) < g_place_coreBounds.y) {
153  y = g_place_coreBounds.y+h*0.5 +
154  order_width/(1.0+g_place_coreBounds.y-edge);
155  }
156  else if ((edge=y+h*0.5) > g_place_coreBounds.y+g_place_coreBounds.h) {
158  order_width/(1.0+edge-g_place_coreBounds.x-g_place_coreBounds.w);
159  }
160  cell->m_x = x;
161  cell->m_y = y;
162  }
163 }
165 
AbstractCell * m_parent
Definition: place_base.h:57
ABC_NAMESPACE_IMPL_START int g_place_numPartitions
Definition: place_gordian.c:28
#define REALLOCATE_PARTITIONS
Definition: place_gordian.h:27
float h
Definition: place_base.h:36
float x
Definition: place_base.h:35
float m_width
Definition: place_base.h:45
Partition * g_place_rootPartition
void constructQuadraticProblem()
Constructs the matrices necessary to do analytical placement.
Definition: place_genqp.c:53
float y
Definition: place_base.h:35
ConcreteCell ** g_place_concreteCells
Definition: place_base.c:33
#define IGNORE_COG
Definition: place_gordian.h:29
bool m_fixed
Definition: place_base.h:59
#define FINAL_REALLOCATE_PARTITIONS
Definition: place_gordian.h:28
float m_height
Definition: place_base.h:45
void globalFixDensity(int numBins, float maxMovement)
Doesn't deal well with fixed cells in the core area.
Definition: place_bin.c:43
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
bool refinePartitions()
Splits large leaf partitions.
float getTotalWirelength()
Returns the total HPWL of all nets.
Definition: place_base.c:86
void incrementalPartition()
Adds new cells to an existing partition. Partition sizes/locations are unchanged. ...
Rect g_place_coreBounds
Definition: place_base.c:30
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
float w
Definition: place_base.h:36
void globalPlace()
Performs analytic placement using a GORDIAN-like algorithm.
Definition: place_gordian.c:39
void sanitizePlacement()
Moves any cells that are outside of the core bounds to the nearest location within.
ABC_NAMESPACE_IMPL_START int g_place_numCells
Definition: place_base.c:26
void globalIncremental()
Performs analytic placement using a GORDIAN-like algorithm.
Definition: place_gordian.c:94
float g_place_rowHeight
Definition: place_base.c:28
void reallocPartitions()
Reallocates the partitions based on placement information.
void solveQuadraticProblem(bool useCOG)
Calls quadratic solver.
Definition: place_genqp.c:275
void initPartitioning()
Initializes data structures necessary for partitioning.