Skip to content

refactor(runtime): move orch_device_id into aicpu_device_config, out of platform_regs#1228

Merged
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
ChaoZheng109:refactor/orch-device-id-to-config
Jul 1, 2026
Merged

refactor(runtime): move orch_device_id into aicpu_device_config, out of platform_regs#1228
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
ChaoZheng109:refactor/orch-device-id-to-config

Conversation

@ChaoZheng109

Copy link
Copy Markdown
Collaborator

What

Follow-up cleanup to #1223. orch_device_id (the ACL device ordinal) is latched once per device by simpler_aicpu_init (from InitArgs.device_id) and read by the AICPU executor (create_orch_so_file(..., get_orch_device_id(), ...)) to make the staged orchestration-SO filename unique per device.

It is a per-device, run-invariant knob — the exact same category as scheduler_timeout (moved in #1223) — and has nothing to do with per-core register addressing. It lived in platform_regs only for historical reasons. #1223 introduced aicpu_device_config as the dedicated home for per-device AICPU config latched by simpler_aicpu_init; this finishes the job by moving orch_device_id there too, so platform_regs is left strictly for per-core register access.

How

  • aicpu_device_config.{h,cpp}: add set/get_orch_device_id + the g_orch_device_id global, alongside set/get_scheduler_timeout_ms.
  • platform_regs.{h,cpp} (a5 + a2a3): remove them.
  • aicpu_executor.cpp (a5 + a2a3): include aicpu/aicpu_device_config.h for the get_orch_device_id consumer (keeps platform_regs.h — still uses get_platform_regs).
  • kernel.cpp (latch) and sim device_runner (dlsym set_orch_device_id): unchanged — the symbol name is identical, only its defining TU moved (same AICPU SO; sim dlsym still resolves it).

No behavior change. platform_regs now holds only register-addressing state.

Test

  • All four quadrants (onboard/sim × a5/a2a3) build clean.
  • runtime_fatal_codes::scheduler_timeout — which exercises the register_callableload_orch_socreate_orch_so_file(get_orch_device_id()) consumer path — passes on a5sim + a2a3sim.

Onboard hardware runs still recommended before merge.

🤖 Generated with Claude Code

…of platform_regs

orch_device_id is the ACL device ordinal latched once per device by
simpler_aicpu_init (from InitArgs.device_id) and read by the AICPU executor to
make the staged orchestration SO filename unique per device. It is a per-device
run-invariant knob — the same category as scheduler_timeout — and has nothing to
do with per-core register addressing, so platform_regs was the wrong home.

Now that aicpu_device_config exists as the dedicated home for per-device AICPU
config latched by simpler_aicpu_init, move set/get_orch_device_id + the global
there, alongside set/get_scheduler_timeout_ms. platform_regs is left strictly for
per-core register access.

- aicpu_device_config.{h,cpp}: add set/get_orch_device_id + g_orch_device_id.
- platform_regs.{h,cpp} (a5 + a2a3): remove them.
- aicpu_executor.cpp (a5 + a2a3): include aicpu_device_config.h for the
  get_orch_device_id consumer (still needs platform_regs.h for get_platform_regs).
- kernel.cpp / sim device_runner: unchanged — the symbol name is identical, only
  its defining TU moved (same AICPU SO; sim dlsym still resolves it).

No behavior change. Verified: all four quadrants build; runtime_fatal_codes
scheduler_timeout (which exercises the register->orch-SO path) passes on
a5sim + a2a3sim.

Stacked on hw-native-sys#1223 (which introduces aicpu_device_config).
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: eea29cb8-8c1b-4cdb-ad2c-168cb2b0f8ea

📥 Commits

Reviewing files that changed from the base of the PR and between 2c98abc and 46d998a.

📒 Files selected for processing (8)
  • src/a2a3/platform/include/aicpu/platform_regs.h
  • src/a2a3/platform/shared/aicpu/platform_regs.cpp
  • src/a2a3/runtime/tensormap_and_ringbuffer/aicpu/aicpu_executor.cpp
  • src/a5/platform/include/aicpu/platform_regs.h
  • src/a5/platform/shared/aicpu/platform_regs.cpp
  • src/a5/runtime/tensormap_and_ringbuffer/aicpu/aicpu_executor.cpp
  • src/common/platform/include/aicpu/aicpu_device_config.h
  • src/common/platform/shared/aicpu/aicpu_device_config.cpp
💤 Files with no reviewable changes (4)
  • src/a5/platform/shared/aicpu/platform_regs.cpp
  • src/a2a3/platform/include/aicpu/platform_regs.h
  • src/a5/platform/include/aicpu/platform_regs.h
  • src/a2a3/platform/shared/aicpu/platform_regs.cpp

📝 Walkthrough

Walkthrough

This PR relocates the orchestration device ordinal API (set_orch_device_id/get_orch_device_id) from platform-specific platform_regs header/source files (a2a3 and a5) into a shared aicpu_device_config header/source, backed by a new latched global variable, and adds the corresponding include to both aicpu executors.

Changes

Orchestration Device ID Relocation

Layer / File(s) Summary
New API in aicpu_device_config
src/common/platform/include/aicpu/aicpu_device_config.h, src/common/platform/shared/aicpu/aicpu_device_config.cpp
Adds set_orch_device_id/get_orch_device_id declarations and implementation backed by a new latched-per-device global variable.
Removal from a2a3 platform_regs
src/a2a3/platform/include/aicpu/platform_regs.h, src/a2a3/platform/shared/aicpu/platform_regs.cpp
Deletes the orchestration device id declaration, global storage, and accessor functions previously defined here.
Removal from a5 platform_regs
src/a5/platform/include/aicpu/platform_regs.h, src/a5/platform/shared/aicpu/platform_regs.cpp
Deletes the orchestration device id declaration, global storage, and accessor functions previously defined here.
Executor wiring
src/a2a3/runtime/tensormap_and_ringbuffer/aicpu/aicpu_executor.cpp, src/a5/runtime/tensormap_and_ringbuffer/aicpu/aicpu_executor.cpp
Adds #include "aicpu/aicpu_device_config.h" to consume the relocated API.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

Possibly related PRs

  • hw-native-sys/simpler#1201: Relates to the one-shot simpler_aicpu_init flow that now latches per-device state including this relocated orch_device_id API.
  • hw-native-sys/simpler#1216: Modifies device-register launch logic depending on the same orch device-id wiring being relocated here.

Poem

A hop from platform_regs I made,
To aicpu_device_config, freshly laid.
The orch id now lives one shared place,
Latched per device, tidy and safe.
Twiddles my whiskers — includes now trace! 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main refactor: moving orch_device_id from platform_regs into aicpu_device_config.
Description check ✅ Passed The description is directly related to the changeset and matches the refactor and validation notes in the diff.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ChaoWao ChaoWao merged commit 0c7d4e8 into hw-native-sys:main Jul 1, 2026
30 of 31 checks passed
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