Refactor: converge A2A3 and A5 TMR internals - #1718
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe change aligns a2a3 and a5 runtime APIs, removes scheduler scan profiling, updates profiling documentation, replaces header guards with ChangesRuntime API and behavior
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/a2a3/runtime/tensormap_and_ringbuffer/docs/profiling_levels.md`:
- Line 74: Update the scheduler output example in profiling_levels.md to remove
the stale scan row, matching the scheduler counter lists at the documented
sections. Ensure all scheduler output documentation consistently reflects only
counters that are emitted.
In `@src/a2a3/runtime/tensormap_and_ringbuffer/runtime/scheduler/pto_scheduler.h`:
- Line 388: Update the comment for init_data_from_layout() to state that
arena-internal pointer fields, including ready_queues[].slots, are bound by
wire_arena_pointers() rather than init_data_from_layout().
In `@src/a5/runtime/tensormap_and_ringbuffer/docs/profiling_levels.md`:
- Line 114: Remove the stale scan row from the Level 2 output example in
profiling_levels.md, leaving only the complete, dispatch, and idle phase
statistics to match the current emitted output.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a50ecad5-36d4-45c3-928f-2c58d696ec92
📒 Files selected for processing (49)
src/a2a3/runtime/tensormap_and_ringbuffer/aicpu/aicpu_executor.cppsrc/a2a3/runtime/tensormap_and_ringbuffer/common/pto_runtime_status.hsrc/a2a3/runtime/tensormap_and_ringbuffer/docs/profiling_levels.mdsrc/a2a3/runtime/tensormap_and_ringbuffer/host/dep_gen_replay.hsrc/a2a3/runtime/tensormap_and_ringbuffer/orchestration/pto_orchestration_api.hsrc/a2a3/runtime/tensormap_and_ringbuffer/runtime/aicore_completion_mailbox.hsrc/a2a3/runtime/tensormap_and_ringbuffer/runtime/aicore_completion_mailbox_types.hsrc/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_async_kernel_api.hsrc/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_async_wait.hsrc/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_completion_token.hsrc/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_constants.hsrc/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_dep_compute.hsrc/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_orchestrator.hsrc/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_ring_buffer.hsrc/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2_types.hsrc/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_tensormap.hsrc/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_types.hsrc/a2a3/runtime/tensormap_and_ringbuffer/runtime/runtime.hsrc/a2a3/runtime/tensormap_and_ringbuffer/runtime/scheduler/pto_scheduler.hsrc/a2a3/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_context.hsrc/a2a3/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_types.hsrc/a2a3/runtime/tensormap_and_ringbuffer/runtime/shared/pto_runtime2_init.cppsrc/a5/runtime/tensormap_and_ringbuffer/common/pto_runtime_status.hsrc/a5/runtime/tensormap_and_ringbuffer/docs/MULTI_RING.mdsrc/a5/runtime/tensormap_and_ringbuffer/docs/RUNTIME_LOGIC.mdsrc/a5/runtime/tensormap_and_ringbuffer/docs/profiling_levels.mdsrc/a5/runtime/tensormap_and_ringbuffer/host/dep_gen_replay.hsrc/a5/runtime/tensormap_and_ringbuffer/runtime/aicore_completion_mailbox.hsrc/a5/runtime/tensormap_and_ringbuffer/runtime/aicore_completion_mailbox_types.hsrc/a5/runtime/tensormap_and_ringbuffer/runtime/backend/sdma/sdma_completion_kernel.hsrc/a5/runtime/tensormap_and_ringbuffer/runtime/backend/sdma/sdma_completion_scheduler.hsrc/a5/runtime/tensormap_and_ringbuffer/runtime/backend/urma/urma_completion_kernel.hsrc/a5/runtime/tensormap_and_ringbuffer/runtime/backend/urma/urma_completion_scheduler.hsrc/a5/runtime/tensormap_and_ringbuffer/runtime/pto_async_kernel_api.hsrc/a5/runtime/tensormap_and_ringbuffer/runtime/pto_async_wait.hsrc/a5/runtime/tensormap_and_ringbuffer/runtime/pto_completion_token.hsrc/a5/runtime/tensormap_and_ringbuffer/runtime/pto_constants.hsrc/a5/runtime/tensormap_and_ringbuffer/runtime/pto_dep_compute.hsrc/a5/runtime/tensormap_and_ringbuffer/runtime/pto_orchestrator.cppsrc/a5/runtime/tensormap_and_ringbuffer/runtime/pto_ring_buffer.hsrc/a5/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2_types.hsrc/a5/runtime/tensormap_and_ringbuffer/runtime/pto_tensormap.hsrc/a5/runtime/tensormap_and_ringbuffer/runtime/pto_types.hsrc/a5/runtime/tensormap_and_ringbuffer/runtime/runtime.hsrc/a5/runtime/tensormap_and_ringbuffer/runtime/scheduler/pto_scheduler.hsrc/a5/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_cold_path.cppsrc/a5/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_context.hsrc/a5/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_types.htests/ut/cpp/a2a3/test_a2a3_fatal.cpp
4bd115d to
4c1cebb
Compare
Align scope-mode forwarding, payload prefetch, scheduler layout, internal names, and profiling documentation across the TMR runtimes. Retain compatibility header guards in otherwise-unchanged headers so existing architecture detection remains available.
4c1cebb to
7a6761e
Compare
Close the two P4/P5 residuals flagged in hw-native-sys#1582's 2026-08-09 re-audit (after hw-native-sys#1718 landed): R1 — a5 lacked the scope-guard regression test that a2a3 gained in hw-native-sys#1718. a5's `PTO2_SCOPE_GUARD(...)` has been variadic (and its MANUAL path live, read by `rt_scope_begin` -> `begin_scope(mode)`) since the hw-native-sys#1100 import, but `ut-a5` would not have caught a regression in MANUAL forwarding. Mirror `ScopeGuardForwardsModeUntilLexicalScopeExit` to `test_a5_fatal.cpp`: `FakeRuntime` gains `pending_scope_mode` (immediately after `ops`, the prefix the inline wrappers pun through) and `last_scope_mode`; `fake_scope_begin` records the mode; the test asserts AUTO then MANUAL forwarding across lexical scope exit. Both test files also extend the single `offsetof(ops) == 0` guard to a second one pinning `pending_scope_mode` at `sizeof(PTO2RuntimeOps *)`, since the `reinterpret_cast` now depends on the two-field prefix, not one. R2 — a2a3 `RUNTIME_LOGIC.md` still described the retained temp buffer as a single runner-owned instance, but the shared host-runtime callback `get_retained_temp_buffer(runner_ctx, pipeline_slot, ...)` is per-slot and a5's matching paragraph already says so. Align a2a3 to a5's wording ("each slot's buffer lives on the runner"). Also fix a stale accessor location in both trees' `MULTI_RING.md`: `PTO2TaskId`'s direct accessors live in `src/common/task_interface/pto_task_id.h`, not `pto_runtime2_types.h`. Verification: built and ran `test_a2a3_fatal` and `test_a5_fatal` — 4/4 tests pass each (including the new a5 ScopeGuard case).
Close the two P4/P5 residuals flagged in hw-native-sys#1582's 2026-08-09 re-audit (after hw-native-sys#1718 landed): R1 — a5 lacked the scope-guard regression test that a2a3 gained in hw-native-sys#1718. a5's `PTO2_SCOPE_GUARD(...)` has been variadic (and its MANUAL path live, read by `rt_scope_begin` -> `begin_scope(mode)`) since the hw-native-sys#1100 import, but `ut-a5` would not have caught a regression in MANUAL forwarding. Mirror `ScopeGuardForwardsModeUntilLexicalScopeExit` to `test_a5_fatal.cpp`: `FakeRuntime` gains `pending_scope_mode` (immediately after `ops`, the prefix the inline wrappers pun through) and `last_scope_mode`; `fake_scope_begin` records the mode; the test asserts AUTO then MANUAL forwarding across lexical scope exit. Both test files also extend the single `offsetof(ops) == 0` guard to a second one pinning `pending_scope_mode` at `offsetof(PTO2Runtime, pending_scope_mode)`, directly asserting the fake matches the production `PTO2Runtime` prefix layout the inline wrappers pun through (not just pointer size). Both tests also seed `pending_scope_mode = PTO2ScopeMode::MANUAL` before the first guard so the `AUTO` assertion actually verifies the guard writes the default, rather than reading a pre-existing `AUTO` from the member initializer. R2 — a2a3 `RUNTIME_LOGIC.md` still described the retained temp buffer as a single runner-owned instance, but the shared host-runtime callback `get_retained_temp_buffer(runner_ctx, pipeline_slot, ...)` is per-slot and a5's matching paragraph already says so. Align a2a3 to a5's wording ("each slot's buffer lives on the runner"). Also fix a stale accessor location in both trees' `MULTI_RING.md`: `PTO2TaskId`'s direct accessors live in `src/common/task_interface/pto_task_id.h`, not `pto_runtime2_types.h`. Verification: built and ran `test_a2a3_fatal` and `test_a5_fatal` — 4/4 tests pass each (including the new a5 ScopeGuard case); both files are clang-format clean (ColumnLimit 120).
…#1752) Close the two P4/P5 residuals flagged in #1582's 2026-08-09 re-audit (after #1718 landed): R1 — a5 lacked the scope-guard regression test that a2a3 gained in #1718. a5's `PTO2_SCOPE_GUARD(...)` has been variadic (and its MANUAL path live, read by `rt_scope_begin` -> `begin_scope(mode)`) since the #1100 import, but `ut-a5` would not have caught a regression in MANUAL forwarding. Mirror `ScopeGuardForwardsModeUntilLexicalScopeExit` to `test_a5_fatal.cpp`: `FakeRuntime` gains `pending_scope_mode` (immediately after `ops`, the prefix the inline wrappers pun through) and `last_scope_mode`; `fake_scope_begin` records the mode; the test asserts AUTO then MANUAL forwarding across lexical scope exit. Both test files also extend the single `offsetof(ops) == 0` guard to a second one pinning `pending_scope_mode` at `offsetof(PTO2Runtime, pending_scope_mode)`, directly asserting the fake matches the production `PTO2Runtime` prefix layout the inline wrappers pun through (not just pointer size). Both tests also seed `pending_scope_mode = PTO2ScopeMode::MANUAL` before the first guard so the `AUTO` assertion actually verifies the guard writes the default, rather than reading a pre-existing `AUTO` from the member initializer. R2 — a2a3 `RUNTIME_LOGIC.md` still described the retained temp buffer as a single runner-owned instance, but the shared host-runtime callback `get_retained_temp_buffer(runner_ctx, pipeline_slot, ...)` is per-slot and a5's matching paragraph already says so. Align a2a3 to a5's wording ("each slot's buffer lives on the runner"). Also fix a stale accessor location in both trees' `MULTI_RING.md`: `PTO2TaskId`'s direct accessors live in `src/common/task_interface/pto_task_id.h`, not `pto_runtime2_types.h`. Verification: built and ran `test_a2a3_fatal` and `test_a5_fatal` — 4/4 tests pass each (including the new a5 ScopeGuard case); both files are clang-format clean (ColumnLimit 120).
Summary
Converge the remaining low-risk A2/A3 and A5
tensormap_and_ringbufferruntime differences identified in #1582.What changed
PTO2_SCOPE_GUARD(...)to forwardPTO2ScopeMode, with AUTO/MANUAL lifetime coverage.PTO2TaskPayload::prefetch(), remove the duplicate helper, dead A2/A3 aliases/overloads, stale internal names, and A5's always-zerosched_scan_cycleleftover from the cleanup scoped to A2/A3 in Refactor: drop SCHED_IDLE_WAIT phase records and vestigial SCAN slot #869.#pragma onceand correct staleinit_data_from_layoutreferences.The cleanup is intentionally limited to the TMR runtime;
host_build_graphis unchanged.Verification
pre-commit run --files $(git diff --name-only upstream/main...)passed, including clang-tidy, cpplint, and markdownlint.ctest -LE requires_hardware --output-on-failure: 89/89 passed.git diff --checkand residual-symbol/header scans passed.mkdocs build --strictwas not available locally becausemkdocsis not installed in the current environment; Markdown lint passed and CI will run the repository docs job.Related to #1582.