Skip to content
volt
GitHub

std::simd

Vectors of numbers kept in SIMD registers, so one operation works on every lane at once. vec(T, n) is the vector of n Ts (ints of up to 64 bits or f32/f64; n a power of two, 64 bytes at most); the usual ones have names. Two vectors of one type add, subtract and multiply lane by lane (int lanes wrap, as SIMD does), float lanes divide too and int lanes take & | ^, - negates every lane, v[i] reads or writes lane i (checked, as an array's index is), and a { } literal lists the lanes ({} is every lane 0).

Source: std/simd.volt

Functions

std::simd::vec

comptime fn vec(T: type, n: usize) -> type

the vector of n lanes of T

std::simd::lane

comptime fn lane(V: type) -> type

what each of V's lanes holds

std::simd::lanes

comptime fn lanes(V: type) -> usize

how many lanes V has

std::simd::splat

<V: type> fn splat(x: lane(V)) -> V

the vector with x in every lane: splat<std::simd::f64x4>(1.0)

std::simd::sum

<V: type> fn sum(v: V) -> lane(V)

v's lanes added up

std::simd::load

<V: type> fn load(xs: lane(V)[..]) -> V

the vector of xs' first lanes: load<std::simd::f64x4>(xs[i..]) (xs has at least that many)

std::simd::store

<V: type> fn store(v: V, xs: lane(V)[..]) -> void

v's lanes into xs' first elements (xs has at least as many)