multithread find_merge_pairs
This commit is contained in:
parent
e68051ccc6
commit
0adb5e6cf8
@ -4,6 +4,7 @@ Main connectivity-checking functionality for `snarled`
|
||||
from typing import Tuple, List, Dict, Set, Optional, Union, Sequence, Mapping, Callable
|
||||
from collections import defaultdict
|
||||
from pprint import pformat
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
import logging
|
||||
|
||||
import numpy
|
||||
@ -308,6 +309,8 @@ def find_merge_pairs(
|
||||
logger.warning(f'No vias between layers {top_layer}, {bot_layer}')
|
||||
return merge_pairs
|
||||
|
||||
tested_pairs = set()
|
||||
with ThreadPoolExecutor() as executor:
|
||||
for top_name in nets.keys():
|
||||
top_polys = nets[top_name][top_layer]
|
||||
if not top_polys:
|
||||
@ -318,13 +321,30 @@ def find_merge_pairs(
|
||||
continue
|
||||
|
||||
name_pair: Tuple[NetName, NetName] = tuple(sorted((top_name, bot_name))) #type: ignore
|
||||
if name_pair in merge_pairs:
|
||||
if name_pair in tested_pairs:
|
||||
continue
|
||||
tested_pairs.add(name_pair)
|
||||
|
||||
bot_polys = nets[bot_name][bot_layer]
|
||||
if not bot_polys:
|
||||
continue
|
||||
|
||||
executor.submit(check_overlap, top_polys, via_polys, bot_polys, clipper_scale_factor,
|
||||
lambda np=name_pair: merge_pairs.add(np))
|
||||
|
||||
return merge_pairs
|
||||
|
||||
|
||||
def check_overlap(
|
||||
top_polys: Sequence[contour_t],
|
||||
via_polys: Optional[Sequence[NDArray[numpy.float64]]],
|
||||
bot_polys: Sequence[contour_t],
|
||||
clipper_scale_factor: int,
|
||||
action: Callable[[], None],
|
||||
) -> None:
|
||||
"""
|
||||
Check for interaction between top and bottom polys, mediated by via polys if present.
|
||||
"""
|
||||
if via_polys is not None:
|
||||
top_bot = intersection_evenodd(top_polys, bot_polys)
|
||||
descaled = scale_from_clipper(top_bot, clipper_scale_factor)
|
||||
@ -333,12 +353,12 @@ def find_merge_pairs(
|
||||
# via_polys = difference_evenodd(via_polys, overlap) # reduce set of via polys for future nets
|
||||
else:
|
||||
# overlap = intersection_evenodd(top_polys, bot_polys) # TODO verify there aren't any suspicious corner cases for this
|
||||
overlap = check_any_intersection(scale_from_clipper(top_polys, clipper_scale_factor), scale_from_clipper(bot_polys, clipper_scale_factor))
|
||||
overlap = check_any_intersection(
|
||||
scale_from_clipper(top_polys, clipper_scale_factor),
|
||||
scale_from_clipper(bot_polys, clipper_scale_factor))
|
||||
|
||||
if overlap:
|
||||
merge_pairs.add(name_pair)
|
||||
|
||||
return merge_pairs
|
||||
action()
|
||||
|
||||
|
||||
def check_any_intersection(polys_a, polys_b) -> bool:
|
||||
|
Loading…
Reference in New Issue
Block a user