Skip to content

synth: blackbox SYNTH_BLACKBOXES modules before hierarchy check - #4211

Closed
oharboe wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
oharboe:synth-blackboxes-for-parallel-partition
Closed

oharboe wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
oharboe:synth-blackboxes-for-parallel-partition

Conversation

@oharboe

@oharboe oharboe commented May 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds an optional SYNTH_BLACKBOXES env var that, when set, blackboxes the listed modules before hierarchy -check.

Intended for external orchestrators that drive parallel partition synthesis: every partition loads the same canonical RTLIL checkpoint, then blackboxes the modules that belong to other partitions so it only synthesises its own subhierarchy.

Names not present in the loaded design are skipped silently (catch {blackbox $m}), so the same list can be reused across all partitions without per-partition filtering. No behaviour change when the env var is unset.

This block is currently carried as a vendored modification of synth.tcl in bazel-orfs. Upstreaming it lets bazel-orfs drop the vendored copy and source flow/scripts/synth.tcl directly from ORFS.

Test plan

  • No behaviour change when SYNTH_BLACKBOXES is unset (the if block is skipped)
  • CI green

@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 introduces the SYNTH_BLACKBOXES environment variable to support parallel partition synthesis by blackboxing modules before the hierarchy check. Feedback points out that SYNTH_BLACKBOXES is already defined in variables.yaml, leading to a duplicate entry. Furthermore, the implementation in synth.tcl is inconsistent with synth_preamble.tcl regarding error handling and execution order relative to the hierarchy check, requiring alignment for consistent behavior.

Comment thread flow/scripts/variables.yaml Outdated
Comment on lines +986 to +996
SYNTH_BLACKBOXES:
description: |
Space-separated list of module names to blackbox before the hierarchy
check. Used by external orchestrators that drive parallel partition
synthesis: each partition loads the shared canonical RTLIL checkpoint
and blackboxes the modules that belong to other partitions, so it only
synthesises its own subhierarchy. Names not present in the loaded
design are skipped silently, so the same list can be reused across
partitions.
stages:
- synth

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.

high

The variable SYNTH_BLACKBOXES is already defined at line 251 of this file. Adding it again here creates a duplicate entry in the YAML configuration, which can lead to parsing errors or confusion. Please merge any improvements to the description into the existing definition at line 251 and remove this duplicate block.

Comment thread flow/scripts/synth.tcl
Comment on lines +47 to +51
if { [env_var_exists_and_non_empty SYNTH_BLACKBOXES] } {
foreach m $::env(SYNTH_BLACKBOXES) {
catch {blackbox $m}
}
}

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.

medium

The implementation of SYNTH_BLACKBOXES logic here is inconsistent with the implementation in flow/scripts/synth_preamble.tcl (lines 129-134).

  1. This block uses catch {blackbox $m} to silently skip missing modules, whereas synth_preamble.tcl calls blackbox $m directly, which would cause a Tcl error if a listed module is not found in the design.
  2. This block runs before hierarchy -check, while the one in synth_preamble.tcl runs after it.

To ensure consistent behavior between the source-based flow and the checkpoint-based flow, these implementations should be aligned. The "before" order and the use of catch are generally more robust for the intended use case of parallel partition synthesis where the list of modules might be shared across partitions.

Adds an optional SYNTH_BLACKBOXES env var that, when set, blackboxes
the listed modules before `hierarchy -check`.  Intended for external
orchestrators that drive parallel partition synthesis: every partition
loads the same canonical RTLIL checkpoint, then blackboxes the modules
that belong to other partitions so it only synthesises its own
subhierarchy.

Names not present in the loaded design are skipped silently, so the
same list can be reused across partitions without per-partition
filtering.

No behaviour change when the env var is unset.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
@oharboe
oharboe force-pushed the synth-blackboxes-for-parallel-partition branch from 970de8f to 6ccadbe Compare May 6, 2026 03:32
@oharboe

oharboe commented May 6, 2026

Copy link
Copy Markdown
Collaborator Author

Closing — after running the numbers on a real partition synth (8-slice ProcessingUnit, 46 partitions): the shared-canonicalize optimization that bazel-orfs is built around saves only ~5% total CPU and 0-2% wall time, because slang's --blackboxed-module already skips parsing of blackboxed modules at the source level. We're going to refactor bazel-orfs to run per-partition canonicalize via the standard ORFS flow, which makes this checkpoint-side SYNTH_BLACKBOXES handling unnecessary. Apologies for the noise.

@oharboe oharboe closed this May 6, 2026
@oharboe

oharboe commented May 6, 2026

Copy link
Copy Markdown
Collaborator Author

Reopening — measured the cost on a real partition synth (8-slice ProcessingUnit, 46 partitions; data in the previous comment). Per-partition canonicalize from a bare top doesn't actually work without a brittle rename pass: slang elaborates parameterized modules to mangled names like Foo$Path.To.Inst and the parent design references those mangled names, so a fresh-top elaboration produces Foo and links don't match. The shared canonicalize is doing semantic work, not just bookkeeping.

Also addressed Gemini's consistency feedback by aligning the existing synth_preamble.tcl verilog-frontend path: it now uses catch (matching the slang and new synth.tcl paths) and blackboxes before hierarchy -check -top (matching the new synth.tcl path).

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