nupp.simd

Explicit SIMD support.

simd.species returns a species for an element: as wide as the running code's vector registers, and one lane wide where there are none, so a kernel is written once and species:over runs it a chunk at a time, the last chunk under its tail mask:

local array = require("nupp.mem.array")
local span = require("nupp.mem.span")
local simd = require("nupp.simd")

@aot
local function countQuotes(borrows source: span.Span<uint8>): uint32
    local species = simd.species(array.uint8)
    local found: uint32 = 0
    for at, active in species:over(#source) do
        found = found + ((species:load(source, at, active) == 34) & active):count()
    end
    return found
end

Loads are span-checked, inactive tail lanes read as zero, and bits() maps the first logical lane to bit zero. A vector and a mask have no boxed Lua representation in compiled code, where they are registers. In a body running as ordinary Lua a preferred species is one lane wide, so a vector is a number and a mask a boolean, and a fixed species simd.species(array.float, 4) is its four lanes, so a vector is a table of four numbers and a mask of four booleans. simd.vectors is the species where there are vector registers and nil where there are none, for a kernel that keeps a hand-written scalar loop of its own.

Use explicit vectors when SIMD execution is part of the algorithm: shuffles, transposes, prefix scans, fixed-tree reductions, gathers, compress, expand, or any loop that should run in vector lanes. simd.reducer accepts scalar contributions or explicit vector-plus-mask contributions, and simd.horizontal reduces a vector to one value.

See SIMD programming for the complete SIMD contract.

Module contents

Types

TypeKindDescription
AlgebraicDotrecordA dot product permitting reassociation and multiply-add contraction.
AlgebraicProductrecordA floating-point product whose named contract permits reassociation.
AlgebraicSumrecordA floating-point sum whose named contract permits reassociation.
AllrecordWhether every contribution is true; true for an empty loop.
AndBitsrecord
AnyrecordWhether any contribution is true; false for an empty loop.
CompensatedSumrecordA floating-point sum carrying the rounding error each addition discards.
CountrecordCounts true contributions exactly, modulo 2^64.
FixedinterfaceA target-neutral fixed logical lane count.
IntegerArgMaxrecordFirst one-based logical position of the integer extremum; zero when empty.
IntegerArgMinrecordFirst one-based logical position of the integer extremum; zero when empty.
IntegerMaxrecordAn integer extremum including its initial value.
IntegerMinrecordAn integer extremum including its initial value.
MaskinterfaceOne predicate bit per lane of Vector<T, S>.
NumberArgMaxrecordFirst logical position, or zero when empty.
NumberArgMinrecordFirst logical position, or zero when empty.
NumberMaxrecordFloating extremum including the initial value; NaNs are canonicalized.
NumberMinrecordFloating extremum including the initial value; NaNs are canonicalized.
OrBitsrecord
OrderedDotrecordA dot product committed in logical iteration order without contraction.
OrderedProductrecordA floating-point product committed in logical iteration order.
OrderedSumrecordA floating-point sum committed in logical iteration order.
PairwiseDotrecordA non-contracting dot product using the adjacent-pair sum tree.
PairwiseProductrecordA floating-point product using the width-independent adjacent-pair tree.
PairwiseSumrecordA floating-point sum using the width-independent adjacent-pair tree.
PreferredinterfaceTarget-selected native species identity.
PropagatingArgMaxrecordFirst logical position, or zero when empty.
PropagatingArgMinrecordFirst logical position, or zero when empty.
PropagatingMaxrecordFloating extremum including the initial value; NaNs are canonicalized.
PropagatingMinrecordFloating extremum including the initial value; NaNs are canonicalized.
ReducerinterfaceWhat every reducer shares: contributions go in through add, and value returns the finished reduction as a T.
SpeciesinterfaceOperations whose lane count is selected from T and S at AOT lowering.
VectorinterfaceAn immutable register-as-data value.
WrappingProductrecord
WrappingSumrecordFixed-width reducers name their element with its array witness, as a species does.
XorBitsrecord

Functions

FunctionKindDescription
horizontal.algebraicDotfunctionAs ordinary Lua the vectors are one lane each, which is the product.
horizontal.algebraicProductfunctionAs ordinary Lua a preferred-species vector is one lane, which is the reduction; a fixed-species vector is folded.
horizontal.algebraicSumfunctionAs ordinary Lua a preferred-species vector is one lane, which is the reduction; a fixed-species vector is folded.
horizontal.andBitsfunctionThe bitwise and of every lane of an integer vector.
horizontal.integerMaxfunctionThe largest lane of an integer vector, by the element's signedness.
horizontal.integerMinfunctionThe smallest lane of an integer vector, by the element's signedness.
horizontal.numberArgMaxfunctionAs ordinary Lua a preferred-species vector is one lane, which is the position; a fixed-species vector is searched.
horizontal.numberArgMinfunctionAs ordinary Lua a preferred-species vector is one lane, which is the position; a fixed-species vector is searched.
horizontal.numberMaxfunctionAs ordinary Lua a preferred-species vector is one lane, which is the reduction; a fixed-species vector is folded.
horizontal.numberMinfunctionAs ordinary Lua a preferred-species vector is one lane, which is the reduction; a fixed-species vector is folded.
horizontal.orBitsfunctionThe bitwise or of every lane of an integer vector.
horizontal.orderedDotfunctionAs ordinary Lua the vectors are one lane each, which is the product.
horizontal.orderedProductfunctionAs ordinary Lua a preferred-species vector is one lane, which is the reduction; a fixed-species vector is folded.
horizontal.orderedSumfunctionAs ordinary Lua a preferred-species vector is one lane, which is the reduction; a fixed-species vector is folded.
horizontal.pairwiseDotfunctionAs ordinary Lua the vectors are one lane each, which is the product.
horizontal.pairwiseProductfunctionAs ordinary Lua a preferred-species vector is one lane, which is the reduction; a fixed-species vector is folded.
horizontal.pairwiseSumfunctionAs ordinary Lua a preferred-species vector is one lane, which is the reduction; a fixed-species vector is folded.
horizontal.propagatingArgMaxfunctionAs ordinary Lua a preferred-species vector is one lane, which is the position; a fixed-species vector is searched.
horizontal.propagatingArgMinfunctionThe one-based lane holding the matching reduction's answer.
horizontal.propagatingMaxfunctionAs ordinary Lua a preferred-species vector is one lane, which is the reduction; a fixed-species vector is folded.
horizontal.propagatingMinfunctionThe smallest lane, and the largest, under the contract the name selects.
horizontal.wrappingProductfunctionThe lanes of an integer vector multiplied, wrapping in the lane's width.
horizontal.wrappingSumfunctionThe lanes of an integer vector summed, wrapping in the lane's own width: a byte vector's sum wraps at a byte, as...
horizontal.xorBitsfunctionThe bitwise exclusive or of every lane of an integer vector.
lane.binaryfunction
lane.fromStoragefunctionThe N-lane vector a stored Fixed field holds: storage is the field's C array, lane i at index i - 1, each wrapped...
lane.methodfunction
lane.unaryfunction
reducer.allfunctionConstructs an all reducer.
reducer.andBitsfunctionConstructs a bitwise and over element, including the supplied initial value.
reducer.anyfunctionConstructs an any reducer.
reducer.countfunctionConstructs a count reducer.
reducer.integerArgMaxfunctionConstructs an integer argmax reducer.
reducer.integerArgMinfunctionConstructs an integer argmin reducer.
reducer.integerMaxfunctionConstructs an integer max reducer.
reducer.integerMinfunctionConstructs an integer min reducer.
reducer.orBitsfunctionConstructs a bitwise or over element, including the supplied initial value.
reducer.wrappingProductfunctionConstructs a wrapping product over element, including the supplied initial value.
reducer.wrappingSumfunctionConstructs a wrapping sum over element, including the supplied initial value.
reducer.xorBitsfunctionConstructs a bitwise exclusive or over element, including the supplied initial value.
transposefunctionTransposes a square tile of Fixed row vectors into N column vectors.

Values

ValueKindDescription
horizontalvariableNamed horizontal operations over an explicit register value.
lanevariableThe lane operations, as the code generator calls them for a value the checker typed as a vector or a mask: a binary...
reducervariableClosed reduction values for scalar or explicit masked vector contributions.

Types#

AlgebraicDotrecord#

record simd.AlgebraicDot<T is float | number> is simd.Reducer<T> ...

A dot product permitting reassociation and multiply-add contraction.

T is the element it accumulates in: number is binary64, and float is binary32, each contribution and every operation's result rounded as nupp.math.f32 rounds them. Ordinary Lua rounds each product before adding it; native lowering may fuse the two.

Type parameters

NameDescription
T

Members

NameKindDescription
totalfield
roundmethod
addmethodactive selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the...
valuemethod

totalfield#

total: number
@private

roundmethod#

round: function(number): number
@private
Arguments
NameTypeDescription
?number
Returns
TypeDescription
number

addmethod#

add: function add<S>(self, left: T | simd.Vector<T, S>, right: T | simd.Vector<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the do block around it. As ordinary Lua a preferred species is one lane wide, so the vector is that lane's value and the mask a boolean; a fixed species contributes its lanes in order, each under its own lane of the mask.

Arguments
NameTypeDescription
selfany
leftT | simd.Vector<T, S>
rightT | simd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): T
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
T

AlgebraicProductrecord#

record simd.AlgebraicProduct<T is float | number> is simd.Reducer<T> ...

A floating-point product whose named contract permits reassociation.

T is the element it accumulates in: number is binary64, and float is binary32, each contribution and every operation's result rounded as nupp.math.f32 rounds them.

Type parameters

NameDescription
T

Members

NameKindDescription
totalfield
roundmethod
addmethodactive selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the...
valuemethod

totalfield#

total: number
@private

roundmethod#

round: function(number): number
@private
Arguments
NameTypeDescription
?number
Returns
TypeDescription
number

addmethod#

add: function add<S>(self, value: T | simd.Vector<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the do block around it. As ordinary Lua a preferred species is one lane wide, so the vector is that lane's value and the mask a boolean; a fixed species contributes its lanes in order, each under its own lane of the mask.

Arguments
NameTypeDescription
selfany
valueT | simd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): T
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
T

AlgebraicSumrecord#

record simd.AlgebraicSum<T is float | number> is simd.Reducer<T> ...

A floating-point sum whose named contract permits reassociation.

Ordinary Lua has no lane width to exploit, so its executable reference uses a left fold. Native lowering may use several accumulators.

T is the element it accumulates in: number is binary64, and float is binary32, each contribution and every operation's result rounded as nupp.math.f32 rounds them.

Type parameters

NameDescription
T

Members

NameKindDescription
totalfield
roundmethod
addmethodactive selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the...
valuemethod

totalfield#

total: number
@private

roundmethod#

round: function(number): number
@private
Arguments
NameTypeDescription
?number
Returns
TypeDescription
number

addmethod#

add: function add<S>(self, value: T | simd.Vector<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the do block around it. As ordinary Lua a preferred species is one lane wide, so the vector is that lane's value and the mask a boolean; a fixed species contributes its lanes in order, each under its own lane of the mask.

Arguments
NameTypeDescription
selfany
valueT | simd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): T
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
T

Allrecord#

record simd.All is simd.Reducer<boolean> ...

Whether every contribution is true; true for an empty loop.

Members

NameKindDescription
totalfield
addmethodactive selects the lanes of a mask that contribute, each lane's truth in lane order, as one masked contribution per...
valuemethod

totalfield#

total: boolean
@private

addmethod#

add: function add<T, S>(self, value: boolean | simd.Mask<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a mask that contribute, each lane's truth in lane order, as one masked contribution per iteration of the do block around it. As ordinary Lua a preferred species is one lane wide, so both masks are booleans; a fixed species contributes its lanes in order, each under its own lane of active.

Arguments
NameTypeDescription
selfany
valueboolean | simd.Mask<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): boolean
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
boolean

AndBitsrecord#

record simd.AndBits<T is int32 | uint32 | int64 | uint64> is simd.Reducer<T> ...

Type parameters

NameDescription
T

Members

NameKindDescription
totalfield
operationmethod
addmethodactive selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the...
valuemethod

totalfield#

total: T
@private

operationmethod#

operation: function(T, T): T
@private
Arguments
NameTypeDescription
?T
?T
Returns
TypeDescription
T

addmethod#

add: function add<S>(self, value: T | simd.Vector<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the do block around it. As ordinary Lua a preferred species is one lane wide, so the vector is that lane's value and the mask a boolean; a fixed species contributes its lanes in order, each under its own lane of the mask.

Arguments
NameTypeDescription
selfany
valueT | simd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): T
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
T

Anyrecord#

record simd.Any is simd.Reducer<boolean> ...

Whether any contribution is true; false for an empty loop.

Members

NameKindDescription
totalfield
addmethodactive selects the lanes of a mask that contribute, each lane's truth in lane order, as one masked contribution per...
valuemethod

totalfield#

total: boolean
@private

addmethod#

add: function add<T, S>(self, value: boolean | simd.Mask<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a mask that contribute, each lane's truth in lane order, as one masked contribution per iteration of the do block around it. As ordinary Lua a preferred species is one lane wide, so both masks are booleans; a fixed species contributes its lanes in order, each under its own lane of active.

Arguments
NameTypeDescription
selfany
valueboolean | simd.Mask<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): boolean
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
boolean

CompensatedSumrecord#

record simd.CompensatedSum<T is float | number> is simd.Reducer<T> ...

A floating-point sum carrying the rounding error each addition discards.

Ordered, pairwise and algebraic sums differ in how they associate, and each discards the low bits of every addition it makes. This one keeps them: the part that did not fit rides alongside the running total and is added back at the end, which recovers the totals an ordered sum loses entirely -- 1 + 1e100 + 1 - 1e100 returns two here and zero there.

Compensating is not the same as exact. The answer is enormously closer to the correctly rounded total than the other three, and like them it still depends on the order the contributions arrived in, which is why its contribution edges stay serial rather than being reassociated.

Neumaier's form rather than Kahan's: it compensates the larger operand as well as the smaller, so a large value added to a small running total does not lose its correction, which is the case plain Kahan gets wrong.

T is the element it accumulates in: number is binary64, and float is binary32, each contribution and every operation's result rounded as nupp.math.f32 rounds them. A float reducer keeps its total and its compensation in binary32.

Type parameters

NameDescription
T

Members

NameKindDescription
totalfield
compensationfield
roundmethod
addmethodactive selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the...
valuemethod

totalfield#

total: number
@private

compensationfield#

compensation: number
@private

roundmethod#

round: function(number): number
@private
Arguments
NameTypeDescription
?number
Returns
TypeDescription
number

addmethod#

add: function add<S>(self, value: T | simd.Vector<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the do block around it. As ordinary Lua a preferred species is one lane wide, so the vector is that lane's value and the mask a boolean; a fixed species contributes its lanes in order, each under its own lane of the mask.

Arguments
NameTypeDescription
selfany
valueT | simd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): T
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
T

Countrecord#

record simd.Count is simd.Reducer<uint64> ...

Counts true contributions exactly, modulo 2^64.

Members

NameKindDescription
totalfield
addmethodactive selects the lanes of a mask that contribute, each lane's truth in lane order, as one masked contribution per...
valuemethod

totalfield#

total: uint64
@private

addmethod#

add: function add<T, S>(self, value: boolean | simd.Mask<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a mask that contribute, each lane's truth in lane order, as one masked contribution per iteration of the do block around it. As ordinary Lua a preferred species is one lane wide, so both masks are booleans; a fixed species contributes its lanes in order, each under its own lane of active.

Arguments
NameTypeDescription
selfany
valueboolean | simd.Mask<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): uint64
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
uint64

Fixedinterface#

sealed interface simd.Fixed<const N: integer>

A target-neutral fixed logical lane count.

Type parameters

NameDescription
N

IntegerArgMaxrecord#

record simd.IntegerArgMax<T is int32 | uint32 | int64 | uint64> is simd.Reducer<integer> ...

First one-based logical position of the integer extremum; zero when empty.

Type parameters

NameDescription
T

Members

NameKindDescription
bestfield
positionfield
countfield
addmethodactive selects the lanes of a vector that are candidates, in lane order, as one masked contribution per iteration of...
valuemethod

bestfield#

best: T?
@private

positionfield#

position: integer
@private

countfield#

count: integer
@private

addmethod#

add: function add<S>(self, value: T | simd.Vector<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a vector that are candidates, in lane order, as one masked contribution per iteration of the do block around it. Lane i of the vector has logical position base + i, where base advances by the species' lane count for every vector contribution and by one for every scalar one, whether or not a lane was active. As ordinary Lua a preferred species is one lane wide, so the vector is that lane's value and the mask a boolean; a fixed species contributes its lanes in order, each taking a position.

Arguments
NameTypeDescription
selfany
valueT | simd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): integer
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
integer

IntegerArgMinrecord#

record simd.IntegerArgMin<T is int32 | uint32 | int64 | uint64> is simd.Reducer<integer> ...

First one-based logical position of the integer extremum; zero when empty.

Type parameters

NameDescription
T

Members

NameKindDescription
bestfield
positionfield
countfield
addmethodactive selects the lanes of a vector that are candidates, in lane order, as one masked contribution per iteration of...
valuemethod

bestfield#

best: T?
@private

positionfield#

position: integer
@private

countfield#

count: integer
@private

addmethod#

add: function add<S>(self, value: T | simd.Vector<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a vector that are candidates, in lane order, as one masked contribution per iteration of the do block around it. Lane i of the vector has logical position base + i, where base advances by the species' lane count for every vector contribution and by one for every scalar one, whether or not a lane was active. As ordinary Lua a preferred species is one lane wide, so the vector is that lane's value and the mask a boolean; a fixed species contributes its lanes in order, each taking a position.

Arguments
NameTypeDescription
selfany
valueT | simd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): integer
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
integer

IntegerMaxrecord#

record simd.IntegerMax<T is int32 | uint32 | int64 | uint64> is simd.Reducer<T> ...

An integer extremum including its initial value.

Type parameters

NameDescription
T

Members

NameKindDescription
bestfield
addmethodactive selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the...
valuemethod

bestfield#

best: T
@private

addmethod#

add: function add<S>(self, value: T | simd.Vector<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the do block around it. As ordinary Lua a preferred species is one lane wide, so the vector is that lane's value and the mask a boolean; a fixed species contributes its lanes in order, each under its own lane of the mask.

Arguments
NameTypeDescription
selfany
valueT | simd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): T
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
T

IntegerMinrecord#

record simd.IntegerMin<T is int32 | uint32 | int64 | uint64> is simd.Reducer<T> ...

An integer extremum including its initial value.

Type parameters

NameDescription
T

Members

NameKindDescription
bestfield
addmethodactive selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the...
valuemethod

bestfield#

best: T
@private

addmethod#

add: function add<S>(self, value: T | simd.Vector<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the do block around it. As ordinary Lua a preferred species is one lane wide, so the vector is that lane's value and the mask a boolean; a fixed species contributes its lanes in order, each under its own lane of the mask.

Arguments
NameTypeDescription
selfany
valueT | simd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): T
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
T

Maskinterface#

sealed interface simd.Mask<T, S> ...

One predicate bit per lane of Vector<T, S>.

Type parameters

NameDescription
T
S

Members

NameKindDescription
__eqmetamethod
__unmmetamethod
selectmethod
anymethod
allmethod
countmethod
firstmethodReturns the first set lane, or zero when the mask is empty.
bitsmethodReturns lane bits in a uint64; bit zero denotes lane one.

__eqmetamethod#

__eq: function(left: simd.Mask<T, S>, right: simd.Mask<T, S>): simd.Mask<T, S>
Arguments
NameTypeDescription
leftsimd.Mask<T, S>
rightsimd.Mask<T, S>
Returns
TypeDescription
simd.Mask<T, S>

__unmmetamethod#

__unm: function(value: simd.Mask<T, S>): simd.Mask<T, S>
Arguments
NameTypeDescription
valuesimd.Mask<T, S>
Returns
TypeDescription
simd.Mask<T, S>

selectmethod#

select: function(
    borrows self: simd.Mask<T, S>,
    whenTrue: simd.Vector<T, S> | T,
    whenFalse: simd.Vector<T, S> | T
): simd.Vector<T, S>
Arguments
NameTypeDescription
borrows selfsimd.Mask<T, S>
whenTruesimd.Vector<T, S> | T
whenFalsesimd.Vector<T, S> | T
Returns
TypeDescription
simd.Vector<T, S>

anymethod#

any: function(borrows self: simd.Mask<T, S>): boolean
Arguments
NameTypeDescription
borrows selfsimd.Mask<T, S>
Returns
TypeDescription
boolean

allmethod#

all: function(borrows self: simd.Mask<T, S>): boolean
Arguments
NameTypeDescription
borrows selfsimd.Mask<T, S>
Returns
TypeDescription
boolean

countmethod#

count: function(borrows self: simd.Mask<T, S>): uint32
Arguments
NameTypeDescription
borrows selfsimd.Mask<T, S>
Returns
TypeDescription
uint32

firstmethod#

first: function(borrows self: simd.Mask<T, S>): uint32

Returns the first set lane, or zero when the mask is empty.

Arguments
NameTypeDescription
borrows selfsimd.Mask<T, S>
Returns
TypeDescription
uint32

bitsmethod#

bits: function(borrows self: simd.Mask<T, S>): uint64

Returns lane bits in a uint64; bit zero denotes lane one.

Arguments
NameTypeDescription
borrows selfsimd.Mask<T, S>
Returns
TypeDescription
uint64

NumberArgMaxrecord#

record simd.NumberArgMax<T is float | number> is simd.Reducer<integer> ...

First logical position, or zero when empty. A number wins over every NaN. Signed zero follows -0 < +0.

T is the element: number or float. An extremum rounds nothing, so the two differ only in what a vector contribution is a vector of.

Type parameters

NameDescription
T

Members

NameKindDescription
bestfield
positionfield
countfield
addmethodactive selects the lanes of a vector that are candidates, in lane order, as one masked contribution per iteration of...
valuemethod

bestfield#

best: number
@private

positionfield#

position: integer
@private

countfield#

count: integer
@private

addmethod#

add: function add<S>(self, value: T | simd.Vector<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a vector that are candidates, in lane order, as one masked contribution per iteration of the do block around it. Lane i of the vector has logical position base + i, where base advances by the species' lane count for every vector contribution and by one for every scalar one, whether or not a lane was active. As ordinary Lua a preferred species is one lane wide, so the vector is that lane's value and the mask a boolean; a fixed species contributes its lanes in order, each taking a position.

Arguments
NameTypeDescription
selfany
valueT | simd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): integer
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
integer

NumberArgMinrecord#

record simd.NumberArgMin<T is float | number> is simd.Reducer<integer> ...

First logical position, or zero when empty. A number wins over every NaN. Signed zero follows -0 < +0.

T is the element: number or float. An extremum rounds nothing, so the two differ only in what a vector contribution is a vector of.

Type parameters

NameDescription
T

Members

NameKindDescription
bestfield
positionfield
countfield
addmethodactive selects the lanes of a vector that are candidates, in lane order, as one masked contribution per iteration of...
valuemethod

bestfield#

best: number
@private

positionfield#

position: integer
@private

countfield#

count: integer
@private

addmethod#

add: function add<S>(self, value: T | simd.Vector<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a vector that are candidates, in lane order, as one masked contribution per iteration of the do block around it. Lane i of the vector has logical position base + i, where base advances by the species' lane count for every vector contribution and by one for every scalar one, whether or not a lane was active. As ordinary Lua a preferred species is one lane wide, so the vector is that lane's value and the mask a boolean; a fixed species contributes its lanes in order, each taking a position.

Arguments
NameTypeDescription
selfany
valueT | simd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): integer
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
integer

NumberMaxrecord#

record simd.NumberMax<T is float | number> is simd.Reducer<T> ...

Floating extremum including the initial value; NaNs are canonicalized. A number wins over every NaN. Signed zero follows -0 < +0.

T is the element: number or float. An extremum rounds nothing, so the two differ only in what a vector contribution is a vector of.

Type parameters

NameDescription
T

Members

NameKindDescription
bestfield
addmethodactive selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the...
valuemethod

bestfield#

best: number
@private

addmethod#

add: function add<S>(self, value: T | simd.Vector<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the do block around it. As ordinary Lua a preferred species is one lane wide, so the vector is that lane's value and the mask a boolean; a fixed species contributes its lanes in order, each under its own lane of the mask.

Arguments
NameTypeDescription
selfany
valueT | simd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): T
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
T

NumberMinrecord#

record simd.NumberMin<T is float | number> is simd.Reducer<T> ...

Floating extremum including the initial value; NaNs are canonicalized. A number wins over every NaN. Signed zero follows -0 < +0.

T is the element: number or float. An extremum rounds nothing, so the two differ only in what a vector contribution is a vector of.

Type parameters

NameDescription
T

Members

NameKindDescription
bestfield
addmethodactive selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the...
valuemethod

bestfield#

best: number
@private

addmethod#

add: function add<S>(self, value: T | simd.Vector<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the do block around it. As ordinary Lua a preferred species is one lane wide, so the vector is that lane's value and the mask a boolean; a fixed species contributes its lanes in order, each under its own lane of the mask.

Arguments
NameTypeDescription
selfany
valueT | simd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): T
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
T

OrBitsrecord#

record simd.OrBits<T is int32 | uint32 | int64 | uint64> is simd.Reducer<T> ...

Type parameters

NameDescription
T

Members

NameKindDescription
totalfield
operationmethod
addmethodactive selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the...
valuemethod

totalfield#

total: T
@private

operationmethod#

operation: function(T, T): T
@private
Arguments
NameTypeDescription
?T
?T
Returns
TypeDescription
T

addmethod#

add: function add<S>(self, value: T | simd.Vector<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the do block around it. As ordinary Lua a preferred species is one lane wide, so the vector is that lane's value and the mask a boolean; a fixed species contributes its lanes in order, each under its own lane of the mask.

Arguments
NameTypeDescription
selfany
valueT | simd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): T
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
T

OrderedDotrecord#

record simd.OrderedDot<T is float | number> is simd.Reducer<T> ...

A dot product committed in logical iteration order without contraction.

T is the element it accumulates in: number is binary64, and float is binary32, each contribution and every operation's result rounded as nupp.math.f32 rounds them. Each product rounds before it is added.

Type parameters

NameDescription
T

Members

NameKindDescription
totalfield
roundmethod
addmethodactive selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the...
valuemethod

totalfield#

total: number
@private

roundmethod#

round: function(number): number
@private
Arguments
NameTypeDescription
?number
Returns
TypeDescription
number

addmethod#

add: function add<S>(self, left: T | simd.Vector<T, S>, right: T | simd.Vector<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the do block around it. As ordinary Lua a preferred species is one lane wide, so the vector is that lane's value and the mask a boolean; a fixed species contributes its lanes in order, each under its own lane of the mask.

Arguments
NameTypeDescription
selfany
leftT | simd.Vector<T, S>
rightT | simd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): T
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
T

OrderedProductrecord#

record simd.OrderedProduct<T is float | number> is simd.Reducer<T> ...

A floating-point product committed in logical iteration order.

T is the element it accumulates in: number is binary64, and float is binary32, each contribution and every operation's result rounded as nupp.math.f32 rounds them.

Type parameters

NameDescription
T

Members

NameKindDescription
totalfield
roundmethod
addmethodactive selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the...
valuemethod

totalfield#

total: number
@private

roundmethod#

round: function(number): number
@private
Arguments
NameTypeDescription
?number
Returns
TypeDescription
number

addmethod#

add: function add<S>(self, value: T | simd.Vector<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the do block around it. As ordinary Lua a preferred species is one lane wide, so the vector is that lane's value and the mask a boolean; a fixed species contributes its lanes in order, each under its own lane of the mask.

Arguments
NameTypeDescription
selfany
valueT | simd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): T
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
T

OrderedSumrecord#

record simd.OrderedSum<T is float | number> is simd.Reducer<T> ...

A floating-point sum committed in logical iteration order.

T is the element it accumulates in: number is binary64, and float is binary32, each contribution and every operation's result rounded as nupp.math.f32 rounds them.

Type parameters

NameDescription
T

Members

NameKindDescription
totalfield
roundmethod
addmethodactive selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the...
valuemethod

totalfield#

total: number
@private

roundmethod#

round: function(number): number
@private
Arguments
NameTypeDescription
?number
Returns
TypeDescription
number

addmethod#

add: function add<S>(self, value: T | simd.Vector<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the do block around it. As ordinary Lua a preferred species is one lane wide, so the vector is that lane's value and the mask a boolean; a fixed species contributes its lanes in order, each under its own lane of the mask.

Arguments
NameTypeDescription
selfany
valueT | simd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): T
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
T

PairwiseDotrecord#

record simd.PairwiseDot<T is float | number> is simd.Reducer<T> ...

A non-contracting dot product using the adjacent-pair sum tree.

T is the element it accumulates in: number is binary64, and float is binary32, each contribution and every operation's result rounded as nupp.math.f32 rounds them. Each product rounds before it joins the tree.

Type parameters

NameDescription
T

Members

NameKindDescription
sumfield
roundmethod
addmethodactive selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the...
valuemethod

sumfield#

sum: simd.PairwiseSum<T>
@private

roundmethod#

round: function(number): number
@private
Arguments
NameTypeDescription
?number
Returns
TypeDescription
number

addmethod#

add: function add<S>(self, left: T | simd.Vector<T, S>, right: T | simd.Vector<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the do block around it. As ordinary Lua a preferred species is one lane wide, so the vector is that lane's value and the mask a boolean; a fixed species contributes its lanes in order, each under its own lane of the mask.

Arguments
NameTypeDescription
selfany
leftT | simd.Vector<T, S>
rightT | simd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): T
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
T

PairwiseProductrecord#

record simd.PairwiseProduct<T is float | number> is simd.Reducer<T> ...

A floating-point product using the width-independent adjacent-pair tree.

T is the element it accumulates in: number is binary64, and float is binary32, each contribution and every operation's result rounded as nupp.math.f32 rounds them.

Type parameters

NameDescription
T

Members

NameKindDescription
partialsfield
countfield
roundmethod
addmethodactive selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the...
valuemethod

partialsfield#

partials: {number?}
@private

countfield#

count: integer
@private

roundmethod#

round: function(number): number
@private
Arguments
NameTypeDescription
?number
Returns
TypeDescription
number

addmethod#

add: function add<S>(self, value: T | simd.Vector<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the do block around it. As ordinary Lua a preferred species is one lane wide, so the vector is that lane's value and the mask a boolean; a fixed species contributes its lanes in order, each under its own lane of the mask.

Arguments
NameTypeDescription
selfany
valueT | simd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): T
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
T

PairwiseSumrecord#

record simd.PairwiseSum<T is float | number> is simd.Reducer<T> ...

A floating-point sum using the width-independent adjacent-pair tree.

T is the element it accumulates in: number is binary64, and float is binary32, each contribution and every operation's result rounded as nupp.math.f32 rounds them.

Type parameters

NameDescription
T

Members

NameKindDescription
partialsfield
countfield
roundmethod
addmethodactive selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the...
valuemethod

partialsfield#

partials: {number?}
@private

countfield#

count: integer
@private

roundmethod#

round: function(number): number
@private
Arguments
NameTypeDescription
?number
Returns
TypeDescription
number

addmethod#

add: function add<S>(self, value: T | simd.Vector<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the do block around it. As ordinary Lua a preferred species is one lane wide, so the vector is that lane's value and the mask a boolean; a fixed species contributes its lanes in order, each under its own lane of the mask.

Arguments
NameTypeDescription
selfany
valueT | simd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): T
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
T

Preferredinterface#

sealed interface simd.Preferred

Target-selected native species identity.

PropagatingArgMaxrecord#

record simd.PropagatingArgMax<T is float | number> is simd.Reducer<integer> ...

First logical position, or zero when empty. A NaN wins over every number. Signed zero follows -0 < +0.

T is the element: number or float. An extremum rounds nothing, so the two differ only in what a vector contribution is a vector of.

Type parameters

NameDescription
T

Members

NameKindDescription
bestfield
positionfield
countfield
addmethodactive selects the lanes of a vector that are candidates, in lane order, as one masked contribution per iteration of...
valuemethod

bestfield#

best: number
@private

positionfield#

position: integer
@private

countfield#

count: integer
@private

addmethod#

add: function add<S>(self, value: T | simd.Vector<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a vector that are candidates, in lane order, as one masked contribution per iteration of the do block around it. Lane i of the vector has logical position base + i, where base advances by the species' lane count for every vector contribution and by one for every scalar one, whether or not a lane was active. As ordinary Lua a preferred species is one lane wide, so the vector is that lane's value and the mask a boolean; a fixed species contributes its lanes in order, each taking a position.

Arguments
NameTypeDescription
selfany
valueT | simd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): integer
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
integer

PropagatingArgMinrecord#

record simd.PropagatingArgMin<T is float | number> is simd.Reducer<integer> ...

First logical position, or zero when empty. A NaN wins over every number. Signed zero follows -0 < +0.

T is the element: number or float. An extremum rounds nothing, so the two differ only in what a vector contribution is a vector of.

Type parameters

NameDescription
T

Members

NameKindDescription
bestfield
positionfield
countfield
addmethodactive selects the lanes of a vector that are candidates, in lane order, as one masked contribution per iteration of...
valuemethod

bestfield#

best: number
@private

positionfield#

position: integer
@private

countfield#

count: integer
@private

addmethod#

add: function add<S>(self, value: T | simd.Vector<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a vector that are candidates, in lane order, as one masked contribution per iteration of the do block around it. Lane i of the vector has logical position base + i, where base advances by the species' lane count for every vector contribution and by one for every scalar one, whether or not a lane was active. As ordinary Lua a preferred species is one lane wide, so the vector is that lane's value and the mask a boolean; a fixed species contributes its lanes in order, each taking a position.

Arguments
NameTypeDescription
selfany
valueT | simd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): integer
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
integer

PropagatingMaxrecord#

record simd.PropagatingMax<T is float | number> is simd.Reducer<T> ...

Floating extremum including the initial value; NaNs are canonicalized. A NaN wins over every number. Signed zero follows -0 < +0.

T is the element: number or float. An extremum rounds nothing, so the two differ only in what a vector contribution is a vector of.

Type parameters

NameDescription
T

Members

NameKindDescription
bestfield
addmethodactive selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the...
valuemethod

bestfield#

best: number
@private

addmethod#

add: function add<S>(self, value: T | simd.Vector<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the do block around it. As ordinary Lua a preferred species is one lane wide, so the vector is that lane's value and the mask a boolean; a fixed species contributes its lanes in order, each under its own lane of the mask.

Arguments
NameTypeDescription
selfany
valueT | simd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): T
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
T

PropagatingMinrecord#

record simd.PropagatingMin<T is float | number> is simd.Reducer<T> ...

Floating extremum including the initial value; NaNs are canonicalized. A NaN wins over every number. Signed zero follows -0 < +0.

T is the element: number or float. An extremum rounds nothing, so the two differ only in what a vector contribution is a vector of.

Type parameters

NameDescription
T

Members

NameKindDescription
bestfield
addmethodactive selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the...
valuemethod

bestfield#

best: number
@private

addmethod#

add: function add<S>(self, value: T | simd.Vector<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the do block around it. As ordinary Lua a preferred species is one lane wide, so the vector is that lane's value and the mask a boolean; a fixed species contributes its lanes in order, each under its own lane of the mask.

Arguments
NameTypeDescription
selfany
valueT | simd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): T
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
T

Reducerinterface#

interface simd.Reducer<T> ...

What every reducer shares: contributions go in through add, and value returns the finished reduction as a T.

What add takes depends on the family -- one value, two for a dot product, and an optional mask beside a vector -- so this names the member without fixing its parameters. Contribute through the concrete reducer; code that only finishes a reduction can take any Reducer<T>.

Type parameters

NameDescription
T

Members

NameKindDescription
addmethodContributes to the reduction; the concrete reducer states its parameters.
valuemethodReturns the finished reduction.

addmethod#

add: function(self: simd.Reducer<T>, value: never, ...: never): nil
@readonly

Contributes to the reduction; the concrete reducer states its parameters.

Arguments
NameTypeDescription
selfsimd.Reducer<T>
valuenever
...never
Returns
TypeDescription
nil

valuemethod#

value: function(self: simd.Reducer<T>): T
@readonly

Returns the finished reduction.

Arguments
NameTypeDescription
selfsimd.Reducer<T>
Returns
TypeDescription
T

Speciesinterface#

sealed interface simd.Species<T, S> ...

Operations whose lane count is selected from T and S at AOT lowering.

Type parameters

NameDescription
T
S

Members

NameKindDescription
lanesfield
convertmethodConverts each lane using LuaJIT FFI numeric conversion rules.
reinterpretmethodPreserves every lane's bits.
widenmethodThe species of the next wider element of this one's family and signedness -- uint8 to uint16, int32 to int64, float...
narrowmethodThe species of the next narrower element with this species' lane count, the inverse of widen: a widened species...
splatmethod
iotamethod
tailmethod
maskmethodA mask of this species: every lane from one boolean, or lane for lane from another species' mask with the same lane...
overmethodThe chunks of a span of count elements, for a loop written once: for at, active in species:over(input) do ...
mapmethodA scalar operation on every lane: a closed-set math operation such as math.sqrt over a floating species, one of the...
loadmethodThe next lanes of a span from offset, or one named field of its rows.
storemethodWrites the next lanes of a span or one named field of its rows.
loadPairsmethodThe next 2 lanes elements from offset, dealt out a lane at a time: the first vector holds the elements at odd...
loadTriplesmethodThe next 3 lanes elements, lane i of the jth vector reading element 3 (i - 1) + j of the run.
loadQuadsmethodThe next 4 lanes elements, lane i of the jth vector reading element 4 (i - 1) + j of the run.
storePairsmethodThe inverse of loadPairs: 2 lanes elements from offset, alternating a lane of first with the same lane of second.
storeTriplesmethodThe inverse of loadTriples.
storeQuadsmethodThe inverse of loadQuads.
gathermethodReads one-based element indices.
scattermethodWrites one-based element indices, ignoring inactive or out-of-range lanes.
scatterUncheckedmethodAsserts that all active indices are unique, without checking them.

lanesfield#

lanes: uint32
@readonly

convertmethod#

convert: function<U>(borrows self: simd.Species<T, S>, value: simd.Vector<U, S>): simd.Vector<T, S>

Converts each lane using LuaJIT FFI numeric conversion rules. Integer narrowing keeps low bits; float-to-integer truncates through int64, except uint64 which accepts the union of signed and unsigned ranges. Integer-to-float follows LuaJIT's double intermediate, including the possible double rounding when converting a 64-bit integer to float. NaN, infinities and out-of-range inputs have target-specific results, never undefined behavior. Both species must have the same lane count.

Arguments
NameTypeDescription
borrows selfsimd.Species<T, S>
valuesimd.Vector<U, S>
Returns
TypeDescription
simd.Vector<T, S>

reinterpretmethod#

reinterpret: function<U>(borrows self: simd.Species<T, S>, value: simd.Vector<U, S>): simd.Vector<T, S>

Preserves every lane's bits. Element widths and lane counts must match.

Arguments
NameTypeDescription
borrows selfsimd.Species<T, S>
valuesimd.Vector<U, S>
Returns
TypeDescription
simd.Vector<T, S>

widenmethod#

widen: function<W>(borrows self: simd.Species<T, S>, wider: StorageWitness<W>): simd.Species<W, S>

The species of the next wider element of this one's family and signedness -- uint8 to uint16, int32 to int64, float to number -- with this species' logical lane count, named by the wider element's storage witness. A Fixed<N> species widens to the Fixed<N> species of that element. A Preferred one widens to a species holding as many lanes as its own register does, twice what the wider element's preferred species holds, so a widened vector occupies two native registers the way a Fixed<N> past one register does. It is the species a byte kernel converts into for a sum its bytes would overflow, without naming a register width:

local bytes = assert(simd.species(array.uint8))
local wide = bytes:widen(array.uint16)
local weighted = wide:convert(bytes:load(reds, at + 1)) * 77

The widened species keeps the checker's species identity S, so it reads as simd.Species<uint16, simd.Preferred>, the type simd.species(array.uint16) also has. They are different species once the function is lowered, one with the lane count of a uint8 register and the other with its own, and a vector of one meets a vector of the other only through convert, which is refused there when the counts differ. Nothing is wider than 64 bits: widening a 64-bit species is refused where the function is lowered, as is a witness that is not the next wider element.

Arguments
NameTypeDescription
borrows selfsimd.Species<T, S>
widerStorageWitness<W>
Returns
TypeDescription
simd.Species<W, S>

narrowmethod#

narrow: function<W>(borrows self: simd.Species<T, S>, narrower: StorageWitness<W>): simd.Species<W, S>

The species of the next narrower element with this species' lane count, the inverse of widen: a widened species narrows back to the species it came from, and a Preferred species narrows to one holding half the lanes the narrower element's own register does. Nothing is narrower than 8 bits.

Arguments
NameTypeDescription
borrows selfsimd.Species<T, S>
narrowerStorageWitness<W>
Returns
TypeDescription
simd.Species<W, S>

splatmethod#

splat: function(borrows self: simd.Species<T, S>, value: T): simd.Vector<T, S>
Arguments
NameTypeDescription
borrows selfsimd.Species<T, S>
valueT
Returns
TypeDescription
simd.Vector<T, S>

iotamethod#

iota: function(borrows self: simd.Species<T, S>, first: T, step: T): simd.Vector<T, S>
Arguments
NameTypeDescription
borrows selfsimd.Species<T, S>
firstT
stepT
Returns
TypeDescription
simd.Vector<T, S>

tailmethod#

tail: function(borrows self: simd.Species<T, S>, active: integer): simd.Mask<T, S>
Arguments
NameTypeDescription
borrows selfsimd.Species<T, S>
activeinteger
Returns
TypeDescription
simd.Mask<T, S>

maskmethod#

mask: function(borrows self: simd.Species<T, S>, value: boolean): simd.Mask<T, S>
& function<U>(borrows self: simd.Species<T, S>, value: simd.Mask<U, S>): simd.Mask<T, S>

A mask of this species: every lane from one boolean, or lane for lane from another species' mask with the same lane count, which is what carries a comparison of one element type to a select on another.

Arguments
NameTypeDescription
borrows selfsimd.Species<T, S>
valueboolean
Returns
TypeDescription
simd.Mask<T, S>

overmethod#

over: function(borrows self: simd.Species<T, S>, count: integer): function(): (uint32?, simd.Mask<T, S>)

The chunks of a span of count elements, for a loop written once: for at, active in species:over(#input) do ... end visits every element from offset one, lanes at a time, binding at to the one-based offset of the chunk and active to its mask. Every chunk but the last is full, and an access under its mask is the unmasked one the loop's own bound proves; the last chunk's mask is the tail. Pass active to every load and store, and to every reducer contribution, and the loop is the whole strip-mined algorithm: no separate tail, no scalar continuation.

Arguments
NameTypeDescription
borrows selfsimd.Species<T, S>
countinteger
Returns
TypeDescription
function(): (uint32?, simd.Mask<T, S>)

mapmethod#

map: function(
    borrows self: simd.Species<T, S>,
    operation: function(...: any): T | number,
    ...: simd.Vector<T, S>
): simd.Vector<T, S>

A scalar operation on every lane: a closed-set math operation such as math.sqrt over a floating species, one of the corrected binary32 operations nupp.math.f32.fma, min and max over a float species, or a pure helper of this element taking one argument per vector. The operands must be locals.

Arguments
NameTypeDescription
borrows selfsimd.Species<T, S>
operationfunction(...: any): T | number
...simd.Vector<T, S>
Returns
TypeDescription
simd.Vector<T, S>

loadmethod#

load: function(
    borrows self: simd.Species<T, S>,
    borrows source: Span<T>,
    offset: integer,
    active: simd.Mask<T, S>?
): simd.Vector<T, S>
    & function<E>(
        borrows self: simd.Species<T, S>,
        borrows source: Span<E>,
        offset: integer,
        field: string,
        active: simd.Mask<T, S>?
    ): simd.Vector<T, S>

    & function(
        borrows self: simd.Species<T, S>,
        borrows source: WriteSpan<T>,
        offset: integer,
        active: simd.Mask<T, S>?
    ): simd.Vector<T, S>
    & function<E>(
        borrows self: simd.Species<T, S>,
        borrows source: WriteSpan<E>,
        offset: integer,
        field: string,
        active: simd.Mask<T, S>?
    ): simd.Vector<T, S>
    & function<E>(
        borrows self: simd.Species<T, S>,
        borrows source: SoaWriteToken & SoaWriteSpan<E>,
        offset: integer,
        field: string,
        active: simd.Mask<T, S>?
    ): simd.Vector<T, S>
    & function(
        borrows self: simd.Species<T, S>,
        borrows source: SoaReadView,
        offset: integer,
        field: string,
        active: simd.Mask<T, S>?
    ): simd.Vector<T, S>

The next lanes of a span from offset, or one named field of its rows. A field in a span of structs is strided; a SoA row field is contiguous. active limits the lanes. The vector retains no storage borrow.

Arguments
NameTypeDescription
borrows selfsimd.Species<T, S>
borrows sourceSpan<E>
offsetinteger
fieldstring
activesimd.Mask<T, S>?
Returns
TypeDescription
simd.Vector<T, S>

storemethod#

store: function(
    borrows self: simd.Species<T, S>,
    exclusive destination: WriteSpan<T>,
    offset: integer,
    value: simd.Vector<T, S>,
    active: simd.Mask<T, S>?
): nil
    & function<E>(
        borrows self: simd.Species<T, S>,
        exclusive destination: WriteSpan<E>,
        offset: integer,
        field: string,
        value: simd.Vector<T, S>,
        active: simd.Mask<T, S>?
    ): nil
    & function<E>(
        borrows self: simd.Species<T, S>,
        exclusive destination: SoaWriteToken & SoaWriteSpan<E>,
        offset: integer,
        field: string,
        value: simd.Vector<T, S>,
        active: simd.Mask<T, S>?
    ): nil

Writes the next lanes of a span or one named field of its rows. Other fields are unchanged.

Arguments
NameTypeDescription
borrows selfsimd.Species<T, S>
exclusive destinationWriteSpan<E>
offsetinteger
fieldstring
valuesimd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

loadPairsmethod#

loadPairs: function(
    borrows self: simd.Species<T, S>,
    borrows source: Span<T>,
    offset: integer
): (simd.Vector<T, S>, simd.Vector<T, S>)
    & function(
        borrows self: simd.Species<T, S>,
        borrows source: WriteSpan<T>,
        offset: integer
    ): (simd.Vector<T, S>, simd.Vector<T, S>)

The next 2 * lanes elements from offset, dealt out a lane at a time: the first vector holds the elements at odd positions of the run and the second those at even ones, so interleaved pairs arrive as two vectors of their halves. Elements past the span read zero. The results initialize locals, local re, im = s:loadPairs(zs, at + 1).

On NEON this is one ld2; loadTriples and loadQuads are ld3 and ld4, which is what a three-byte or four-byte record costs to de-interleave there.

Arguments
NameTypeDescription
borrows selfsimd.Species<T, S>
borrows sourceSpan<T>
offsetinteger
Returns
TypeDescription
simd.Vector<T, S>
simd.Vector<T, S>

loadTriplesmethod#

loadTriples: function(
    borrows self: simd.Species<T, S>,
    borrows source: Span<T>,
    offset: integer
): (simd.Vector<T, S>, simd.Vector<T, S>, simd.Vector<T, S>)
    & function(
        borrows self: simd.Species<T, S>,
        borrows source: WriteSpan<T>,
        offset: integer
    ): (simd.Vector<T, S>, simd.Vector<T, S>, simd.Vector<T, S>)

The next 3 * lanes elements, lane i of the jth vector reading element 3 * (i - 1) + j of the run.

Arguments
NameTypeDescription
borrows selfsimd.Species<T, S>
borrows sourceSpan<T>
offsetinteger
Returns
TypeDescription
simd.Vector<T, S>
simd.Vector<T, S>
simd.Vector<T, S>

loadQuadsmethod#

loadQuads: function(
    borrows self: simd.Species<T, S>,
    borrows source: Span<T>,
    offset: integer
): (simd.Vector<T, S>, simd.Vector<T, S>, simd.Vector<T, S>, simd.Vector<T, S>)
    & function(
        borrows self: simd.Species<T, S>,
        borrows source: WriteSpan<T>,
        offset: integer
    ): (simd.Vector<T, S>, simd.Vector<T, S>, simd.Vector<T, S>, simd.Vector<T, S>)

The next 4 * lanes elements, lane i of the jth vector reading element 4 * (i - 1) + j of the run.

Arguments
NameTypeDescription
borrows selfsimd.Species<T, S>
borrows sourceSpan<T>
offsetinteger
Returns
TypeDescription
simd.Vector<T, S>
simd.Vector<T, S>
simd.Vector<T, S>
simd.Vector<T, S>

storePairsmethod#

storePairs: function(
    borrows self: simd.Species<T, S>,
    exclusive destination: WriteSpan<T>,
    offset: integer,
    first: simd.Vector<T, S>,
    second: simd.Vector<T, S>
): nil

The inverse of loadPairs: 2 * lanes elements from offset, alternating a lane of first with the same lane of second. Elements past the span are not written.

Arguments
NameTypeDescription
borrows selfsimd.Species<T, S>
exclusive destinationWriteSpan<T>
offsetinteger
firstsimd.Vector<T, S>
secondsimd.Vector<T, S>
Returns
TypeDescription
nil

storeTriplesmethod#

storeTriples: function(
    borrows self: simd.Species<T, S>,
    exclusive destination: WriteSpan<T>,
    offset: integer,
    first: simd.Vector<T, S>,
    second: simd.Vector<T, S>,
    third: simd.Vector<T, S>
): nil

The inverse of loadTriples.

Arguments
NameTypeDescription
borrows selfsimd.Species<T, S>
exclusive destinationWriteSpan<T>
offsetinteger
firstsimd.Vector<T, S>
secondsimd.Vector<T, S>
thirdsimd.Vector<T, S>
Returns
TypeDescription
nil

storeQuadsmethod#

storeQuads: function(
    borrows self: simd.Species<T, S>,
    exclusive destination: WriteSpan<T>,
    offset: integer,
    first: simd.Vector<T, S>,
    second: simd.Vector<T, S>,
    third: simd.Vector<T, S>,
    fourth: simd.Vector<T, S>
): nil

The inverse of loadQuads.

Arguments
NameTypeDescription
borrows selfsimd.Species<T, S>
exclusive destinationWriteSpan<T>
offsetinteger
firstsimd.Vector<T, S>
secondsimd.Vector<T, S>
thirdsimd.Vector<T, S>
fourthsimd.Vector<T, S>
Returns
TypeDescription
nil

gathermethod#

gather: function<I>(
    borrows self: simd.Species<T, S>,
    borrows source: Span<T>,
    indices: simd.Vector<I, S>,
    active: simd.Mask<T, S>?
): simd.Vector<T, S>

Reads one-based element indices. Inactive or out-of-range lanes return zero. Indices use int32, uint32, int64 or uint64 and must have the same logical lane count as this species at every emitted tier.

Arguments
NameTypeDescription
borrows selfsimd.Species<T, S>
borrows sourceSpan<T>
indicessimd.Vector<I, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
simd.Vector<T, S>

scattermethod#

scatter: function<I>(
    borrows self: simd.Species<T, S>,
    exclusive destination: WriteSpan<T>,
    indices: simd.Vector<I, S>,
    value: simd.Vector<T, S>,
    active: simd.Mask<T, S>?
): nil

Writes one-based element indices, ignoring inactive or out-of-range lanes. The compiler must prove that indices are unique; currently a directly supplied constant, non-wrapping iota provides that proof. No runtime collision check is emitted.

Arguments
NameTypeDescription
borrows selfsimd.Species<T, S>
exclusive destinationWriteSpan<T>
indicessimd.Vector<I, S>
valuesimd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

scatterUncheckedmethod#

scatterUnchecked: function<I>(
    borrows self: simd.Species<T, S>,
    exclusive destination: WriteSpan<T>,
    indices: simd.Vector<I, S>,
    value: simd.Vector<T, S>,
    active: simd.Mask<T, S>?
): nil

Asserts that all active indices are unique, without checking them. Duplicate active indices are undefined behavior, even if the values agree. This promises no winning lane or accumulation order and does not authorize collisions between separate scatter operations. Bounds and inactive lanes behave as in scatter.

Arguments
NameTypeDescription
borrows selfsimd.Species<T, S>
exclusive destinationWriteSpan<T>
indicessimd.Vector<I, S>
valuesimd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

Vectorinterface#

sealed interface simd.Vector<T, S> ...

An immutable register-as-data value.

Type parameters

NameDescription
T
S

Members

NameKindDescription
__addmetamethod
__submetamethod
__mulmetamethod
__divmetamethod
__modmetamethod% and // are Lua's: the remainder takes the divisor's sign and the quotient rounds toward negative infinity, lane by...
__unmmetamethod
__eqmetamethod
__ltmetamethod
__lemetamethod
propagatingMinmethodThe smaller of each lane pair, and the larger, under the contract the name selects.
propagatingMaxmethod
numberMinmethodnumberMin returns the operand that is not NaN, and the canonical NaN only when both are, which is IEEE-754's minNum.
numberMaxmethod
fmamethodself multiplier + addend with one rounding per lane: the product is exact and only the sum rounds, so the two-step...
saturatingAddmethodself + other and self - other clamped to the element's range rather than wrapped: a byte that would reach 300...
saturatingSubmethod
popcountmethodThe number of one bits in each lane's two's complement representation at the element's width, so -1 on a signed byte...
mulHighmethodThe high half of each lane's full-width product: the bits above the element's width of self other taken at twice...
extractmethodLane indices are one-based and decided when the function is lowered: a literal, the species' lanes, or +, - and over...
insertmethod
reversemethodReverses logical lane order.
interleavemethodAlternates lanes from self and other, then splits that sequence into two species-width results.
deinterleavemethodReturns the odd and even lanes of self followed by other.
rotateLeftmethodRotates logical lanes.
rotateRightmethod
alignmethodSelects a species-width window from previous ..
swizzlemethodEvery lane read from another lane this vector names at run time.
compressmethodPacks selected lanes toward lane one and zeroes the remainder.
expandmethodDistributes packed lanes into selected positions and zeroes the rest.
orderedPrefixSummethodInclusive, logical-lane-order prefix operations.
prefixXormethod

__addmetamethod#

__add: function(left: simd.Vector<T, S>, right: simd.Vector<T, S> | T): simd.Vector<T, S>
Arguments
NameTypeDescription
leftsimd.Vector<T, S>
rightsimd.Vector<T, S> | T
Returns
TypeDescription
simd.Vector<T, S>

__submetamethod#

__sub: function(left: simd.Vector<T, S>, right: simd.Vector<T, S> | T): simd.Vector<T, S>
Arguments
NameTypeDescription
leftsimd.Vector<T, S>
rightsimd.Vector<T, S> | T
Returns
TypeDescription
simd.Vector<T, S>

__mulmetamethod#

__mul: function(left: simd.Vector<T, S>, right: simd.Vector<T, S> | T): simd.Vector<T, S>
Arguments
NameTypeDescription
leftsimd.Vector<T, S>
rightsimd.Vector<T, S> | T
Returns
TypeDescription
simd.Vector<T, S>

__divmetamethod#

__div: function(left: simd.Vector<T, S>, right: simd.Vector<T, S> | T): simd.Vector<T, S>
Arguments
NameTypeDescription
leftsimd.Vector<T, S>
rightsimd.Vector<T, S> | T
Returns
TypeDescription
simd.Vector<T, S>

__modmetamethod#

__mod: function(left: simd.Vector<T, S>, right: simd.Vector<T, S> | T): simd.Vector<T, S>

% and // are Lua's: the remainder takes the divisor's sign and the quotient rounds toward negative infinity, lane by lane, as a - floor(a / b) * b and floor(a / b) on a floating species and exactly on an integer one. An integer lane divided by zero returns zero, as / does, rather than trapping.

Arguments
NameTypeDescription
leftsimd.Vector<T, S>
rightsimd.Vector<T, S> | T
Returns
TypeDescription
simd.Vector<T, S>

__unmmetamethod#

__unm: function(value: simd.Vector<T, S>): simd.Vector<T, S>
Arguments
NameTypeDescription
valuesimd.Vector<T, S>
Returns
TypeDescription
simd.Vector<T, S>

__eqmetamethod#

__eq: function(left: simd.Vector<T, S>, right: simd.Vector<T, S> | T): simd.Mask<T, S>
Arguments
NameTypeDescription
leftsimd.Vector<T, S>
rightsimd.Vector<T, S> | T
Returns
TypeDescription
simd.Mask<T, S>

__ltmetamethod#

__lt: function(left: simd.Vector<T, S>, right: simd.Vector<T, S> | T): simd.Mask<T, S>
Arguments
NameTypeDescription
leftsimd.Vector<T, S>
rightsimd.Vector<T, S> | T
Returns
TypeDescription
simd.Mask<T, S>

__lemetamethod#

__le: function(left: simd.Vector<T, S>, right: simd.Vector<T, S> | T): simd.Mask<T, S>
Arguments
NameTypeDescription
leftsimd.Vector<T, S>
rightsimd.Vector<T, S> | T
Returns
TypeDescription
simd.Mask<T, S>

propagatingMinmethod#

propagatingMin: function(borrows self: simd.Vector<T, S>, other: simd.Vector<T, S> | T): simd.Vector<T, S>

The smaller of each lane pair, and the larger, under the contract the name selects. There is no unqualified min: the two disagree on every pair containing a NaN, and which one a program wanted is not recoverable from the call.

propagatingMin returns the canonical NaN whenever either operand is NaN, which is nupp.math.f32.min's contract and what makes a reduction built on it independent of which lane the NaN landed in and of how many lanes the target chose. -0 is the smaller zero and +0 the larger, so an equal pair of zeros is ordered by sign rather than by position. -inf and +inf are ordinary values at the ends of the order.

Arguments
NameTypeDescription
borrows selfsimd.Vector<T, S>
othersimd.Vector<T, S> | T
Returns
TypeDescription
simd.Vector<T, S>

propagatingMaxmethod#

propagatingMax: function(borrows self: simd.Vector<T, S>, other: simd.Vector<T, S> | T): simd.Vector<T, S>
Arguments
NameTypeDescription
borrows selfsimd.Vector<T, S>
othersimd.Vector<T, S> | T
Returns
TypeDescription
simd.Vector<T, S>

numberMinmethod#

numberMin: function(borrows self: simd.Vector<T, S>, other: simd.Vector<T, S> | T): simd.Vector<T, S>

numberMin returns the operand that is not NaN, and the canonical NaN only when both are, which is IEEE-754's minNum. It is the contract for a scan looking for the smallest real measurement in data that carries NaN for a missing one. Zeros and infinities behave as they do above.

A reduction over it depends on how many lanes were NaN, which is the price of ignoring them and the reason it is not the default.

An integer element has no NaN, so the two contracts coincide there and either spelling returns the same value.

Arguments
NameTypeDescription
borrows selfsimd.Vector<T, S>
othersimd.Vector<T, S> | T
Returns
TypeDescription
simd.Vector<T, S>

numberMaxmethod#

numberMax: function(borrows self: simd.Vector<T, S>, other: simd.Vector<T, S> | T): simd.Vector<T, S>
Arguments
NameTypeDescription
borrows selfsimd.Vector<T, S>
othersimd.Vector<T, S> | T
Returns
TypeDescription
simd.Vector<T, S>

fmamethod#

fma: function(
    borrows self: simd.Vector<T, S>,
    multiplier: simd.Vector<T, S> | T,
    addend: simd.Vector<T, S> | T
): simd.Vector<T, S>

self * multiplier + addend with one rounding per lane: the product is exact and only the sum rounds, so the two-step form's second rounding, and its overflow in a product the sum would have brought back, do not happen. On a float species this is nupp.math.f32.fma's contract, the binary64 fused operation on a number one, and a NaN lane returns the canonical NaN either way. A floating species only; an integer product has nothing to round.

Arguments
NameTypeDescription
borrows selfsimd.Vector<T, S>
multipliersimd.Vector<T, S> | T
addendsimd.Vector<T, S> | T
Returns
TypeDescription
simd.Vector<T, S>

saturatingAddmethod#

saturatingAdd: function(borrows self: simd.Vector<T, S>, other: simd.Vector<T, S> | T): simd.Vector<T, S>

self + other and self - other clamped to the element's range rather than wrapped: a byte that would reach 300 returns 255, and an unsigned lane taken below zero returns zero. An integer species only.

Arguments
NameTypeDescription
borrows selfsimd.Vector<T, S>
othersimd.Vector<T, S> | T
Returns
TypeDescription
simd.Vector<T, S>

saturatingSubmethod#

saturatingSub: function(borrows self: simd.Vector<T, S>, other: simd.Vector<T, S> | T): simd.Vector<T, S>
Arguments
NameTypeDescription
borrows selfsimd.Vector<T, S>
othersimd.Vector<T, S> | T
Returns
TypeDescription
simd.Vector<T, S>

popcountmethod#

popcount: function(borrows self: simd.Vector<T, S>): simd.Vector<T, S>

The number of one bits in each lane's two's complement representation at the element's width, so -1 on a signed byte returns 8. An integer species only.

Arguments
NameTypeDescription
borrows selfsimd.Vector<T, S>
Returns
TypeDescription
simd.Vector<T, S>

mulHighmethod#

mulHigh: function(borrows self: simd.Vector<T, S>, other: simd.Vector<T, S> | T): simd.Vector<T, S>

The high half of each lane's full-width product: the bits above the element's width of self * other taken at twice that width, signed or unsigned as the element is. * returns the low half, so the two together are the whole product; alone, this is the fixed-point multiply, (a * b) >> bits, that a scaled reciprocal turns a division into. An integer species only.

Arguments
NameTypeDescription
borrows selfsimd.Vector<T, S>
othersimd.Vector<T, S> | T
Returns
TypeDescription
simd.Vector<T, S>

extractmethod#

extract: function(borrows self: simd.Vector<T, S>, lane: integer): T

Lane indices are one-based and decided when the function is lowered: a literal, the species' lanes, or +, - and * over those, so lanes names the last lane of any species and lanes - 1 the one before it. An index past the lanes the tier gives the species is refused there.

Arguments
NameTypeDescription
borrows selfsimd.Vector<T, S>
laneinteger
Returns
TypeDescription
T

insertmethod#

insert: function(borrows self: simd.Vector<T, S>, lane: integer, value: T): simd.Vector<T, S>
Arguments
NameTypeDescription
borrows selfsimd.Vector<T, S>
laneinteger
valueT
Returns
TypeDescription
simd.Vector<T, S>

reversemethod#

reverse: function(borrows self: simd.Vector<T, S>): simd.Vector<T, S>

Reverses logical lane order.

Arguments
NameTypeDescription
borrows selfsimd.Vector<T, S>
Returns
TypeDescription
simd.Vector<T, S>

interleavemethod#

interleave: function(
    borrows self: simd.Vector<T, S>,
    other: simd.Vector<T, S>
): (simd.Vector<T, S>, simd.Vector<T, S>)

Alternates lanes from self and other, then splits that sequence into two species-width results. No lane bits are changed.

Arguments
NameTypeDescription
borrows selfsimd.Vector<T, S>
othersimd.Vector<T, S>
Returns
TypeDescription
simd.Vector<T, S>
simd.Vector<T, S>

deinterleavemethod#

deinterleave: function(
    borrows self: simd.Vector<T, S>,
    other: simd.Vector<T, S>
): (simd.Vector<T, S>, simd.Vector<T, S>)

Returns the odd and even lanes of self followed by other. This is the inverse of interleave, including for odd logical lane counts.

Arguments
NameTypeDescription
borrows selfsimd.Vector<T, S>
othersimd.Vector<T, S>
Returns
TypeDescription
simd.Vector<T, S>
simd.Vector<T, S>

rotateLeftmethod#

rotateLeft: function(borrows self: simd.Vector<T, S>, count: integer): simd.Vector<T, S>

Rotates logical lanes. Counts are reduced modulo the species width.

Arguments
NameTypeDescription
borrows selfsimd.Vector<T, S>
countinteger
Returns
TypeDescription
simd.Vector<T, S>

rotateRightmethod#

rotateRight: function(borrows self: simd.Vector<T, S>, count: integer): simd.Vector<T, S>
Arguments
NameTypeDescription
borrows selfsimd.Vector<T, S>
countinteger
Returns
TypeDescription
simd.Vector<T, S>

alignmethod#

align: function(borrows self: simd.Vector<T, S>, previous: simd.Vector<T, S>, offset: integer): simd.Vector<T, S>

Selects a species-width window from previous .. self. Offset zero returns self; positive offsets bring trailing lanes of previous into the beginning. The offset is decided when the function is lowered, on the terms extract's lane is, and one past the lanes returns previous whole.

Arguments
NameTypeDescription
borrows selfsimd.Vector<T, S>
previoussimd.Vector<T, S>
offsetinteger
Returns
TypeDescription
simd.Vector<T, S>

swizzlemethod#

swizzle: function(
    borrows self: simd.Vector<T, S>,
    indices: simd.Vector<T, S>,
    other: simd.Vector<T, S>?,
    third: simd.Vector<T, S>?,
    fourth: simd.Vector<T, S>?
): simd.Vector<T, S>

Every lane read from another lane this vector names at run time.

Lane i returns self:extract(indices:extract(i)), and zero where that index is outside 1..lanes. Zero rather than a refusal because the native instructions return zero for an out-of-range byte and a check per lane would cost more than the lookup.

This is the table lookup: a table is a vector, so there is no table type and no constructor taking one entry per argument. A sixteen-entry byte table is a Fixed<16> vector of constants, or a preferred-width one with those sixteen entries repeated, and looking up in it is this.

With other, the lanes of both are numbered in one run: an index in 1..lanes reads self and one in lanes+1..2*lanes reads other. That is the shape align needs and one vector cannot reach, and it is what makes this one operation rather than a family of them. third and fourth continue the run to three and four tables, which is how a 64-entry byte table on a sixteen-lane species is one lookup. They are optional on the same terms load's mask is. An index a lane cannot hold -- past 255 for bytes -- is not reachable.

The indices are read as lane numbers, so the element must be an integer one. A float vector has no lane numbering to offer.

Arguments
NameTypeDescription
borrows selfsimd.Vector<T, S>
indicessimd.Vector<T, S>
othersimd.Vector<T, S>?
thirdsimd.Vector<T, S>?
fourthsimd.Vector<T, S>?
Returns
TypeDescription
simd.Vector<T, S>

compressmethod#

compress: function(borrows self: simd.Vector<T, S>, selected: simd.Mask<T, S>): simd.Vector<T, S>

Packs selected lanes toward lane one and zeroes the remainder.

Arguments
NameTypeDescription
borrows selfsimd.Vector<T, S>
selectedsimd.Mask<T, S>
Returns
TypeDescription
simd.Vector<T, S>

expandmethod#

expand: function(borrows self: simd.Vector<T, S>, selected: simd.Mask<T, S>): simd.Vector<T, S>

Distributes packed lanes into selected positions and zeroes the rest.

Arguments
NameTypeDescription
borrows selfsimd.Vector<T, S>
selectedsimd.Mask<T, S>
Returns
TypeDescription
simd.Vector<T, S>

orderedPrefixSummethod#

orderedPrefixSum: function(borrows self: simd.Vector<T, S>): simd.Vector<T, S>

Inclusive, logical-lane-order prefix operations. The ordered sum adds lanes from the first, the way orderedSum does.

Arguments
NameTypeDescription
borrows selfsimd.Vector<T, S>
Returns
TypeDescription
simd.Vector<T, S>

prefixXormethod#

prefixXor: function(borrows self: simd.Vector<T, S>): simd.Vector<T, S>
Arguments
NameTypeDescription
borrows selfsimd.Vector<T, S>
Returns
TypeDescription
simd.Vector<T, S>

WrappingProductrecord#

record simd.WrappingProduct<T is int32 | uint32 | int64 | uint64> is simd.Reducer<T> ...

Type parameters

NameDescription
T

Members

NameKindDescription
totalfield
operationmethod
addmethodactive selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the...
valuemethod

totalfield#

total: T
@private

operationmethod#

operation: function(T, T): T
@private
Arguments
NameTypeDescription
?T
?T
Returns
TypeDescription
T

addmethod#

add: function add<S>(self, value: T | simd.Vector<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the do block around it. As ordinary Lua a preferred species is one lane wide, so the vector is that lane's value and the mask a boolean; a fixed species contributes its lanes in order, each under its own lane of the mask.

Arguments
NameTypeDescription
selfany
valueT | simd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): T
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
T

WrappingSumrecord#

record simd.WrappingSum<T is int32 | uint32 | int64 | uint64> is simd.Reducer<T> ...

Fixed-width reducers name their element with its array witness, as a species does. Their initial value participates in the fold. Narrow storage loads contribute to i32 or u32; i64 and u64 never pass through a Lua double.

Type parameters

NameDescription
T

Members

NameKindDescription
totalfield
operationmethod
addmethodactive selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the...
valuemethod

totalfield#

total: T
@private

operationmethod#

operation: function(T, T): T
@private
Arguments
NameTypeDescription
?T
?T
Returns
TypeDescription
T

addmethod#

add: function add<S>(self, value: T | simd.Vector<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the do block around it. As ordinary Lua a preferred species is one lane wide, so the vector is that lane's value and the mask a boolean; a fixed species contributes its lanes in order, each under its own lane of the mask.

Arguments
NameTypeDescription
selfany
valueT | simd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): T
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
T

XorBitsrecord#

record simd.XorBits<T is int32 | uint32 | int64 | uint64> is simd.Reducer<T> ...

Type parameters

NameDescription
T

Members

NameKindDescription
totalfield
operationmethod
addmethodactive selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the...
valuemethod

totalfield#

total: T
@private

operationmethod#

operation: function(T, T): T
@private
Arguments
NameTypeDescription
?T
?T
Returns
TypeDescription
T

addmethod#

add: function add<S>(self, value: T | simd.Vector<T, S>, active: simd.Mask<T, S>?): nil

active selects the lanes of a vector that contribute, in lane order, as one masked contribution per iteration of the do block around it. As ordinary Lua a preferred species is one lane wide, so the vector is that lane's value and the mask a boolean; a fixed species contributes its lanes in order, each under its own lane of the mask.

Arguments
NameTypeDescription
selfany
valueT | simd.Vector<T, S>
activesimd.Mask<T, S>?
Returns
TypeDescription
nil

valuemethod#

value: function value(self): T
Arguments
NameTypeDescription
selfany
Returns
TypeDescription
T

Functions#

horizontal.algebraicDotfunction#

function horizontal.algebraicDot<T, S>(left: simd.Vector<T, S>, right: simd.Vector<T, S>): T

As ordinary Lua the vectors are one lane each, which is the product.

Type parameters

NameDescription
T
S

Arguments

NameTypeDescription
leftsimd.Vector<T, S>
rightsimd.Vector<T, S>

Returns

TypeDescription
T

horizontal.algebraicProductfunction#

function horizontal.algebraicProduct<T, S>(value: simd.Vector<T, S>): T

As ordinary Lua a preferred-species vector is one lane, which is the reduction; a fixed-species vector is folded.

Type parameters

NameDescription
T
S

Arguments

NameTypeDescription
valuesimd.Vector<T, S>

Returns

TypeDescription
T

horizontal.algebraicSumfunction#

function horizontal.algebraicSum<T, S>(value: simd.Vector<T, S>): T

As ordinary Lua a preferred-species vector is one lane, which is the reduction; a fixed-species vector is folded.

Type parameters

NameDescription
T
S

Arguments

NameTypeDescription
valuesimd.Vector<T, S>

Returns

TypeDescription
T

horizontal.andBitsfunction#

function horizontal.andBits<T, S>(value: simd.Vector<T, S>): T

The bitwise and of every lane of an integer vector. As ordinary Lua a preferred-species vector is one lane, which is the reduction; a fixed-species vector is folded.

Type parameters

NameDescription
T
S

Arguments

NameTypeDescription
valuesimd.Vector<T, S>

Returns

TypeDescription
T

horizontal.integerMaxfunction#

function horizontal.integerMax<T, S>(value: simd.Vector<T, S>): T

The largest lane of an integer vector, by the element's signedness. As ordinary Lua a preferred-species vector is one lane, which is the reduction; a fixed-species vector is folded.

Type parameters

NameDescription
T
S

Arguments

NameTypeDescription
valuesimd.Vector<T, S>

Returns

TypeDescription
T

horizontal.integerMinfunction#

function horizontal.integerMin<T, S>(value: simd.Vector<T, S>): T

The smallest lane of an integer vector, by the element's signedness. As ordinary Lua a preferred-species vector is one lane, which is the reduction; a fixed-species vector is folded.

Type parameters

NameDescription
T
S

Arguments

NameTypeDescription
valuesimd.Vector<T, S>

Returns

TypeDescription
T

horizontal.numberArgMaxfunction#

function horizontal.numberArgMax<T, S>(value: simd.Vector<T, S>): integer

As ordinary Lua a preferred-species vector is one lane, which is the position; a fixed-species vector is searched.

Type parameters

NameDescription
T
S

Arguments

NameTypeDescription
valuesimd.Vector<T, S>

Returns

TypeDescription
integer

horizontal.numberArgMinfunction#

function horizontal.numberArgMin<T, S>(value: simd.Vector<T, S>): integer

As ordinary Lua a preferred-species vector is one lane, which is the position; a fixed-species vector is searched.

Type parameters

NameDescription
T
S

Arguments

NameTypeDescription
valuesimd.Vector<T, S>

Returns

TypeDescription
integer

horizontal.numberMaxfunction#

function horizontal.numberMax<T, S>(value: simd.Vector<T, S>): T

As ordinary Lua a preferred-species vector is one lane, which is the reduction; a fixed-species vector is folded.

Type parameters

NameDescription
T
S

Arguments

NameTypeDescription
valuesimd.Vector<T, S>

Returns

TypeDescription
T

horizontal.numberMinfunction#

function horizontal.numberMin<T, S>(value: simd.Vector<T, S>): T

As ordinary Lua a preferred-species vector is one lane, which is the reduction; a fixed-species vector is folded.

Type parameters

NameDescription
T
S

Arguments

NameTypeDescription
valuesimd.Vector<T, S>

Returns

TypeDescription
T

horizontal.orBitsfunction#

function horizontal.orBits<T, S>(value: simd.Vector<T, S>): T

The bitwise or of every lane of an integer vector. As ordinary Lua a preferred-species vector is one lane, which is the reduction; a fixed-species vector is folded.

Type parameters

NameDescription
T
S

Arguments

NameTypeDescription
valuesimd.Vector<T, S>

Returns

TypeDescription
T

horizontal.orderedDotfunction#

function horizontal.orderedDot<T, S>(left: simd.Vector<T, S>, right: simd.Vector<T, S>): T

As ordinary Lua the vectors are one lane each, which is the product.

Type parameters

NameDescription
T
S

Arguments

NameTypeDescription
leftsimd.Vector<T, S>
rightsimd.Vector<T, S>

Returns

TypeDescription
T

horizontal.orderedProductfunction#

function horizontal.orderedProduct<T, S>(value: simd.Vector<T, S>): T

As ordinary Lua a preferred-species vector is one lane, which is the reduction; a fixed-species vector is folded.

Type parameters

NameDescription
T
S

Arguments

NameTypeDescription
valuesimd.Vector<T, S>

Returns

TypeDescription
T

horizontal.orderedSumfunction#

function horizontal.orderedSum<T, S>(value: simd.Vector<T, S>): T

As ordinary Lua a preferred-species vector is one lane, which is the reduction; a fixed-species vector is folded.

Type parameters

NameDescription
T
S

Arguments

NameTypeDescription
valuesimd.Vector<T, S>

Returns

TypeDescription
T

horizontal.pairwiseDotfunction#

function horizontal.pairwiseDot<T, S>(left: simd.Vector<T, S>, right: simd.Vector<T, S>): T

As ordinary Lua the vectors are one lane each, which is the product.

Type parameters

NameDescription
T
S

Arguments

NameTypeDescription
leftsimd.Vector<T, S>
rightsimd.Vector<T, S>

Returns

TypeDescription
T

horizontal.pairwiseProductfunction#

function horizontal.pairwiseProduct<T, S>(value: simd.Vector<T, S>): T

As ordinary Lua a preferred-species vector is one lane, which is the reduction; a fixed-species vector is folded.

Type parameters

NameDescription
T
S

Arguments

NameTypeDescription
valuesimd.Vector<T, S>

Returns

TypeDescription
T

horizontal.pairwiseSumfunction#

function horizontal.pairwiseSum<T, S>(value: simd.Vector<T, S>): T

As ordinary Lua a preferred-species vector is one lane, which is the reduction; a fixed-species vector is folded.

Type parameters

NameDescription
T
S

Arguments

NameTypeDescription
valuesimd.Vector<T, S>

Returns

TypeDescription
T

horizontal.propagatingArgMaxfunction#

function horizontal.propagatingArgMax<T, S>(value: simd.Vector<T, S>): integer

As ordinary Lua a preferred-species vector is one lane, which is the position; a fixed-species vector is searched.

Type parameters

NameDescription
T
S

Arguments

NameTypeDescription
valuesimd.Vector<T, S>

Returns

TypeDescription
integer

horizontal.propagatingArgMinfunction#

function horizontal.propagatingArgMin<T, S>(value: simd.Vector<T, S>): integer

The one-based lane holding the matching reduction's answer.

The lowest such lane when several tie, which is the logical-index tie rule every lane-selecting operation here uses. propagatingArgMin returns the lowest NaN lane when any lane is NaN, because that is the lane whose element is what propagatingMin returns; numberArgMin skips NaN lanes and returns the lowest only when every lane is NaN. Either way the identity value:extract(horizontal.<name>ArgMin(value)) holds against the reduction of the same name.

A lane index rather than a lane and its value, because an AOT expression returns a value and extract already spells the pair. As ordinary Lua a preferred-species vector is one lane, which is the position; a fixed-species vector is searched.

Type parameters

NameDescription
T
S

Arguments

NameTypeDescription
valuesimd.Vector<T, S>

Returns

TypeDescription
integer

horizontal.propagatingMaxfunction#

function horizontal.propagatingMax<T, S>(value: simd.Vector<T, S>): T

As ordinary Lua a preferred-species vector is one lane, which is the reduction; a fixed-species vector is folded.

Type parameters

NameDescription
T
S

Arguments

NameTypeDescription
valuesimd.Vector<T, S>

Returns

TypeDescription
T

horizontal.propagatingMinfunction#

function horizontal.propagatingMin<T, S>(value: simd.Vector<T, S>): T

The smallest lane, and the largest, under the contract the name selects.

These take no order where the sums and products above take three: min and max round nothing, so every association of them returns the same value and three names would have named one answer. What they do take is the NaN contract, for the same reason Vector.propagatingMin and Vector.numberMin are separate names -- and each is the elementwise operation of that name, folded over the lanes.

propagatingMin returns the canonical NaN when any lane is NaN, so its answer does not depend on how many lanes the target chose. numberMin returns the smallest lane that is not NaN, and the canonical NaN only when every lane is. -0 is the smaller zero under both. As ordinary Lua a preferred-species vector is one lane, which is the reduction; a fixed-species vector is folded.

Type parameters

NameDescription
T
S

Arguments

NameTypeDescription
valuesimd.Vector<T, S>

Returns

TypeDescription
T

horizontal.wrappingProductfunction#

function horizontal.wrappingProduct<T, S>(value: simd.Vector<T, S>): T

The lanes of an integer vector multiplied, wrapping in the lane's width. As ordinary Lua a preferred-species vector is one lane, which is the reduction; a fixed-species vector is folded.

Type parameters

NameDescription
T
S

Arguments

NameTypeDescription
valuesimd.Vector<T, S>

Returns

TypeDescription
T

horizontal.wrappingSumfunction#

function horizontal.wrappingSum<T, S>(value: simd.Vector<T, S>): T

The lanes of an integer vector summed, wrapping in the lane's own width: a byte vector's sum wraps at a byte, as simd.reducer.wrappingSum wraps at its element. Every association returns the same, so there is one name. As ordinary Lua a preferred-species vector is one lane, which is the reduction; a fixed-species vector is folded.

Type parameters

NameDescription
T
S

Arguments

NameTypeDescription
valuesimd.Vector<T, S>

Returns

TypeDescription
T

horizontal.xorBitsfunction#

function horizontal.xorBits<T, S>(value: simd.Vector<T, S>): T

The bitwise exclusive or of every lane of an integer vector. As ordinary Lua a preferred-species vector is one lane, which is the reduction; a fixed-species vector is folded.

Type parameters

NameDescription
T
S

Arguments

NameTypeDescription
valuesimd.Vector<T, S>

Returns

TypeDescription
T

lane.binaryfunction#

function lane.binary(op: string, element: string, a: any, b: any): any

Arguments

NameTypeDescription
opstring
elementstring
aany
bany

Returns

TypeDescription
any

Raises

TypeCondition
string

when the operator is not one the lanes have

lane.fromStoragefunction#

function lane.fromStorage(element: string, n: integer, storage: any): any

The N-lane vector a stored Fixed<N> field holds: storage is the field's C array, lane i at index i - 1, each wrapped to the element as a load wraps it. Writing the field back is the assignment itself, since the FFI copies an N-lane table into an N-element array.

Arguments

NameTypeDescription
elementstring
ninteger
storageany

Returns

TypeDescription
any

lane.methodfunction#

function lane.method(name: string, element: string, receiver: any, ...: any): any

Arguments

NameTypeDescription
namestring
elementstring
receiverany
...any

Returns

TypeDescription
any

Raises

TypeCondition
string

when the method is not one the lanes have

lane.unaryfunction#

function lane.unary(op: string, element: string, a: any): any

Arguments

NameTypeDescription
opstring
elementstring
aany

Returns

TypeDescription
any

reducer.allfunction#

function reducer.all(): simd.All

Constructs an all reducer.

Returns

TypeDescription
simd.All

reducer.andBitsfunction#

function reducer.andBits<T is int32 | uint32 | int64 | uint64>(element: StorageWitness<T>, initial: Given(T)): simd.AndBits<T>

Constructs a bitwise and over element, including the supplied initial value.

Type parameters

NameDescription
T

Arguments

NameTypeDescription
elementStorageWitness<T>
initialGiven(T)

Returns

TypeDescription
simd.AndBits<T>

reducer.anyfunction#

function reducer.any(): simd.Any

Constructs an any reducer.

Returns

TypeDescription
simd.Any

reducer.countfunction#

function reducer.count(): simd.Count

Constructs a count reducer.

Returns

TypeDescription
simd.Count

reducer.integerArgMaxfunction#

function reducer.integerArgMax<T is int32 | uint32 | int64 | uint64>(element: StorageWitness<T>): simd.IntegerArgMax<T>

Constructs an integer argmax reducer.

Type parameters

NameDescription
T

Arguments

NameTypeDescription
elementStorageWitness<T>

Returns

TypeDescription
simd.IntegerArgMax<T>

reducer.integerArgMinfunction#

function reducer.integerArgMin<T is int32 | uint32 | int64 | uint64>(element: StorageWitness<T>): simd.IntegerArgMin<T>

Constructs an integer argmin reducer.

Type parameters

NameDescription
T

Arguments

NameTypeDescription
elementStorageWitness<T>

Returns

TypeDescription
simd.IntegerArgMin<T>

reducer.integerMaxfunction#

function reducer.integerMax<T is int32 | uint32 | int64 | uint64>(element: StorageWitness<T>, initial: Given(T)): simd.IntegerMax<T>

Constructs an integer max reducer.

Type parameters

NameDescription
T

Arguments

NameTypeDescription
elementStorageWitness<T>
initialGiven(T)

Returns

TypeDescription
simd.IntegerMax<T>

reducer.integerMinfunction#

function reducer.integerMin<T is int32 | uint32 | int64 | uint64>(element: StorageWitness<T>, initial: Given(T)): simd.IntegerMin<T>

Constructs an integer min reducer.

Type parameters

NameDescription
T

Arguments

NameTypeDescription
elementStorageWitness<T>
initialGiven(T)

Returns

TypeDescription
simd.IntegerMin<T>

reducer.orBitsfunction#

function reducer.orBits<T is int32 | uint32 | int64 | uint64>(element: StorageWitness<T>, initial: Given(T)): simd.OrBits<T>

Constructs a bitwise or over element, including the supplied initial value.

Type parameters

NameDescription
T

Arguments

NameTypeDescription
elementStorageWitness<T>
initialGiven(T)

Returns

TypeDescription
simd.OrBits<T>

reducer.wrappingProductfunction#

function reducer.wrappingProduct<T is int32 | uint32 | int64 | uint64>(element: StorageWitness<T>, initial: Given(T)): simd.WrappingProduct<T>

Constructs a wrapping product over element, including the supplied initial value.

Type parameters

NameDescription
T

Arguments

NameTypeDescription
elementStorageWitness<T>
initialGiven(T)

Returns

TypeDescription
simd.WrappingProduct<T>

reducer.wrappingSumfunction#

function reducer.wrappingSum<T is int32 | uint32 | int64 | uint64>(element: StorageWitness<T>, initial: Given(T)): simd.WrappingSum<T>

Constructs a wrapping sum over element, including the supplied initial value.

Type parameters

NameDescription
T

Arguments

NameTypeDescription
elementStorageWitness<T>
initialGiven(T)

Returns

TypeDescription
simd.WrappingSum<T>

reducer.xorBitsfunction#

function reducer.xorBits<T is int32 | uint32 | int64 | uint64>(element: StorageWitness<T>, initial: Given(T)): simd.XorBits<T>

Constructs a bitwise exclusive or over element, including the supplied initial value.

Type parameters

NameDescription
T

Arguments

NameTypeDescription
elementStorageWitness<T>
initialGiven(T)

Returns

TypeDescription
simd.XorBits<T>

transposefunction#

local transpose: function<Rows...>(
    ...: Rows...
): unpackof Transposed(Rows..., simd.Vector<uint32, simd.Fixed<2>>, simd.Fixed<2>)

Transposes a square tile of Fixed row vectors into N column vectors. All rows have the same element type; lane bits are preserved. Results are separate native vectors, not a table, and cannot escape the AOT kernel.

Type parameters

NameDescription
Rows

Arguments

NameTypeDescription
...Rows...

Returns

TypeDescription
unpackof Transposed(Rows..., simd.Vector<uint32, simd.Fixed<2>>, simd.Fixed<2>)

Values#

horizontalvariable#

Named horizontal operations over an explicit register value.

Ordered operations follow logical lane order. Pairwise operations use the adjacent-pair tree. Algebraic operations permit reassociation; only algebraicDot additionally permits multiply-add contraction. Those three orders are floating-point contracts, because addition rounds; the wrapping, bitwise and integer extremum operations below are the integer contracts, which return the same under every association and so take one name each.

lanevariable#

local lane

The lane operations, as the code generator calls them for a value the checker typed as a vector or a mask: a binary operator, a unary one, and a method. element is the element name, or "mask" for a mask. Each returns an N-lane form lane by lane through the one-lane operation beneath it.

reducervariable#

local reducer: {
    orderedSum: function(initial: number): simd.OrderedSum<number>
    & function<T is float | number>(element: StorageWitness<T>, initial: number): simd.OrderedSum<T>,
    pairwiseSum: function(initial: number): simd.PairwiseSum<number>
    & function<T is float | number>(element: StorageWitness<T>, initial: number): simd.PairwiseSum<T>,
    compensatedSum: function(initial: number): simd.CompensatedSum<number>
    & function<T is float | number>(element: StorageWitness<T>, initial: number): simd.CompensatedSum<T>,
    algebraicSum: function(initial: number): simd.AlgebraicSum<number>
    & function<T is float | number>(element: StorageWitness<T>, initial: number): simd.AlgebraicSum<T>,
    orderedProduct: function(initial: number): simd.OrderedProduct<number>
    & function<T is float | number>(element: StorageWitness<T>, initial: number): simd.OrderedProduct<T>,
    pairwiseProduct: function(initial: number): simd.PairwiseProduct<number>
    & function<T is float | number>(element: StorageWitness<T>, initial: number): simd.PairwiseProduct<T>,
    algebraicProduct: function(initial: number): simd.AlgebraicProduct<number>
    & function<T is float | number>(element: StorageWitness<T>, initial: number): simd.AlgebraicProduct<T>,
    orderedDot: function(initial: number): simd.OrderedDot<number>
    & function<T is float | number>(element: StorageWitness<T>, initial: number): simd.OrderedDot<T>,
    pairwiseDot: function(initial: number): simd.PairwiseDot<number>
    & function<T is float | number>(element: StorageWitness<T>, initial: number): simd.PairwiseDot<T>,
    algebraicDot: function(initial: number): simd.AlgebraicDot<number>
    & function<T is float | number>(element: StorageWitness<T>, initial: number): simd.AlgebraicDot<T>,
    wrappingSum: function<T is int32 | uint32 | int64 | uint64>(
        element: StorageWitness<T>,
        initial: Given(T)
    ): simd.WrappingSum<T>,
    wrappingProduct: function<T is int32 | uint32 | int64 | uint64>(
        element: StorageWitness<T>,
        initial: Given(T)
    ): simd.WrappingProduct<T>,
    andBits: function<T is int32 | uint32 | int64 | uint64>(
        element: StorageWitness<T>,
        initial: Given(T)
    ): simd.AndBits<T>,
    orBits: function<T is int32 | uint32 | int64 | uint64>(
        element: StorageWitness<T>,
        initial: Given(T)
    ): simd.OrBits<T>,
    xorBits: function<T is int32 | uint32 | int64 | uint64>(
        element: StorageWitness<T>,
        initial: Given(T)
    ): simd.XorBits<T>,
    any: function(): simd.Any,
    all: function(): simd.All,
    count: function(): simd.Count,
    integerMin: function<T is int32 | uint32 | int64 | uint64>(
        element: StorageWitness<T>,
        initial: Given(T)
    ): simd.IntegerMin<T>,
    integerMax: function<T is int32 | uint32 | int64 | uint64>(
        element: StorageWitness<T>,
        initial: Given(T)
    ): simd.IntegerMax<T>,
    integerArgMin: function<T is int32 | uint32 | int64 | uint64>(element: StorageWitness<T>): simd.IntegerArgMin<T>,
    integerArgMax: function<T is int32 | uint32 | int64 | uint64>(element: StorageWitness<T>): simd.IntegerArgMax<T>,
    propagatingMin: function(initial: number): simd.PropagatingMin<number>
    & function<T is float | number>(element: StorageWitness<T>, initial: number): simd.PropagatingMin<T>,
    propagatingMax: function(initial: number): simd.PropagatingMax<number>
    & function<T is float | number>(element: StorageWitness<T>, initial: number): simd.PropagatingMax<T>,
    propagatingArgMin: function(): simd.PropagatingArgMin<number>
    & function<T is float | number>(element: StorageWitness<T>): simd.PropagatingArgMin<T>,
    propagatingArgMax: function(): simd.PropagatingArgMax<number>
    & function<T is float | number>(element: StorageWitness<T>): simd.PropagatingArgMax<T>,
    numberMin: function(initial: number): simd.NumberMin<number>
    & function<T is float | number>(element: StorageWitness<T>, initial: number): simd.NumberMin<T>,
    numberMax: function(initial: number): simd.NumberMax<number>
    & function<T is float | number>(element: StorageWitness<T>, initial: number): simd.NumberMax<T>,
    numberArgMin: function(): simd.NumberArgMin<number>
    & function<T is float | number>(element: StorageWitness<T>): simd.NumberArgMin<T>,
    numberArgMax: function(): simd.NumberArgMax<number>
    & function<T is float | number>(element: StorageWitness<T>): simd.NumberArgMax<T>
}

Closed reduction values for scalar or explicit masked vector contributions.

One reducer takes scalar contributions and masked vector contributions in any mix, in program order; every masked contribution belongs to one do block, which is the reducer's region. A floating-point reducer is constructed either from its initial value alone, which accumulates in number, or from an element witness and the initial value -- pairwiseSum(array.float, 0.0) -- which accumulates in the float or number the witness names. An integer reducer always names its element with its witness, because an int32 and a uint32 are the same Lua number.