Skip to content

Excessive alignment constraints for larger than machine-sized vectors #495

@MMunier

Description

@MMunier

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);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: a feature request, i.e. not implemented / a PR

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions