Skip to main content

EdgeSimd

Trait EdgeSimd 

Source
pub trait EdgeSimd: Sized + Copy {
    // Required methods
    fn dot_simd(a: &[Self], b: &[Self]) -> Self;
    fn exp_in_place_simd(x: &mut [Self]);
}
Expand description

SIMD-accelerated primitives over slices of a float type.

Implemented once per concrete float type; algorithm code never dispatches on the type itself.

Required Methods§

Source

fn dot_simd(a: &[Self], b: &[Self]) -> Self

Dot product of two equal-length slices.

§Params
  • a - Left operand
  • b - Right operand, must be the same length as a
§Returns

The sum of the elementwise products. Excess elements beyond b’s length are ignored, so a length mismatch truncates rather than panics.

Source

fn exp_in_place_simd(x: &mut [Self])

Exponentiates a slice in place.

This is the mu = exp(eta) step of every GLM fit in the crate, so it sits on the hottest path there is.

§Params
  • x - Values to exponentiate, modified in place

Note that each tier vectorises what it can and hands the remainder down, and the last tier calls libm. wide’s polynomial and libm disagree in the last ulp, so the same input value can come back with two different bit patterns depending on where in the slice it sits, on the slice length, and on which tier the machine dispatched to: vec![0.37; n] gives two distinct patterns for every odd n. This is elementwise rather than a reassociation, so it is a stronger caveat than the one on EdgeSimd::dot_simd, but the magnitude is still one ulp and nothing in the crate depends on it. The vector lanes also flush a deep underflow to zero where libm returns a subnormal: exp(-745.0) is exactly 0 in a lane, 5e-324 in the tail.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl EdgeSimd for f32

Source§

fn dot_simd(a: &[f32], b: &[f32]) -> f32

Source§

fn exp_in_place_simd(x: &mut [f32])

Source§

impl EdgeSimd for f64

Source§

fn dot_simd(a: &[f64], b: &[f64]) -> f64

Source§

fn exp_in_place_simd(x: &mut [f64])

Implementors§