performance bottleneck
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 91 KiB |
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 120 KiB |
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 89 KiB |
|
Before Width: | Height: | Size: 130 KiB After Width: | Height: | Size: 303 KiB |
|
|
@ -1,11 +1,12 @@
|
|||
import numpy as np
|
||||
import time
|
||||
from inire.geometry.collision import CollisionEngine
|
||||
from inire.geometry.primitives import Port
|
||||
from inire.router.astar import AStarRouter
|
||||
from inire.router.cost import CostEvaluator
|
||||
from inire.router.danger_map import DangerMap
|
||||
from inire.router.pathfinder import PathFinder
|
||||
from inire.utils.visualization import plot_routing_results
|
||||
from inire.utils.visualization import plot_routing_results, plot_danger_map, plot_expanded_nodes
|
||||
from shapely.geometry import box
|
||||
|
||||
def main() -> None:
|
||||
|
|
@ -28,8 +29,8 @@ def main() -> None:
|
|||
|
||||
evaluator = CostEvaluator(engine, danger_map, greedy_h_weight=1.5)
|
||||
|
||||
router = AStarRouter(evaluator, node_limit=50000, snap_size=5.0)
|
||||
pf = PathFinder(router, evaluator, max_iterations=10)
|
||||
router = AStarRouter(evaluator, node_limit=5000, snap_size=10.0)
|
||||
pf = PathFinder(router, evaluator, max_iterations=20, base_congestion_penalty=500.0)
|
||||
|
||||
# 2. Define Netlist
|
||||
netlist = {}
|
||||
|
|
@ -48,16 +49,51 @@ def main() -> None:
|
|||
|
||||
net_widths = {nid: 2.0 for nid in netlist}
|
||||
|
||||
def iteration_callback(idx, current_results):
|
||||
print(f" Iteration {idx} finished. Successes: {sum(1 for r in current_results.values() if r.is_valid)}/{len(netlist)}")
|
||||
# fig, ax = plot_routing_results(current_results, obstacles, bounds, netlist=netlist)
|
||||
# plot_danger_map(danger_map, ax=ax)
|
||||
# fig.savefig(f"examples/07_iteration_{idx:02d}.png")
|
||||
# import matplotlib.pyplot as plt
|
||||
# plt.close(fig)
|
||||
|
||||
# 3. Route
|
||||
print(f"Routing {len(netlist)} nets through 200um bottleneck...")
|
||||
results = pf.route_all(netlist, net_widths)
|
||||
import cProfile, pstats
|
||||
profiler = cProfile.Profile()
|
||||
profiler.enable()
|
||||
t0 = time.perf_counter()
|
||||
results = pf.route_all(netlist, net_widths, store_expanded=True, iteration_callback=iteration_callback)
|
||||
t1 = time.perf_counter()
|
||||
profiler.disable()
|
||||
stats = pstats.Stats(profiler).sort_stats('tottime')
|
||||
stats.print_stats(20)
|
||||
print(f"Routing took {t1-t0:.4f}s")
|
||||
|
||||
# 4. Check Results
|
||||
success_count = sum(1 for res in results.values() if res.is_valid)
|
||||
print(f"Routed {success_count}/{len(netlist)} nets successfully.")
|
||||
|
||||
for nid, res in results.items():
|
||||
if not res.is_valid:
|
||||
print(f" FAILED: {nid}")
|
||||
else:
|
||||
types = [move.move_type for move in res.path]
|
||||
from collections import Counter
|
||||
counts = Counter(types)
|
||||
print(f" {nid}: {len(res.path)} segments, {dict(counts)}")
|
||||
|
||||
# 5. Visualize
|
||||
fig, ax = plot_routing_results(results, obstacles, bounds, netlist=netlist)
|
||||
|
||||
# Overlay Danger Map
|
||||
plot_danger_map(danger_map, ax=ax)
|
||||
|
||||
# Overlay Expanded Nodes from last routed net (as an example)
|
||||
if pf.router.last_expanded_nodes:
|
||||
print(f"Plotting {len(pf.router.last_expanded_nodes)} expanded nodes for the last net...")
|
||||
plot_expanded_nodes(pf.router.last_expanded_nodes, ax=ax, color='blue', alpha=0.1)
|
||||
|
||||
fig.savefig("examples/07_large_scale_routing.png")
|
||||
print("Saved plot to examples/07_large_scale_routing.png")
|
||||
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 122 KiB After Width: | Height: | Size: 88 KiB |
|
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 52 KiB |