Skip to content

Add BLOCK_LOAD_STRIPED_VECTORIZE to cub::BlockLoad #12170

Open

Description

@bernhardmgruber

cub::BlockLoad has no algorithm that is both vectorized and coalesced:

Algorithm Vectorized Warp access pattern
BLOCK_LOAD_DIRECT no blocked, uncoalesced
BLOCK_LOAD_STRIPED no coalesced
BLOCK_LOAD_VECTORIZE yes blocked: lanes are ItemsPerThread * sizeof(T) apart
BLOCK_LOAD_TRANSPOSE, BLOCK_LOAD_WARP_TRANSPOSE[_TIMESLICED] no coalesced, then a shared-memory transpose to blocked

Proposal. Add BLOCK_LOAD_STRIPED_VECTORIZE: each thread loads vectors in a striped fashion. A warp's wide load then reads one contiguous, fully used segment, with no transpose. The resulting arrangement is not blocked, so this suits algorithms that don't depend on per-thread item order. Like BLOCK_LOAD_VECTORIZE, it should pick the widest word dividing ItemsPerThread * sizeof(T) (so non-power-of-two types work) and fall back when misaligned.

Motivation. DeviceFind hand-rolls exactly this load pattern, limited to power-of-two vector types. Replacing it with BLOCK_LOAD_VECTORIZE gives near-identical SASS, but the warp loads become strided, costing about 1% on 1–4 byte types on an RTX 5090. With the new algorithm, DeviceFind could drop its hand-written loads.

Other uses. agent_reduce (DeviceReduce, DeviceSegmentedReduce) and DeviceTransform's vectorized kernel hand-roll the same striped vector load, and agent_histogram approximates it with BlockLoad<VecT, ..., BLOCK_LOAD_STRIPED> over a manually chosen vector type.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

  • Status
    Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions