Skip to content

Make GPU reductions process multiple items per thread - #107

Merged
maleadt merged 2 commits into
JuliaGPU:mainfrom
shreyas-omkar:sh/backend-specialize
Aug 20, 2026
Merged

Make GPU reductions process multiple items per thread#107
maleadt merged 2 commits into
JuliaGPU:mainfrom
shreyas-omkar:sh/backend-specialize

Conversation

@shreyas-omkar

@shreyas-omkar shreyas-omkar commented Aug 5, 2026

Copy link
Copy Markdown
Member

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.

@shreyas-omkar
shreyas-omkar force-pushed the sh/backend-specialize branch from 02730e1 to ec42890 Compare August 6, 2026 05:18
@shreyas-omkar
shreyas-omkar force-pushed the sh/backend-specialize branch from ec42890 to c581e6a Compare August 18, 2026 16:55
@shreyas-omkar
shreyas-omkar marked this pull request as ready for review August 18, 2026 16:55
@shreyas-omkar
shreyas-omkar marked this pull request as draft August 18, 2026 17:04
Comment thread src/reduce/mapreduce_1d_gpu.jl Outdated
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 maleadt changed the title Add compile-time tiling primitive and use it in the 1D reduce Make GPU reduction items per thread configurable Aug 19, 2026
@maleadt
maleadt force-pushed the sh/backend-specialize branch from c581e6a to 182e566 Compare August 19, 2026 12:37
@maleadt maleadt changed the title Make GPU reduction items per thread configurable Make GPU reductions process multiple items per thread Aug 19, 2026
@maleadt

maleadt commented Aug 19, 2026

Copy link
Copy Markdown
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
maleadt marked this pull request as ready for review August 19, 2026 12:38
@maleadt
maleadt merged commit 6d7e105 into JuliaGPU:main Aug 20, 2026
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants