Fix: add store barriers in AICPU-AICore handshake on aarch64#521
Merged
ChaoWao merged 1 commit intoApr 12, 2026
Merged
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces OUT_OF_ORDER_STORE_BARRIER() calls across several aicpu_executor.cpp files to ensure memory visibility of status flags before proceeding to synchronization loops. While these additions improve consistency, the reviewer identified a recurring issue where an additional barrier is needed between register initialization and the setting of the aicpu_regs_ready flag to prevent race conditions on architectures with weak memory models like aarch64.
Add OUT_OF_ORDER_STORE_BARRIER() after volatile handshake stores (aicpu_ready, aicpu_regs_ready) in handshake_all_cores() across all five runtime variants. On aarch64's weak memory model, stores to volatile fields can remain in the CPU store buffer while the writing thread spins on a different field, invisible to the polling AICore thread — causing mutual deadlock. The barrier before aicpu_regs_ready ensures register initialization stores from platform_init_aicore_regs() are globally visible before the flag, so AICore does not proceed with uninitialized registers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
e30121d to
05428ba
Compare
ChaoWao
approved these changes
Apr 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OUT_OF_ORDER_STORE_BARRIER()after volatile handshake stores (aicpu_ready,aicpu_regs_ready) inhandshake_all_cores()across all five runtime variantsRoot cause analysis
GDB core dump of a hung 4-worker sim process showed:
aicore_executor.cpp:69— idle-pollingread_reg(DATA_MAIN_BASE)for task dispatchaicpu_executor.cpp:955— idle spin inresolve_and_dispatchaicpu_regs_readywas 1 in memory but the AICore thread never observed it (store buffer not drained)The existing
emergency_shutdown()path in the same files already uses the correct barrier pattern — the handshake path was the only omission.Files changed
src/a2a3/runtime/host_build_graph/aicpu/aicpu_executor.cppaicpu_ready=1loop,aicpu_regs_ready=1src/a2a3/runtime/aicpu_build_graph/aicpu/aicpu_executor.cppaicpu_ready=1loop,aicpu_regs_ready=1src/a2a3/runtime/tensormap_and_ringbuffer/aicpu/aicpu_executor.cppaicpu_ready=1loop,aicpu_regs_ready=1src/a5/runtime/host_build_graph/aicpu/aicpu_executor.cppaicpu_ready=1loop,aicpu_regs_ready=1src/a5/runtime/tensormap_and_ringbuffer/aicpu/aicpu_executor.cppaicpu_ready=1loop,aicpu_regs_ready=1Test plan
python ci.py -p a2a3sim— 20/20 pass (1 worker, baseline)python ci.py -p a5sim— sim regression check🤖 Generated with Claude Code