You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[sim] dcci lacks cache-line atomicity in simulation mode — handshake store reordering can cause deadlock #266
On hardware, dcci(addr, SINGLE_CACHE_LINE, CACHELINE_OUT) atomically flushes an entire 64-byte cache line to HBM. Other processors (AICPU) reading from HBM see a complete cache-line snapshot — no partial visibility.
In simulation mode, dcci is implemented as std::atomic_thread_fence(std::memory_order_seq_cst) (dmb ish on aarch64). This provides fence semantics but no cache-line atomicity. Individual stores pass through the store buffer independently and can be reordered by the aarch64 weak memory model.
Reproduced Failures
multi-round-paged-attention and batch_paged_attention hung on a2a3sim + aarch64. Root cause: during the AICore-AICPU handshake, physical_core_id/core_type stores were reordered after the aicore_done signal store. AICPU observed aicore_done != 0 but read a stale physical_core_id (0), causing two cores to share the same register block — deadlock.
Core 0: AIC, physical_id=0, reg_addr=0xaaab24c20d40 <- correct
Core 27: AIV, physical_id=0, reg_addr=0xaaab24c20d40 <- wrong, should be 27
Not affected: hardware (a2a3) — dcci atomically flushes the cache line; x86 simulation — TSO memory model prevents store-store reordering.
Fix Status
Writer side (AICore) — applied to HBG and TMR
Insert dcci barrier between data fields and signal field:
The missing __sync_synchronize() in TMR is unlikely to cause issues in practice:
The writer-side dcci (dmb ish) already guarantees global store ordering
All fields reside in the same 64-byte aligned Handshake struct (single cache line) — when the reader fetches aicore_done, the same cache-line fetch also brings the updated physical_core_id
However, adding it would ensure formal correctness and consistency across all three runtimes.
Root Cause
The simulation dcci only provides fence semantics without modeling the hardware's cache-line atomic flush. For multi-field release-acquire protocols within the same cache line, developers must manually insert dcci/fence at the correct position, whereas the hardware's cache-line atomicity provides this guarantee implicitly.
Activity
ChaoWao commentedon Mar 12, 2026
This is actually a existing issue when running in sim mode and the sim process can execute out of order. My opinion is
Please refer to two things to give a PR
ChaoWao commentedon Mar 12, 2026
Fixed by #271 .