Skip to content

lutpack: warn when the installed LUT library is narrower than the network - #557

Open
marcelwa wants to merge 1 commit into
berkeley-abc:masterfrom
marcelwa:u8-lutpack-default-k
Open

lutpack: warn when the installed LUT library is narrower than the network#557
marcelwa wants to merge 1 commit into
berkeley-abc:masterfrom
marcelwa:u8-lutpack-default-k

Conversation

@marcelwa

@marcelwa marcelwa commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

lutpack's own usage text says it "determines LUT size as the max fanin count of a node", but Lpk_Resynthesize only does that in the else branch, when no LUT library is installed, and If_Init() installs a 4-input library at start-up and nothing removes it — so in a normal session the fallback is unreachable and plain lutpack always packs for 4 inputs, which on a 6-LUT netlist is close to a no-op. On EPFL mem_ctrl mapped with strash; if -K 6, lutpack alone goes 12104 -> 12069 nodes, while the same command after read_lut of a 6-input library goes 12104 -> 11494; across 31 benchmarks the stock default changed the LUT count on 2 of 31 fresh mappings, against 15 of 31 and geomean -2.39% (Wilcoxon p = 6.2e-4) when the width is set to 6, and it regressed neither LUT count nor levels anywhere. So the question is whether the 4-input default is intended — plausibly it is, as a legacy of the 4-LUT era, in which case the usage text is what is out of date. This patch is the smallest thing we could think of that makes the mismatch visible: one warning when the installed library is narrower than the network's max fanin count, no change to any result. The alternative we considered and did not propose is defaulting the width to the network's max fanin count, which is what the usage text already promises but would change everybody's numbers; if you would rather have that, or a line in the help text instead, we are happy to redo it. This is orthogonal to #542 — that one is about lutpack producing a non-equivalent netlist, and this change only prints.

…work

`Lpk_Resynthesize` takes the LUT width from `Abc_FrameReadLibLut()` when a
library is installed, and falls back to the network's max fanin count only when
none is.  `If_Init()` installs a 4-input library at start-up and never removes
it, so the fallback is unreachable in practice and plain `lutpack` packs a
6-LUT netlist for 4 inputs, which barely moves it.  On EPFL mem_ctrl mapped
with `if -K 6`, `lutpack` alone goes 12104 -> 12069 nodes; after `read_lut` of
a 6-input library it goes 12104 -> 11494.

Print a warning when the library width is below the network's max fanin count,
so the mismatch is at least visible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant