Skip to content

ord: register Tech for Python global APIs#10919

Open
naveenvenk17 wants to merge 3 commits into
The-OpenROAD-Project:masterfrom
naveenvenk17:nv-bazel-python-runfiles
Open

ord: register Tech for Python global APIs#10919
naveenvenk17 wants to merge 3 commits into
The-OpenROAD-Project:masterfrom
naveenvenk17:nv-bazel-python-runfiles

Conversation

@naveenvenk17

Copy link
Copy Markdown
Contributor

Direct Python users can construct a Tech object and then call module-level APIs such as set_thread_count(). Those APIs use the process-wide OpenROAD instance, but Tech did not register the instance it owns. The result was a null dereference.

The DRT AES Python target also did not carry the OpenROAD Python runfiles, so it failed at import time and never reached this crash.

This change registers the Tech instance during construction and clears it during destruction when it is still active. It adds a small lifecycle regression and moves the AES target through the standard Python regression macro.

VM testing:

  • focused lifecycle test and four neighboring DRT Python API tests
  • full AES placement, global routing, and detailed routing test
  • relevant Bazel lint build and buildifier checks
  • the lifecycle and full AES tests under ASan on top of bazel: fix hermetic ASan builds #10911

The normal AES run completed in 132 seconds. The ASan run completed in 946 seconds with leak detection disabled.

Signed-off-by: Naveen Venkat <archgen.guest@nyayanidhi.in>
@naveenvenk17
naveenvenk17 requested review from a team as code owners July 15, 2026 10:23
@naveenvenk17
naveenvenk17 requested a review from maliberty July 15, 2026 10:23

@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 a new regression test tech_lifecycle to verify the lifecycle and thread count configuration of the Tech class in Python. To support this, src/Tech.cc has been updated to properly set and reset the global OpenRoad instance during the construction and destruction of Tech. Additionally, the aes_nangate45 test in src/drt/test/BUILD has been simplified by migrating from regression_rule_test to regression_test. There are no review comments, so I have no feedback to provide.

Signed-off-by: Naveen Venkat <archgen.guest@nyayanidhi.in>
@naveenvenk17

Copy link
Copy Markdown
Contributor Author

Black caught an extra blank line in the new lifecycle regression. I fixed it and reran the lifecycle test, the full AES Python regression, and the lint build on the VM. All pass. The earlier Mac failure was a timeout downloading Boost, so the new push will retry that job as well.

Signed-off-by: Naveen Venkat <archgen.guest@nyayanidhi.in>
@naveenvenk17

Copy link
Copy Markdown
Contributor Author

Jenkins exposed a standalone startup bug in the previous update. Tech now registers its application, but the Tcl and -python startup paths registered the same pointer again and exited with Attempt to reinitialize the application. I removed those two redundant registrations.

I reproduced the Jenkins failure on the VM before the fix. After the fix, the Python lifecycle test, commands_without_load, error1, the UPF isolation test, and the full AES Python regression all pass. The lint build for OpenROAD and both Python regressions also passes.

@maliberty

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 963f273fd3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +4 to +5
set_thread_count(2)
assert thread_count() == 2

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid assuming two hardware threads

On runners that expose only one CPU, set_thread_count(2) is clamped by OpenRoad::setThreadCount to std::thread::hardware_concurrency(), so thread_count() returns 1 and this lifecycle regression fails even though the registration works. Use a value guaranteed to be valid, such as 1, or assert against the clamped value.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants