Repository navigation
Open
Description
The issue consolidates implemented and potential optimizations for cub::WarpReduce.
The goal is to keep track of optimizations and provide a common place to track follow-up work.
Context:
Implemented
Hardware reduction (redux)
- Centralize hardware reduction implementations and capability traits in
warp_redux.cuh, simplify dispatch, and introduce native floating-point min/max support. - Extend native floating-point min/max reduction support to SM107.
- Improve dispatch between hardware reduction and shuffle reduction. Use hardware reduction for full 32-thread logical warps when the operator/type is supported; support partial valid counts through identity padding where available. Smaller logical warps retain shuffle reduction.
- Refine integer eligibility traits for hardware reduction.
- Prefer integer-mapped floating-point min/max over native FP32 redux: compare both approaches and disable the slower native path. The native implementation remains in the source, but its capability trait is disabled.
Operator and type specializations
- Wide integer bitwise reductions: reduce independent 32-bit chunks with hardware instructions. Reported improvements: approximately 4× for 64-bit and 25× for 128-bit integers.
- Extend the bitwise specialization to signed integer types.
- Wide integer sum: use carry-aware decomposition with three hardware reductions for 64-bit integers and five for 128-bit integers. Reported improvements: 2.4× and 5.8×, respectively.
- Wide integer min/max: reduce words from most significant to least significant, retaining candidate lanes. Use two hardware reductions for 64-bit integers and four for 128-bit integers. Reported improvements: 4× and 20×, respectively.
- Floating-point min/max: map values to order-preserving integer representations and reuse integer hardware reductions. Cover
__half,__nv_bfloat16,float,double, and__float128, subject to target/type availability. - Boolean reductions: use warp vote instructions for
logical_andandlogical_or, including smaller power-of-two logical warps and partial valid counts. Reported results on RTX A6000: 9× lower latency and 6× higher throughput.
Related work
- Add
Min/Maxand multiple-items-per-thread overloads. - Add internal integer splitting/merging and floating-point comparison mappings.
- Extend internal thread operators, SIMD support, and logical warp utilities.
- Clean up the
WarpReduceimplementation, centralize existing optimizations, and add hardware specializations for bitwise AND/OR. - Add device-side
WarpReducethroughput benchmarks covering integer, floating-point, and complex types, including extended floating-point types; validate generated instructions. - Add
BlockReducebenchmarks to compare its algorithms and evaluate downstream performance. - Improve generic
cuda::device::warp_shufflecode generation and register usage. - Reenable HW warp redux min/max f32
Potential follow-up work
- Segmented hardware reductions: evaluate hardware reduction and vote paths for head-/tail-segmented reductions, accounting for segment-mask construction and segment size. The current shuffle implementation still performs reduction steps.
- Non-power-of-two logical warps: revisit the shared-memory fallback and evaluate shuffle-based alternatives, preserving participation and ordering requirements.
- Shuffle fallback: revisit predication, compile-time masks, reduction-tree structure, and recursive template instantiation for unsupported hardware combinations.
- Packed/SIMD reductions: evaluate specialized sum and min/max paths for
__half2,__nv_bfloat162,float2,short2, andushort2, including DPX instructions where applicable. - Complex sum: evaluate mapping complex values to packed/vector representations and reusing optimized component-wise reductions.
- Absolute min/max operators: consider introducing suitable operators and enabling the corresponding hardware instructions.
- TODO in warp_redux.cuh
- Result broadcast: evaluate an explicit API for returning the aggregate to every participating lane.
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
- StatusShow more project fieldsTodo
Activity
arcusbuilds commentedon Oct 16, 2026
Hi @fbusato, I'd like to take the packed min/max follow-up for
__half2,__nv_bfloat162,short2andushort2.Plan: split the pair into its two 16-bit lanes, reuse the order-preserving integer mapping from #11974, and do two
redux.syncreductions instead of the shuffle tree, then repack. I'd addshort2/ushort2sum the same way, and extend the existingWarpReducetests and the #6431 benchmarks to cover the new types.fbusato commentedon Oct 16, 2026
@arcusbuilds, thanks for looking at the issue. I'm not 100% sure that the proposed approach is strongly valuable.
reduxis ~3x faster than shuffle reduction. On the other hand, we could use@p add.s16x2to leverage SIMD instructions. So thereduxapproach could be only slightly faster, or even slower considering register moving from packed to plain values.We also need to keep in mind that
reduxneeds the full mask.Third minor related problem. There are more than one data type that map to
__half2,__nv_bfloat162,short2,ushort2, e.g. arrays, spans,cuda::std::simdetc.