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

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

Classes

struct  NextLarger
 Helper template to determine the next larger type for a given type. More...
struct  NextSmaller
 Helper template to determine the next smaller type for a given type. More...
struct  ArgonFor
 Helper template to get the Argon type for a given vector type. More...

Concepts

concept  has_smaller
 Concept to check if a type has a smaller corresponding type.
concept  has_larger

Typedefs

template<typename VectorType, typename ScalarType>
using LaneFor_t
 The lane type for a ScalarType value used alongside VectorType's lanes.
template<typename T>
using NextLarger_t = NextLarger<T>::type
 Helper alias to get the next larger type for a given type.
template<typename T>
using NextSmaller_t = NextSmaller<T>::type
 Helper alias to get the next smaller type for a given type.
template<typename T>
using ArgonFor_t = typename ArgonFor<std::remove_cv_t<T>>::type
 Helper alias to get the Argon type for a given vector type.

Functions

uint32_t saturate_to_uint32 (float x)
int32x4_t convert_to_int32 (float32x4_t a)
int32x2_t convert_to_int32 (float32x2_t a)
uint32x4_t convert_to_uint32 (float32x4_t a)
uint32x2_t convert_to_uint32 (float32x2_t a)
template<int fracbits>
int32x4_t convert_n_to_int32 (float32x4_t a)
template<int fracbits>
int32x2_t convert_n_to_int32 (float32x2_t a)
template<int fracbits>
uint32x4_t convert_n_to_uint32 (float32x4_t a)
template<int fracbits>
uint32x2_t convert_n_to_uint32 (float32x2_t a)
template<typename T>
constexpr size_t vectorizeable_size (size_t size)
 Calculates the size of a vectorized range.
template<typename T>
constexpr size_t vectorized_size (size_t size)
 Calculates the number of vectorized elements in a range.

Variables

template<typename T>
constexpr bool has_smaller_v
 Helper template to determine if a type has a smaller corresponding type.
template<typename T>
constexpr bool has_larger_v
 Helper template to determine if a type has a larger corresponding type.

Detailed Description

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

Workarounds that keep Argon's float operations on NEON with the NEON instructions' semantics.

  • GCC on AArch32 scalarises generic vector-extension float arithmetic, comparisons and ?: to VFP unless -ffast-math is on (AArch32 NEON flushes denormals, so it is not IEEE), and its arm_neon.h implements vc{lt,gt,le,ge}{q}_f32 as such generic comparisons. Argon uses the NEON builtins behind the arithmetic intrinsics there (see ARGON_GCC_AARCH32_FLOAT), and the inline vcgt/vcge below for comparisons.
  • clang on AArch32 lowers vcvt{q}_{s,u}32_f32 to IR fptosi/fptoui, which are poison for NaN and out-of-range inputs and get constant-folded to wrong values (AArch64 uses llvm.fpto{s,u}i.sat). The conversions below emit vcvt directly there, keeping its truncate/saturate/NaN→0 semantics.
  • SIMDe (x86) converts float values between 2^31 and 2^32 to uint32 as 2^31; the conversions below convert per lane there.

Typedef Documentation

◆ ArgonFor_t

template<typename T>
using argon::helpers::ArgonFor_t = typename ArgonFor<std::remove_cv_t<T>>::type

Helper alias to get the Argon type for a given vector type.

Template Parameters
TThe vector type to get the Argon type for.

◆ LaneFor_t

template<typename VectorType, typename ScalarType>
using argon::helpers::LaneFor_t
Initial value:
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>

The lane type for a ScalarType value used alongside VectorType's lanes.

An integer of the same size and signedness as VectorType's lanes becomes that lane type, so a literal like 3 (int) pairs with int32_t lanes even where int32_t is long (arm-none-eabi), which has no Argon<int>.

◆ NextLarger_t

template<typename T>
using argon::helpers::NextLarger_t = NextLarger<T>::type

Helper alias to get the next larger type for a given type.

Template Parameters
TThe scalar type to determine the next larger type for.

◆ NextSmaller_t

template<typename T>
using argon::helpers::NextSmaller_t = NextSmaller<T>::type

Helper alias to get the next smaller type for a given type.

Template Parameters
TThe scalar type to determine the next smaller type for.

Function Documentation

◆ vectorizeable_size()

template<typename T>
size_t argon::helpers::vectorizeable_size ( size_t size)
constexpr

Calculates the size of a vectorized range.

Template Parameters
TThe type of the elements in the range.
Parameters
sizeThe size of the range.
Returns
The size of the vectorized range.

◆ vectorized_size()

template<typename T>
size_t argon::helpers::vectorized_size ( size_t size)
constexpr

Calculates the number of vectorized elements in a range.

Template Parameters
TThe type of the elements in the range.
Parameters
sizeThe size of the range.
Returns
The number of vectorized elements in the range.

Variable Documentation

◆ has_larger_v

template<typename T>
bool argon::helpers::has_larger_v
constexpr
Initial value:
=
std::is_same_v<T, uint8_t>
|| std::is_same_v<T, uint16_t>
|| std::is_same_v<T, uint32_t>
|| std::is_same_v<T, int8_t>
|| std::is_same_v<T, int16_t>
|| std::is_same_v<T, int32_t>
|| std::is_same_v<T, float>
|| std::is_same_v<T, float16_t>

Helper template to determine if a type has a larger corresponding type.

Template Parameters
TThe scalar type to check.

◆ has_smaller_v

template<typename T>
bool argon::helpers::has_smaller_v
constexpr
Initial value:
=
std::is_same_v<T, uint16_t>
|| std::is_same_v<T, uint32_t>
|| std::is_same_v<T, uint64_t>
|| std::is_same_v<T, int16_t>
|| std::is_same_v<T, int32_t>
|| std::is_same_v<T, int64_t>
|| std::is_same_v<T, double>
|| std::is_same_v<T, float>
|| std::is_same_v<T, float32_t>

Helper template to determine if a type has a smaller corresponding type.

Template Parameters
TThe scalar type to check.