You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[CUB] Take a block offset in LoadDirectStripedVectorized - #12601
LoadDirectStripedVectorized loads the vectors block_offset items after the base pointer. The offset must be a multiple of VecSize, so the vectors keep that pointer's alignment.
The loads are unchanged: each vector is still a CubVector, and a pointer that is not aligned to it is still loaded item by item.
This is the first signature of the function, which is new in 3.6, so a later change of the vector width does not need an overload of the old signature.
Test plan
nvcc compiles a kernel that calls the new signature with LOAD_DEFAULT and LOAD_LDG
cub.cpp17.test.block_load covers a misaligned pointer and a block_offset that is a multiple of the vector size
Vectorized block loads can begin at an element offset within the input, so callers can select a tile without adjusting the input pointer themselves.
Offsets aligned to the vector width use vectorized loading; other offsets retain the same striped arrangement through item-by-item loading. Loads support aligned and unaligned input addresses and both default and LOAD_LDG cache modifiers.
LoadDirectStripedVectorized now accepts an item offset and uses it for vectorized and item-by-item loads. BlockLoad::Load passes zero. Tests cover offset loads across input alignments and cache modifiers.
The primitive accepts an integral block_offset and uses the offset pointer for vectorized loads and item-by-item fallback. BlockLoad::Load passes zero.
Offset load test coverage cub/test/catch2_test_block_load.cu
The test kernel and helper pass block_offset to the primitive. Tests check expected tiles for offsets 8 and three tile sizes, input alignment offsets 0 and 1, and default and LOAD_LDG modifiers.
Possibly related issues
NVIDIA/cccl#12419 — This change updates a striped vectorized load helper and its alignment and offset behavior, which relates to the issue’s vectorized global-load implementations.
Suggested reviewers:bernhardmgruber
Change: Feature
Merge Risk: Moderate · up to f41c3
The scalar fallback for misaligned inputs no longer applies the requested cache modifier. This can change load semantics, for example volatile loads, for existing BlockLoad users with striped vectorized loading. Restore the modifier in the fallback before merging.
Architecture risk: Low · up to f41c3
The change affects 1 system.
Changed systems:cub
Architecture concerns
No architecture-level concerns identified.
Review details
Systems and components
observed — cub (service) was modified; 2 changed files map to changed impact.
Before / after behavior
observed — Modified behavior in cub/test/catch2_test_block_load.cu: The kernel now accepts block_offset and forwards it to LoadDirectStripedVectorized; previously it passed no offset.
observed — Modified behavior in cub/test/catch2_test_block_load.cu: The test helper adds an optional block_offset parameter defaulting to zero and passes it through to the kernel launch.
observed — Modified behavior in cub/test/catch2_test_block_load.cu: Adds a test for loading a tile beginning at block_offset elements after the input. It generates alignment offsets 0 or 1 and block offsets 8 or three tile sizes, then checks the expected tile for default and LOAD_LDG modifiers.
observed — Modified behavior in cub/cub/block/block_load.cuh: The documentation now specifies that striped vectors are loaded from block_offset items after block_src_ptr.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
The function is new in 3.6, so its first signature loads the vectors `block_offset` items after the base pointer. The offset is a multiple of the vector size, which keeps the vectors aligned with that pointer, and later changes can select the vector width without adding an overload.
Reviewing files that changed from the base of the PR and between c7da36f and f41c362.
Files selected for processing: 1
cub/cub/block/block_load.cuh
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.
cat -n cub/cub/thread/thread_load.cuh | sed -n '240,400p'
Repository: NVIDIA/cccl
Length of output: 8139
important: Preserve Modifier in scalar loads.
When a non-volatile input falls back to scalar loads, LoadDirectBlocked uses ordinary pointer loads and ignores Modifier. This also affects BlockLoad with a cache-modified iterator. For LOAD_VOLATILE, the loads lack the volatile semantics of ThreadLoad<LOAD_VOLATILE>.
Preserve the modifier in the fallback and test the generated loads. Preserve the supported input types and their copy behavior.
The reason will be displayed to describe this comment to others. Learn more.
As discussed offline, I think this shouldn't be necessary since something like LoadDirectStripedVectorized(tid, assume_aligned<A>(ptr + offset), items) should give the desired effect.
I am especially unhappy because this is a public API and would then be the only one with an offset argument. Users will be confused.
If we really need this, can we make the one with an offset parameter internal and leave the public one as is?
This branch has not been deployed
No deployments
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
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.
Summary
LoadDirectStripedVectorizedloads the vectorsblock_offsetitems after the base pointer. The offset must be a multiple ofVecSize, so the vectors keep that pointer's alignment.CubVector, and a pointer that is not aligned to it is still loaded item by item.Test plan
nvcccompiles a kernel that calls the new signature withLOAD_DEFAULTandLOAD_LDGcub.cpp17.test.block_loadcovers a misaligned pointer and ablock_offsetthat is a multiple of the vector size