test(simt): unify scatter kernel on templated MSCATTER, drop __CPU_SIM fork#1275
Conversation
… MSCATTER The simt_basic scatter kernel forked the scatter call on __CPU_SIM because pto-isa previously gated the templated MSCATTER overloads behind PTO_NPU_ARCH_A5 only, so the CPU simulator had to use the non-templated form. The pinned pto-isa (bumped to 016396b5 in hw-native-sys#1156, the pto-isa#166 mechanism) now exposes the templated overloads to __CPU_SIM as well, so both backends can call the same explicit MSCATTER<Coalesce::Elem, ScatterAtomicOp::None, ScatterOOB::Skip>. Note the non-templated MSCATTER is still not portable: CPU sim defaults to Coalesce::Elem while a5 onboard defaults to Coalesce::Row, so the explicit templated form is the only instruction unified across both. Verified on --platform a5sim. Onboard call site is unchanged. Closes hw-native-sys#1159
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughA conditional ChangesScatter Kernel Cleanup
Estimated code review effort: 1 (Trivial) | ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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.
Code Review
This pull request simplifies the simt_scatter_impl kernel by removing the conditional compilation fork (#ifdef __CPU_SIM) for the MSCATTER instruction. Both the CPU simulation and onboard backends now consistently use the templated MSCATTER overload with Coalesce::Elem configuration. There are no review comments, so no further feedback is provided.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
What
Remove the
#ifdef __CPU_SIMfork in the SIMT element-scatter ST kernel(
kernel_simt_scatter.cpp)so both the CPU simulator and a5 onboard issue the same instruction:
MSCATTER<Coalesce::Elem, ScatterAtomicOp::None, ScatterOOB::Skip>(outGlobal, srcTile, idxTile);Why
The fork existed because pto-isa previously gated the templated
MSCATTERoverloads behind
PTO_NPU_ARCH_A5only — they weren't visible to the CPUsimulator, so the sim path had to fall back to the non-templated form
(pto-isa#164). The templated overloads were later opened to
__CPU_SIMaswell as
PTO_NPU_ARCH_A5(pto-isa#166), so the explicit templated call nowcompiles and runs identically on both backends.
This branch is based on current
main, whosepto_isa.pin(83d01313) is adescendant of
016396b5(bumped in #1156, the pto-isa#166 mechanism). At thatpin the
__CPU_SIMguard on the templated overload is present, which is whatlets the sim compile the explicit call.
Caveat — non-templated form is still not portable
Only the templated overload was unified. The non-templated
MSCATTER(dst, src, idx)still picks each backend's own default:Coalesce::Elemon CPU sim (pto/cpu/MScatter.hpp) vsCoalesce::Rowona5 onboard (
pto/npu/a5/MScatter.hpp). So the explicitMSCATTER<Coalesce::Elem, ...>is the only instruction that behaves the sameon both — hence keeping the template arguments rather than relying on the
non-templated default.
Testing
--platform a5sim:1 passed(run against the branch's pinned pto-isa83d01313, i.e. the same pin CI uses — no--pto-isa-commitoverride).exact instruction), so a5 behavior is unaffected. An a5 onboard rerun via
CI's
st-onboard-a5closes the loop — not available on the current a2a3 devbox.
Relationship to #1160
Supersedes #1160 (same change, by @ChaoZheng109). That PR's branch was cut
before #1156 landed and still pinned the pre-pto-isa#166 revision
ddafa8da, where the templated overload is not visible under__CPU_SIM—so its
st-sim-a5failed to compile ('Coalesce' was not declared in this scope). This branch is the same one-line cleanup, rebased onto currentmainso it builds against the correct pin.
Closes #1159