This module provides functions for working conveniently with SIMD (Single Instruction; Multiple Data), which may offer a potential boost in performance on some targets by performing the same operations on multiple elements at once. Please be aware that some functions are known to not work on MIPS.
Functions
fn countElementsWithValue(vec: anytype, value: field_call) VectorCount(@TypeOf(vec))
No documentation provided.
fn deinterlace(comptime vec_count: usize, interlaced: anytype) [vec_count]@Vector(vectorLength(@TypeOf(interlaced)) / vec_count, field_call)
The contents of
interlaced
is evenly split between vec_count vectors that are …The contents of
interlaced
is evenly split between vec_count vectors that are returned as an array. They “take turns”, receiving one element frominterlaced
at a time.fn extract(vec: anytype, comptime first: VectorIndex(@TypeOf(vec)), comptime count: VectorCount(@TypeOf(vec))) @Vector(count, field_call)
No documentation provided.
fn firstIndexOfValue(vec: anytype, value: field_call) ?VectorIndex(@TypeOf(vec))
No documentation provided.
fn interlace(vecs: anytype) @Vector(vectorLength(@TypeOf(elem_val_node)) * vecs.len, field_call)
Returns a vector whose elements alternates between those of each input vector. …
Returns a vector whose elements alternates between those of each input vector. For example,
interlace(.{[4]u32{11, 12, 13, 14}, [4]u32{21, 22, 23, 24}})
returns a vector containing.{11, 21, 12, 22, 13, 23, 14, 24}
.inline fn iota(comptime T: type, comptime len: usize) @Vector(len, T)
Returns a vector containing the first
len
integers in order from 0 tolen
-1….Returns a vector containing the first
len
integers in order from 0 tolen
-1. For example,iota(i32, 8)
will return a vector containing.{0, 1, 2, 3, 4, 5, 6, 7}
.fn join(a: anytype, b: anytype) @Vector(vectorLength(@TypeOf(a)) + vectorLength(@TypeOf(b)), field_call)
Returns a vector containing all elements of the first vector at the lower indice…
Returns a vector containing all elements of the first vector at the lower indices followed by all elements of the second vector at the higher indices.
fn lastIndexOfValue(vec: anytype, value: field_call) ?VectorIndex(@TypeOf(vec))
No documentation provided.
fn mergeShift(a: anytype, b: anytype, comptime shift: VectorCount(@TypeOf(a, b))) @TypeOf(a, b)
Joins two vectors, shifts them leftwards (towards lower indices) and extracts th…
Joins two vectors, shifts them leftwards (towards lower indices) and extracts the leftmost elements into a vector the size of a and b.
fn prefixScan(comptime op: std.builtin.ReduceOp, comptime hop: isize, vec: anytype) @TypeOf(vec)
Returns a vector whose elements are the result of performing the specified opera…
Returns a vector whose elements are the result of performing the specified operation on the corresponding element of the input vector and every hop’th element that came before it (or after, if hop is negative). Supports the same operations as the @reduce() builtin. Takes O(logN) to compute. The scan is not linear, which may affect floating point errors. This may affect the determinism of algorithms that use this function.
fn prefixScanWithFunc(comptime hop: isize, vec: anytype, comptime ErrorType: type, comptime func: fn (@TypeOf(vec), @TypeOf(vec)) if (ErrorType == void) @TypeOf(vec) else ErrorType!@TypeOf(vec), comptime identity: field_call) if (ErrorType == void) @TypeOf(vec) else ErrorType!@TypeOf(vec)
Same as prefixScan, but with a user-provided, mathematically associative functio…
Same as prefixScan, but with a user-provided, mathematically associative function.
fn repeat(comptime len: usize, vec: anytype) @Vector(len, field_call)
Returns a vector containing the same elements as the input, but repeated until t…
Returns a vector containing the same elements as the input, but repeated until the desired length is reached. For example,
repeat(8, [_]u32{1, 2, 3})
will return a vector containing.{1, 2, 3, 1, 2, 3, 1, 2}
.fn rotateElementsLeft(vec: anytype, comptime amount: VectorCount(@TypeOf(vec))) @TypeOf(vec)
Elements are shifted leftwards (towards lower indices). Elements that leave to t…
Elements are shifted leftwards (towards lower indices). Elements that leave to the left will reappear to the right in the same order.
fn rotateElementsRight(vec: anytype, comptime amount: VectorCount(@TypeOf(vec))) @TypeOf(vec)
Elements are shifted rightwards (towards higher indices). Elements that leave to…
Elements are shifted rightwards (towards higher indices). Elements that leave to the right will reappear to the left in the same order.
fn shiftElementsLeft(vec: anytype, comptime amount: VectorCount(@TypeOf(vec)), shift_in: field_call) @TypeOf(vec)
Elements are shifted leftwards (towards lower indices). New elements are added t…
Elements are shifted leftwards (towards lower indices). New elements are added to the right, and the leftmost elements are cut off so that no elements with indices below 0 remain.
fn shiftElementsRight(vec: anytype, comptime amount: VectorCount(@TypeOf(vec)), shift_in: field_call) @TypeOf(vec)
Elements are shifted rightwards (towards higher indices). New elements are added…
Elements are shifted rightwards (towards higher indices). New elements are added to the left, and the rightmost elements are cut off so that the size of the vector stays the same.
fn suggestVectorSize(comptime T: type) ?usize
Suggests a target-dependant vector size for a given type, or null if scalars are…
Suggests a target-dependant vector size for a given type, or null if scalars are recommended. Not yet implemented for every CPU architecture.
fn suggestVectorSizeForCpu(comptime T: type, comptime cpu: std.Target.Cpu) ?usize
No documentation provided.