3.1. Data-Parallel Computation Framework
To achieve efficient parallel polygon Boolean operations, we propose a novel algorithm using the divide-and-conquer strategy. The layouts are partitioned into smaller grids that are more tractable to be processed concurrently on different threads. As depicted in
Figure 5, the new algorithm comprises three key phases: build spatial index, clip and Boolean operations, and merge grids.
The building spatial index phase establishes the containing relationship between grids and polygons. The layout is first divided into equally sized grids. Then, the algorithm traverses all polygons and checks the spatial relationships between polygons’ minimum bounding boxes and grids. Cross-grid polygons are registered in all overlapping grids, while polygons fully contained within a grid and polygon crossing grids are indexed separately in different arrays (see
Figure 6). This process employs a layer-wise parallelization: different IC layout layers are processed concurrently by independent threads.
In the clipping and Boolean operation phase, polygons crossing the grids are first clipped by grid boundaries using the AND operation. Our approach fundamentally differs from Kullberg’s layer-wise implementation [
14] because we adopted grid-wise parallelization for clipping, enabling better thread scalability. Then, Boolean operations are performed on clipped polygons and polygons within grids. The clipping and Boolean operations utilize Boost.Polygon [
6], which defines polygons as 2-d functions and treats polygon Boolean operations as the calculus of these functions. Boost.Polygon can process many-to-many Boolean operations in a single pass with
time complexity, where n is the number of edges and k is the number of intersections. It also demonstrates industrial strength for correctly handling arbitrary input polygons without preprocessing, including self-intersecting, self-overlapping, and hole-containing polygons.
The grid-merging phase combines results from all grids to eliminate overlapping edges at grid boundaries and produce final outputs. A typical way to implement merging is using generic OR operations as in [
14]. However, this approach incurs unacceptable runtime when cross-grid polygons are numerous, as generic Boolean OR treats all edges as new inputs, ignoring prior computations. It reprocesses all edges, even if most of them remain unchanged. According to Amdahl’s Law, the parallel speedup of an algorithm is limited by its serial fraction. Our test reveals that grid merging using generic OR occupies over 50% of total runtime for OR/XOR operations and over 16% for NOT operations. To overcome this limitation, we developed a novel merge algorithm that drastically improves merging efficiency, which will be elaborated in the following section.
3.2. Novel Merge Algorithm
The inefficiency of generic-OR-based merging stems from redundant operations for non-boundary edges. After Boolean operations, polygons within grids have no overlaps, and only edges along grid boundaries require further modification. To theoretically prove that edge modifications during merging can be restricted solely to the grid boundaries without affecting the correctness of the result, we establish the following two lemmas, proven using winding number theory.
In the following text, polygons are represented by sets of vertices in counterclockwise order, while holes are represented by sets of vertices in clockwise order. All edges are directed, defined by initial vertices and terminal vertices. The merging algorithm is described only for vertical boundaries, as the process for horizontal boundaries follows the same principle.
Consider two adjacent grids: (left grid, ) and (right grid, ), sharing a common boundary L defined as . Each grid contains a set of non-overlapping polygons: in and in . The polygons’ boundaries do not cross L because they have been clipped. We define merged polygons M as the union of all polygons in and , with boundary .
Lemma 1.
Edges not on L remain unchanged after merging.
Proof of Lemma 1. The winding number
of a point
p with respect to a closed path
measures the number of times the path encircles
p. For a polygon
P with counterclockwise orientation,
if
p is inside
P, and 0 otherwise. For a hole
H with clockwise orientation,
if
p is inside the hole. For the merged region, the winding number is:
Consider a point
with
, away from
L. Since all boundaries of polygons in
lie in
, they cannot encircle
p, so
for all
. Thus:
So, the winding number distribution inside depends only on and is not affected by . Edges in , where the winding number transitions, remain unchanged in . An analogous argument applies to edges in with . Thus, edges not on L remain unchanged in . □
Lemma 2.
Edges on L are replaced by their XOR operation results after merging.
Proof of Lemma 2. Define as the set of edges on L from , and the set of edges on L from . For a point , we analyze its neighborhood by considering points on either side: (left, ) and (right, ), where is small.
If , for (), since , is inside a , so . For (), since , is inside a , so . Thus, in the neighborhood, indicating q is an interior point of M, not on .
If , for (), implies is inside a , so . For (), , and no polygon cover , . The left side is inside M, and the right side is outside, so .
If , for (), , so . For (), implies is inside a , so . The right side is inside M, and the left side is outside, so .
Thus, , which is the symmetric difference (XOR) result of the edges on L from both grids. □
An example depicting the two lemmas is shown in
Figure 7. Based on these lemmas, we develop a novel merge algorithm that exclusively processes boundary edges through incremental computation. Compared to computationally demanding generic Boolean OR, our method replaced complex 2-d operations for all edges with tractable 1-d operations for only boundary edges. The correctness of the underlying parallel framework—comprising spatial partitioning, clipping, local Boolean operations, and merging—has been established in [
14]. The proposed algorithm inherits this proven framework but replaces the computationally expensive generic OR merging with a novel boundary-based incremental approach. Lemmas 1 and 2 prove that updating edges on grid boundaries can produce the same result as generic Boolean OR. Consequently, the global correctness of the proposed algorithm is guaranteed by the correctness of the framework in [
14] and the equivalence proved herein.
The algorithm traverses all edges to identify edges along the shared grid boundary. For each boundary edge, we record its initial vertex, terminal vertex, and the successive boundary vertex, defined as the initial vertex of the next boundary edge in the same polygon, as depicted in
Figure 8. These successive boundary vertices indicate topological connections among boundary vertices, which are needed in subsequent procedures.
With the boundary edges identified, the algorithm performs an XOR operation on these edges using a sweep-line algorithm adapted from [
16,
17]. We first sort all edge vertices by ascending y-coordinates and then sweep them from bottom to top to detect non-overlapping parts of the edges to generate edges in the XOR operation result. This XOR procedure is detailed in Algorithm 1.
After determining the remaining edges on the boundary using the XOR operation, they must be connected to non-boundary edges to form the resulting polygons. We introduce boundary vertex arrays that contain the boundary vertices of each polygon in geometric order to help construct the resulting polygons. The arrays are constructed using the following rules: an initial vertex of an edge in
(e.g.,
L,
F in
Figure 7) connects to its terminal vertex; an initial vertex absent from
(e.g.,
B,
P in
Figure 7) connects to its counterpart in the adjacent grid, which is next to it in the ordered
and can be easily found; and a terminal vertex (e.g.,
I,
M in
Figure 7) links to its successive boundary vertex.
| Algorithm 1 Edge XOR. |
- 1:
Input: Boundary edges from left grid , boundary edges from right grid - 2:
Output: Edges after XOR operation , binary search tree - 3:
Sort all vertices in and in ascending y-coordinates and save them in . - 4:
- 5:
for each vertex in do - 6:
y-coordinate of current vertex - 7:
if current vertex is an initial vertex from then - 8:
- 9:
else if current vertex is a terminal vertex from then - 10:
- 11:
else if current vertex is an initial vertex from then - 12:
- 13:
else if current vertex is a terminal vertex from then - 14:
- 15:
end if - 16:
if current vertex is last vertex or y-coordinate of next vertex then - 17:
- 18:
if then - 19:
- 20:
if then - 21:
new edge in - 22:
if current vertex comes from then - 23:
Set initial vertex of as current vertex - 24:
else - 25:
Set terminal vertex of as current vertex - 26:
end if - 27:
else - 28:
Set undetermined vertex of as current vertex - 29:
end if - 30:
end if - 31:
end if - 32:
end for
|
Each boundary vertex array represents a polygonal boundary. If the first vertex of an array is an initial vertex from
or a terminal vertex from
, the array represents a counterclockwise boundary (a polygon); otherwise, it represents a clockwise boundary (a hole). Our algorithm provides two ways to represent polygons with holes—storing holes independently or as self-contacting polygons, offering flexibility for various EDA applications (see
Figure 9). For the self-contacting polygon approach, hole arrays are embedded into the polygon array at the hole array’s first vertex and the highest vertex below it in the polygon array. Since only boundary vertices are processed instead of all vertices, boundary vertex arrays are efficient for large polygons with complex holes. Algorithm 2 formalizes the construction process of boundary vertex arrays.
With boundary vertex arrays constructed via Algorithm 2, the final merged polygons are generated by traversing the boundary vertex arrays in . For each vertex, if its next vertex in the array is its successive boundary vertex, the algorithm retrieves their positions in the input polygon’s vertex array using their pointers and copies the intervening path into the merged polygon. Otherwise, the vertex is directly included.
To illustrate the merge algorithm, consider the case in
Figure 7. The algorithm begins by identifying boundary edges
,
from
and
,
from
, with terminal vertices
C,
G,
M,
I and successive boundary vertices
F,
B,
P,
L, respectively. Applying XOR operations on these boundary edges yields
and
. Subsequent vertex sorting produces the sequence
. Starting traversal from the first vertex
B generates the initial boundary vertex array
, counterclockwise (as
B is an initial vertex from
), denoting an external polygon boundary. Tracing from
C, the remaining lowest vertex, yields
, clockwise (as
C is a termial vertex from
), representing a hole. For independent storage,
is saved separately. For self-contacting polygons,
is embedded into
at
C and
B (the highest vertex in
lower than
C), forming
. Final polygon generation directly extracts intermediate vertices between two boundary vertices from input polygons, such as
between
I and
L in the right side polygon, producing the external boundary
and hole
, or the self-contacting polygon
.
| Algorithm 2 Generating boundary vertex arrays. |
- 1:
Input: , , , , flag - 2:
Output: Set of boundary vertex arrays - 3:
Initialize empty set - 4:
while is not empty do - 5:
Initialize empty array - 6:
first vertex in - 7:
while is empty or do - 8:
Append to - 9:
if is an initial vertex then - 10:
if is a vertex of an edge then - 11:
terminal vertex of the edge - 12:
else - 13:
corresponding vertex of in the adjacent grid - 14:
end if - 15:
else if is a terminal vertex then - 16:
successive boundary vertex of - 17:
end if - 18:
Delete from - 19:
end while - 20:
if composes a counterclockwise boundary then - 21:
Append to as an exterior boundary - 22:
else if then - 23:
Append to as a hole - 24:
else - 25:
Embed into last array in - 26:
end if - 27:
end while
|
3.3. Complexity Analysis
The complexity of the merge algorithm for two grids is analyzed, then extended to the parallel polygon Boolean algorithm. Let n be the total polygon edges across two grids, and m the edges on the shared boundary. The key steps for pairwise merging are:
Searching boundary edges has a time complexity of and a space complexity of . The XOR operation, dominated by sorting boundary vertices, has a time complexity of and a space complexity of . Generating boundary vertex arrays has a time complexity of and a space complexity of since it traverses boundary vertices and operates a binary search tree. Polygon generation, traversing all vertices in polygons with edges on the grid boundary, has a time complexity of and a space complexity of . Thus, the total time complexity is , and the space complexity is . Since the condition generally holds in the context of integrated circuit layout processing, the time complexity is approximately linear, . This assumption is grounded in both geometric characteristics and empirical data. With grid sizes on the order of 100 µm, the grid dimensions significantly exceed the deep submicron technology nodes (<100 nm) of modern IC layouts, where a linear scale difference of approximately times (and thus times the area) results in a sparse grid structure. Consequently, the edges within grids significantly outnumber those along boundaries, ensuring . To validate this empirically, we performed statistical analysis on the industrial layouts used in our experiments. The results indicate that with a 100 µm grid size, the number of edges on grid boundaries constitutes less than 1% of the total edge count across all layouts. This quantitative evidence ensures the algorithm’s near-linear performance in practical scenarios. In contrast, the time complexity of merging with a generic Boolean OR operation is , less efficient for large n.
Assume there are n edges, k intersections, grid partitions, and p threads. Grid indexing, which traverses all polygons, yields a time complexity of and a space complexity of . Clipping and Boolean operations have a time complexity of and a space complexity of .
The current merging strategy performs row-wise merging followed by column-wise merging. Although there exist other merging strategies, such as tree-based merging in [
18], we chose the current approach due to its simplicity in implementation. The merging step has a space complexity of
. Assuming linear time complexity for pairwise grid merging, if all polygons span at most two grids, the time complexity is
. In the worst case, with a single polygon spanning all grids, the time complexity is
, derived as follows:
For a participation with
a rows and
b columns as shown in
Figure 10, the polygons after the Boolean operation contain at most
edges. Assume the edges are evenly distributed, with each grid containing
edges. The initial step of row merging involves
edges, and the subsequent steps involve progressively
to
edges as illustrated in
Figure 11. So, in total,
edges are processed, leading to
time complexity. Processing all rows results in
time complexity. For the column merging illustrated in
Figure 12, each merging step processes progressively
,
to
edges, totally taking
edges, resulting in
time complexity. Combining the results above, the worst-case time complexity is
. Applying generic Boolean OR to merge grids yields
complexity, where the logarithmic term degrades performance for IC layouts with billions of polygons, as seen in Kullberg’s approach [
14].
Combining all three phases, the parallel algorithm’s time complexity is typically and escalates to in worst-case scenarios where polygons span all grids. The space complexity is .