Skip to main content

coalesce_alignment

Function coalesce_alignment 

Source
pub fn coalesce_alignment(access_width: usize, warp_size: u32) -> usize
Expand description

Computes the smallest alignment that ensures coalesced memory access for a given access_width (in bytes) across a warp of warp_size threads.

The coalesced access pattern requires that warp_size * access_width bytes are naturally aligned to the segment boundary used by the memory controller. This function returns the smallest power-of-two alignment that is at least warp_size * access_width bytes, capped at 4096 (page alignment).

§Examples

// 32 threads × 4 bytes = 128 → rounded up to 128
assert_eq!(coalesce_alignment(4, 32), 128);
// 32 threads × 16 bytes = 512
assert_eq!(coalesce_alignment(16, 32), 512);