rust-lang / rust-lang/portable-simd

Excessive alignment constraints for larger than machine-sized vectors

Open
#495 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-feature-request
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.