rust-lang / rust-lang/portable-simd
Excessive alignment constraints for larger than machine-sized vectors
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.1k
- Forks
- 108
- Avg merge
- 22h 53m
- Merged PRs (30d)
- 3
Description
I have been playing around with portable_simd on my regular avx512 capable laptop,
and noticed that the alignment constraints of the larger vector types seem to grow beyond the limitations imposed by the hardware (u64x64 require their full size, so 512 byte! alignment).
Is this behavior intended? (E.g. to be directly forward compatible with future even larger vector extensions?)
Since the underlying types leverage repr_simd this might be a issue for the compiler itself, but I wanted to check here first.
macro_rules! debug_simd_align {
(@inner $t:ty, $($N:literal)*) => {
$(
println!("{} {:?}", std::any::type_name::<Simd::<$t, $N>>(), std::alloc::Layout::new::<Simd::<$t, $N>>());
)*
};
($t:ty) => {
debug_simd_align!(@inner $t, 1 2 4 8 16 32 64)
};
}
#[test]
fn test_simd_alignment() {
debug_simd_align!(u8);
debug_simd_align!(u16);
debug_simd_align!(u32);
debug_simd_align!(u64);
debug_simd_align!(usize);
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided test_simd_alignment reproducer and inspect the portable_simd types plus their repr_simd representation. Confirm the reported alignment for larger vectors on the AVX-512 laptop, then determine whether the behavior is intentional or needs a change; done means a documented or tested resolution for the alignment constraints.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100