Trait vrl::Vec8fBase

source ·
pub trait Vec8fBase: SIMDBase<8> + SIMDFloat + Copy + Clone {
    // Required methods
    fn new(
        v0: f32,
        v1: f32,
        v2: f32,
        v3: f32,
        v4: f32,
        v5: f32,
        v6: f32,
        v7: f32
    ) -> Self;
    fn join(a: Vec4f, b: Vec4f) -> Self;
    unsafe fn load_ptr_aligned(addr: *const f32) -> Self;
    unsafe fn store_ptr_aligned(self, addr: *mut f32);
    unsafe fn store_ptr_non_temporal(self, addr: *mut f32);
    fn low(self) -> Vec4f;
    fn high(self) -> Vec4f;

    // Provided method
    fn split(self) -> (Vec4f, Vec4f) { ... }
}
Expand description

Base trait for Vec8f: a SIMD vector with eight elements of type f32.

Required Methods§

source

fn new( v0: f32, v1: f32, v2: f32, v3: f32, v4: f32, v5: f32, v6: f32, v7: f32 ) -> Self

Initializes elements of returned vector with given values.

§Example
assert_eq!(
    Vec8f::new(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0),
    [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0].into()
);
source

fn join(a: Vec4f, b: Vec4f) -> Self

Joins two Vec4f into a single Vec8f. The first four elements of returned vector are elements of a and the last four elements are elements of b.

See also split.

§Exmaples
let a = Vec4f::new(1.0, 2.0, 3.0, 4.0);
let b = Vec4f::new(5.0, 6.0, 7.0, 8.0);
let joined = Vec8f::join(a, b);
assert_eq!(a, joined.low());
assert_eq!(b, joined.high());
assert_eq!(joined.split(), (a, b));
source

unsafe fn load_ptr_aligned(addr: *const f32) -> Self

Loads vector from aligned array pointed by addr.

§Safety

Like load_ptr, requires addr to be valid. Unlike load_ptr, requires addr to be divisible by 32, i.e. to be a 32-bytes aligned address.

§Examples
#[repr(align(32))]
struct AlignedArray([f32; 8]);

let array = AlignedArray([42.0; 8]);
let vec = unsafe { Vec8f::load_ptr_aligned(array.0.as_ptr()) };
assert_eq!(vec, Vec8f::broadcast(42.0));

In the following example zeros is aligned as u16, i.e. 2-bytes aligned. Therefore zeros.as_ptr().byte_add(1) is an odd address and hence not divisible by 32.

let zeros = unsafe { std::mem::zeroed::<[u16; 20]>() };
unsafe { Vec8f::load_ptr_aligned(zeros.as_ptr().byte_add(1) as *const f32) };
source

unsafe fn store_ptr_aligned(self, addr: *mut f32)

Stores vector into aligned array at given address.

§Safety

Like store_ptr, requires addr to be valid. Unlike store_ptr, requires addr to be divisible by 32, i.e. to be a 32-bytes aligned address.

source

unsafe fn store_ptr_non_temporal(self, addr: *mut f32)

Stores vector into aligned array at given address in uncached memory (non-temporal store). This may be more efficient than store_ptr_aligned if it is unlikely that stored data will stay in cache until it is read again, for instance, when storing large blocks of memory.

§Safety

Has same requirements as store_ptr_aligned: addr must be valid and divisible by 32, i.e. to be a 32-bytes aligned address.

source

fn low(self) -> Vec4f

Returns the first four elements of vector.

§Exmaples
let vec8 = Vec8f::new(1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0);
assert_eq!(vec8.low(), Vec4f::broadcast(1.0));
source

fn high(self) -> Vec4f

Returns the last four elements of vector.

§Exmaples
let vec8 = Vec8f::new(1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0);
assert_eq!(vec8.high(), Vec4f::broadcast(2.0));

Provided Methods§

source

fn split(self) -> (Vec4f, Vec4f)

Splits vector into low and high halfs.

See also join.

§Example
let vec = Vec8f::new(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0);
let (low, high) = vec.split();
assert_eq!(low, vec.low());
assert_eq!(high, vec.high());
assert_eq!(Vec8f::join(low, high), vec);

Object Safety§

This trait is not object safe.

Implementors§