Reduce: vectorize contiguous by-block loads - #105
Merged
Conversation
shreyas-omkar
force-pushed
the
sh/vec-loads-simd
branch
from
August 17, 2026 11:31
40ab38f to
dcb27ad
Compare
shreyas-omkar
marked this pull request as ready for review
August 18, 2026 11:54
Member
Author
|
@christiangnrd and @maleadt Please review it :) |
Member
|
Can you add a few tests that are guaranteed to trigger this path? |
Member
Author
|
Yes I'll add them. |
shreyas-omkar
force-pushed
the
sh/vec-loads-simd
branch
from
August 18, 2026 14:40
d25dc26 to
1a3314e
Compare
Member
|
@shreyas-omkar I added |
shreyas-omkar
force-pushed
the
sh/vec-loads-simd
branch
from
August 18, 2026 17:37
1a3314e to
71c33cf
Compare
Member
Author
|
@christiangnrd . Thank you for adding it. I have used it in the PR. |
Load aligned stride-1 reductions in 128-bit vectors. Keep scalar loads for unsupported layouts, pointers, types, and index ranges. Route every by-block call site through the same dispatch.
maleadt
force-pushed
the
sh/vec-loads-simd
branch
from
August 19, 2026 13:43
71c33cf to
5b84a5d
Compare
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.
Use aligned 128-bit SIMD loads for stride-1 by-block reductions of 4- and
8-byte primitive elements. Each thread folds a
Vec{4}orVec{2}load intoits local accumulator; unsupported layouts continue through the scalar kernel.
The fast path requires a 16-byte-aligned buffer and row starts, a contiguous
reduced dimension, and an extent that is safe for the kernel's
UInt32indexarithmetic. A shared launcher applies the same dispatch to every by-block call
site.
The original benchmarks measured speedups of up to 44% on CUDA, 19% on AMDGPU,
37% on POCL, and 19% on oneAPI.
Validation:
ld.global.v4forFloat32and oneld.global.v2forFloat64