Skip to content

synth: no SYNTH_KEEP_MODULES name check in a partition - #4770

Open
oharboe wants to merge 3 commits into
The-OpenROAD-Project:masterfrom
oharboe:synth-keep-modules-partition
Open

oharboe wants to merge 3 commits into
The-OpenROAD-Project:masterfrom
oharboe:synth-keep-modules-partition

Conversation

@oharboe

@oharboe oharboe commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Since #4745, a partition of a parallel synthesis stops at its first kept module that sits in another partition:

ERROR: TCL interpreter returned an error: SYNTH_KEEP_MODULES: no module counter in the design

A partition run (SYNTH_CHECKPOINT set, one run per partition, driven by an external orchestrator) reads a checkpoint that holds only its own portion of the design. The kept modules of the other partitions are not in it: blackboxed, or, for a kept module that is an ancestor of another, absent from the child's slice. So the check from #4745 has to skip them there.

  • synth: no SYNTH_KEEP_MODULES name check in a partition: the check runs only when the whole design is synthesised. In that case a name that selects no module is still a typo and still stops synthesis.
  • synth: a partition is told by SYNTH_CHECKPOINT, not SYNTH_BLACKBOXES: SYNTH_BLACKBOXES is also set in single-design runs (asap7/aes top, asap7/uart), where the check must run; and a partition synthesised from its own slice does not set it. variables.yaml says where the check applies.

Tested in bazel-orfs, whose parallel synthesis is such an orchestrator: The-OpenROAD-Project/bazel-orfs#1534 carries this change and adds a seconds-long test of nested kept modules in one partition, which stops with no module nested_inner without the change and with the SYNTH_BLACKBOXES gate. tclfmt and tclint 0.7.0 are clean; variables.json and FlowVariables.md regenerated.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies the synthesis script flow/scripts/synth.tcl to avoid throwing an error when a module specified in SYNTH_KEEP_MODULES is not found, as long as SYNTH_BLACKBOXES is defined. The feedback highlights that if the module is missing, the script still attempts to run setattr on an empty selection, which could lead to unintended behavior in Yosys. It is recommended to guard the setattr command so that it only runs when the module is actually found.

Comment thread flow/scripts/synth.tcl Resolved
A partition of a parallel synthesis (SYNTH_BLACKBOXES set, one run per
partition driven by an external orchestrator) loads only its own
portion of the design; the kept modules of the other partitions are
not in it. The check added in The-OpenROAD-Project#4745, that every SYNTH_KEEP_MODULES name
selects a module, therefore stops such a partition with
"SYNTH_KEEP_MODULES: no module <name> in the design".

The check now runs only when the whole design is synthesised, where a
name that matches nothing is a typo; in a partition a missing name is
expected, as it already is for SYNTH_BLACKBOXES.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
@oharboe
oharboe force-pushed the synth-keep-modules-partition branch from 7fb9cb3 to 48126f2 Compare October 30, 2026 06:01
@openroad-ci

openroad-ci commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

🔍 QoR check

Metrics reflect the PR merge build — i.e. what will land on the target branch.

Commit 35cc46a · Jenkins build #5 · Baseline: build · View build on dashboard

62 design(s) checked — 0 with regression(s), 0 without a comparable baseline.

@oharboe
oharboe marked this pull request as ready for review November 2, 2026 17:15
@oharboe
oharboe requested a review from maliberty November 2, 2026 17:15
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>

@maliberty maliberty left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bug is real: each bazel-orfs partition loads its own per-module RTLIL slice, so a check against the whole design can't pass there. My main concern is the flag used to detect a partition (see the inline comment).

Two more points:

  • variables.yaml: SYNTH_KEEP_MODULES still says "A name that matches no module of the design stops synthesis." It should say this applies only when the whole design is synthesized, not in a partition.
  • Question: partition mode always runs synth -flatten. In a partition, the other kept modules are already blackboxes and the partition's own top is never flattened, so setattr keep_hierarchy may do nothing there. If so, bazel-orfs could simply not pass SYNTH_KEEP_MODULES to partitions, and synth.tcl would need no change. Is there a case where the attribute matters in a partition?

Comment thread flow/scripts/synth.tcl Outdated
# partition is not loaded: the selection is empty and setattr below
# marks nothing.
if {
![env_var_exists_and_non_empty SYNTH_BLACKBOXES]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SYNTH_BLACKBOXES isn't a partition-only flag. variables.yaml documents it as a general option ("List of cells treated as a black box by Yosys"), and asap7/aes (FLOW_VARIANT=top) and asap7/uart set it in ordinary single-design make runs. In those runs this condition turns the typo check off without any warning, which is what TclContract.md rules out ("A script never trades an explicit variable for a clever one").

SYNTH_CHECKPOINT is the variable that actually means "partition". variables.yaml says it is for parallel synthesis and should be left unset in the normal flow, synth.tcl already uses it further down to pick the "Partition mode" branches, and all three partition calls in bazel-orfs synth_partition.sh set it:

Suggested change
![env_var_exists_and_non_empty SYNTH_BLACKBOXES]
![env_var_exists_and_non_empty SYNTH_CHECKPOINT]

(bazel-orfs patch 0168 would need the same change.)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in f24a00e: gated on SYNTH_CHECKPOINT. bazel-orfs 0168 already had this gate; with the SYNTH_BLACKBOXES gate a grouped pinned partition (no SYNTH_BLACKBOXES) still stopped, see the test in The-OpenROAD-Project/bazel-orfs#1534.

Comment thread flow/scripts/synth.tcl Outdated
Comment on lines +91 to +93
# In a partition (SYNTH_BLACKBOXES set) a kept module of another
# partition is not loaded: the selection is empty and setattr below
# marks nothing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the gate changed, this comment should say SYNTH_CHECKPOINT instead. Also, the other partitions' kept modules may be missing from the per-module slice entirely, not only unloaded, so maybe "is not in this partition's checkpoint".

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in f24a00e: "In a partition (SYNTH_CHECKPOINT set) a kept module of another partition is not in this partition's checkpoint".

SYNTH_BLACKBOXES is a general option: asap7/aes (FLOW_VARIANT=top) and
asap7/uart set it in single-design runs, and keying the
SYNTH_KEEP_MODULES name check on it turned the check off there without
a word. It also missed a partition synthesised from a per-module slice
without SYNTH_BLACKBOXES: a kept module that is an ancestor of another
is not in the child's slice at all, so the check still stopped it.

SYNTH_CHECKPOINT is what synth.tcl already reads as "partition mode"
further down, and every partition of a parallel synthesis sets it. The
check now runs whenever it is unset. variables.yaml says where the
check applies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
@oharboe

oharboe commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author

variables.yaml: done in f24a00e (variables.json and FlowVariables.md regenerated).

On the question: the attribute matters in a partition. bazel-orfs fixtures, partitions run with and without SYNTH_KEEP_MODULES, merged 1_2_yosys.v, top module:

fixture with SYNTH_KEEP_MODULES without
adder, counter kept, one partition each 0 std cells, instances u_adder, u_counter 47 std cells, adder flattened in, u_counter only
nested_outer kept containing kept nested_inner, one partition 32 std cells, instance u_outer 98 std cells, both flattened in

The top partition does not blackbox every kept module, and setattr keep_hierarchy is what stops synth -flatten there. So bazel-orfs keeps passing SYNTH_KEEP_MODULES to partitions, and synth.tcl needs the gate.

@oharboe
oharboe requested a review from maliberty November 6, 2026 05:57
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.

3 participants