Skip to content

fix: share cpu sim pipe state across runtime tasks#29

Merged
zhoubot merged 2 commits intomainfrom
codex/issue-26-fix-cpu-sim-split-pipe
Mar 30, 2026
Merged

fix: share cpu sim pipe state across runtime tasks#29
zhoubot merged 2 commits intomainfrom
codex/issue-26-fix-cpu-sim-split-pipe

Conversation

@zhoubot
Copy link
Copy Markdown
Collaborator

@zhoubot zhoubot commented Mar 30, 2026

Summary

  • add dynamic CPU-sim runtime hooks so the same PTO ISA call surface can resolve execution context and shared storage when running under the A5 sim runtime
  • scope CPU-sim TPipe shared state by runtime task cookie as well as block/pipe metadata, so mixed tasks on the same cluster do not alias the same FIFO state
  • keep the split DIR_C2V local FIFO semantics from the earlier fix, but make them safe for the cross-DSO a5sim execution model

Root Cause

The original CPU-sim split-pipe fix only covered in-process tests. In the real a5sim BGEMM flow, the producer and consumers run through separate DSOs under the host runtime, so plain header-local static pipe state is not shared across them. On top of that, reusing one shared FIFO per block was too coarse for the PTO2 scheduler, which can dispatch multiple mixed tasks on the same cluster.

This PR moves CPU-sim pipe coordination onto runtime-provided hooks and keys the shared state by task cookie, which makes the public PTO ISA interface work unchanged across CPU sim and A5.

Validation

cmake -S tests/cpu/st -B build/issue26 -DTEST_CASE=tpushpop -DCMAKE_BUILD_TYPE=Release
cmake --build build/issue26 --target tpushpop -j4
./build/issue26/bin/tpushpop

Result:

  • 12/12 tests passed

End-to-end validation was also run against the real simpler a5sim BGEMM flow after the paired runtime-side fix:

source /Users/zhoubot/github/pto-orgs/simpler/.venv313/bin/activate
export PTO_ISA_ROOT=/Users/zhoubot/github/pto-isa
export CC=/opt/homebrew/bin/gcc-15
export CXX=/opt/homebrew/bin/g++-15
python /Users/zhoubot/github/pto-orgs/simpler/examples/scripts/run_example.py \
  -k /Users/zhoubot/github/pto-orgs/simpler/tests/st/a5/tensormap_and_ringbuffer/bgemm/kernels \
  -g /Users/zhoubot/github/pto-orgs/simpler/tests/st/a5/tensormap_and_ringbuffer/bgemm/golden.py \
  -p a5sim \
  --build

Result:

  • TEST PASSED
  • C: PASS (131072/131072 elements matched)

Related

Closes #26.

@zhoubot zhoubot changed the title [codex] fix split c2v pipe semantics in cpu sim fix: share cpu sim pipe state across runtime tasks Mar 30, 2026
@zhoubot zhoubot marked this pull request as ready for review March 30, 2026 04:12
@zhoubot zhoubot merged commit 7ba5a0e into main Mar 30, 2026
@zhoubot zhoubot deleted the codex/issue-26-fix-cpu-sim-split-pipe branch March 30, 2026 04:15
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.

a5sim: TPUSH/TPOP simulation produces incorrect results for BGEMM (precision errors)

1 participant