Argon 0.1.0
Loading...
Searching...
No Matches
argon Namespace Reference

A 128-bit SIMD vector wrapping a scalar type, providing arithmetic, logical, and data-movement operations. More...

Namespaces

namespace  helpers
 Contains helper templates and concepts for type manipulation and compile-time utilities.

Classes

class  CondMonad
 The result of if_(...) and each else_if_(...): a value chosen per lane by a chain of conditions. More...
struct  Bool
 Helper template to determine the boolean type of a SIMD operation. More...
class  Vector
 Represents a SIMD vector with various operations. More...
class  ConstLane
 Represents a single lane of a SIMD vector with the lane index known at compile time. More...
class  Lane
 Represents a single lane of a SIMD vector with a runtime-determined index. More...
class  PointerVector
 One pointer per lane, gathered from and scattered to together, and advanced together: walking several buffers (channels, matrix columns, filter states) at once. More...
class  Predicate
 A per-lane boolean for vectors of type VectorType, as returned by comparisons. More...

Concepts

concept  widenable_from
 Whether lanes of integer type W can be loaded from (and stored as) the narrower integer type N, as MVE's widening loads and narrowing stores allow: 8-bit into 16- or 32-bit lanes, 16-bit into 32-bit lanes.
concept  lane_scalar
 A scalar type a vector lane can hold: an arithmetic type, or float16_t where half-float vectors exist.
concept  lane_floating_point
 A floating-point lane type: float, double, or float16_t where half-float vectors exist.
concept  arithmetic

Typedefs

template<typename VectorType, typename ScalarType>
using VectorFor_t
 The Argon type holding ScalarType values with the same width as VectorType (Argon or ArgonHalf).
template<typename T>
using Bool_t = Bool<T>::type
 Helper alias to get the boolean type of a SIMD operation.

Enumerations

enum class  DotForm { Plain , Exchange , Subtract , SubtractExchange }
 The forms of Argon::DotProduct and friends. See Argon::DotProduct.
enum class  Platform { NEON , MVE , SIMDe }

Functions

template<typename T, typename V>
ace auto reinterpret (Vector< V > in)
 Reinterpret a vector of one type to another.
template<typename argon_type, simd::is_vector_type V>
ace argon_type reinterpret (V in)
 Reinterpret a vector of one type to another.
template<typename ScalarType, typename ArgonType>
ace ScalarType bit_cast (ArgonType in)
 Reinterpret a vector of one type to another.
template<typename argon_type>
ace std::array< argon_type, 2 > zip (argon_type a, argon_type b)
 Zip two vectors together into a pair of output vectors.
template<typename argon_type>
ace std::array< argon_type, 2 > unzip (argon_type a, argon_type b)
 Unzip vectors into a pair of output vectors.
template<typename argon_type>
ace std::array< argon_type, 2 > transpose (argon_type a, argon_type b)
 Treats the lanes of its inputs as elements of a 2x2 matrix and transposes the matrices.
template<typename T>
ace Argon< T > combine (ArgonHalf< T > low, ArgonHalf< T > high)
 Combine two double-word vectors into a single quad-word vector.
template<typename T>
ace Argon< T > load (const T *ptr)
 Load a quad-word vector from a pointer.
template<typename T>
ace ArgonHalf< T > load_half (const T *ptr)
 Load a double-word vector from a pointer.
template<typename VectorType, typename BranchType>
ace BranchType ternary (Predicate< VectorType > condition, BranchType true_value, BranchType false_value)
 Create a new vector depending on the result of a conditional.
template<typename MaskType, typename BranchType>
ace BranchType ternary (MaskType mask, BranchType true_value, BranchType false_value)
 Create a new vector depending on the result of a conditional.
template<typename MaskType, typename ValueType>
ace auto ternary (MaskType mask, ValueType true_value, ValueType false_value)
 Create a new vector depending on the result of a conditional.
template<typename BranchType, typename CondType>
ace BranchType ternary (CondType condition, BranchType true_value, BranchType false_value)
template<typename VectorType, typename ValueType>
ace auto ternary (Predicate< VectorType > condition, ValueType true_value, ValueType false_value)
 Create a new vector depending on the result of a conditional.
template<typename VectorType, typename ValueType>
ace CondMonad< VectorType, ValueType > if_ (Predicate< VectorType > condition, ValueType value)
 Start a per-lane if / else-if / else chain: value in the lanes where condition holds.
template<typename VectorType, typename ScalarType>
ace auto if_ (Predicate< VectorType > condition, ScalarType value)
 Start a per-lane if / else-if / else chain: value in the lanes where condition holds.
template<typename VectorType, std::invocable FunctionType>
ace auto if_ (Predicate< VectorType > condition, FunctionType func)
 Start a per-lane if / else-if / else chain: value in the lanes where condition holds.
template<class T, std::size_t N>
constexpr std::array< helpers::ArgonFor_t< T >, N > to_array (T(&a)[N])
 Convert a C-style array of vector types to a std::array of Argon types.
template<class T, std::size_t N>
constexpr std::array< helpers::ArgonFor_t< T >, N > to_array (T(&&a)[N])
 Convert a C-style array of vector types to a std::array of Argon types.
template<typename scalar_type>
std::pair< std::span< scalar_type >, std::span< scalar_type > > split_head_aligned (std::span< scalar_type > span)
 Split a span into two spans, with the first span aligned to the vector size.
template<typename scalar_type>
std::pair< std::span< scalar_type >, std::span< scalar_type > > split_tail_aligned (std::span< scalar_type > span)
 Split a span into two spans, with the second span aligned to the vector size.
template<size_t stride, typename scalar_type, typename intrinsic_type>
ace void store_interleaved (scalar_type *ptr, simd::MultiVector_t< intrinsic_type, stride > multi_vec)
 Store a multi-vector to a location in memory with interleaving.
template<size_t stride, typename scalar_type, typename argon_type>
ace void store_interleaved (scalar_type *ptr, std::array< argon_type, stride > multi_vec)
 Store an array of vectors to a location in memory with interleaving.
template<typename scalar_type, typename... argon_types>
ace void store_interleaved (scalar_type *ptr, argon_types... vecs)
 Store vectors to a location in memory with interleaving.
template<typename scalar_type, typename argon_type>
ace void store (scalar_type *ptr, argon_type vector)
 Store a vector to a location in memory.
template<typename scalar_type, simd::is_vector_type intrinsic_type>
ace void store (scalar_type *ptr, intrinsic_type vector)
 Store a vector to a location in memory.
template<int lane, size_t stride, typename scalar_type, typename argon_type>
ace void store_lane_interleaved (scalar_type *ptr, std::array< argon_type, stride > multi_vec)
 Store a lane of an array of vectors to a location in memory with interleaving.
template<int lane, size_t stride, typename scalar_type, typename intrinsic_type>
ace void store_lane_interleaved (scalar_type *ptr, simd::MultiVector_t< intrinsic_type, stride > multi_vec)
 Store a lane of a multi-vector to a location in memory with interleaving.

Variables

constexpr Platform platform = Platform::SIMDe
template<typename T>
constexpr bool is_half_float_v
 Whether T is the half-precision lane type, float16_t (__fp16), on a platform with half-float vectors.
template<typename T, typename... Ts>
constexpr bool is_one_of = std::disjunction_v<std::is_same<T, Ts>...>
 Helper template to check if a type is one of the specified types.

Detailed Description

A 128-bit SIMD vector wrapping a scalar type, providing arithmetic, logical, and data-movement operations.

Template Parameters
ScalarTypeThe element type (e.g., int32_t, float, uint8_t).

Inherits all lane-wise operations from argon::Vector and adds 128-bit-specific operations such as narrowing, widening multiplies, cross-half operations, reductions, and (optionally) AES acceleration. Use ArgonHalf<ScalarType> for the 64-bit sibling.

Typedef Documentation

◆ Bool_t

template<typename T>
using argon::Bool_t = Bool<T>::type

Helper alias to get the boolean type of a SIMD operation.

Template Parameters
TThe SIMD vector type (e.g., int8x16_t, float32x4_t).

◆ VectorFor_t

template<typename VectorType, typename ScalarType>
using argon::VectorFor_t
Initial value:
std::conditional_t<sizeof(VectorType) == 16, Argon<helpers::LaneFor_t<VectorType, ScalarType>>,
Definition argon_half.hpp:11
Definition argon_full.hpp:44
std::conditional_t< std::is_integral_v< ScalarType > &&std::is_integral_v< simd::Scalar_t< VectorType > > && sizeof(ScalarType)==sizeof(simd::Scalar_t< VectorType >) && std::is_signed_v< ScalarType >==std::is_signed_v< simd::Scalar_t< VectorType > >, simd::Scalar_t< VectorType >, ScalarType > LaneFor_t
The lane type for a ScalarType value used alongside VectorType's lanes.
Definition argon.hpp:161

The Argon type holding ScalarType values with the same width as VectorType (Argon or ArgonHalf).

Function Documentation

◆ bit_cast()

template<typename ScalarType, typename ArgonType>
ace ScalarType argon::bit_cast ( ArgonType in)

Reinterpret a vector of one type to another.

Template Parameters
argon_typeThe type to reinterpret to
VThe type to reinterpret from
Parameters
inThe vector to reinterpret
Returns
The reinterpreted vector

◆ combine()

template<typename T>
ace Argon< T > argon::combine ( ArgonHalf< T > low,
ArgonHalf< T > high )

Combine two double-word vectors into a single quad-word vector.

Template Parameters
TThe type of the vectors to combine
Parameters
lowThe low half of the vector
highThe high half of the vector
Returns
The combined vector

◆ if_() [1/3]

template<typename VectorType, std::invocable FunctionType>
ace auto argon::if_ ( Predicate< VectorType > condition,
FunctionType func )

Start a per-lane if / else-if / else chain: value in the lanes where condition holds.

argon::if_(x < lo, lo).else_if_(x > hi, hi).else_(x) clamps x to [lo, hi].

◆ if_() [2/3]

template<typename VectorType, typename ScalarType>
ace auto argon::if_ ( Predicate< VectorType > condition,
ScalarType value )

Start a per-lane if / else-if / else chain: value in the lanes where condition holds.

argon::if_(x < lo, lo).else_if_(x > hi, hi).else_(x) clamps x to [lo, hi].

◆ if_() [3/3]

template<typename VectorType, typename ValueType>
ace CondMonad< VectorType, ValueType > argon::if_ ( Predicate< VectorType > condition,
ValueType value )

Start a per-lane if / else-if / else chain: value in the lanes where condition holds.

argon::if_(x < lo, lo).else_if_(x > hi, hi).else_(x) clamps x to [lo, hi].

◆ load()

template<typename T>
ace Argon< T > argon::load ( const T * ptr)

Load a quad-word vector from a pointer.

Template Parameters
TThe type of the vector to load
Parameters
ptrThe pointer to load from
Returns
The loaded vector

◆ load_half()

template<typename T>
ace ArgonHalf< T > argon::load_half ( const T * ptr)

Load a double-word vector from a pointer.

Template Parameters
TThe type of the vector to load
Parameters
ptrThe pointer to load from
Returns
The loaded vector

◆ reinterpret() [1/2]

template<typename argon_type, simd::is_vector_type V>
ace argon_type argon::reinterpret ( V in)

Reinterpret a vector of one type to another.

Template Parameters
argon_typeThe type to reinterpret to
VThe type to reinterpret from
Parameters
inThe vector to reinterpret
Returns
The reinterpreted vector

◆ reinterpret() [2/2]

template<typename T, typename V>
ace auto argon::reinterpret ( Vector< V > in)

Reinterpret a vector of one type to another.

Template Parameters
TThe type to reinterpret to
VThe type to reinterpret from
Parameters
inThe vector to reinterpret
Returns
The reinterpreted vector

◆ split_head_aligned()

template<typename scalar_type>
std::pair< std::span< scalar_type >, std::span< scalar_type > > argon::split_head_aligned ( std::span< scalar_type > span)

Split a span into two spans, with the first span aligned to the vector size.

Parameters
spanThe span to split
Returns
A pair of spans, the first divisible by the vector size and the second containing any remaining elements

◆ split_tail_aligned()

template<typename scalar_type>
std::pair< std::span< scalar_type >, std::span< scalar_type > > argon::split_tail_aligned ( std::span< scalar_type > span)

Split a span into two spans, with the second span aligned to the vector size.

Parameters
spanThe span to split
Returns
A pair of spans, the first containing any remaining elements and the second divisible by the vector size

◆ store() [1/2]

template<typename scalar_type, typename argon_type>
ace void argon::store ( scalar_type * ptr,
argon_type vector )

Store a vector to a location in memory.

Parameters
ptrThe location to store to
vectorThe vector to store

◆ store() [2/2]

template<typename scalar_type, simd::is_vector_type intrinsic_type>
ace void argon::store ( scalar_type * ptr,
intrinsic_type vector )

Store a vector to a location in memory.

Parameters
ptrThe location to store to
vectorThe vector to store

◆ store_interleaved() [1/3]

template<typename scalar_type, typename... argon_types>
ace void argon::store_interleaved ( scalar_type * ptr,
argon_types... vecs )

Store vectors to a location in memory with interleaving.

Parameters
ptrThe location to store to
vecsThe vectors to store

◆ store_interleaved() [2/3]

template<size_t stride, typename scalar_type, typename intrinsic_type>
ace void argon::store_interleaved ( scalar_type * ptr,
simd::MultiVector_t< intrinsic_type, stride > multi_vec )

Store a multi-vector to a location in memory with interleaving.

Template Parameters
strideThe interleaving stride: 2, 3, 4
Parameters
ptrThe location to store to
multi_vecThe multi-vector to store

◆ store_interleaved() [3/3]

template<size_t stride, typename scalar_type, typename argon_type>
ace void argon::store_interleaved ( scalar_type * ptr,
std::array< argon_type, stride > multi_vec )

Store an array of vectors to a location in memory with interleaving.

Template Parameters
strideThe interleaving stride: 2, 3, 4
Parameters
ptrThe location to store to
multi_vecThe multi-vector to store

◆ store_lane_interleaved() [1/2]

template<int lane, size_t stride, typename scalar_type, typename intrinsic_type>
ace void argon::store_lane_interleaved ( scalar_type * ptr,
simd::MultiVector_t< intrinsic_type, stride > multi_vec )

Store a lane of a multi-vector to a location in memory with interleaving.

Template Parameters
laneThe lane to store
strideThe interleaving stride: 2, 3, 4
Parameters
ptrThe location to store to
multi_vecThe multi-vector to store

◆ store_lane_interleaved() [2/2]

template<int lane, size_t stride, typename scalar_type, typename argon_type>
ace void argon::store_lane_interleaved ( scalar_type * ptr,
std::array< argon_type, stride > multi_vec )

Store a lane of an array of vectors to a location in memory with interleaving.

Template Parameters
laneThe lane to store:
strideThe interleaving stride: 2, 3, 4
Parameters
ptrThe location to store to
multi_vecThe array to store

◆ ternary() [1/4]

template<typename MaskType, typename BranchType>
ace BranchType argon::ternary ( MaskType mask,
BranchType true_value,
BranchType false_value )

Create a new vector depending on the result of a conditional.

Template Parameters
VectorTypeThe vector type the condition was computed from
BranchTypeThe type of the branches
Parameters
conditionThe predicate to select by
true_valueThe vector to select lanes from if the condition is true
false_valueThe vector to select lanes from if the condition is false
Returns
The new vector
Warning
This function does not short-circuit. It will evaluate both branches regardless of the condition. Due to the way the NEON pipeline works (i.e. without conditional execution flags the way that VFP has), we're required to execute both branches of the conditional and then select the lanes we want, even if one of the branches is completely unused.

Selects by a mask vector (all ones / all zeros per lane), e.g. from Predicate::ToMask().

◆ ternary() [2/4]

template<typename MaskType, typename ValueType>
ace auto argon::ternary ( MaskType mask,
ValueType true_value,
ValueType false_value )

Create a new vector depending on the result of a conditional.

Template Parameters
VectorTypeThe vector type the condition was computed from
BranchTypeThe type of the branches
Parameters
conditionThe predicate to select by
true_valueThe vector to select lanes from if the condition is true
false_valueThe vector to select lanes from if the condition is false
Returns
The new vector
Warning
This function does not short-circuit. It will evaluate both branches regardless of the condition. Due to the way the NEON pipeline works (i.e. without conditional execution flags the way that VFP has), we're required to execute both branches of the conditional and then select the lanes we want, even if one of the branches is completely unused.

◆ ternary() [3/4]

template<typename VectorType, typename BranchType>
ace BranchType argon::ternary ( Predicate< VectorType > condition,
BranchType true_value,
BranchType false_value )

Create a new vector depending on the result of a conditional.

Template Parameters
VectorTypeThe vector type the condition was computed from
BranchTypeThe type of the branches
Parameters
conditionThe predicate to select by
true_valueThe vector to select lanes from if the condition is true
false_valueThe vector to select lanes from if the condition is false
Returns
The new vector
Warning
This function does not short-circuit. It will evaluate both branches regardless of the condition. Due to the way the NEON pipeline works (i.e. without conditional execution flags the way that VFP has), we're required to execute both branches of the conditional and then select the lanes we want, even if one of the branches is completely unused.

◆ ternary() [4/4]

template<typename VectorType, typename ValueType>
ace auto argon::ternary ( Predicate< VectorType > condition,
ValueType true_value,
ValueType false_value )

Create a new vector depending on the result of a conditional.

Template Parameters
VectorTypeThe vector type the condition was computed from
BranchTypeThe type of the branches
Parameters
conditionThe predicate to select by
true_valueThe vector to select lanes from if the condition is true
false_valueThe vector to select lanes from if the condition is false
Returns
The new vector
Warning
This function does not short-circuit. It will evaluate both branches regardless of the condition. Due to the way the NEON pipeline works (i.e. without conditional execution flags the way that VFP has), we're required to execute both branches of the conditional and then select the lanes we want, even if one of the branches is completely unused.

◆ to_array() [1/2]

template<class T, std::size_t N>
std::array< helpers::ArgonFor_t< T >, N > argon::to_array ( T(&&) a[N])
constexpr

Convert a C-style array of vector types to a std::array of Argon types.

Template Parameters
TThe type of the elements in the array.
NThe number of elements in the array.
Parameters
aThe C-style array to convert.
Returns
A std::array of Argon types.

This overload is for rvalue references to arrays.

◆ to_array() [2/2]

template<class T, std::size_t N>
std::array< helpers::ArgonFor_t< T >, N > argon::to_array ( T(&) a[N])
constexpr

Convert a C-style array of vector types to a std::array of Argon types.

Template Parameters
TThe type of the elements in the array.
NThe number of elements in the array.
Parameters
aThe C-style array to convert.
Returns
A std::array of Argon types.

◆ transpose()

template<typename argon_type>
ace std::array< argon_type, 2 > argon::transpose ( argon_type a,
argon_type b )

Treats the lanes of its inputs as elements of a 2x2 matrix and transposes the matrices.

Template Parameters
argon_typeThe type of the vectors to transpose
Parameters
aThe first vector
bThe second vector
Returns
The transposed multi-vector

Given two vectors: {a0, a1, a2, a3}, {b0, b1, b2, b3} The result will be: {b1, a1, b3, a3}, {b0, a0, b2, a2}

See also
https://developer.arm.com/documentation/dui0489/i/neon-and-vfp-programming/vtrn

◆ unzip()

template<typename argon_type>
ace std::array< argon_type, 2 > argon::unzip ( argon_type a,
argon_type b )

Unzip vectors into a pair of output vectors.

Template Parameters
argon_typeThe type of the vectors to unzip
Parameters
aThe first vector
bThe second vector
Returns
The unzipped multi-vector

Given two vectors: {a0, b0, a1, b1}, {a2, b2, a3, b3} The result will be: {a0, a1, a2, a3}, {b0, b1, b2, b3}

◆ zip()

template<typename argon_type>
ace std::array< argon_type, 2 > argon::zip ( argon_type a,
argon_type b )

Zip two vectors together into a pair of output vectors.

Template Parameters
argon_typeThe type of the vectors to zip
Parameters
aThe first vector
bThe second vector
Returns
The zipped multi-vector

Given two vectors: {a0, a1, a2, a3}, {b0, b1, b2, b3} The result will be: {a0, b0, a1, b1}, {a2, b2, a3, b3}

Variable Documentation

◆ is_half_float_v

template<typename T>
bool argon::is_half_float_v
constexpr
Initial value:
=
std::is_same_v<std::remove_cv_t<T>, float16_t>

Whether T is the half-precision lane type, float16_t (__fp16), on a platform with half-float vectors.

The standard type traits don't count __fp16 as arithmetic or floating point, so it needs naming.

◆ is_one_of

template<typename T, typename... Ts>
bool argon::is_one_of = std::disjunction_v<std::is_same<T, Ts>...>
inlineconstexpr

Helper template to check if a type is one of the specified types.

Template Parameters
TThe type to check.
TsThe types to check against.

This template uses a variadic template to check if T is one of the types in Ts.