Repository navigation
feat(intrinsics): add CTA barrier reductions - #1138
almightychang wants to merge 3 commits into
Conversation
Signed-off-by: Sam, Joochul Chang <almightychang@icloud.com>
Signed-off-by: Sam, Joochul Chang <almightychang@icloud.com>
Signed-off-by: Sam, Joochul Chang <almightychang@icloud.com>
|
nihalpasham
left a comment
There was a problem hiding this comment.
- Benefit required: name the concrete workload and show whether fused barrier reduction removes synchronization/instructions, improves performance, or closes a safety/API gap. The current PR adds surface area without establishing that benefit.
- Compiler blocker: LLVM 21 leaves all 12 reduction calls unresolved, so
ptxasrejects the generated PTX. - libNVVM blocker:
sync_allemits one operand but declaresr,r,~{memory}. The extra constraint makes the inline assembly contract invalid. - Metadata blocker: aligned
bar.redforms are assigned later PTX/SM floors even though the instruction family is valid at PTX 2.0 /sm_20. - Safety/test blocker: the unsafe contract is incomplete, some generated docs contain unrelated atomic text, and the example never launches a kernel or checks a result.
- A complete repair needs an LLVM fallback or inline-PTX lowering, corrected libNVVM constraints and canonical floors, regenerated docs/ABI, plus a real GPU oracle and sanitizer run. Generator and MIR-lowering suites pass locally, but they do not cover these failures.
|
Reviewed this as part of a full pass over the open queue. Closing it. The catalog plumbing itself follows the #721 counted-barrier route correctly, so this isn't about the approach; it's about what's broken in the current head and what's missing around it. Correctness problems we verified by running things, not just reading
And the bar itself Features need a concrete consumer and evidenced benefit. This adds 13 raw unsafe intrinsics while explicitly deferring the CUDA-parity wrappers ( If you want to bring this back
The instruction family is worth having; this needs to arrive working and with a consumer. |
Summary
Admit 13 CTA barrier intrinsics end to end: 12 reduction forms and
barrier.cta.sync.all. LLVM imported these records, but the catalog did not admit them. PR #721 already admitted the four countedbarrier.cta.{sync,arrive}[.aligned].countsiblings, so this PTX family was only half admitted.Users already had
sync_threads(), but there was no path corresponding to CUDA's__syncthreads_and,__syncthreads_or, or__syncthreads_count, including no inline-assembly route.Changes
allandcountshapes, with plainbarrier.redand alignedbar.redspellings: 12 intrinsics total.barrier.cta.sync.all.selp.b32followed by truncation toi1; keep POPC results as directu32values.counted_barrierexample with compile-only coverage for all 13 additions: 4 AND forms, 4 OR forms, 4 POPC forms, andbarrier_cta_sync_all.This PR keeps the libNVVM route at
minimum_sm = sm_75. That is the CUDA 12.9 evidence target, not the instruction floor. It will be lowered only after evidence is produced at a lower target. The counted-barrier siblings already use the same evidence floor.This PR exposes only raw APIs that take a barrier ID; count forms also take the participant count. CUDA-style barrier-ID-free wrappers remain out of scope. They can be added after a separate safety and barrier-ID aliasing contract is agreed.
The current branch-generated ABI entries occupy
i1016..i1028, but that range is not a merge contract. Open PRs #1101 and #1104 also start ati1016. Immediately before merge, this branch will rebase onto the latestmain, append its entries after the then-current ledger end, and regenerate all generated files.Testing
just checkpasses (the local mirror of CI:cargo oxide fmt --check, clippy, tests, CUDA-linked tests, guards, generated-intrinsic checks, ABI history, rustdoc, and doctests). Exit 0 with local CUDA 12.9 and pinned LLVM 22.1.2.cargo oxide run <example>passes, orscripts/smoketest.sh -o '^<example>$'— runtime was not executed because this machine has no usable GPU (nvidia-smireports a driver/NVML communication failure).counted_barrierexample).Additional checks actually run:
bash scripts/check-book-catalog-stamp.sh: exit 0; stamp9b5ce71c, 588 total NVVM operations, 562 generated operations, 1028 catalog entries.scripts/smoketest.sh --compile-only --no-color --only '^counted_barrier$':Pass: 1 / 1, using local CUDA 12.9 and pinned LLVM 22.1.2. The compile-only kernel covers all 13 additions listed above; it is deliberately not launched.cargo run -p cuda-intrinsics-gen -- probe --all --skip-terminal: all 1028 LLVM routes passed. The pinnedllcselectedbarrier.red.and.pred,barrier.red.or.pred, andbarrier.red.popc.u32, plus aligned forms andbarrier.sync.ptxasassembled the recorded PTX evidence. Evidence profile names identify the local CUDA 12.9.86 toolkit.-W --keep-goingbuild: succeeded.git diff --check main..HEAD: exit 0.cargo run -p cuda-intrinsics-gen -- check-abi-history --base-ref b7fe543b:intrinsics/abi-v1.toml preserves 1015 base entries and has 1028 total entries. Run explicitly against the PR base, sincejust checkdefaults this toHEAD^, which is not the pre-ABI base on a three-commit branch.Not verified locally:
llc-21/opt-21.ptxasacceptance. Local terminal evidence uses CUDA 12.9.86.runtime_validationremainsunexecuted; compile and assembly evidence does not claim runtime semantics.just checkdeliberately excludes these CI jobs, as documented in the Justfile: per-example clippy, examples-compile, book, and CodeQL. The focused changed-example compile and book build above cover local substitutes; CodeQL and the exact CUDA 13.1.1/LLVM 21 environment remain CI-only.Checklist
git commit -s)