mirror of
https://github.com/YosysHQ/yosys
synced 2026-07-19 05:35:47 +00:00
autoname: avoid O(iterations x module size) full rescan
AutonamePass rescanned every selected cell/wire from scratch on every iteration, and naming only propagates one hop per iteration, so cost scaled with O(iterations x module_size). On a large, fully flattened netlist with long dependency chains this meant multi-hour runtime and 40+ GB RSS. Likely the same issue as #5394, #4509 and #2816. Replace the full-rescan loop with a ModuleAutonamer that keeps a persistent worklist and only recomputes an object's proposal when a direct neighbor was just renamed, using precomputed adjacency. Same round-by-round batching as before, so the final naming is unchanged. Adds tests/various/autoname_scaling.sh, which checks a 10000-cell propagation chain still autonames within a time budget the old algorithm could not meet.
This commit is contained in:
parent
aa18c921a7
commit
f2d648e499
2 changed files with 314 additions and 79 deletions
51
tests/various/autoname_scaling.sh
Executable file
51
tests/various/autoname_scaling.sh
Executable file
|
|
@ -0,0 +1,51 @@
|
|||
#!/usr/bin/env bash
|
||||
# Regression test for the incremental worklist rewrite of autoname_worker
|
||||
# ("autoname: avoid O(iterations x module size) full rescan").
|
||||
#
|
||||
# Before that change, AutonamePass::execute() rescanned every selected
|
||||
# cell's every connection on every round. Naming only propagates one hop
|
||||
# per round, so a design containing a long public-name-to-public-name
|
||||
# propagation chain of length N needed O(N) rounds, each doing an O(N)
|
||||
# rescan: O(N^2) total. This builds such a chain and checks that autoname
|
||||
# finishes within a time budget the old O(N^2) algorithm could not meet
|
||||
# (it took tens of seconds at this size; the fixed algorithm takes low
|
||||
# single-digit seconds), without pinning an exact runtime, which would be
|
||||
# too flaky across machines.
|
||||
|
||||
set -e
|
||||
|
||||
if ! which timeout > /dev/null; then
|
||||
echo "No 'timeout', skipping test"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
n=10000
|
||||
il=autoname_scaling.il
|
||||
trap 'rm -f $il' EXIT
|
||||
|
||||
{
|
||||
echo 'module \top'
|
||||
echo ' wire input 1 \a'
|
||||
for i in $(seq 0 $((n-1))); do
|
||||
echo " wire \$w$i"
|
||||
done
|
||||
prev='\a'
|
||||
for i in $(seq 0 $((n-1))); do
|
||||
echo " cell \$not \$c$i"
|
||||
echo ' parameter \A_SIGNED 0'
|
||||
echo ' parameter \A_WIDTH 1'
|
||||
echo ' parameter \Y_WIDTH 1'
|
||||
echo " connect \\A $prev"
|
||||
echo " connect \\Y \$w$i"
|
||||
echo ' end'
|
||||
prev="\$w$i"
|
||||
done
|
||||
echo 'end'
|
||||
} > $il
|
||||
|
||||
if ! timeout 20 ${YOSYS} -q -p "read_rtlil $il; autoname" ; then
|
||||
echo "autoname did not finish a $n-long propagation chain within the time" \
|
||||
"budget -- looks like the O(iterations x module size) full-rescan" \
|
||||
"behaviour is back"
|
||||
exit 1
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue