Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@uenoku
Copy link
Member

@uenoku uenoku commented Jul 22, 2025

This commit refactors the AIG longest path analysis C API to use native C structures instead of JSON strings, providing better performance and type safety.

The API changes replace aigLongestPathCollectionGetPath returning JSON with aigLongestPathCollectionGetDataflowPath returning native objects. New opaque handle types are added including AIGLongestPathObject, AIGLongestPathHistory, and AIGLongestPathDataflowPath. Comprehensive APIs are provided for accessing path data, history, and object properties.

InstancePath C API support is introduced in circt-c/Support/InstanceGraph.h. Currently InstancePathCache itself is not provided, as the use of LongestPathAnalysis is read-only and there is no need to mutate/construct InstancePath. Unfortunately due to that testing of CAPI of InstancePath got a bit tricky. For now AIGLongestPathAnalysis is used to produce InstancePath in CAPI.

The Python binding updates refactor Object, DataflowPath, and LongestPathHistory classes to use the native C API. JSON parsing dependencies and from_json_string() methods are removed. Proper property accessors using the new C API are added while maintaining backward compatibility for existing Python interfaces. So the existing integration tests cover most of the APIs.

Testing updates include comprehensive coverage in the existing C API tests in test/CAPI/aig.c. A new test/CAPI/support.c is added for InstancePath API testing. Python integration tests are updated to work with the new API.

This change improves performance by eliminating JSON serialization/deserialization overhead and provides a more robust, type-safe interface for accessing longest path analysis results.

@uenoku uenoku force-pushed the dev/hidetou/python-aig-change branch 4 times, most recently from c32352e to 02dac18 Compare July 22, 2025 06:04
…gest path analysis

This commit refactors the AIG longest path analysis C API to use native C structures instead of JSON strings, providing better performance and type safety.

The API changes replace aigLongestPathCollectionGetPath() returning JSON with aigLongestPathCollectionGetDataflowPath() returning native objects. New opaque handle types are added including AIGLongestPathObject, AIGLongestPathHistory, and AIGLongestPathDataflowPath. Comprehensive APIs are provided for accessing path data, history, and object properties. InstanceGraph C API support is introduced in circt-c/Support/InstanceGraph.h.

The Python binding updates refactor Object, DataflowPath, and LongestPathHistory classes to use the native C API. JSON parsing dependencies and from_json_string() methods are removed. Proper property accessors using the new C API are added while maintaining backward compatibility for existing Python interfaces.

Testing updates include comprehensive coverage in the existing C API tests in test/CAPI/aig.c. A new test/CAPI/support.c is added for InstanceGraph API testing. Python integration tests are updated to work with the new API.

This change improves performance by eliminating JSON serialization/deserialization overhead and provides a more robust, type-safe interface for accessing longest path analysis results.
@uenoku uenoku force-pushed the dev/hidetou/python-aig-change branch from 02dac18 to 0833aef Compare July 22, 2025 08:53
Copy link
Contributor

@fabianschuiki fabianschuiki left a comment

Choose a reason for hiding this comment

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

LGTM! Very cool to have this expose in the C API 🥳 🦀

@uenoku uenoku merged commit 640daf0 into main Jul 22, 2025
7 checks passed
@uenoku uenoku deleted the dev/hidetou/python-aig-change branch July 22, 2025 18:30
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.

2 participants