Skip to content

Refactor: consolidate pto_runtime_c_api.h into src/common/worker#450

Merged
ChaoWao merged 1 commit intohw-native-sys:mainfrom
hw-native-sys-bot:feat/orchestration-api
Apr 3, 2026
Merged

Refactor: consolidate pto_runtime_c_api.h into src/common/worker#450
ChaoWao merged 1 commit intohw-native-sys:mainfrom
hw-native-sys-bot:feat/orchestration-api

Conversation

@hw-native-sys-bot
Copy link
Copy Markdown
Collaborator

@hw-native-sys-bot hw-native-sys-bot commented Apr 3, 2026

Summary

The pto_runtime_c_api.h header existed in three copies with divergent content:

  • src/common/worker/pto_runtime_c_api.h — public API only (4 dlsym'd functions)
  • src/a2a3/platform/include/host/pto_runtime_c_api.h — full API including record_tensor_pair
  • src/a5/platform/include/host/pto_runtime_c_api.h — identical to a2a3

This PR merges them into a single canonical header at src/common/worker/pto_runtime_c_api.h that declares all extern "C" functions:

  • Public API (resolved by ChipWorker via dlsym): get_runtime_size, set_device, run_runtime, finalize_device
  • Internal API (resolved at link time): record_tensor_pair

Arch-specific copies deleted. All four platform CMakeLists.txt updated to include src/common/worker in the build path.

Testing

  • python ci.py -p a2a3sim -c 6622890 -t 600 --build-runtime — 15/15 PASS

Copy link
Copy Markdown

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

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 centralizes the loading of orchestration shared objects by introducing a platform-specific load_orch_so function and refactoring temporary file handling across the aicpu and host runtimes. Key feedback includes addressing security vulnerabilities in the onboard implementation—such as race conditions from getpid() and lack of partial write handling—removing now-redundant unlink calls in the executor, and enhancing error reporting with dlerror().

Merge three divergent copies into one canonical header declaring all
extern-C functions (public API + record_tensor_pair). Delete arch-specific
copies. Add src/common/worker to cmake include path for platform builds.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@ChaoWao ChaoWao merged commit 30fdeca into hw-native-sys:main Apr 3, 2026
10 checks passed
@ChaoWao ChaoWao deleted the feat/orchestration-api branch April 3, 2026 12:42
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