MacroPlacement

Proxy Cost Computation in Circuit Training

In this documentation, we use gridcell and grid interchangeably. They both mean the grid system induced by the gridding process.

In Circuit Training, proxy cost is the weighted sum of wirelength, density, and congestion costs. It is used to determine the overall quality of the macro placement solution.

Proxy Cost = Wwirelength × Costwirelength + Wdensity × Costdensity + Wcongestion × Costcongestion

Where Wwirelength, Wdensity and Wcongestion are the weights. From the Circuit Training repo, we found that Wwirelength = 1, Wdensity = 1, and Wcongestion = 0.5. From communication with Google engineers, we learned that in their internal flow, they use Wwirelength = 1, Wdensity = 0.5, and Wcongestion = 0.5.

Circuit Training repo provides the plc_wrapper_main binary to compute these cost functions. There is no available detailed description, or open-source implementation, of these cost functions. With feedback and confirmations from Google engineers, we have implemented all three cost functions; the source code is available here. In the following, we provide a detailed description of the implementation of these cost functions.

Comparison with Google’s Plc_client

Testcase Method HPWL Cost
Density Cost Congestion Cost
Google's Ariane
Google 0.050186608 0.756401122 0.984565650
Our 0.050186604 0.756401122 0.984565675
Ariane-NanGate45
Google 0.387988658 0.500452106 2.448659090
Our 0.387988659 0.500452101 2.448659182

Table of Contents

Wirelength cost computation

The wirelength cost function depends on the net (bounding box) half-perimeter wirelength (HPWL). So, first we describe steps to compute HPWL of a net – and then we compute the wirelength cost.

Procedure to compute net HPWL
  1. Initialize xmin = floatmax, ymin = floatmax, xmax = 0, ymax = 0
  2. For each node in net
    1. xmin = min(xmin, node→x), ymin = min(ymin, node→y)
    2. xmax = max(xmax, node→x), ymax = max(ymax, node→y)
  3. nethpwl = (xmax - xmin) + (ymax - ymin)

A protobuf netlist consists of different types of nodes. Different possible types of nodes are macro, standard cell, macro pin and port. A net consists of one source node and one or more sink nodes. A net can have only standard cell, macro pin and port as its source or sink nodes. In the following wirelength cost computation procedure, we use the term net weight, which is the weight of the source node of the net. This weight indicates the total number of connections between the source and each sink node.

Procedure to compute wirelength cost
  1. hpwl = 0, netcount = 0
  2. For each net
    1. Compute nethpwl using the previous procedure
    2. hpwl += net→weight × nethpwl
    3. netcount += net→weight
  3. Costwirelength = hpwl ⁄ [netcount × (canvasheight + canvaswidth)]

In the above procedure, canvasheight is the height of the canvas and canvaswidth is the width of the canvas.

Density cost computation

Density cost function depends on the gridcell density. So, first we describe the steps to compute gridcell density – and then we compute the density cost.

The gridcell density of grid (i, j) is the ratio of the summation of all the overlapped areas (the common area between the node and the grid) of standard cell and macro nodes with the grid (i, j) to the total gridcell area.

Procedure to compute density cost
  1. n = number of rows × number of columns
  2. k = floor(n × 0.1)
  3. if k == 0
    1. k = 1
  4. Costdensity = (average density of top k densest gridcells) × 0.5

Notice that 0.5 is not the “weight” of this cost function, but simply another factor applied besides the weight factor from the cost function. Google engineers informed us “ the 0.5 is there to correct the bloating of the std cell clusters”.

Congestion cost computation

We divide the congestion cost computation into six sub-stages:

  1. Compute horizontal and vertical congestion of each grid due to net routing.
  2. Apply smoothing only to grid congestion due to net routing.
  3. Compute congestion of each grid due to macros.
  4. Grid horizontal congestion = horizontal congestion due to macros + horizontal congestion due to net routing after smoothing.
  5. Grid vertical congestion = vertical congestion due to macros + vertical congestion due to net routing after smoothing.
  6. Finally, we concatenate the Grid horizontal congestion array and the Grid vertical congestion array and take the average of the top 5% of the concatenated list.

Computation of grid congestion due to net routing

We first want to address that the following computation is “grid-based” (not to be confused with the conventional n-pin net) derived from gridding. The main differences are instead of looking at each pin location, we only look at grid cells subject to pin locations. This implies that if all net entities (source pin and sink pins) are within the same grid cell, no routing congestion will be computed (except for macro congestions). More formally, we define a n-grid net as a net whose pins occupy n different grids. We also define the grid occupied by the source pin of a net as the source grid of the net, and remaining grids occupied by other pins of the net as sink grids. In other words, if a three-pin net has a source pin in grid gi and two sink pins in the same grid gj, we would consider this as a two-grid net.

Given the above grid-base routing setting, we divide this problem into three sub-problems.

  1. Congestion due to two-grid nets.
  2. Congestion due to three-grid nets.
  3. Congestion due to multi-grid nets where the number of grids is greater than three.

A grid location (i, j) is the intersection of the ith column with the jth row.

For these three problems we consider that the horizontal routing cost due to a net-segment from (i, j) grid to (i+1, j) grid applies only to the grid (i, j). Similarly the vertical routing cost due to a net-segment from (i, j) grid to (i, j+1) grid applies only to the grid (i, j). Here the direction of the net does not matter.

Now we compute the congestion due to different nets:

Congestion due to two-grid nets

Two-grid net routing depends on the source and sink node. Consider

  1. Source node is (i1, j1)
  2. Sink node is (i2, j2)
Procedure for congestion computation due to two-grid nets
  1. imin = min(i1, i2), imax = max(i1, i2)
  2. w = netweight
  3. Add horizontal congestion cost (considering weight w) due this grid from (imin, j1) to (imax-1, j1).
  4. jmin = min(j1, j2), jmax = max(j1, j2)
  5. Add vertical congestion cost (considering weight w) due to this grid from (i2, jmin) to (i2, jmax - 1).

In the following figure P2 is the source grid and P1 is the sink grid of the net. When the arrow crosses the top edge of the grid cell it contributes to the vertical congestion cost of the grid cell and when it crosses the right edge of the grid cell it contributes to the horizontal congestion cost of the grid cell.

Congestion due to three-grid nets

The Congestion cost of three-grid nets does not change when the locations of the grids are interchanged.

In the following figure, P3 is the source and P1 and P2 are the sinks. We see that interchanging the position does not change the route.

Consider the three grid locations are (i1, j1), (i2, j2) and (i3, j3). We compute congestion due to three-grids using two functions:

  1. Lrouting
  2. Trouting

In the below function all congestion cost computation takes into account the weight.

First we describe these two functions and then we describe how the congestion due to three grid nets are computed.

Congestion cost update using Lrouting:

The inputs are three grid id and net weight. We consider the following grids are (i1, j1), (i2, j2) and (i3, j3) where i1 < i2 < i3 and (j1 < j2 < j3) or (j1 > j2 > j3).

  1. Add horizontal congestion cost due to grids from (i1, j1) to (i2-1, j1)
  2. Add horizontal congestion cost due to grids from (i2, j2) to (i3-1, j2)
  3. Add vertical congestion cost due to grids from (i2, min(j1, j2)) to (i2, max(j1, j2) - 1).
  4. Add vertical congestion cost due to grids from (i3, min(j2, j3)) to (i3, max(j2, j3) - 1).
Congestion cost update using Trouting:

The inputs are three grid id and net weight. We consider the following grids as (i1, j1), (i2, j2) and (i3, j3) where (j1 <= j2 <= j3 ) or (j1 >= j2 >= j3).

  1. imin = min(i1, i2, i3), imax = max(i1, i2, i3)
  2. Add horizontal congestion cost due to grids from (imin, j2) to (imax - 1, j2).
  3. Add vertical congestion cost due to grids from (i1, min(j1, j2)) to (i1, max(j1, j2) - 1).
  4. Add vertical congestion cost due to grids from (i3, min(j2, j3)) to (i3, max(j2, j3) - 1).
Procedure congestion cost computation due to three-grid nets:

The inputs are three grid locations and the net weight.

  1. Sort the grid based on the column. After sorting grid locations are (i1, j1), (i2, j2) and (i3, j3). As it is sorted based on column i1 <= i2 <= i3.
  2. If i1 < i2 and i2 < i3 and min(j1, j3) < j2 and max(j1, j3) > j2:
    1. Update congestion cost using Lrouting.
    2. Return.
  3. If i2 == i3 and i1 < i2 and j1 < min(j2, j3):
    1. Add horizontal congestion cost due to grids from (i1, j1) to (i2-1, j1)
    2. Add vertical congestion cost due to grids from (i2, j1) to (i2, max(j2, j3) -1)
    3. Return.
  4. If j2 == j3:
    1. Add horizontal congestion cost due to grids from (i1, j1) to (i2 -1, j1)
    2. Add horizontal congestion cost due to grids from (i2, j2) to (i3 -1, j2)
    3. Add vertical congestion cost due to grids from (i2, min(j1, j2)) to (i2, max(j1, j2) - 1).
    4. Return
  5. Update congestion cost using Trouting.

The following four figures represent the four cases mentioned in the above procedure from point two to point five.

Figure corresponding to point two.

Figure corresponding to point three.

Figure corresponding to point four.

Figure corresponding to point five.

Congestion due to multi-grid nets where the number of grids is greater than three

  1. Consider the net is a n-grid net where n > 3.
  2. We break this net using the star model into n-1 two-grid nets where the source grid is the common node.
  3. For each two-grid nets we update congestion values.

Computation for Smoothing:

  1. Congestion smoothing = 0.0
    1. Return the grid congestion that is due to net routing: no smoothing is applied.
  2. Congestion smoothing > 0.0 = k (k is an integer; both CT and our code appear to use the floor of any non-integer smoothing value)
    1. Take grid congestion due to net routing
    2. For horizontal grid congestion
      1. For each gridcell
        1. If not out-of-bound, take k gridcells on each side (left/right), divide the current cell entry by the total number of gridcells taken and add the value to the corresponding gridcell.
    3. For vertical grid congestion
      1. For each gridcell
        1. If not out-of-bound, take k gridcells on each side (up/down), divide the current cell entry by the total number of gridcells taken and add the value to the corresponding gridcell.
    4. For example, suppose that smoothing = 2 (default value), and we apply it to horizontal grid congestion in four rows of gridcells with respect to the red gridcell highlighted in each row. Then, the blue gridcells in each row show the numbers of gridcells that we divide by (respectively from the top row to the bottom row: 3, 4, 5, 4) when smoothing congestion.

Computation for Macro Congestion:

Macro congestion is induced by the location of hard macros over the grid cells. For each hard macro, we need to consider its dimension of overlapping over the grid cells and the macro routing resources given. The computation of macro congestion is quite straightforward. We just need to add the rout- ing resources blocked by the macros to the corresponding boundaries of the gridcells.

When a macro overlaps with multiple gridcells, if any part of the module partially overlaps with the grid cell (either vertically, or horizontally), we set the top row (if vertical) or right column (if horizontal) to 0. We define partially overlaps as when a hard macro does not fully cover a grid cell.

Vertical Partial Overlap is when in vertical direction, a macro (purple) is not entirely all covering the grid cells it overlaps with. Shown in the picture below. In this case, we set the macro congestion of grid cells from the top row (red) to 0.

Horizontal Partial Overlap is when in horizontal direction, a macro (purple) is not entirely all covering the grid cells it overlaps with. Shown in the picture below. In this case, we set the macro congestion of grid cells from the right column (red) to 0.

Note that these two situations are mutually inclusive.

Finally, we provide our computation steps below:

Computation of the final congestion cost: