Argon 0.1.0
Loading...
Searching...
No Matches
argon::Vector< VectorType > Class Template Reference

Represents a SIMD vector with various operations. More...

#include <vector.hpp>

Inheritance diagram for argon::Vector< VectorType >:

Public Types

template<size_t LaneIndex>
using const_lane_type = ConstLane<LaneIndex, VectorType>
 The type of a single lane of the SIMD vector.
using lane_type = Lane<VectorType>
 The type of a single lane of the SIMD vector.
using scalar_type = simd::Scalar_t<VectorType>
 The scalar type of the SIMD vector.
using vector_type = VectorType
 The SIMD vector type.
using argon_type = helpers::ArgonFor_t<VectorType>
 The Argon type for the SIMD vector.
using mask_type
 The mask vector type (all ones / all zeros per lane), see Predicate::ToMask.
using argon_bool_type = Predicate<VectorType>
 The type comparisons return.
using offset_type
 Per-lane gather/scatter offsets.

Public Member Functions

constexpr Vector ()=default
 The default constructor for the Vector class.
constexpr Vector (Vector &&other)=default
 Move constructor for the Vector class.
constexpr Vector (const Vector &other)=default
 Copy constructor for the Vector class.
constexpr Vector & operator= (Vector &&other)=default
 Move assignment operator for the Vector class.
constexpr Vector & operator= (const Vector &other)=default
 Copy assignment operator for the Vector class.
ace Vector (VectorType vector)
 Constructs a Vector from a SIMD vector type.
ace Vector (scalar_type scalar)
 Constructs a Vector from a scalar value.
ace Vector (argon::Lane< VectorType > lane)
 Constructs a Vector from a Lane object.
template<size_t LaneIndex>
ace Vector (argon::ConstLane< LaneIndex, VectorType > lane)
 Constructs a Vector from a ConstLane object.
template<typename... ArgTypes>
ace Vector (ArgTypes... args)
 Constructs a Vector from one value per lane.
ace argon_type operator- () const
 Negate the SIMD vector and return the result.
ace argon_type operator+ (argon_type b) const
 Add a vector and return the result.
ace argon_type operator- (argon_type b) const
 Subtract a vector and return the result.
ace argon_type operator* (argon_type b) const
 Multiply a vector and return the result.
ace argon_type operator/ (argon_type b) const
 Divide a vector and return the result.
ace argon_bool_type operator== (argon_type b) const
 Compare two vectors for equality.
ace argon_bool_type operator!= (argon_type b) const
 Compare two vectors for inequality.
ace argon_bool_type operator< (argon_type b) const
 Compare two vectors, checking if this vector is less than the other.
ace argon_bool_type operator> (argon_type b) const
 Compare two vectors, checking if this vector is greater than the other.
ace argon_bool_type operator<= (argon_type b) const
 Compare two vectors, checking if this vector is less than or equal to the other.
ace argon_bool_type operator>= (argon_type b) const
 Compare two vectors, checking if this vector is greater than or equal to the other.
ace argon_type operator++ () const
 Increment the vector by 1 and return the result.
ace argon_type operator-- () const
 Decrement the vector by 1 and return the result.
ace argon_type operator& (argon_type b) const
 Bitwise AND two vectors and return the result.
ace argon_type operator| (argon_type b) const
 Bitwise OR two vectors and return the result.
ace argon_type operator^ (argon_type b) const
 Bitwise XOR two vectors and return the result.
ace argon_type operator~ () const
 Bitwise NOT the vector and return the result.
ace Lane< const VectorType > operator[] (const size_t i) const
 Access a lane of the vector by index.
ace lane_type operator[] (const size_t i)
 Access a lane of the vector by index.
ace argon_type operator>> (const int i) const
 Shift the elements of the vector to the right by a specified number of bits.
ace argon_type operator<< (const int i) const
 Shift the elements of the vector to the left by a specified number of bits.
constexpr VectorType vec () const
 Get the underlying SIMD vector.
constexpr operator VectorType () const
 Convert the vector to the underlying SIMD vector type.
ace std::array< scalar_type, lanes > to_array () const
 Convert the vector to an array of scalar values.
ace Lane< const VectorType > GetLane (const size_t i) const
 Get a single lane of the vector by index.
ace lane_type GetLane (const size_t i)
ace Lane< const VectorType > GetLane (const int i) const
 Get a single lane of the vector by index.
ace lane_type GetLane (const int i)
template<size_t LaneIndex>
ace ConstLane< LaneIndex, const VectorType > GetLane () const
 Get a single lane of the vector by index.
template<size_t LaneIndex>
ace const_lane_type< LaneIndex > GetLane ()
ace const_lane_type< lanes - 1 > LastLane ()
 Get the last lane of the vector.
ace argon_type ShiftRight (const int i) const
 Shift the elements of the vector to the right by a specified number of bits.
ace argon_type ShiftLeft (const int i) const
 Shift the elements of the vector to the left by a specified number of bits.
ace argon_type Negate () const
 Bitwise negate the vector and return the result.
ace argon_type Add (argon_type b) const
 Add two vectors.
ace argon_type AddHalve (argon_type b) const
 Adds two vectors, halving the result.
ace argon_type AddHalveRound (argon_type b) const
 Adds two vectors, halving and rounding the result.
ace argon_type AddSaturate (argon_type b) const
 Adds two vectors, saturating the result.
ace argon_type Subtract (argon_type b) const
 Subtract two vectors.
ace argon_type SubtractHalve (argon_type b) const
 Subtract two vectors, halving the result.
ace argon_type SubtractSaturate (argon_type b) const
 Subtract two vectors, saturating the result.
ace argon_type SubtractAbs (argon_type b) const
 Subtract two vectors, taking the absolute value of the result.
ace argon_type SubtractAbsAdd (argon_type b, argon_type c) const
 Subtract two vectors, taking the absolute value of the result and adding a third vector.
ace argon_type Multiply (argon_type b) const
 Multiply two vectors.
ace argon_type Multiply (scalar_type b) const
 Multiply a vector by a scalar value.
ace argon_type Multiply (lane_type b) const
 Multiply a vector by a lane value.
template<size_t LaneIndex>
ace argon_type Multiply (const_lane_type< LaneIndex > b) const
 Multiply a vector by a lane value.
ace argon_type MultiplyAdd (argon_type b, argon_type c) const
 Multiply two vectors and add a third vector.
ace argon_type MultiplyAdd (argon_type b, scalar_type c) const
 Multiply a vector by a scalar value and add a third vector.
ace argon_type MultiplyAdd (scalar_type b, argon_type c) const
 Multiply a vector by a scalar value and add a third vector.
ace argon_type MultiplyAdd (argon_type b, lane_type c) const
 Multiply a vector by a lane value and add a third vector.
ace argon_type MultiplyAdd (lane_type b, argon_type c) const
 Multiply a vector by a lane value and add a third vector.
template<size_t LaneIndex>
ace argon_type MultiplyAdd (argon_type b, const_lane_type< LaneIndex > c) const
 Multiply a vector by a lane value and add a third vector.
template<size_t LaneIndex>
ace argon_type MultiplyAdd (const_lane_type< LaneIndex > b, argon_type c) const
 Multiply a vector by a lane value and add a third vector.
ace argon_type MultiplySubtract (argon_type b, argon_type c) const
 Multiply two vectors and subtract from a third vector.
ace argon_type MultiplySubtract (argon_type b, scalar_type c) const
 Multiply a vector by a scalar value and subtract from a third vector.
ace argon_type MultiplySubtract (scalar_type b, argon_type c) const
 Multiply a vector by a scalar value and subtract from a third vector.
ace argon_type MultiplySubtract (argon_type b, lane_type c) const
 Multiply a vector by a lane value and subtract from a third vector.
ace argon_type MultiplyFixedQMax (argon_type v) const
 Multiply two QMax fixed-point vectors, returning a fixed-point product.
ace argon_type MultiplyFixedQMax (scalar_type s) const
 Multiply a QMax fixed-point vector by a scalar value, returning a fixed-point product.
ace argon_type MultiplyFixedQMax (lane_type l) const
 Multiply a QMax fixed-point vector by a lane value, returning a fixed-point product.
ace argon_type MultiplyRoundFixedQMax (argon_type v) const
 Multiply two fixed-point vectors, returning a fixed-point product.
ace argon_type MultiplyRoundFixedQMax (scalar_type s) const
 Multiply a fixed-point vector by a scalar value, returning a fixed-point product.
ace argon_type MultiplyRoundFixedQMax (lane_type l) const
 Multiply a fixed-point vector by a lane value, returning a fixed-point product.
ace argon_type Absolute () const
 Get the absolute value of the vector.
ace argon_type ReciprocalEstimate () const
 1 / value, using an estimate for speed
ace argon_type ReciprocalSqrtEstimate () const
 1 / sqrt(value), using an estimate for speed
ace argon_type ReciprocalStep (argon_type b) const
 Newton-Raphson step for reciprocal refinement: (2 - a * b) / 2.
ace argon_type ReciprocalSqrtStep (argon_type b) const
 Newton-Raphson step for reciprocal-sqrt refinement: (3 - a * b) / 2.
ace argon_type ReciprocalEstimateRefine (int n_iters=1) const
 Compute a refined reciprocal estimate using Newton-Raphson iterations.
ace argon_type ReciprocalSqrtEstimateRefine (int n_iters=1) const
 Compute a refined reciprocal-sqrt estimate using Newton-Raphson iterations.
template<typename arg_type>
ace argon_type MultiplyAddFixedQMax (argon_type b, arg_type c) const
 Multiply-add three fixed-point vectors, returning a fixed-point sum.
template<typename arg_type>
ace argon_type MultiplyRoundAddFixedQMax (argon_type b, arg_type c) const
 Multiply-round-add three fixed-point vectors, returning a fixed-point sum.
ace argon_type Divide (argon_type b) const
 Divide two vectors.
ace argon_type Modulo (argon_type b) const
 Get the modulo of two vectors.
ace argon_type Modulo (scalar_type b) const
 Get the modulo of a vector and a scalar value.
ace argon_type Max (argon_type b) const
 Compare the lanes of two vectors, copying the larger of each lane to the result.
ace argon_type Min (argon_type b) const
 Compare the lanes of two vectors, copying the smaller of each lane to the result.
ace argon_type MaxNumber (argon_type b) const
 The larger of each lane by IEEE 754 maxNum, as Arm's vmaxnm: a quiet NaN in one operand gives the other (NaN only where both are), and +0 is larger than -0.
ace argon_type MinNumber (argon_type b) const
 The smaller of each lane by IEEE 754 minNum, as Arm's vminnm: a quiet NaN in one operand gives the other (NaN only where both are), and -0 is smaller than +0.
template<bool max>
ace argon_type NumberMinMax (argon_type b) const
 MaxNumber/MinNumber from compares and selects, where there is no vmaxnm/vminnm.
ace argon_bool_type Equal (argon_type b) const
 Compare the lanes of two vectors, returning a predicate active where a == b.
ace argon_bool_type GreaterThanOrEqual (argon_type b) const
 Compare the lanes of two vectors, returning a predicate active where a is greater than or equal to b.
ace argon_bool_type LessThanOrEqual (argon_type b) const
 Compare the lanes of two vectors, returning a predicate active where a is less than or equal to b.
ace argon_bool_type GreaterThan (argon_type b) const
 Compare the lanes of two vectors, returning a predicate active where a is greater than b.
ace argon_bool_type LessThan (argon_type b) const
 Compare the lanes of two vectors, returning a predicate active where a is less than b.
ace argon_type ShiftLeft (helpers::ArgonFor_t< simd::make_signed_t< Bool_t< VectorType > > > b) const
 Shift the elemnets of the vector to the left by a specified number of bits.
ace argon_type ShiftLeft (std::make_signed_t< simd::Scalar_t< Bool_t< VectorType > > > n) const
 Shift the elements of the vector to the left by a specified number of bits.
ace argon_type ShiftByVector (int count) const
 vshl by count in every lane: left for positive counts, right (arithmetic or logical) for negative ones.
template<int n>
ace argon_type ShiftLeft () const
 Shift the elements of the vector to the left by a specified number of bits.
ace argon_type ShiftLeftSaturate (helpers::ArgonFor_t< simd::make_signed_t< Bool_t< VectorType > > > b) const
 Shift the elements of the vector to the left by a specified number of bits, saturating the result.
ace argon_type ShiftLeftRound (argon_type b) const
 Shift the elements of the vector to the left by a specified number of bits, rounding the result.
ace argon_type ShiftLeftRoundSaturate (argon_type b) const
 Shift the elements of the vector to the left by a specified number of bits, rounding and saturating the result.
template<int n>
ace argon_type ShiftLeftSaturate () const
 Shift the elements of the vector to the left by a specified number of bits, saturating the result.
template<int n>
ace argon_type ShiftLeftInsert (argon_type b) const
 Shift the elements of the vector to the left by a specified number of bits, and then OR the result with another vector masked to the number of shift bits.
template<int n>
ace argon_type ShiftRight () const
 Shift the elements of the vector to the right by a specified number of bits.
template<int n>
ace argon_type ShiftRightRound () const
 Shift the elements of the vector to the right by a specified number of bits, rounding the result.
template<int n>
ace argon_type ShiftRightAccumulate (argon_type b) const
 Shift the elements of the b vector to the right by a specified number of bits, and then add the result to this vector.
template<int n>
ace argon_type ShiftRightAccumulateRound (argon_type b) const
 Shift the elements of the b vector to the right by a specified number of bits, and then add the result to this vector.
template<int n>
ace argon_type ShiftRightInsert (argon_type b) const
 Shift the elements of the vector to the right by a specified number of bits, ORing the result with the vector masked to the number of shift bits.
template<size_t lane>
ace argon_type LoadToLane (const scalar_type *ptr)
 Load a lane from a pointer.
ace void StoreTo (scalar_type *ptr) const
 Store the vector to a pointer.
ace void StoreTo (scalar_type *ptr, argon_bool_type active) const
 Store the active lanes of the vector to a pointer; memory for inactive lanes is not written.
ace void StoreScatterOffsetBytes (scalar_type *base, offset_type offsets) const
 Scatter the lanes to base plus a byte offset per lane.
ace void StoreScatterOffsetBytes (scalar_type *base, offset_type offsets, argon_bool_type active) const
 Scatter the active lanes to base plus a byte offset per lane; inactive lanes are not written.
ace void StoreScatterOffsetIndex (scalar_type *base, offset_type offsets) const
 Scatter the lanes to base[offsets[i]].
ace void StoreScatterOffsetIndex (scalar_type *base, offset_type offsets, argon_bool_type active) const
 Scatter the active lanes to base[offsets[i]]; inactive lanes are not written.
template<int LaneIndex>
ace void StoreLaneTo (scalar_type *ptr)
 Store a lane of the vector to a pointer.
ace argon_type PairwiseAdd (argon_type b) const
 Pairwise ops.
ace argon_type PairwiseMax (argon_type b) const
 Select the maximum of each pair of lanes in the two vectors.
ace argon_type PairwiseMin (argon_type b) const
 Select the maximum of each pair of lanes in the two vectors.
ace argon_type BitwiseNot () const
 Bitwise ops.
ace argon_type BitwiseAnd (argon_type b) const
 Bitwise AND of the vector with another vector.
ace argon_type BitwiseOr (argon_type b) const
 Bitwise OR of the vector with another vector.
ace argon_type BitwiseXor (argon_type b) const
 Bitwise XOR of the vector with another vector.
ace argon_type BitwiseOrNot (argon_type b) const
 Bitwise OR of the vector with the NOT of another vector.
ace argon_type BitwiseAndNot (argon_type b) const
 Bitwise AND of the vector with the NOT of another vector.
ace argon_type BitwiseClear (argon_type b) const
 Bitwise AND of the vector with the NOT of another vector.
template<typename ArgType>
ace ArgType BitwiseSelect (ArgType true_value, ArgType false_value) const
 Bitwise select between two vectors, using the current vector as a mask.
template<typename ArgType>
ace ArgType Select (ArgType true_value, ArgType false_value) const
 Bitwise select between two vectors, using the current vector as a mask.
ace argon_bool_type CompareTestNonzero (argon_type b) const
 Compare the lanes of (a & b) with zero, returning a predicate active where they share a set bit.
ace argon_bool_type TestNonzero () const
 Return a predicate active where the lane is nonzero.
ace argon_type MultiplyAdd (argon_type b, argon_type c, argon_bool_type active) const
 MultiplyAdd under a predicate: lanes outside active keep this vector's value, the accumulator (as ACLE's vfmaq_m).
ace argon_type MultiplyAdd (argon_type b, scalar_type c, argon_bool_type active) const
 MultiplyAdd under a predicate: lanes outside active keep this vector's value, the accumulator (as ACLE's vfmaq_m).
ace argon_type MultiplySubtract (argon_type b, argon_type c, argon_bool_type active) const
 MultiplySubtract under a predicate: lanes outside active keep this vector's value (as ACLE's vfmsq_m).
ace argon_bool_type Equal (argon_type b, argon_bool_type active) const
 Compare only the lanes of active: a predicate active where active holds and a == b.
ace argon_bool_type GreaterThan (argon_type b, argon_bool_type active) const
 Compare only the lanes of active: a predicate active where active holds and a > b.
ace argon_bool_type GreaterThanOrEqual (argon_type b, argon_bool_type active) const
 Compare only the lanes of active: a predicate active where active holds and a >= b.
ace argon_bool_type LessThan (argon_type b, argon_bool_type active) const
 Compare only the lanes of active: a predicate active where active holds and a < b.
ace argon_bool_type LessThanOrEqual (argon_type b, argon_bool_type active) const
 Compare only the lanes of active: a predicate active where active holds and a <= b.
ace helpers::ArgonFor_t< simd::make_signed_t< Bool_t< VectorType > > > CountLeadingSignBits () const
 Count the number of consecutive bits following the sign bit that are set to the same value as the sign bit.
ace argon_type CountLeadingZeroBits () const
 Count the number of consecutive top bits that are set to zero.
ace argon_type CountActiveBits () const
 Count the number of bits that are set to one in the vector.
ace argon_type Popcount () const
 Count the number of bits that are set to one in the vector.
template<int n>
ace argon_type Extract (argon_type b) const
 Extract n elements from the lower end of the operand, and the remaining elements from the top end of this vector, combining them into the result vector.
ace argon_type Reverse64bit () const
ace argon_type Reverse32bit () const
ace argon_type Reverse16bit () const
ace std::array< argon_type, 2 > ZipWith (argon_type b) const
 Zip two vectors together, returning two vectors of pairs.
std::array< argon_type, 2 > UnzipWith (argon_type b)
 Unzip two vectors, returning two vectors of pairs.
std::array< argon_type, 2 > TransposeWith (argon_type b) const
 Perform a 2x2 matrix transpose on two vectors, returning two vectors of pairs.
template<typename FuncType>
ace argon_type map (FuncType body) const
template<typename FuncType>
ace argon_type map_with_index (FuncType body) const
template<typename FuncType>
ace argon_type map2 (argon_type other, FuncType body) const
template<typename FuncType>
ace argon_type each_lane (FuncType body)
template<typename FuncType>
ace argon_type each_lane_with_index (FuncType body)
template<typename FuncType>
ace void if_lane (FuncType true_branch)
template<typename FuncType>
ace void if_else_lane (FuncType true_branch, FuncType false_branch)
template<typename FuncType>
ace void if_lane_with_index (FuncType true_branch)
template<typename FuncType1, typename FuncType2>
ace void if_else_lane_with_index (FuncType1 true_branch, FuncType2 false_branch)
ace bool any () const
 Whether any lane is nonzero.
ace bool all () const
 Whether every lane is nonzero.
template<std::size_t Index>
std::tuple_element_t< Index, argon_type > get ()

Static Public Member Functions

static ace argon_type LoadScalar (const scalar_type *ptr)
 Constructs a Vector from a scalar pointer.
static ace argon_type FromScalar (scalar_type scalar)
 Constructs a Vector from a scalar value.
template<simd::is_vector_type IntrinsicType>
static ace argon_type FromLane (argon::Lane< IntrinsicType > lane)
 Constructs a Vector from a Lane object.
template<size_t LaneIndex>
static ace argon_type FromLane (argon::ConstLane< LaneIndex, VectorType > lane)
 Constructs a Vector from a ConstLane object.
static ace argon_type Iota (scalar_type start)
 Constructs a Vector from an incrementing sequence.
template<typename FuncType>
static ace argon_type Generate (FuncType body)
 Constructs a Vector from a function that generates values.
template<typename FuncType>
static ace argon_type GenerateWithIndex (FuncType body)
 Constructs a Vector from a function that generates values with an index.
static ace argon_type Load (const scalar_type *ptr)
 Load a vector from a pointer.
static ace argon_type LoadCopy (const scalar_type *ptr)
 Load a vector from a pointer, duplicating the value across all lanes.
static ace argon_type Load (const scalar_type *ptr, argon_bool_type active)
 Load the active lanes of a vector from a pointer; inactive lanes are zero and their memory is not read.
static ace argon_type LoadGatherOffsetBytes (const scalar_type *base, offset_type offsets)
 Gather a vector from base plus a byte offset per lane.
static ace argon_type LoadGatherOffsetBytes (const scalar_type *base, offset_type offsets, argon_bool_type active)
 Gather the active lanes from base plus a byte offset per lane; inactive lanes are zero and not read.
static ace argon_type LoadGatherOffsetIndex (const scalar_type *base, offset_type offsets)
 Gather a vector from base[offsets[i]].
static ace argon_type LoadGatherOffsetIndex (const scalar_type *base, offset_type offsets, argon_bool_type active)
 Gather the active lanes from base[offsets[i]]; inactive lanes are zero and not read.
template<size_t stride>
static ace std::array< argon_type, stride > LoadInterleaved (const scalar_type *ptr)
 Load multiple vectors from a pointer, de-interleaving.
template<size_t stride>
static ace std::array< argon_type, stride > LoadCopyInterleaved (const scalar_type *ptr)
 Load multiple vectors from a pointer, duplicating the value across all lanes.
template<size_t LaneIndex, size_t Stride>
static ace std::array< argon_type, Stride > LoadToLaneInterleaved (simd::MultiVector_t< VectorType, Stride > multi, const scalar_type *ptr)
 Load a value from a pointer into a vector at the lane index lane, de-interleaving.
template<size_t lane, size_t stride>
static ace std::array< argon_type, stride > LoadToLaneInterleaved (std::array< argon_type, stride > multi, const scalar_type *ptr)
 Load a value from a pointer into a vector at the lane index lane, de-interleaving.
template<size_t stride>
static ace std::array< argon_type, stride > LoadGatherOffsetIndexInterleaved (const scalar_type *base_ptr, helpers::ArgonFor_t< simd::make_unsigned_t< Bool_t< VectorType > > > offset_vector)
 Perform a Load-Gather of interleaved elements.
template<size_t n>
static ace std::array< argon_type, n > LoadMulti (const scalar_type *ptr)
 Load n vectors from a single contiguous set of memory.
static ace int size ()
 Get the number of elements.

Static Public Attributes

static constexpr bool extension_arithmetic
 Whether arithmetic may use the compiler's generic vector extensions (see ARGON_GCC_AARCH32_FLOAT).
static constexpr bool mve_platform = false
 Whether this is the MVE (Helium) platform.
static constexpr bool mve_float = mve_platform && lane_floating_point<scalar_type>
 Float lanes on Helium, which go through MVE intrinsics where GCC mishandles the vector extensions.
static constexpr bool native_maxnm
 Whether MaxNumber/MinNumber are single instructions (vmaxnm/vminnm) for these lanes: every float lane on Helium and Armv8 NEON, half lanes on NEON only with FP16 vector arithmetic.
static constexpr bool fixup_float_compare = ARGON_GCC_AARCH32_FLOAT && std::is_same_v<scalar_type, float>
 Whether float comparisons need the inline vcgt/vcge (see ARGON_GCC_AARCH32_FLOAT).
static constexpr size_t lanes = (simd::is_quadword_v<VectorType> ? 16 : 8) / sizeof(scalar_type)
 The number of lanes in the SIMD vector.

Protected Member Functions

template<bool byte_offsets, typename... PredicateType>
ace void Scatter (scalar_type *base, offset_type offsets, PredicateType... active) const
 Scatter by byte or element offsets, optionally only the lanes of one predicate.

Static Protected Member Functions

template<bool byte_offsets, typename PointerType, typename OffsetType>
static ace PointerType * LaneAddress (PointerType *base, OffsetType offset)
 The address of one gathered / scattered lane: base plus a byte offset, or base indexed by an element offset.
template<bool byte_offsets, typename... PredicateType>
static ace argon_type Gather (const scalar_type *base, offset_type offsets, PredicateType... active)
 Gather by byte or element offsets, optionally only the lanes of one predicate (inactive lanes are zero).
template<typename ArgType>
static ace decltype(auto) LaneValue (ArgType &&arg)
 Convert an arithmetic constructor argument to the lane type, passing anything else through.
template<std::size_t... Ints>
static ace argon_type IotaHelper (scalar_type start, std::index_sequence< Ints... >)

Protected Attributes

VectorType vec_

Detailed Description

template<typename VectorType>
class argon::Vector< VectorType >

Represents a SIMD vector with various operations.

Template Parameters
VectorTypeThe type of the SIMD vector. (e.g. int32x4_t, float32x4_t)

This class provides a wrapper around SIMD vector types, allowing for object-oriented operations on the vector.

Member Typedef Documentation

◆ mask_type

template<typename VectorType>
using argon::Vector< VectorType >::mask_type
Initial value:
Bool< T >::type Bool_t
Helper alias to get the boolean type of a SIMD operation.
Definition bool.hpp:49

The mask vector type (all ones / all zeros per lane), see Predicate::ToMask.

◆ offset_type

template<typename VectorType>
using argon::Vector< VectorType >::offset_type
Initial value:
typename ArgonFor< std::remove_cv_t< T > >::type ArgonFor_t
Helper alias to get the Argon type for a given vector type.
Definition argon_for.hpp:46

Per-lane gather/scatter offsets.

Constructor & Destructor Documentation

◆ Vector() [1/5]

template<typename VectorType>
ace argon::Vector< VectorType >::Vector ( VectorType vector)
inline

Constructs a Vector from a SIMD vector type.

Parameters
vectorThe SIMD vector to construct from.

◆ Vector() [2/5]

template<typename VectorType>
ace argon::Vector< VectorType >::Vector ( scalar_type scalar)
inline

Constructs a Vector from a scalar value.

Parameters
scalarThe scalar value to construct from.

This constructor duplicates the scalar value across all lanes of the SIMD vector. Where the vector type is the scalar type (GCC's AArch32 int64x1_t and uint64x1_t are plain 64-bit integers), Vector(VectorType) is the same constructor, and this one is left out.

◆ Vector() [3/5]

template<typename VectorType>
ace argon::Vector< VectorType >::Vector ( argon::Lane< VectorType > lane)
inline

Constructs a Vector from a Lane object.

Parameters
laneThe Lane object to construct from.

This constructor duplicates the lane value across all lanes of the SIMD vector.

◆ Vector() [4/5]

template<typename VectorType>
template<size_t LaneIndex>
ace argon::Vector< VectorType >::Vector ( argon::ConstLane< LaneIndex, VectorType > lane)
inline

Constructs a Vector from a ConstLane object.

Parameters
laneThe ConstLane object to construct from.

This constructor duplicates the lane value across all lanes of the SIMD vector.

Parameters
laneThe ConstLane object to construct from.

◆ Vector() [5/5]

template<typename VectorType>
template<typename... ArgTypes>
ace argon::Vector< VectorType >::Vector ( ArgTypes... args)
inline

Constructs a Vector from one value per lane.

Arithmetic arguments are converted to the lane type, so Argon<uint16_t>{1, 2, ...} does not narrow (an error in braced initialisation under Clang).

Member Function Documentation

◆ Absolute()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::Absolute ( ) const
inline

Get the absolute value of the vector.

Integer lanes wrap at the minimum (the most negative value stays itself); the saturating form is simd::absolute_saturate. On hardware -0.0f becomes +0.0f; SIMDe's doubleword (ArgonHalf) path keeps the sign bit.

◆ AddHalve()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::AddHalve ( argon_type b) const
inline

Adds two vectors, halving the result.

Equivalent to (a + b) / 2.

◆ AddHalveRound()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::AddHalveRound ( argon_type b) const
inline

Adds two vectors, halving and rounding the result.

Equivalent to round((a + b) / 2).

◆ AddSaturate()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::AddSaturate ( argon_type b) const
inline

Adds two vectors, saturating the result.

Equivalent to a + b, but saturates to the maximum value if the result exceeds the maximum representable value.

◆ BitwiseAndNot()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::BitwiseAndNot ( argon_type b) const
inline

Bitwise AND of the vector with the NOT of another vector.

Equivalent to a & ~b.

◆ BitwiseClear()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::BitwiseClear ( argon_type b) const
inline

Bitwise AND of the vector with the NOT of another vector.

Equivalent to a & ~b.

◆ BitwiseNot()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::BitwiseNot ( ) const
inline

Bitwise ops.

Bitwise NOT of the vector

◆ BitwiseOrNot()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::BitwiseOrNot ( argon_type b) const
inline

Bitwise OR of the vector with the NOT of another vector.

Equivalent to a | ~b.

◆ BitwiseSelect()

template<typename VectorType>
template<typename ArgType>
ace ArgType argon::Vector< VectorType >::BitwiseSelect ( ArgType true_value,
ArgType false_value ) const
inline

Bitwise select between two vectors, using the current vector as a mask.

Equivalent to (mask & b) | (~mask & c).

Returns
A vector of the operands' type (not the mask's).

◆ CompareTestNonzero()

template<typename VectorType>
ace argon_bool_type argon::Vector< VectorType >::CompareTestNonzero ( argon_type b) const
inline

Compare the lanes of (a & b) with zero, returning a predicate active where they share a set bit.

NEON: vtst.

◆ CountActiveBits()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::CountActiveBits ( ) const
inline

Count the number of bits that are set to one in the vector.

Equivalent to std::popcount(a).

◆ CountLeadingSignBits()

template<typename VectorType>
ace helpers::ArgonFor_t< simd::make_signed_t< Bool_t< VectorType > > > argon::Vector< VectorType >::CountLeadingSignBits ( ) const
inline

Count the number of consecutive bits following the sign bit that are set to the same value as the sign bit.

Equivalent to std::countl_one(a).

◆ CountLeadingZeroBits()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::CountLeadingZeroBits ( ) const
inline

Count the number of consecutive top bits that are set to zero.

Equivalent to std::countl_zero(a)

◆ Equal()

template<typename VectorType>
ace argon_bool_type argon::Vector< VectorType >::Equal ( argon_type b,
argon_bool_type active ) const
inline

Compare only the lanes of active: a predicate active where active holds and a == b.

MVE: one predicated compare (vcmpq_m), rather than a compare and a predicate AND through core registers.

◆ Extract()

template<typename VectorType>
template<int n>
ace argon_type argon::Vector< VectorType >::Extract ( argon_type b) const
inline

Extract n elements from the lower end of the operand, and the remaining elements from the top end of this vector, combining them into the result vector.

For example: {a0, a1, a2, a3} and {b0, b1, b2, b3} with n = 1 will result in {b0, a1, a2, a3}

◆ FromLane() [1/2]

template<typename VectorType>
template<size_t LaneIndex>
ace argon_type argon::Vector< VectorType >::FromLane ( argon::ConstLane< LaneIndex, VectorType > lane)
inlinestatic

Constructs a Vector from a ConstLane object.

Parameters
laneThe ConstLane object to construct from.

This constructor duplicates the lane value across all lanes of the SIMD vector.

Returns
The constructed SIMD vector.

◆ FromLane() [2/2]

template<typename VectorType>
template<simd::is_vector_type IntrinsicType>
ace argon_type argon::Vector< VectorType >::FromLane ( argon::Lane< IntrinsicType > lane)
inlinestatic

Constructs a Vector from a Lane object.

Parameters
laneThe Lane object to construct from.

This constructor duplicates the lane value across all lanes of the SIMD vector.

Returns
The constructed SIMD vector.

◆ FromScalar()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::FromScalar ( scalar_type scalar)
inlinestatic

Constructs a Vector from a scalar value.

Parameters
scalarThe scalar value to construct from.

This constructor duplicates the scalar value across all lanes of the SIMD vector.

Returns
The constructed SIMD vector.

◆ Generate()

template<typename VectorType>
template<typename FuncType>
ace argon_type argon::Vector< VectorType >::Generate ( FuncType body)
inlinestatic

Constructs a Vector from a function that generates values.

Parameters
bodyThe function that generates the values.

This constructor creates a SIMD vector with lanes containing values generated by the function.

Returns
The constructed SIMD vector.

◆ GenerateWithIndex()

template<typename VectorType>
template<typename FuncType>
ace argon_type argon::Vector< VectorType >::GenerateWithIndex ( FuncType body)
inlinestatic

Constructs a Vector from a function that generates values with an index.

Parameters
bodyThe function that generates the values.

This constructor creates a SIMD vector with lanes containing values generated by the function using the index.

Returns
The constructed SIMD vector.

◆ GetLane() [1/3]

template<typename VectorType>
template<size_t LaneIndex>
ace ConstLane< LaneIndex, const VectorType > argon::Vector< VectorType >::GetLane ( ) const
inline

Get a single lane of the vector by index.

Template Parameters
LaneIndexThe index of the lane to get.
Returns
The value of the specified lane in the SIMD vector.

◆ GetLane() [2/3]

template<typename VectorType>
ace Lane< const VectorType > argon::Vector< VectorType >::GetLane ( const int i) const
inline

Get a single lane of the vector by index.

Parameters
iThe index of the lane to get.
Returns
The value of the specified lane in the SIMD vector.

◆ GetLane() [3/3]

template<typename VectorType>
ace Lane< const VectorType > argon::Vector< VectorType >::GetLane ( const size_t i) const
inline

Get a single lane of the vector by index.

Parameters
iThe index of the lane to get.
Returns
The value of the specified lane in the SIMD vector.
Note
If you know the index of the lane at compile time, you should use GetLane<LaneIndex>() instead.

◆ GreaterThan()

template<typename VectorType>
ace argon_bool_type argon::Vector< VectorType >::GreaterThan ( argon_type b,
argon_bool_type active ) const
inline

Compare only the lanes of active: a predicate active where active holds and a > b.

MVE: one predicated compare (vcmpq_m), rather than a compare and a predicate AND through core registers.

◆ GreaterThanOrEqual()

template<typename VectorType>
ace argon_bool_type argon::Vector< VectorType >::GreaterThanOrEqual ( argon_type b,
argon_bool_type active ) const
inline

Compare only the lanes of active: a predicate active where active holds and a >= b.

MVE: one predicated compare (vcmpq_m), rather than a compare and a predicate AND through core registers.

◆ Iota()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::Iota ( scalar_type start)
inlinestatic

Constructs a Vector from an incrementing sequence.

Parameters
startThe starting value of the sequence.
stepThe step size of the sequence.
Returns
The constructed SIMD vector.

This constructor creates a SIMD vector with lanes containing values from start to start + (lanes - 1) * step.

◆ LessThan()

template<typename VectorType>
ace argon_bool_type argon::Vector< VectorType >::LessThan ( argon_type b,
argon_bool_type active ) const
inline

Compare only the lanes of active: a predicate active where active holds and a < b.

MVE: one predicated compare (vcmpq_m), rather than a compare and a predicate AND through core registers.

◆ LessThanOrEqual()

template<typename VectorType>
ace argon_bool_type argon::Vector< VectorType >::LessThanOrEqual ( argon_type b,
argon_bool_type active ) const
inline

Compare only the lanes of active: a predicate active where active holds and a <= b.

MVE: one predicated compare (vcmpq_m), rather than a compare and a predicate AND through core registers.

◆ Load()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::Load ( const scalar_type * ptr,
argon_bool_type active )
inlinestatic

Load the active lanes of a vector from a pointer; inactive lanes are zero and their memory is not read.

MVE: vld1q_z, so a tail past the end of a buffer cannot fault. NEON: loads the active lanes one by one.

Parameters
ptrThe address of lane 0.
activeThe lanes to load.

◆ LoadCopyInterleaved()

template<typename VectorType>
template<size_t stride>
ace std::array< argon_type, stride > argon::Vector< VectorType >::LoadCopyInterleaved ( const scalar_type * ptr)
inlinestatic

Load multiple vectors from a pointer, duplicating the value across all lanes.

Template Parameters
strideThe interleave stride
Parameters
ptrThe pointer to load from
Returns
The new multi-vector Example: {r0, g0, b0, r1, g1, b1} will become {{r0, r0}, {g0, g0}, {b0, b0}}

◆ LoadGatherOffsetBytes() [1/2]

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::LoadGatherOffsetBytes ( const scalar_type * base,
offset_type offsets )
inlinestatic

Gather a vector from base plus a byte offset per lane.

Note
On NEON this loads lane by lane.
Parameters
baseThe address the offsets are relative to.
offsetsThe byte offset of each lane.
Returns
A new vector constructed from the addressed elements.

◆ LoadGatherOffsetBytes() [2/2]

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::LoadGatherOffsetBytes ( const scalar_type * base,
offset_type offsets,
argon_bool_type active )
inlinestatic

Gather the active lanes from base plus a byte offset per lane; inactive lanes are zero and not read.

Parameters
baseThe address the offsets are relative to.
offsetsThe byte offset of each lane.
activeThe lanes to load.

◆ LoadGatherOffsetIndex() [1/2]

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::LoadGatherOffsetIndex ( const scalar_type * base,
offset_type offsets )
inlinestatic

Gather a vector from base[offsets[i]].

Note
On NEON this loads lane by lane. On MVE the index is scaled by the lane size in hardware.
Parameters
baseThe array to index.
offsetsThe element index of each lane.
Returns
A new vector constructed from the indexed elements.

◆ LoadGatherOffsetIndex() [2/2]

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::LoadGatherOffsetIndex ( const scalar_type * base,
offset_type offsets,
argon_bool_type active )
inlinestatic

Gather the active lanes from base[offsets[i]]; inactive lanes are zero and not read.

Parameters
baseThe array to index.
offsetsThe element index of each lane.
activeThe lanes to load.

◆ LoadGatherOffsetIndexInterleaved()

template<typename VectorType>
template<size_t stride>
ace std::array< argon_type, stride > argon::Vector< VectorType >::LoadGatherOffsetIndexInterleaved ( const scalar_type * base_ptr,
helpers::ArgonFor_t< simd::make_unsigned_t< Bool_t< VectorType > > > offset_vector )
inlinestatic

Perform a Load-Gather of interleaved elements.

Note
On NEON this incurs a writeback + load penalty
Template Parameters
stridethe distance between similar elements
Parameters
base_ptrthe address to use as a base for the gather operation
offset_vectora vector of offset values that are added to base_ptr to get the address to load
Returns
std::array<argon_type, stride> An array of vectors from the resulting interleaved loads

◆ LoadInterleaved()

template<typename VectorType>
template<size_t stride>
ace std::array< argon_type, stride > argon::Vector< VectorType >::LoadInterleaved ( const scalar_type * ptr)
inlinestatic

Load multiple vectors from a pointer, de-interleaving.

Template Parameters
strideThe interleave stride
Parameters
ptrThe pointer to load from
Returns
The new multi-vector This is useful for multi-channel audio or RGB image data. For example: {r0, g0, b0, r1, g1, b1} will become {{r0, r1}, {g0, g1}, {b0, b1}}

◆ LoadMulti()

template<typename VectorType>
template<size_t n>
ace std::array< argon_type, n > argon::Vector< VectorType >::LoadMulti ( const scalar_type * ptr)
inlinestatic

Load n vectors from a single contiguous set of memory.

Template Parameters
nThe number of vectors to load
Parameters
ptrThe pointer to the location in memory to load from
Returns
std::array An array of NEON vectors.

◆ LoadScalar()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::LoadScalar ( const scalar_type * ptr)
inlinestatic

Constructs a Vector from a scalar pointer.

Parameters
ptrThe pointer to the scalar value to construct from.

This constructor loads the scalar value from the pointer and duplicates it across all lanes of the SIMD vector.

Returns
The constructed SIMD vector.

◆ LoadToLane()

template<typename VectorType>
template<size_t lane>
ace argon_type argon::Vector< VectorType >::LoadToLane ( const scalar_type * ptr)
inline

Load a lane from a pointer.

Parameters
ptrThe pointer to load from
Returns
The new vector

◆ LoadToLaneInterleaved() [1/2]

template<typename VectorType>
template<size_t LaneIndex, size_t Stride>
ace std::array< argon_type, Stride > argon::Vector< VectorType >::LoadToLaneInterleaved ( simd::MultiVector_t< VectorType, Stride > multi,
const scalar_type * ptr )
inlinestatic

Load a value from a pointer into a vector at the lane index lane, de-interleaving.

Template Parameters
laneThe lane to load
strideThe interleave stride
Parameters
multiThe multi-vector to load into
ptrThe pointer to load from
Returns
The new multi-vector

◆ LoadToLaneInterleaved() [2/2]

template<typename VectorType>
template<size_t lane, size_t stride>
ace std::array< argon_type, stride > argon::Vector< VectorType >::LoadToLaneInterleaved ( std::array< argon_type, stride > multi,
const scalar_type * ptr )
inlinestatic

Load a value from a pointer into a vector at the lane index lane, de-interleaving.

Template Parameters
laneThe lane to load
strideThe interleave stride
Parameters
multiThe multi-vector to load into
ptrThe pointer to load from
Returns
The new multi-vector

◆ Max()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::Max ( argon_type b) const
inline

Compare the lanes of two vectors, copying the larger of each lane to the result.

Equivalent to a > b ? a : b: a NaN in either lane gives b. One instruction on NEON and x86 (maxps); on Helium a compare and a select. For floats that are never NaN, MaxNumber gives the same results and is one instruction (vmaxnm) where native_maxnm is true, so a clamp can pick the cheaper per platform:

if constexpr (Argon<float>::native_maxnm) x = x.MaxNumber(lo).MinNumber(hi);
else x = x.Max(lo).Min(hi);
static constexpr bool native_maxnm
Definition vector.hpp:74

◆ MaxNumber()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::MaxNumber ( argon_type b) const
inline

The larger of each lane by IEEE 754 maxNum, as Arm's vmaxnm: a quiet NaN in one operand gives the other (NaN only where both are), and +0 is larger than -0.

Max is a > b ? a : b, which passes a NaN in b through.

One instruction (vmaxnm) where native_maxnm is true: Helium and Armv8 NEON. Elsewhere (Armv7 NEON, x86 via SIMDe) it is emulated with several compares and selects, so use it there only when NaNs must be ignored. For floats that are never NaN, Max and MaxNumber agree; choose the cheaper per platform:

if constexpr (Argon<float>::native_maxnm) x = x.MaxNumber(lo).MinNumber(hi);
else x = x.Max(lo).Min(hi);

◆ Min()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::Min ( argon_type b) const
inline

Compare the lanes of two vectors, copying the smaller of each lane to the result.

Equivalent to a < b ? a : b: a NaN in either lane gives b. One instruction on NEON and x86 (minps); on Helium a compare and a select. For floats that are never NaN, MinNumber gives the same results and is one instruction (vminnm) where native_maxnm is true; see Max for the clamp idiom.

◆ MinNumber()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::MinNumber ( argon_type b) const
inline

The smaller of each lane by IEEE 754 minNum, as Arm's vminnm: a quiet NaN in one operand gives the other (NaN only where both are), and -0 is smaller than +0.

Min is a < b ? a : b, which passes a NaN in b through.

One instruction (vminnm) where native_maxnm is true, emulated elsewhere; see MaxNumber for when to use it and the clamp idiom.

◆ Modulo() [1/2]

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::Modulo ( argon_type b) const
inline

Get the modulo of two vectors.

Equivalent to a % b.

◆ Modulo() [2/2]

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::Modulo ( scalar_type b) const
inline

Get the modulo of a vector and a scalar value.

Equivalent to a % b.

◆ MultiplyAdd() [1/9]

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::MultiplyAdd ( argon_type b,
argon_type c ) const
inline

Multiply two vectors and add a third vector.

Equivalent to a + (b * c). Fused (one rounding) for floats on Helium, whose only float multiply-accumulate is vfma; GCC never contracts the vector-extension form into it.

◆ MultiplyAdd() [2/9]

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::MultiplyAdd ( argon_type b,
argon_type c,
argon_bool_type active ) const
inline

MultiplyAdd under a predicate: lanes outside active keep this vector's value, the accumulator (as ACLE's vfmaq_m).

On MVE, floats are one predicated vfma, which lets GCC tail-predicate a vectorize::for_each accumulation; elsewhere it is MultiplyAdd and a Select.

◆ MultiplyAdd() [3/9]

template<typename VectorType>
template<size_t LaneIndex>
ace argon_type argon::Vector< VectorType >::MultiplyAdd ( argon_type b,
const_lane_type< LaneIndex > c ) const
inline

Multiply a vector by a lane value and add a third vector.

Equivalent to a + (b * c).

◆ MultiplyAdd() [4/9]

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::MultiplyAdd ( argon_type b,
lane_type c ) const
inline

Multiply a vector by a lane value and add a third vector.

Equivalent to a + (b * c).

◆ MultiplyAdd() [5/9]

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::MultiplyAdd ( argon_type b,
scalar_type c ) const
inline

Multiply a vector by a scalar value and add a third vector.

Equivalent to a + (b * c). Fused for floats on Helium (vfma).

◆ MultiplyAdd() [6/9]

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::MultiplyAdd ( argon_type b,
scalar_type c,
argon_bool_type active ) const
inline

MultiplyAdd under a predicate: lanes outside active keep this vector's value, the accumulator (as ACLE's vfmaq_m).

On MVE, floats are one predicated vfma, which lets GCC tail-predicate a vectorize::for_each accumulation; elsewhere it is MultiplyAdd and a Select.

◆ MultiplyAdd() [7/9]

template<typename VectorType>
template<size_t LaneIndex>
ace argon_type argon::Vector< VectorType >::MultiplyAdd ( const_lane_type< LaneIndex > b,
argon_type c ) const
inline

Multiply a vector by a lane value and add a third vector.

Equivalent to a + (b * c).

◆ MultiplyAdd() [8/9]

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::MultiplyAdd ( lane_type b,
argon_type c ) const
inline

Multiply a vector by a lane value and add a third vector.

Equivalent to a + (b * c).

◆ MultiplyAdd() [9/9]

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::MultiplyAdd ( scalar_type b,
argon_type c ) const
inline

Multiply a vector by a scalar value and add a third vector.

Equivalent to a + (b * c).

◆ MultiplyAddFixedQMax()

template<typename VectorType>
template<typename arg_type>
ace argon_type argon::Vector< VectorType >::MultiplyAddFixedQMax ( argon_type b,
arg_type c ) const
inline

Multiply-add three fixed-point vectors, returning a fixed-point sum.

This is equivalent to a + ((b * c) >> 31)

◆ MultiplyFixedQMax() [1/3]

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::MultiplyFixedQMax ( argon_type v) const
inline

Multiply two QMax fixed-point vectors, returning a fixed-point product.

This is equivalent to ((uint64_t)a * b) >> 31

◆ MultiplyFixedQMax() [2/3]

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::MultiplyFixedQMax ( lane_type l) const
inline

Multiply a QMax fixed-point vector by a lane value, returning a fixed-point product.

This is equivalent to ((uint64_t)a * b) >> 31

◆ MultiplyFixedQMax() [3/3]

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::MultiplyFixedQMax ( scalar_type s) const
inline

Multiply a QMax fixed-point vector by a scalar value, returning a fixed-point product.

This is equivalent to ((uint64_t)a * b) >> 31

◆ MultiplyRoundAddFixedQMax()

template<typename VectorType>
template<typename arg_type>
ace argon_type argon::Vector< VectorType >::MultiplyRoundAddFixedQMax ( argon_type b,
arg_type c ) const
inline

Multiply-round-add three fixed-point vectors, returning a fixed-point sum.

This is equivalent to a + (rnd(b * c) >> 31)

◆ MultiplyRoundFixedQMax() [1/3]

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::MultiplyRoundFixedQMax ( argon_type v) const
inline

Multiply two fixed-point vectors, returning a fixed-point product.

This is equivalent to round(a * b) >> 31

◆ MultiplyRoundFixedQMax() [2/3]

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::MultiplyRoundFixedQMax ( lane_type l) const
inline

Multiply a fixed-point vector by a lane value, returning a fixed-point product.

This is equivalent to round(a * b) >> 31

◆ MultiplyRoundFixedQMax() [3/3]

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::MultiplyRoundFixedQMax ( scalar_type s) const
inline

Multiply a fixed-point vector by a scalar value, returning a fixed-point product.

This is equivalent to round(a * b) >> 31

◆ MultiplySubtract() [1/4]

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::MultiplySubtract ( argon_type b,
argon_type c ) const
inline

Multiply two vectors and subtract from a third vector.

Equivalent to a - (b * c). Fused for floats on Helium (vfms).

◆ MultiplySubtract() [2/4]

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::MultiplySubtract ( argon_type b,
lane_type c ) const
inline

Multiply a vector by a lane value and subtract from a third vector.

Equivalent to a - (b * c).

◆ MultiplySubtract() [3/4]

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::MultiplySubtract ( argon_type b,
scalar_type c ) const
inline

Multiply a vector by a scalar value and subtract from a third vector.

Equivalent to a - (b * c). Fused for floats on Helium (vfms).

◆ MultiplySubtract() [4/4]

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::MultiplySubtract ( scalar_type b,
argon_type c ) const
inline

Multiply a vector by a scalar value and subtract from a third vector.

Equivalent to a - (b * c).

◆ PairwiseAdd()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::PairwiseAdd ( argon_type b) const
inline

Pairwise ops.

Pairwise add two vectors, returning the sum of each pair of lanes.

Given a pair of vector {a0, a1, a2, a3} and {b0, b1, b2, b3}, the result is {a0 + a1, a1 + a2, b0 + b1, b1 + b2}

◆ PairwiseMax()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::PairwiseMax ( argon_type b) const
inline

Select the maximum of each pair of lanes in the two vectors.

Given a pair of vector {a0, a1, a2, a3} and {b0, b1, b2, b3}, the result is {max(a0, a1), max(a2, b2), max(b0, b1), max(b2, b3)}

◆ PairwiseMin()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::PairwiseMin ( argon_type b) const
inline

Select the maximum of each pair of lanes in the two vectors.

Given a pair of vector {a0, a1, a2, a3} and {b0, b1, b2, b3}, the result is {max(a0, a1), max(a2, b2), max(b0, b1), max(b2, b3)}

◆ Popcount()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::Popcount ( ) const
inline

Count the number of bits that are set to one in the vector.

Equivalent to std::popcount(a).

◆ ReciprocalEstimate()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::ReciprocalEstimate ( ) const
inline

1 / value, using an estimate for speed

Note
This is not a precise reciprocal, but it is fast and useful for many applications
The unsigned fixed-point form is NEON-only.

◆ ReciprocalEstimateRefine()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::ReciprocalEstimateRefine ( int n_iters = 1) const
inline

Compute a refined reciprocal estimate using Newton-Raphson iterations.

Parameters
n_itersNumber of refinement iterations (1 gives ~23-bit precision for float32).

Each iteration approximately doubles the number of correct mantissa bits.

◆ ReciprocalSqrtEstimate()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::ReciprocalSqrtEstimate ( ) const
inline

1 / sqrt(value), using an estimate for speed

Note
For greater precision, follow with ReciprocalSqrtStep iterations (Newton-Raphson).
The unsigned fixed-point form is NEON-only.

◆ ReciprocalSqrtEstimateRefine()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::ReciprocalSqrtEstimateRefine ( int n_iters = 1) const
inline

Compute a refined reciprocal-sqrt estimate using Newton-Raphson iterations.

Parameters
n_itersNumber of refinement iterations (1 gives ~23-bit precision for float32).

Each iteration approximately doubles the number of correct mantissa bits.

◆ ReciprocalSqrtStep()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::ReciprocalSqrtStep ( argon_type b) const
inline

Newton-Raphson step for reciprocal-sqrt refinement: (3 - a * b) / 2.

Use after ReciprocalSqrtEstimate to increase precision.

Note
Only defined for floating-point types.

◆ ReciprocalStep()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::ReciprocalStep ( argon_type b) const
inline

Newton-Raphson step for reciprocal refinement: (2 - a * b) / 2.

Feeds into the standard NR iteration: est = est * ReciprocalStep(value * est)

Note
Only defined for floating-point types.

◆ Select()

template<typename VectorType>
template<typename ArgType>
ace ArgType argon::Vector< VectorType >::Select ( ArgType true_value,
ArgType false_value ) const
inline

Bitwise select between two vectors, using the current vector as a mask.

Equivalent to (mask & b) | (~mask & c).

Returns
A vector of the operands' type (not the mask's).

◆ ShiftLeft() [1/3]

template<typename VectorType>
template<int n>
ace argon_type argon::Vector< VectorType >::ShiftLeft ( ) const
inline

Shift the elements of the vector to the left by a specified number of bits.

Equivalent to a << b.

◆ ShiftLeft() [2/3]

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::ShiftLeft ( helpers::ArgonFor_t< simd::make_signed_t< Bool_t< VectorType > > > b) const
inline

Shift the elemnets of the vector to the left by a specified number of bits.

Equivalent to a << b.

◆ ShiftLeft() [3/3]

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::ShiftLeft ( std::make_signed_t< simd::Scalar_t< Bool_t< VectorType > > > n) const
inline

Shift the elements of the vector to the left by a specified number of bits.

Equivalent to a << b.

◆ ShiftLeftInsert()

template<typename VectorType>
template<int n>
ace argon_type argon::Vector< VectorType >::ShiftLeftInsert ( argon_type b) const
inline

Shift the elements of the vector to the left by a specified number of bits, and then OR the result with another vector masked to the number of shift bits.

Equivalent to (a << b) | (c & ((1 << b) - 1)).

See also
https://developer.arm.com/documentation/ddi0596/2021-03/SIMD-FP-Instructions/SLI&ndash;Shift-Left-and-Insert&ndash;immediate&ndash;

◆ ShiftRight()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::ShiftRight ( const int i) const
inline

Shift the elements of the vector to the right by a specified number of bits.

Arithmetic for signed lanes, logical for unsigned ones, as a >> i. Without the compiler's vector extensions (MSVC) it is vshl by -i: NEON's shift-by-immediate needs a constant.

◆ ShiftRightAccumulate()

template<typename VectorType>
template<int n>
ace argon_type argon::Vector< VectorType >::ShiftRightAccumulate ( argon_type b) const
inline

Shift the elements of the b vector to the right by a specified number of bits, and then add the result to this vector.

Equivalent to a + (b >> n).

◆ ShiftRightAccumulateRound()

template<typename VectorType>
template<int n>
ace argon_type argon::Vector< VectorType >::ShiftRightAccumulateRound ( argon_type b) const
inline

Shift the elements of the b vector to the right by a specified number of bits, and then add the result to this vector.

Equivalent to a + (b >> n).

◆ ShiftRightInsert()

template<typename VectorType>
template<int n>
ace argon_type argon::Vector< VectorType >::ShiftRightInsert ( argon_type b) const
inline

Shift the elements of the vector to the right by a specified number of bits, ORing the result with the vector masked to the number of shift bits.

Equivalent to (a >> b) | (c & ~((1 << b) - 1)).

◆ StoreLaneTo()

template<typename VectorType>
template<int LaneIndex>
ace void argon::Vector< VectorType >::StoreLaneTo ( scalar_type * ptr)
inline

Store a lane of the vector to a pointer.

Parameters
ptrThe pointer to store to
Template Parameters
laneThe lane to store

◆ StoreScatterOffsetBytes() [1/2]

template<typename VectorType>
ace void argon::Vector< VectorType >::StoreScatterOffsetBytes ( scalar_type * base,
offset_type offsets ) const
inline

Scatter the lanes to base plus a byte offset per lane.

Note
On NEON this stores lane by lane. Lanes addressing the same element are stored in lane order.
Parameters
baseThe address the offsets are relative to.
offsetsThe byte offset of each lane.

◆ StoreScatterOffsetBytes() [2/2]

template<typename VectorType>
ace void argon::Vector< VectorType >::StoreScatterOffsetBytes ( scalar_type * base,
offset_type offsets,
argon_bool_type active ) const
inline

Scatter the active lanes to base plus a byte offset per lane; inactive lanes are not written.

Parameters
baseThe address the offsets are relative to.
offsetsThe byte offset of each lane.
activeThe lanes to store.

◆ StoreScatterOffsetIndex() [1/2]

template<typename VectorType>
ace void argon::Vector< VectorType >::StoreScatterOffsetIndex ( scalar_type * base,
offset_type offsets ) const
inline

Scatter the lanes to base[offsets[i]].

Note
On NEON this stores lane by lane. On MVE the index is scaled by the lane size in hardware.
Parameters
baseThe array to index.
offsetsThe element index of each lane.

◆ StoreScatterOffsetIndex() [2/2]

template<typename VectorType>
ace void argon::Vector< VectorType >::StoreScatterOffsetIndex ( scalar_type * base,
offset_type offsets,
argon_bool_type active ) const
inline

Scatter the active lanes to base[offsets[i]]; inactive lanes are not written.

Parameters
baseThe array to index.
offsetsThe element index of each lane.
activeThe lanes to store.

◆ StoreTo() [1/2]

template<typename VectorType>
ace void argon::Vector< VectorType >::StoreTo ( scalar_type * ptr) const
inline

Store the vector to a pointer.

Parameters
ptrThe pointer to store to

◆ StoreTo() [2/2]

template<typename VectorType>
ace void argon::Vector< VectorType >::StoreTo ( scalar_type * ptr,
argon_bool_type active ) const
inline

Store the active lanes of the vector to a pointer; memory for inactive lanes is not written.

MVE: vst1q_p. NEON: stores the active lanes one by one.

Parameters
ptrThe address of lane 0.
activeThe lanes to store.

◆ SubtractAbs()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::SubtractAbs ( argon_type b) const
inline

Subtract two vectors, taking the absolute value of the result.

Equivalent to |a - b|.

◆ SubtractAbsAdd()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::SubtractAbsAdd ( argon_type b,
argon_type c ) const
inline

Subtract two vectors, taking the absolute value of the result and adding a third vector.

Equivalent to a + |b - c|

◆ SubtractHalve()

template<typename VectorType>
ace argon_type argon::Vector< VectorType >::SubtractHalve ( argon_type b) const
inline

Subtract two vectors, halving the result.

Equivalent to (a - b) / 2.

◆ to_array()

template<typename VectorType>
ace std::array< scalar_type, lanes > argon::Vector< VectorType >::to_array ( ) const
inline

Convert the vector to an array of scalar values.

Returns
An array of scalar values representing the vector.

◆ TransposeWith()

template<typename VectorType>
std::array< argon_type, 2 > argon::Vector< VectorType >::TransposeWith ( argon_type b) const
inline

Perform a 2x2 matrix transpose on two vectors, returning two vectors of pairs.

Given a pair of vectors {{a0, a1, a2, a3}, the result is {{a0, b0, a2, b2},

◆ UnzipWith()

template<typename VectorType>
std::array< argon_type, 2 > argon::Vector< VectorType >::UnzipWith ( argon_type b)
inline

Unzip two vectors, returning two vectors of pairs.

Given a pair of vector {a0, b0, a1, b1} and {a2, b2, a3, b3}, the result is {{a0, a1, a2, a3}, {b0, b1, b2, b3}}

◆ ZipWith()

template<typename VectorType>
ace std::array< argon_type, 2 > argon::Vector< VectorType >::ZipWith ( argon_type b) const
inline

Zip two vectors together, returning two vectors of pairs.

Given a pair of vector {a0, a1, a2, a3} and {b0, b1, b2, b3}, the result is {{a0, b0, a1, b1}, {a2, b2, a3, b3}}

Member Data Documentation

◆ extension_arithmetic

template<typename VectorType>
bool argon::Vector< VectorType >::extension_arithmetic
staticconstexpr
Initial value:
=
ARGON_USE_COMPILER_EXTENSIONS && !(ARGON_GCC_AARCH32_FLOAT && std::is_floating_point_v<scalar_type>)
#define ARGON_GCC_AARCH32_FLOAT
True where GCC compiles AArch32 NEON code without -ffast-math: it then scalarises generic vector-exte...
Definition features.h:111

Whether arithmetic may use the compiler's generic vector extensions (see ARGON_GCC_AARCH32_FLOAT).

◆ native_maxnm

template<typename VectorType>
bool argon::Vector< VectorType >::native_maxnm
staticconstexpr
Initial value:
static constexpr bool mve_platform
Whether this is the MVE (Helium) platform.
Definition vector.hpp:66
A floating-point lane type: float, double, or float16_t where half-float vectors exist.
Definition lane_scalar.hpp:35
#define ARGON_NEON_FP16_VECTOR
True where NEON has half-precision vector arithmetic (FEAT_FP16), so the f16 forms of vmaxnm/vminnm e...
Definition features.h:93
#define ARGON_HAS_MAXNM
True where vmaxnm/vminnm exist (simd::max_strict / min_strict): Helium with floating point,...
Definition features.h:77
constexpr bool is_half_float_v
Whether T is the half-precision lane type, float16_t (__fp16), on a platform with half-float vectors.
Definition lane_scalar.hpp:22

Whether MaxNumber/MinNumber are single instructions (vmaxnm/vminnm) for these lanes: every float lane on Helium and Armv8 NEON, half lanes on NEON only with FP16 vector arithmetic.

False on Armv7 NEON and on x86 (SIMDe), where they are emulated with compares and selects, and Max/Min are the cheap ones (x86's maxps is exactly Max). For inputs that are never NaN, pick with if constexpr (native_maxnm); see MaxNumber.


The documentation for this class was generated from the following files: