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
Commit 2ffc19b
Browse filesBrowse the repository at this point in the historyBrowse files
feat(cuda-device): derive an SM floor cfg and use redux.sync in warp_reduce (#1305)
## What This PR Does
Derives a shared compute-capability floor (`resolve_sm_floor`) across
`mir-importer` and both backend target selectors, and uses
single-instruction `redux.sync` for full-warp `u32`/`i32` reductions in
`cooperative_groups::warp_reduce` when the target floor is `sm_80` or
newer:
1. **Shared SM Floor (`cuda-target-spec`, `mir-importer`,
`cuda-oxide-codegen`)**: `resolve_sm_floor` sets the floor from an
explicit target (`--arch` / `CUDA_OXIDE_TARGET`), or `min(80,
detected_gpu)` when unpinned. Both PTX and NVVM target selectors enforce
`selected.capability() >= floor`, and `mir-importer` folds
`cuda_device::warp::__target_has_integer_redux_sync()` at MIR-import
time without needing a `cuda-device/build.rs` (keeping `cuda-device` and
`cuda-host` cached across `--arch` switches).
2. **Full-Warp Integer `redux.sync` (`cuda-device`)**: Full-warp (`N ==
32`) `u32` (`Sum`, `Min`, `Max`, `BitAnd`, `BitOr`, `BitXor`) and `i32`
(`Sum`, `Min`, `Max`) `warp_reduce` calls emit `redux.sync` at `sm_80+`,
while `f32`, sub-warp tiles (`N < 32`), and `sm_75` builds keep the
shuffle butterfly.
3. **Legacy NVVM Legalization (`nvvm-transforms`)**: Rewrites the 8
integer `llvm.nvvm.redux.sync.*` intrinsics to convergent inline PTX on
the LLVM 7 `libNVVM` path (`sm_80`..`sm_90`).
```text
BEFORE (warp_reduce::<u32, Sum, 32> on sm_80+):
5-round butterfly: 5x shfl.sync.bfly.b32 + 5x add.s32 (10 instructions)
AFTER (warp_reduce::<u32, Sum, 32> on sm_80+):
sm_80+ floor: 1x `redux.sync.add.s32` instruction
sm_75 floor: 5-round shuffle butterfly (unchanged)
```
---
## Verification
* **GPU Execution (`RTX 5090`, `sm_120a`)**: `cargo oxide run
warp_reduce_redux` (default `sm_120a`, `--arch sm_75`, and
`--emit-nvvm-ir --arch sm_80`), `verify-code-shape.sh`, and the
`assert_only_expected_rebuilt` cache-freshness check across `--arch`
switches all pass (`compute-sanitizer --tool memcheck`: `0 errors`).
* **Tests & CI Gates**: `cargo test -p cuda-target-spec -p cuda-device
-p nvvm-transforms -p cuda-oxide-codegen -p mir-importer --all-targets`,
`just fmt-check`, `cargo clippy`, and all repository guards pass.
Partially addresses #811
---------
Signed-off-by: Vyncint Ng <115854244+vyncint@users.noreply.github.com>
Signed-off-by: nihalpasham <nihalp@nvidia.com>
Co-authored-by: nihalpasham <nihalp@nvidia.com>
0 commit comments