Skip to content

Make GPU scans process multiple items per thread - #108

Merged
maleadt merged 6 commits into
JuliaGPU:mainfrom
shreyas-omkar:sh/accumulate-raking
Aug 21, 2026
Merged

Make GPU scans process multiple items per thread#108
maleadt merged 6 commits into
JuliaGPU:mainfrom
shreyas-omkar:sh/accumulate-raking

Conversation

@shreyas-omkar

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

Copy link
Copy Markdown
Member

GPU scans currently process two items per thread. This PR makes that configurable with an items_per_thread keyword and uses eight by default where the element type fits within the 32 KiB shared-memory baseline. The value does not need to be a power of two.

Each thread scans a blocked run after a coalesced load, then the block scans the per-thread totals. On an RTX 5080 with 64M Int32 elements, this reduced ScanPrefixes from 2.00 ms to 1.31 ms and DecoupledLookback from 10.4 ms to 3.8 ms.

This also fixes multi-block exclusive DecoupledLookback scans. After inclusive carry propagation, two epilogue kernels save one boundary value per tile and shift each tile in place; no full-array temporary is allocated. ScanPrefixes remains the default.

Validated with the CUDA and OpenCL accumulate test suites.

@shreyas-omkar

Copy link
Copy Markdown
Member Author

Cross-backend, Float32

Backend (GPU) n ipt=2 (GB/s) ipt=4 (GB/s) ipt=8 (GB/s)
CUDA RTX 5080 1M 70.5 81.0 87.5
16M 489 578 578
64M 269 413 408
AMDGPU RX 9060 XT 1M 97.5 106.7 90.2
16M 139 143 137
64M 57.0 146 137
128M 29.8 148 139
Metal Apple M5 1M 10.4 10.1 10.5
16M 12.4 55.5 60.2
64M 6.3 20.7 40.8
POCL Ryzen 7700X* 1M 3.1 5.2 7.8
8M 3.3 6.7 9.4

@maleadt maleadt changed the title perf(scan): register-raking items-per-thread GPU prefix scan Make GPU scans process multiple items per thread Aug 19, 2026
@maleadt
maleadt force-pushed the sh/accumulate-raking branch from e4c354d to f4e36c6 Compare August 19, 2026 13:44
Comment thread test/generic/accumulate.jl
shreyas-omkar and others added 6 commits August 20, 2026 19:32
Scan block_size*items_per_thread elements by combining per-thread runs
with a block-wide scan. Keep the default within the 32 KiB shared-memory
baseline for wide element types.

For multi-block exclusive decoupled lookback, save tile boundaries in
per-block scratch and shift each tile in place after carry propagation.
Cover nonuniform exclusive scans for both algorithms, non-power-of-two
item counts, wide element types, and oversized scratch arrays.
@maleadt
maleadt force-pushed the sh/accumulate-raking branch from 5f2f07f to c2cd74f Compare August 20, 2026 17:37
@maleadt
maleadt merged commit 0ed7cd3 into JuliaGPU:main Aug 21, 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.

3 participants