CVL

Usage

use CVL;

or

import CVL;
config param implementationWarnings = true
proc numBits(type t) param : int  where isSubtype(t, vector)
record vector : writeSerializable
type eltType
param numElts : int
var data : Intrin.vectorType(eltType, numElts)
proc init(type eltType, param numElts: int)

type init

proc init(type eltType, param numElts: int, value: eltType)

init to single value

proc init(param numElts: int, value: ?eltType)

init to single value, infer type

proc init(type eltType, param numElts: int, value: vector(eltType, numElts))
proc init=(value: vector(?))
operator =(ref lhs: vector(?), rhs: lhs.type)
proc ref set(value: vector(eltType, numElts))
proc init(values)  where isHomogeneousTupleType(values.type)
proc init=(values)  where isHomogeneousTupleType(values.type)
operator =(ref lhs, rhs)  where isSubtype(lhs.type, vector) && isHomogeneousTupleType(rhs.type) && isCoercible(rhs(0).type, lhs.eltType) && lhs.numElts == rhs.size
operator :(x: ?tupType, type t: vector(?))  where isHomogeneousTupleType(tupType) && isCoercible(x(0).type, t.eltType) && x.size == t.numElts
operator :(x: ?eltType, type t: vector(?))  where isCoercible(eltType, t.eltType)
operator :(x: vector(?eltType, ?numElts), type tupType)  where isHomogeneousTupleType(tupType) && isCoercible(eltType, tupType(0)) && tupType.size == numElts
operator +(x: vector(?eltType, ?numElts), y: x.type) : x.type

VECTOR + VECTOR

operator +=(ref x: vector(?eltType, ?numElts), y: x.type)
operator +(x: vector(?eltType, ?numElts), y: ?scalarType) : x.type  where isCoercible(scalarType, eltType)

VECTOR + SCALAR

operator +=(ref x: vector(?eltType, ?numElts), y: ?scalarType)  where isCoercible(scalarType, eltType)
operator +(x: ?scalarType, y: vector(?eltType, ?numElts)) : y.type  where isCoercible(scalarType, eltType)

SCALAR + VECTOR

operator -(x: vector(?eltType, ?numElts), y: x.type) : x.type

VECTOR - VECTOR

operator -=(ref x: vector(?eltType, ?numElts), y: x.type)
operator -(x: vector(?eltType, ?numElts), y: ?scalarType) : x.type  where isCoercible(scalarType, eltType)

VECTOR - SCALAR

operator -=(ref x: vector(?eltType, ?numElts), y: ?scalarType)  where isCoercible(scalarType, eltType)
operator -(x: ?scalarType, y: vector(?eltType, ?numElts)) : y.type  where isCoercible(scalarType, eltType)

SCALAR - VECTOR

operator -(x: vector(?eltType, ?numElts)) : x.type
operator *(x: vector(?eltType, ?numElts), y: x.type) : x.type

VECTOR * VECTOR

operator *=(ref x: vector(?eltType, ?numElts), y: x.type)
operator *(x: vector(?eltType, ?numElts), y: ?scalarType) : x.type  where isCoercible(scalarType, eltType)

VECTOR * SCALAR

operator *=(ref x: vector(?eltType, ?numElts), y: ?scalarType)  where isCoercible(scalarType, eltType)
operator *(x: ?scalarType, y: vector(?eltType, ?numElts)) : y.type  where isCoercible(scalarType, eltType)

SCALAR * VECTOR

operator /(x: vector(?eltType, ?numElts), y: x.type) : x.type

VECTOR / VECTOR

operator /=(ref x: vector(?eltType, ?numElts), y: x.type)
operator /(x: vector(?eltType, ?numElts), y: ?scalarType) : x.type  where isCoercible(scalarType, eltType)

VECTOR / SCALAR

operator /=(ref x: vector(?eltType, ?numElts), y: ?scalarType)  where isCoercible(scalarType, eltType)
operator /(x: ?scalarType, y: vector(?eltType, ?numElts)) : y.type  where isCoercible(scalarType, eltType)

SCALAR / VECTOR

operator &(x: vector(?eltType, ?numElts), y: x.type) : x.type

VECTOR & VECTOR

operator &=(ref x: vector(?eltType, ?numElts), y: x.type)
operator &(x: vector(?eltType, ?numElts), y: ?scalarType) : x.type  where isCoercible(scalarType, eltType)

VECTOR & SCALAR

operator &=(ref x: vector(?eltType, ?numElts), y: ?scalarType)  where isCoercible(scalarType, eltType)
operator &(x: ?scalarType, y: vector(?eltType, ?numElts)) : y.type  where isCoercible(scalarType, eltType)

SCALAR & VECTOR

operator |(x: vector(?eltType, ?numElts), y: x.type) : x.type

VECTOR | VECTOR

operator |=(ref x: vector(?eltType, ?numElts), y: x.type)
operator |(x: vector(?eltType, ?numElts), y: ?scalarType) : x.type  where isCoercible(scalarType, eltType)

VECTOR | SCALAR

operator |=(ref x: vector(?eltType, ?numElts), y: ?scalarType)  where isCoercible(scalarType, eltType)
operator |(x: ?scalarType, y: vector(?eltType, ?numElts)) : y.type  where isCoercible(scalarType, eltType)

SCALAR | VECTOR

operator ^(x: vector(?eltType, ?numElts), y: x.type) : x.type

VECTOR ^ VECTOR

operator ^=(ref x: vector(?eltType, ?numElts), y: x.type)
operator ^(x: vector(?eltType, ?numElts), y: ?scalarType) : x.type  where isCoercible(scalarType, eltType)

VECTOR ^ SCALAR

operator ^=(ref x: vector(?eltType, ?numElts), y: ?scalarType)  where isCoercible(scalarType, eltType)
operator ^(x: ?scalarType, y: vector(?eltType, ?numElts)) : y.type  where isCoercible(scalarType, eltType)

SCALAR ^ VECTOR

operator ~(x: vector(?eltType, ?numElts)) : x.type

~VECTOR

operator ==(x: vector(?eltType, ?numElts), y: x.type) : x.type

VECTOR == VECTOR

operator ==(x: vector(?eltType, ?), y: ?scalarType) : x.type  where isCoercible(scalarType, eltType)

VECTOR == SCALAR

operator ==(x: ?scalarType, y: vector(?eltType, ?)) : y.type  where isCoercible(scalarType, eltType)

SCALAR == VECTOR

operator !=(x: vector(?eltType, ?numElts), y: x.type) : x.type

VECTOR != VECTOR

operator !=(x: vector(?eltType, ?), y: ?scalarType) : x.type  where isCoercible(scalarType, eltType)

VECTOR != SCALAR

operator !=(x: ?scalarType, y: vector(?eltType, ?)) : y.type  where isCoercible(scalarType, eltType)

SCALAR != VECTOR

operator <(x: vector(?eltType, ?numElts), y: x.type) : x.type

VECTOR < VECTOR

operator <(x: vector(?eltType, ?), y: ?scalarType) : x.type  where isCoercible(scalarType, eltType)

VECTOR < SCALAR

operator <(x: ?scalarType, y: vector(?eltType, ?)) : y.type  where isCoercible(scalarType, eltType)

SCALAR < VECTOR

operator <=(x: vector(?eltType, ?numElts), y: x.type) : x.type

VECTOR <= VECTOR

operator <=(x: vector(?eltType, ?), y: ?scalarType) : x.type  where isCoercible(scalarType, eltType)

VECTOR <= SCALAR

operator <=(x: ?scalarType, y: vector(?eltType, ?)) : y.type  where isCoercible(scalarType, eltType)

SCALAR <= VECTOR

operator >(x: vector(?eltType, ?numElts), y: x.type) : x.type

VECTOR > VECTOR

operator >(x: vector(?eltType, ?), y: ?scalarType) : x.type  where isCoercible(scalarType, eltType)

VECTOR > SCALAR

operator >(x: ?scalarType, y: vector(?eltType, ?)) : y.type  where isCoercible(scalarType, eltType)

SCALAR > VECTOR

operator >=(x: vector(?eltType, ?numElts), y: x.type) : x.type

VECTOR >= VECTOR

operator >=(x: vector(?eltType, ?), y: ?scalarType) : x.type  where isCoercible(scalarType, eltType)

VECTOR >= SCALAR

operator >=(x: ?scalarType, y: vector(?eltType, ?)) : y.type  where isCoercible(scalarType, eltType)

SCALAR >= VECTOR

proc ref set(value)  where isCoercible(value.type, eltType)
proc ref set(values)  where isHomogeneousTupleType(values.type) && isCoercible(values(0).type, eltType) && values.size == numElts
proc ref set(param idx: integral, value)  where isCoercible(value.type, eltType)
proc this(param idx: integral) : eltType
iter these() : eltType
proc ref load(ptr: c_ptrConst(eltType), idx: integral = 0, param aligned: bool = false)
proc ref load(arr: [] eltType, idx: integral = 0, param aligned: bool = false)  where isValidContainer(arr, eltType)
proc ref load(tup, idx: integral = 0, param aligned: bool = false)  where isValidContainer(tup, eltType) && isHomogeneousTuple(tup)
proc store(ptr: c_ptr(eltType), idx: integral = 0, param aligned: bool = false)
proc store(ref arr: [] eltType, idx: integral = 0, param aligned: bool = false)  where isValidContainer(arr, eltType)
proc store(ref tup, idx: integral = 0, param aligned: bool = false)  where isValidContainer(tup, eltType) && isHomogeneousTuple(tup)
proc type load(container: ?, idx: integral = 0, param aligned: bool = false) : this
proc type loadMasked(mask: vector(?), container: ?, idx: integral = 0) : this

loadMasked is not bounds checked

proc ref loadMasked(mask: vector(?), ptr: c_ptrConst(eltType), idx: integral = 0)  where this.type.isValidLoadMask(mask.type)

loadMasked is not bounds checked

proc ref loadMasked(mask: vector(?), arr: [] eltType, idx: integral = 0)  where this.type.isValidLoadMask(mask.type) && isValidContainer(arr, eltType)

loadMasked is not bounds checked

proc ref loadMasked(mask: vector(?), tup, idx: integral = 0)  where this.type.isValidLoadMask(mask.type) && isValidContainer(tup, eltType) && isHomogeneousTuple(tup)

loadMasked is not bounds checked

proc type gather(container: ?, startIdx: integral, indexVector: this.indexVectorType, param scale: int = 0, mask: ? = none) : this

gather is not bounds checked

proc ref gather(ptr: c_ptrConst(eltType), startIdx: integral, indexVector: this.type.indexVectorType, param scale: int = 0, mask: ? = none)  where mask.type == nothing || this.type.isValidLoadMask(mask.type, onlyInts = false)

gather is not bounds checked

proc ref gather(arr: [] eltType, startIdx: integral, indexVector: this.type.indexVectorType, param scale: int = 0, mask: ? = none)  where (mask.type == nothing || this.type.isValidLoadMask(mask.type, onlyInts = false)) && isValidContainer(arr, eltType)

gather is not bounds checked

proc ref gather(tup, startIdx: integral, indexVector: this.type.indexVectorType, param scale: int = 0, mask: ? = none)  where (mask.type == nothing || this.type.isValidLoadMask(mask.type, onlyInts = false)) && isValidContainer(tup, eltType) && isHomogeneousTuple(tup)

gather is not bounds checked

proc transmute(type t) : t  where isSubtype(t, vector) && numBits(t) == numBits(this.type)
proc transmute(type t) : t  where !isSubtype(t, vector)
proc transmute(type t) : t  where isSubtype(t, vector) && numBits(t) != numBits(this.type)
proc type indices(rng: range(?)) : range(?)
proc type indices(dom: domain(?)) : domain(?)
proc type indices(container: ?) : range(?)  where isHomogeneousTuple(container)
proc type indices(container: ?) : domain(?)  where isArray(container)
iter type vectors(container: ?, param aligned: bool = false) : this  where isValidContainer(container, eltType)
iter type vectors(param tag: iterKind, container: ?, param aligned: bool = false) : this  where tag == iterKind.standalone && isValidContainer(container, eltType)
iter type vectors(param tag: iterKind, container: ?, param aligned: bool = false) : this  where tag == iterKind.leader && isValidContainer(container, eltType)
iter type vectors(param tag: iterKind, followThis, container: ?, param aligned: bool = false) : this  where tag == iterKind.follower && isValidContainer(container, eltType)
iter type vectorsRef(ref container: ?, param aligned: bool = false) ref : this  where isValidContainer(container, eltType)
iter type vectorsRef(param tag: iterKind, ref container: ?, param aligned: bool = false) ref : this  where tag == iterKind.standalone && isValidContainer(container, eltType)
iter type vectorsRef(param tag: iterKind, ref container: ?, param aligned: bool = false) ref : this  where tag == iterKind.leader && isValidContainer(container, eltType)
iter type vectorsRef(param tag: iterKind, followThis, ref container: ?, param aligned: bool = false) ref : this  where tag == iterKind.follower && isValidContainer(container, eltType)
iter type vectorsJagged(arr: ?, pad: eltType = 0, param aligned: bool = false) : this
proc serialize(writer, ref serializer) throws
proc swapPairs(x: vector(?eltType, ?numElts)) : x.type
proc swapLowHigh(x: vector(?eltType, ?numElts)) : x.type
proc reverse(x: vector(?eltType, ?numElts)) : x.type
proc rotateLeft(x: vector(?eltType, ?numElts)) : x.type
proc rotateRight(x: vector(?eltType, ?numElts)) : x.type
proc interleaveLower(x: vector(?eltType, ?numElts), y: x.type) : x.type
proc interleaveUpper(x: vector(?eltType, ?numElts), y: x.type) : x.type
proc deinterleaveLower(x: vector(?eltType, ?numElts), y: x.type) : x.type
proc deinterleaveUpper(x: vector(?eltType, ?numElts), y: x.type) : x.type
proc pairwiseAdd(x: vector(?eltType, ?numElts), y: x.type) : x.type

pairwise add adjacent elements

x: [a, b, c, d] y: [e, f, g, h]

returns: [a+b, e+f, c+d, g+h]

proc blendLowHigh(x: vector(?eltType, ?numElts), y: x.type) : x.type

takes the low half of x and the high half of y

proc vector.isZero() : bool
proc vector.moveMask() : c_int
proc type vector.ones() : this
proc type vector.zeros() : this
proc sqrt(x: vector(?eltType, ?numElts)) : x.type
proc rsqrt(x: vector(?eltType, ?numElts)) : x.type
proc fma(x: vector(?eltType, ?numElts), y: x.type, z: x.type) : x.type
proc fms(x: vector(?eltType, ?numElts), y: x.type, z: x.type) : x.type
proc bitSelect(mask: vector(?), x: vector(?eltType, ?numElts), y: x.type) : x.type  where numBits(mask.type) == numBits(x.type)
proc andNot(x: vector(?eltType, ?numElts), y: x.type) : x.type
proc andNot(x: vector(?eltType, ?numElts), y: ?scalarType) : x.type  where isCoercible(scalarType, eltType)
proc andNot(x: ?scalarType, y: vector(?eltType, ?numElts)) : y.type  where isCoercible(scalarType, eltType)
proc min(x: vector(?eltType, ?numElts), y: x.type) : x.type
proc max(x: vector(?eltType, ?numElts), y: x.type) : x.type
proc abs(x: vector(?eltType, ?numElts)) : x.type
record vectorRef : writeSerializable

a transparent record that iterators can yield, takes in modifications to the yielded vector and then writes them back out to the raw address when this goes out of scope

type vectorType
param aligned : bool
var vec : vectorType
var address : c_ptr(vectorType.eltType)
proc init(type vectorType, param aligned: bool = false)
proc init(vec: ?vecType, address: c_ptr(vecType.eltType), param aligned: bool = false)
proc init(type vectorType, address: c_ptr(vectorType.eltType), param aligned: bool = false)
proc deinit()
proc commitChanges()
proc serialize(writer, ref serializer) throws
operator +(lhs: ?lhsType, rhs: ?rhsType) : returnTypeForOpTypes(lhsType, rhsType)  where returnTypeForOpTypes(lhsType, rhsType) != nothing
operator +=(ref lhs: vectorRef(?), rhs: ?rhsType)  where validEqOperatorTypes(lhs.type, rhsType)
operator -(lhs: ?lhsType, rhs: ?rhsType) : returnTypeForOpTypes(lhsType, rhsType)  where returnTypeForOpTypes(lhsType, rhsType) != nothing
operator -=(ref lhs: vectorRef(?), rhs: ?rhsType)  where validEqOperatorTypes(lhs.type, rhsType)
operator *(lhs: ?lhsType, rhs: ?rhsType) : returnTypeForOpTypes(lhsType, rhsType)  where returnTypeForOpTypes(lhsType, rhsType) != nothing
operator *=(ref lhs: vectorRef(?), rhs: ?rhsType)  where validEqOperatorTypes(lhs.type, rhsType)
proc validEqOperatorTypes(type lhsType, type rhsType) param : bool