Skip to content

Refactor: localize A5 HBG scheduler state and configuration - #2398

Merged
poursoul merged 1 commit into
hw-native-sys:mainfrom
zhusy54:refactor/a5-hbg-local-scheduler-state
Sep 21, 2026
Merged

poursoul merged 1 commit into
hw-native-sys:mainfrom
zhusy54:refactor/a5-hbg-local-scheduler-state

Conversation

@zhusy54

@zhusy54 zhusy54 commented Sep 20, 2026

Copy link
Copy Markdown
Collaborator

A5 HBG repeatedly accesses GM for scheduler-owned bookkeeping and immutable configuration. This refactor moves ready-owner pending queues and the profiling loop counter into per-core local state, consolidates local slot/completion bookkeeping under SchedulerLocalState, and captures validated configuration after READY for each invocation.

Dispatch and completion already consume cached worker IDs. The Executor derives payload addresses from one shared payload-region offset and three 16-bit worker IDs. Fixed-prefix offsets use 32 bits after range checks; task-dependent offsets retain 64 bits. Per-worker core type and active copies are omitted, while shared GM participation control remains unchanged.

Self-execution readiness uses a pending-slot mask and reconstructs the publication from the local slot generation/state. A pending READY slot cannot be reused before the same-core Executor claims and completes it; generation, state, and duplicate-publication checks remain. Worker trace validity uses one mask, and the loop counter has one source in local state.

SchedulerLocalState is 336 B under the 64-bit ABI, versus 264 B before this PR and 536 B in its earlier form. These are structure sizes, not the complete AICore stack high-water mark. Profiling fields remain allocated when profiling is disabled.

Shared ready inboxes, dependencies, dispatch/completion mailboxes, and per-task completion accounting remain in GM. Dispatch-slot and completion-inbox offsets are read from the shared context rather than cached locally. Before bootstrap, each participating core invalidates its entire data cache; the callable table and task metadata are immutable for that invocation, allowing the two repeated immutable-line invalidations to be omitted.

The three scheduler test suites share a parameterized fixture, preserving capacities 16 and 8192 and the existing assertions. Owner-endpoint sentinel/INT32_MAX boundaries, narrowed-offset rejection, route consistency, and pending-notification stability are covered. SchedulerCompletionStats keeps its original field order. Named GM reserved bytes retain the wire layout and reject nonzero values.

Follow-up: packed SSBUF mailboxes

This PR is the first commit of the A5 HBG SSBUF work. The earlier full stack remains available on feat/a5-hbg-ssbuf-split; it has not yet absorbed these review changes.

  • 293a8001 replaces GM dispatch/completion generations and Executor trace handoffs with packed SSBUF mailboxes. Local timing_slot fields belong there, and Executor trace storage should be limited to the two self-execution slots.
  • cfa87998 batches completion accounting and reduces ready-directory/profiling overhead.
  • Removing the full active-worker selection mechanism and eliminating Profiling storage when disabled are deferred. Task-ID narrowing and deeper slot/generation compression are not part of this PR; subtask_slot is retained.

The follow-up branch starts from the earlier form of this refactor and will need rebasing/adaptation before submission.

Expected overall benefit of the complete SSBUF optimization

A direct hardware comparison of the earlier complete implementation (e9bbcf4a) against old main (72a4cc03) provides a performance reference for this PR plus its follow-ups. These are measured results for the complete implementation, used here to indicate the expected overall benefit; they are not measurements of this preparatory PR alone or of the newly split/rebased stack.

Workload Old main Device (μs) Complete optimization Device (μs) Device time reduction
AIC chain, 64 tasks 520.2 325.9 37.4%
AIV chain, 64 tasks 542.5 320.8 40.9%
AIC chain, 64 tasks, larger kernel (kernel_repeats=8) 875.7 642.2 26.7%
Paged attention unroll, Case1 998.0 928.2 7.0%

Device time is the full on-NPU AICPU RunWall, not kernel-only time. The larger AIC chain repeats the scalar dependency-check/writeback body eight times; a separate profiling run measured about 5.3× the original per-task kernel duration. It preserves the same 64-task chain.

Measurement setup:

  • One A5 NPU (device 0), held by one allocation for the entire comparison; baseline/current/current/baseline order for each workload.
  • Two batches of 100 rounds per version and workload, with chip-swimlane profiling disabled and identical STRACE timing enabled. Each batch drops its 10 lowest and 10 highest values; the table averages the two trimmed means.
  • Identical workload sources and PTO-ISA revision (c0d7148e95ef73bd12a73165fdce4b723a3b7e72) on both sides, with separate build environments. The baseline receives only the matching chain workload and PTO pin, not the runtime optimizations.
  • All eight one-round golden checks passed. Device improvements held in both execution orders: AIC chain 36.7–38.0%, AIV chain 40.2–41.5%, larger AIC chain 25.2–28.1%, and paged attention 6.2–7.8%.

The complete implementation had been rebased onto 6e383fc5, so this old-main comparison also includes intervening mainline changes; it does not isolate the contribution of the three optimization commits. The split/rebased follow-ups still need their own performance validation.

Host wall time was variable and does not establish a stable end-to-end gain. Observed trimmed Host means were 2513.7→3570.0 μs for AIC chain (+42.0%), 4022.0→2460.9 μs for AIV chain (−38.8%), 4016.9→3462.9 μs for the larger AIC chain (−13.8%), and 33265.2→32787.2 μs for paged attention (−1.4%). The AIC Host increase needs separate investigation; the Device reductions above should not be presented as end-to-end improvements.

Validation

  • Local checks before the latest main rebase: 85 scheduler C++ tests; 22 HBG simulation tests; phase-Profiling simulation and A5 onboard tests passed.
  • The A5 HBG onboard sweep plus remaining-test rerun passed 31 tests and skipped one. test_result_reads_while_successor_runs_hbg failed to observe the successor remaining Pending across the predecessor-result read; all predecessor results were valid. The same failure reproduced in an isolated run and with independently built, unmodified PR binaries. This remains a known validation limitation, not a claimed full onboard pass.
  • After the latest-main rebase: 85 scheduler C++ tests and clang-tidy/cpplint passed. CI exposed a local clang-format fallback to version 17; the exact whitespace-only output from CI clang-format 21.1.0 has been applied. CI pre-commit passed on e953777a. The final commit passed 26 HBG simulation tests and the phase-Profiling simulation test (one other test deselected). CI independently validates the final pushed commit.
  • Full dynamic AICore stack headroom and the historical AIC Host-time increase remain unverified.

@coderabbitai

coderabbitai Bot commented Sep 20, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 8ebc7ad2-cd5b-489d-bc36-b57a2e5a6861

📥 Commits

Reviewing files that changed from the base of the PR and between 978123b and c0c5a4f.

📒 Files selected for processing (14)
  • src/a5/runtime/host_build_graph/aicore/aicore_executor.cpp
  • src/a5/runtime/host_build_graph/aicpu/aicore_lifecycle.cpp
  • src/a5/runtime/host_build_graph/docs/RESIDENT_SCHEDULER.md
  • src/a5/runtime/host_build_graph/docs/RUNTIME_LOGIC.md
  • src/a5/runtime/host_build_graph/host/runtime_maker.cpp
  • src/a5/runtime/host_build_graph/runtime/scheduler/scheduler_completion.h
  • src/a5/runtime/host_build_graph/runtime/scheduler/scheduler_dispatch.h
  • src/a5/runtime/host_build_graph/runtime/scheduler/scheduler_layout.h
  • src/a5/runtime/host_build_graph/runtime/scheduler/scheduler_ready.h
  • src/a5/runtime/host_build_graph/runtime/scheduler/scheduler_types.h
  • tests/ut/cpp/a5/hbg_scheduler_test_support.h
  • tests/ut/cpp/a5/test_hbg_scheduler_contracts.cpp
  • tests/ut/cpp/a5/test_hbg_scheduler_dispatch.cpp
  • tests/ut/cpp/a5/test_hbg_scheduler_ready.cpp
💤 Files with no reviewable changes (4)
  • src/a5/runtime/host_build_graph/runtime/scheduler/scheduler_layout.h
  • src/a5/runtime/host_build_graph/aicpu/aicore_lifecycle.cpp
  • src/a5/runtime/host_build_graph/host/runtime_maker.cpp
  • tests/ut/cpp/a5/test_hbg_scheduler_contracts.cpp

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The scheduler now stores mutable execution state in SchedulerLocalState. Ready-owner wire state and layout storage are removed. Executor, dispatch, completion, lifecycle, tests, and documentation use local configuration, worker routes, and ready-inbox refresh.

Changes

Resident scheduler local-state migration

Layer / File(s) Summary
Local state and wire contracts
src/a5/runtime/host_build_graph/runtime/scheduler/scheduler_types.h, scheduler_layout.h, scheduler_ready.h
Adds local configuration and worker routes. Removes shared ready-owner structures, offsets, and fields.
Ready, dispatch, and completion helpers
src/a5/runtime/host_build_graph/runtime/scheduler/scheduler_ready.h, scheduler_dispatch.h, scheduler_completion.h
Updates helper APIs to use SchedulerLocalState, local slots, worker routes, and ready-inbox refresh.
Executor integration
src/a5/runtime/host_build_graph/aicore/aicore_executor.cpp, aicpu/aicore_lifecycle.cpp, host/runtime_maker.cpp
Initializes and validates local configuration before bootstrap and dispatch. Removes obsolete topology and layout assignments.
Tests and documentation
tests/ut/cpp/a5/*, src/a5/runtime/host_build_graph/docs/*
Adds shared test fixtures, updates scheduler tests, adds configuration validation coverage, and documents resident scheduler state ownership.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Refactor

Sequence Diagram(s)

sequenceDiagram
  participant AICoreExecutor
  participant SchedulerLocalState
  participant ReadyInbox
  participant DispatchHelpers
  participant CompletionHelpers
  AICoreExecutor->>SchedulerLocalState: Initialize and validate local configuration
  AICoreExecutor->>ReadyInbox: Bootstrap ready tasks
  AICoreExecutor->>DispatchHelpers: Fill and publish dispatch slots
  DispatchHelpers->>CompletionHelpers: Service completions and refills
  CompletionHelpers->>ReadyInbox: Refresh and claim ready work
Loading

Merge Risk: ⚪ Minimal · up to c0c5a

The reviewed concerns do not identify a remaining correctness or documentation issue; the change is ready to merge after normal checks.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 3.30% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 182 functions across 8 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Linked Issues check ❓ Inconclusive The context identifies PR #2398 but provides no linked issue or issue acceptance criteria for independent verification. Provide the linked issue reference and its acceptance criteria, or confirm that no linked issue is required.
✅ Passed checks (3 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed The implementation changes, layout updates, tests, and documentation all support the stated scheduler-state localization objective. Deferred SSBUF work is explicitly excluded.
Title check ✅ Passed The title clearly and concisely describes the main change: localizing A5 HBG scheduler state and configuration.
Description check ✅ Passed The description directly explains the scheduler state refactor, configuration snapshotting, retained GM state, testing, validation, and follow-up work.
Full details: Docstring Coverage

Explanation

Docstring coverage is 3.30% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 182 functions across 8 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

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

A rabbit checks local state,
Routes align and slots await,
Ready inboxes clear the way,
Tests protect each dispatch day,
Old owner wires fade from view,
The scheduler starts anew.

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

@zhusy54
zhusy54 force-pushed the refactor/a5-hbg-local-scheduler-state branch 3 times, most recently from 678417b to 4317d19 Compare September 21, 2026 00:55

@poursoul poursoul left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

结论

机制正确,CI 全绿,没有发现会导致错误结果的缺陷。owner pending 队列 / advertised 标志 / profiling loop 计数本来就是 owner 私有状态(thief 偷任务只读 inbox->head 和 GM 链表,从不碰 owner queue),放在 GM 里纯属浪费 —— 搬到 core-local 的方向是对的,alignas(128) + 已有的 offsetof 断言也让布局改动在编译期自校验。

主要问题是 PR 描述与实际改动不一致,另有两处硬编码 / 边界隐患建议修掉。verdict: needs discussion(补说明 + 修 2 项后可合)。


一、声明与实现不一致

1. 「热路径尚未消费 route 快照」与代码不符 ❌

正文写「does not switch the dispatch/completion hot path to those snapshots yet」,并把 SchedulerWorkerRoute::{active, core_type, dispatch_payload_offset} 的消费归给后续 commit 293a8001。实际上本 PR 里已经在消费了:

  • worker_routes[].worker_id 全线替代 cluster_worker_ids[]scheduler_dispatch.h:65/127/248/270scheduler_completion.h:48/238aicore_executor.cpp:233
  • worker_routes[self_lane].dispatch_payload_offset 替代了 executor ready 派发路径上的 context->dispatch_payload_offsetaicore_executor.cpp:423

确实纯预留的只有 .active(仅在 config 校验里读一次)、.core_typeSchedulerLocalSlotState::timing_slot(完全未被读写)。

这句话需要改写 —— 否则 reviewer 会误以为可以不审 route 快照的正确性。

2. 两处 scheduler_observe_cache_line 移除未披露 ➕

scheduler_ready.h 里去掉了 scheduler_lookup_callable_address 读 callable table 前、以及 scheduler_resolve_completion 读 task metadata 前的缓存行失效。

这两处删除是安全的aicore_execute 在 bootstrap 之前对每个 active core 调了 scheduler_observe_data_cache(...),它是 dcci(addr, ENTIRE_DATA_CACHE) 整个数据缓存失效,而 callable table 和 task metadata 整轮不变。但这是热路径上的内存序改动,正文完全没提,建议补上这条兜底理由。

3. 「单测共用一个 fixture」只做了 2/3 ⚠️

test_hbg_scheduler_contracts.cpp 仍自带一份 SchedulerStateBuffer(:84)和 GraphBuffer(:98),与新 header 里的重复;新 header 的注释还指回它("see the same note in test_hbg_scheduler_contracts.cpp")。要么一起收口,要么说明为什么 contracts 留在外面。

4. 搭车改动 ➕

  • RUNTIME_LOGIC.md 那段调度描述的重写,改的是本 PR 之前就存在的文档陈旧问题。修得对,但顺手删掉的「the highest-index thread first attaches the prebuilt runtime and publishes the boot barrier」这个事实在新表述里没有落点。
  • SchedulerCompletionStats 字段重排:确认是逐字段赋值(aicore_executor.cpp:94-97)而非 memcpy,所以无副作用 —— 但也就是纯 churn。

另外,删掉的 3 个测试核过了:2 个是 SchedulerReadyOwnerState 删除后的强制清理;LocalCompletionKeepsSharedSlotMetadataPublished 的断言(local slot 转 FREE / 共享 slot publication 仍为 READY / kernel 时戳落入 trace)确实由 SpscGenerationCompletesNormalTasktest_hbg_scheduler_dispatch.cpp:188-202)覆盖 —— 「重复覆盖」的说法成立。


二、建议修改

Should fix

1. owner_pending_endpoints 的初始化硬编码了 2 个元素

scheduler_ready.h:164-167

uint64_t owner_pending_endpoints[SCHEDULER_CORE_TYPE_COUNT]{
    SCHEDULER_READY_PENDING_EMPTY,
    SCHEDULER_READY_PENDING_EMPTY,
};

旧的 GM 版本是 for (type = 0; type < SCHEDULER_CORE_TYPE_COUNT; ++type) 循环写 sentinel,与规模无关。

失败场景:SCHEDULER_CORE_TYPE_COUNT 从 2 改成 3 后,owner_pending_endpoints[2] 被零初始化成 0,而 EMPTYUINT64_MAX。于是 scheduler_ready_pending_head(0) == 0 != EMPTYscheduler_refresh_ready_inbox_type 会走 pending 提升分支,把不存在的 task 0 当成 pending head 发布到 inbox —— 静默重复派发 task 0,没有任何编译期或运行期告警。

建议加 static_assert(SCHEDULER_CORE_TYPE_COUNT == 2),或在构造函数里循环填。

2. worker_id() 越界索引无保护,且默认值就是越界值

scheduler_ready.h:156-157

inline __aicore__ bool is_scheduler() const {
    return config.self_lane < PLATFORM_CORES_PER_BLOCKDIM && config.self_lane == config.scheduler_lane;
}
inline __aicore__ uint64_t worker_id() const { return worker_routes[config.self_lane].worker_id; }

self_lane 默认 UINT32_MAX,兄弟访问器 is_scheduler() 明确做了上界检查,worker_id() 没有。

当前不可达aicore_executeconfig_valid = (context->active == 0) || initialize(...),两条使用路径都额外 && context->active != 0,所以 active == 0(local state 全默认)时不会调到。但这靠调用点的两个条件耦合维持,属于隐式不变式;而且 scheduler_initialize_local_config 失败返回时还会留下部分填充的 local state。建议给 worker_id() 加同样的上界保护,或至少把「self_lane 已校验」写成注释 / 断言。

Consider

  • scheduler_ssbuf_reserved1 和 topology 组尾部那 8 字节隐式 padding,都没遵循同结构体内 graph_reserved_address 立下的规矩(注释要求「写 0 并拒绝非 0 读」)。实际值是 0(host 侧 std::vector<uint8_t> storage(allocation_size) 值初始化),但 padding 建议显式命名成 topology_reserved[3]
  • scheduler_ready_batch_pushinbox_index 形参现在只有一个调用点、传的就是 context->config.scheduler_index,函数内 inbox_index != context->config.scheduler_index 守卫因此恒真 —— 参数和守卫都可以去掉。
  • 被删的 PackedOwnerEndpointsRoundTripAsOneWord 覆盖的是 pack/unpack 的边界值INT32_MAXpack(EMPTY,EMPTY) == UINT64_MAX)。现在只有 FIFO 测试里的小 task id 间接覆盖,边界丢了。这个测试改一行(换成读 local 数组)就能留,比删掉划算。
  • scheduler->is_scheduler() == 0 / != 0scheduler_completion.h:151scheduler_dispatch.h:53scheduler_ready.h:314)—— 返回值已是 bool,这几处是从整数字段迁移时留下的写法。
  • SchedulerLocalState 大约从 ~290B 涨到 ~510B,而它是 aicore_execute 里的栈对象。onboard CI 通过说明没爆,但后续 commit 还要往里加东西,建议确认一下 AICore 标量栈的余量。
  • scheduler_initialize_local_config 补一句注释:失败返回时 local 处于部分初始化状态,调用方不得使用(新测试 RejectsInvalidTopologyBeforeMailboxAccess 正是复用同一个 local 连续调用的)。

三、其他

改动规模:Core 769 行 / Test 1593 行 / Docs 8 行,总 churn 2370。超标部分几乎全在测试,且其中绝大多数是签名穿线(去掉 owner_state / scheduler_local_state 两个参数)和 fixture 抽取的机械改动,不是新逻辑 —— 单次可审,不要求拆分。

pto_isa.pin 仍固定在 c0d7148e,本 PR 未改动任何 pto-isa 头文件引用路径也没新增 include,确认当前 pin 够用即可。

最后:性能数据那块处理得很规范 —— 明确标注了「这是完整实现 vs 老 main 的测量,不是本 PR 单独的贡献」,还主动披露了 AIC Host 时间 +42% 需要单独查。这个自我约束值得保留。

@zhusy54
zhusy54 force-pushed the refactor/a5-hbg-local-scheduler-state branch from 4317d19 to 068c1b1 Compare September 21, 2026 08:29
@zhusy54

zhusy54 commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator Author

@poursoul 按原 review 的顺序逐项回复如下。

一、声明与实现不一致

1.「热路径尚未消费 route 快照」与代码不符

已修正 PR 描述:worker ID 已用于派发/完成路径,Executor 已消费本地 payload 地址信息。修复后使用一个公共 payload 起点和三个 16-bit worker ID,移除独立 route 结构;不再把这些消费归给后续提交。原来的 active/core_type 本地副本移除,但 GM 的参与控制保留。

2. 两处 scheduler_observe_cache_line 移除未披露

已在 PR 描述及运行文档补充前提:参与运行的核心在 bootstrap 前完成整片 DCache 失效,callable table 和 task metadata 在本轮运行中不变,因此这两处 immutable-line 的重复失效可以省去。没有把这一前提泛化到可变 GM 数据。

3.「单测共用一个 fixture」只做了 2/3

contracts、ready、dispatch 已共用参数化的 GraphBuffer 和 SchedulerStateBuffer 实现。保留 contracts 容量 16、其他两组容量 8192,以及原有断言和 contracts 所需的 payload/storage 访问接口;删除指向旧重复实现的注释。

4. 搭车改动

  • RUNTIME_LOGIC.md:补回最高编号 AICPU 线程 attach runtime 并发布 boot barrier 的事实。
  • SchedulerCompletionStats:恢复原字段顺序,不保留无收益的重排。
  • 三个已删除测试:旧 owner-state 专属默认初始化检查由本地 sentinel 检查承接;共享 slot publication/时间戳的重复覆盖继续由 SpscGenerationCompletesNormalTask 保留;pack/unpack 的边界断言按下面对应意见恢复。

二、建议修改

Should fix

1. owner_pending_endpoints 初始化硬编码两个元素

改为构造时按 SCHEDULER_CORE_TYPE_COUNT 循环填充 EMPTY,避免新增类型时零初始化被解释成 task 0。测试检查所有元素的 sentinel。

2. worker_id() 越界索引无保护

增加 self lane 上界检查,非法时返回 UINT64_MAX;补充默认 local state 的访问测试。初始化失败的 local state 仍禁止交给运行路径使用。

Consider

1. scheduler_ssbuf_reserved1 和 topology 尾部隐式 padding

将 topology 尾部现有空隙命名为 topology_reserved[3],保持 GM 结构大小及已有字段偏移不变。存储初始化已有整区清零;配置初始化拒绝这组 reserved 字段非零,并补充测试。GM 缓存行隔离不照搬到本地结构。

2. scheduler_ready_batch_push 的冗余 inbox_index 参数和守卫

删除参数,直接使用 config 的 scheduler index;保留容量边界检查,调用点和测试同步调整。

3. PackedOwnerEndpointsRoundTripAsOneWord 边界覆盖丢失

恢复针对本地 endpoints 的 INT32_MAX pack/unpack、EMPTY 初始化和 pack(EMPTY, EMPTY) == UINT64_MAX 断言。

4. is_scheduler() 与 0 比较

相关调用改为直接使用布尔返回值。

5. SchedulerLocalState 增长与标量栈余量

核实 64-bit ABI 下原主线为 264 B、原 PR 为 536 B,修复后为 336 B(相对主线 +72 B)。Config 按实际范围缩窄并在转换前校验;worker trace valid 集中;ready masks 缩窄;循环计数由 state 唯一维护;删除重复的 local ready publications,领取时根据 self slot 重建 token,并保留非法状态、重复领取和 GM generation 一致性检查。补充通知跨 Scheduler 扫描轮次仍保持 generation 的测试。subtask_slot 保留,本地 timing_slot 留待下一提交实际使用时添加。

设备编译及相关执行测试通过,但结构大小不等于完整调用链栈峰值;尚未完成完整动态栈余量验证,不将这部分表述为已经彻底解决。关闭 Profiling 时不分配字段的改造、整个 active 机制的删除以及更深入的 slot 压缩均后移。

6. 配置初始化失败时 local 处于部分初始化状态

增加明确注释,失败返回后调用方不得使用 local;现有运行入口以初始化成功作为 bootstrap/dispatch 的前提。新增缩窄溢出、payload 步长不一致、非法核心类型及 reserved 字段校验测试。

三、其他

1. 改动规模与可审阅性

保持单提交。相对当前 main 共 13 个文件,新增 1374 行、删除 1240 行;测试仍占主要修改量。未合入 SSBUF、active 行为删除或 Profiling 分配拆分。

2. pto_isa.pin

保持 c0d7148e95ef73bd12a73165fdce4b723a3b7e72,该版本已用于本地编译和验证,没有升级依赖。

3. 性能数据口径与 AIC Host +42%

保留“完整实现对比旧主线”的限定,不将历史结果归因于本 PR;AIC Host 时间增长仍需单独调查,本次未解决。

@zhusy54
zhusy54 force-pushed the refactor/a5-hbg-local-scheduler-state branch from 068c1b1 to e953777 Compare September 21, 2026 08:36
Keep ready-owner queues and a single profiling loop counter in core-local
state, consolidate local slot and completion bookkeeping, and validate
immutable configuration after READY. Use compact worker IDs and a shared
payload base; reconstruct self-ready tokens from occupied local slots.
Retain GM mailboxes, worker participation, and per-task accounting.

Share parameterized scheduler fixtures without changing their capacities.
Preserve completion-stat ordering and endpoint boundary coverage, validate
narrowed offsets and reserved fields, and guard invalid local worker lookup.
Document immutable-cache assumptions and the 336-byte local state layout.
@poursoul
poursoul merged commit 88b3205 into hw-native-sys:main Sep 21, 2026
19 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