silk.simd.f64x2.
Operations on simd<f64, 2>: two 64-bit float lanes in one 128-bit vector.
When to use#
Use this module to work on two f64 values at once. Use load and store
to move lanes between a slice and a vector, a lane comparison such as lanesEqual to make
a mask<2>, and silk.simd.mask2 to test that mask.
Details#
The operators +, -, *, / and % apply lane by lane and follow IEEE 754 as the
f64 operators do. == is true only when every lane is equal, and a NaN lane is never
equal. reduceAdd adds lanes in order, so it gives the same result on every target.
Lane 0 is at the lowest address in memory.
Examples#
Scale every lane and add the results#
import silk.simd.f64x2
pub fn main() -> i32 {
let values = f64x2.fromArray([1.0, 2.0])
let doubled = f64x2.mulAdd(values, f64x2.splat(2.0), f64x2.splat(0.0))
if f64x2.reduceAdd(doubled) != 6.0 {
return 1
}
return 0
}Import as f64x2 with import silk.simd.f64x2 as f64x2.
Public declarations: 37.
LANES#
pub const LANES: usizeThe number of lanes in a vector.
splat#
pub fn splat(lane: f64) -> simd<f64, 2>Returns a vector with every lane set to lane.
fromArray#
pub fn fromArray(lanes: [f64; 2]) -> simd<f64, 2>Returns a vector whose lane i is lanes[i].
toArray#
pub fn toArray(vector: simd<f64, 2>) -> [f64; 2]Returns the lanes of vector as an array, in lane order.
extract#
pub fn extract(vector: simd<f64, 2>, index: usize) -> f64Returns lane index of vector. Traps when index is LANES or more.
insert#
pub fn insert(vector: simd<f64, 2>, index: usize, lane: f64) -> simd<f64, 2>Returns vector with lane index replaced by lane. Traps when index is LANES or more.
load#
pub fn load(lanes: &[f64], offset: usize) -> simd<f64, 2>Reads LANES lanes of lanes starting at offset.
Gotchas#
Traps unless offset + LANES is at most lanes.length. The slice needs no alignment beyond
f64.
store#
pub fn store(lanes: &mut [f64], offset: usize, vector: simd<f64, 2>) -> ()Writes the lanes of vector into lanes starting at offset.
Gotchas#
Traps unless offset + LANES is at most lanes.length.
loadUnchecked#
pub unsafe fn loadUnchecked(pointer: [*]const f64) -> simd<f64, 2>Reads LANES lanes starting at pointer, with no bounds check.
Gotchas#
The caller proves that pointer addresses LANES live lanes aligned to f64.
storeUnchecked#
pub unsafe fn storeUnchecked(pointer: [*]mut f64, vector: simd<f64, 2>) -> ()Writes the lanes of vector starting at pointer, with no bounds check.
Gotchas#
The caller proves that pointer addresses LANES writable lanes aligned to f64.
lanesEqual#
pub fn lanesEqual(left: simd<f64, 2>, right: simd<f64, 2>) -> mask<2>Returns a mask with lane i set where lane i of left is equal to lane i of right. A comparison with a
NaN lane is false.
lanesNotEqual#
pub fn lanesNotEqual(left: simd<f64, 2>, right: simd<f64, 2>) -> mask<2>Returns a mask with lane i set where lane i of left is not equal to lane i of right. A NaN lane is
not equal to any lane.
lanesLess#
pub fn lanesLess(left: simd<f64, 2>, right: simd<f64, 2>) -> mask<2>Returns a mask with lane i set where lane i of left is less than lane i of right. A comparison with a
NaN lane is false.
lanesLessOrEqual#
pub fn lanesLessOrEqual(left: simd<f64, 2>, right: simd<f64, 2>) -> mask<2>Returns a mask with lane i set where lane i of left is less than or equal to lane i of right. A comparison with a
NaN lane is false.
lanesGreater#
pub fn lanesGreater(left: simd<f64, 2>, right: simd<f64, 2>) -> mask<2>Returns a mask with lane i set where lane i of left is greater than lane i of right. A comparison with a
NaN lane is false.
lanesGreaterOrEqual#
pub fn lanesGreaterOrEqual(left: simd<f64, 2>, right: simd<f64, 2>) -> mask<2>Returns a mask with lane i set where lane i of left is greater than or equal to lane i of right. A comparison with a
NaN lane is false.
select#
pub fn select(mask: mask<2>, chosen: simd<f64, 2>, other: simd<f64, 2>) -> simd<f64, 2>Returns lane i of chosen where lane i of mask is set, and lane i of other elsewhere.
minimum#
pub fn minimum(left: simd<f64, 2>, right: simd<f64, 2>) -> simd<f64, 2>Returns the smaller lane of each pair. A NaN lane in either input gives NaN, and -0.0 is
less than 0.0.
maximum#
pub fn maximum(left: simd<f64, 2>, right: simd<f64, 2>) -> simd<f64, 2>Returns the larger lane of each pair. A NaN lane in either input gives NaN, and -0.0 is
less than 0.0.
shuffle#
pub fn shuffle(left: simd<f64, 2>, right: simd<f64, 2>, static indices: [usize; 2]) -> simd<f64, 2>Returns a vector whose lane i is lane indices[i] of left followed by right.
Details#
An index below LANES selects from left, and an index from LANES to 2 * LANES - 1
selects from right. The indices are static, so each call is one fixed lane permutation.
reduceAdd#
pub fn reduceAdd(vector: simd<f64, 2>) -> f64Returns the sum of every lane, added in lane order from lane 0.
reduceAddUnordered#
pub fn reduceAddUnordered(vector: simd<f64, 2>) -> f64Returns the sum of every lane, added in the order the target prefers.
Gotchas#
The rounding can differ between targets. Use reduceAdd for a result that is the same
everywhere.
reduceMinimum#
pub fn reduceMinimum(vector: simd<f64, 2>) -> f64Returns the smallest lane. A NaN lane gives NaN.
reduceMaximum#
pub fn reduceMaximum(vector: simd<f64, 2>) -> f64Returns the largest lane. A NaN lane gives NaN.
sqrt#
pub fn sqrt(vector: simd<f64, 2>) -> simd<f64, 2>Returns the square root of each lane. A negative lane gives NaN.
mulAdd#
pub fn mulAdd(left: simd<f64, 2>, right: simd<f64, 2>, addend: simd<f64, 2>) -> simd<f64, 2>Returns left * right + addend for each lane, with one rounding.
toU64x2#
pub fn toU64x2(vector: simd<f64, 2>) -> simd<u64, 2>Converts each lane to u64 as the scalar conversion does. Traps when any lane does not
fit u64.
toI64x2#
pub fn toI64x2(vector: simd<f64, 2>) -> simd<i64, 2>Converts each lane to i64 as the scalar conversion does. Traps when any lane does not
fit i64.
bitcastToU8x16#
pub fn bitcastToU8x16(vector: simd<f64, 2>) -> simd<u8, 16>Returns the bits of vector as a simd<u8, 16>, in memory order.
bitcastToI8x16#
pub fn bitcastToI8x16(vector: simd<f64, 2>) -> simd<i8, 16>Returns the bits of vector as a simd<i8, 16>, in memory order.
bitcastToU16x8#
pub fn bitcastToU16x8(vector: simd<f64, 2>) -> simd<u16, 8>Returns the bits of vector as a simd<u16, 8>, in memory order.
bitcastToI16x8#
pub fn bitcastToI16x8(vector: simd<f64, 2>) -> simd<i16, 8>Returns the bits of vector as a simd<i16, 8>, in memory order.
bitcastToU32x4#
pub fn bitcastToU32x4(vector: simd<f64, 2>) -> simd<u32, 4>Returns the bits of vector as a simd<u32, 4>, in memory order.
bitcastToI32x4#
pub fn bitcastToI32x4(vector: simd<f64, 2>) -> simd<i32, 4>Returns the bits of vector as a simd<i32, 4>, in memory order.
bitcastToU64x2#
pub fn bitcastToU64x2(vector: simd<f64, 2>) -> simd<u64, 2>Returns the bits of vector as a simd<u64, 2>, in memory order.
bitcastToI64x2#
pub fn bitcastToI64x2(vector: simd<f64, 2>) -> simd<i64, 2>Returns the bits of vector as a simd<i64, 2>, in memory order.
bitcastToF32x4#
pub fn bitcastToF32x4(vector: simd<f64, 2>) -> simd<f32, 4>Returns the bits of vector as a simd<f32, 4>, in memory order.
Category: SIMD.
Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, wasm32-wasip1, wasm32-wasip2.