Make GPU reductions process multiple items per thread - #107
Merged
Conversation
shreyas-omkar
force-pushed
the
sh/backend-specialize
branch
from
August 6, 2026 05:18
02730e1 to
ec42890
Compare
shreyas-omkar
force-pushed
the
sh/backend-specialize
branch
from
August 18, 2026 16:55
ec42890 to
c581e6a
Compare
shreyas-omkar
marked this pull request as ready for review
August 18, 2026 16:55
shreyas-omkar
marked this pull request as draft
August 18, 2026 17:04
maleadt
reviewed
Aug 19, 2026
Let each reduction thread process a compile-time number of striped elements. The default remains two items per thread, preserving the existing load geometry, while backends and callers can select larger values.
Cover one, two, and four items per thread across odd input sizes and several map and reduction operators. Also reject zero explicitly.
maleadt
force-pushed
the
sh/backend-specialize
branch
from
August 19, 2026 12:37
c581e6a to
182e566
Compare
Member
|
I removed the tiling abstraction one again :-P It's really not worth here. I'll spend some time on it myself, but let's now just get the improvements out there as-is. |
maleadt
marked this pull request as ready for review
August 19, 2026 12:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GPU reductions currently process two items per thread. This PR makes that configurable with an items_per_thread keyword and a backend-specific default, while keeping the existing value of two by default.
The kernel uses a straightforward striped load so consecutive threads access consecutive elements. items_per_thread=1 is supported, and tests cover 1, 2, and 4 items per thread with uneven input sizes.
This keeps the useful performance knob without introducing a general tiling abstraction. A reusable block-collectives API can be developed separately when there are more consumers.
On the original RTX 3060 benchmark, using four items per thread reduced the time for a 64M-element Int32 sum from 1.36 ms to 0.85 ms. The benefit is hardware-dependent; K=2 and K=4 perform about the same on an RTX 5080.
Validated with the CUDA and OpenCL reduction test suites.