Intel xvec
Experimental C++ simd class library
Loading...
Searching...
No Matches
xvec::simd::detail Namespace Reference

Detect a scoped enum. This will be provided in C++23 onwards. More...

Classes

struct  bit_lshift
struct  bit_rshift
struct  bit_lshift< void >
struct  bit_rshift< void >
class  flag_convert
class  flag_aligned
class  flag_overaligned
class  flag_unchecked
struct  vec_traits
struct  mask_traits
struct  target_overloads
 Allow overloaded lambdas to be used for target-specific code. Described at https://www.cppstories.com/2019/02/2lines3featuresoverload.html/ Working example at: https://godbolt.org/z/cY8nb3Gd6. More...
struct  element_type
struct  element_type< _Tp >
struct  complex_element_type_query
struct  complex_element_type_query< _Tp >
struct  is_fp16
struct  is_floating_point
 Temporary floating-point test. Used to handle half/_Float16 until the compiler catches up. More...
struct  unsigned_to_signed
struct  unsigned_to_signed< unsigned __int128 >
struct  element_storage
struct  element_storage< _Tp >

Concepts

concept  is_scoped_enum
concept  saturation_integer
concept  funnel_shift_source
concept  promotable_type
concept  supported_unary_op
concept  supported_binary_op
concept  supported_relational_op
concept  value_preserving_convertible_to
concept  explicitly_convertible_to
concept  higher_floating_point_rank
concept  higher_integer_rank
concept  contiguous_sized_range
 Check for contiguous range with a finite range.
concept  simple_vectorizable
 Detect a simple vectorizable type.
concept  extended_vectorizable
concept  builtin_vectorizable
concept  vectorizable
concept  udt_vectorizable
concept  needs_explicit_conversion
concept  constexpr_wrapper_like
concept  roundtrippable
concept  wrapped_value_is_representable_by
concept  broadcast_constructible
concept  index_generator_function_with_size
concept  index_generator_function_without_size
concept  index_generator_function
concept  vec_container_element
 Concepts used to simplify some function signature requirements.
concept  generated_value_convertible_to
concept  generator_invocable_at
concept  generator_invocable
concept  mask_operator
concept  math_floating_point
concept  gather_from_requires
 Requirements for the gather interfaces.
concept  scatter_to_requires
 Requirements for the scatter interfaces.
concept  binary_reduction_fn
concept  complex_number
 Detect whether a given type is std::complex.
concept  fundamental_unsigned_integer
 Detect a fundamental unsigned integer type.

Typedefs

template<class _Tp>
using deduced_vec_t = decltype(std::declval<const _Tp&>() + std::declval<const _Tp&>())
template<class _Tp>
using deduced_mask_t = typename deduced_vec_t<_Tp>::mask_type
template<typename _Vp, std::ranges::range _Range>
using load_return_type_range
template<typename _Vp, std::contiguous_iterator _It>
using load_return_type_iter
template<typename _Vp, std::ranges::range _Range>
using load_mask_type_range = typename load_return_type_range<_Vp, _Range>::mask_type
template<typename _Vp, std::contiguous_iterator _It>
using load_mask_type_iter = typename load_return_type_iter<_Vp, _It>::mask_type
template<typename _Parent, typename _Type>
using dependent_type = typename std::conditional<true, _Type, _Parent>::type
using containers_for_num_bytes = std::tuple<void, std::uint8_t, std::uint16_t, std::uint32_t, std::uint64_t, __uint128_t>
template<std::size_t _Bytes>
using container_for_num_bytes = typename std::tuple_element_t<std::bit_width(std::bit_ceil(_Bytes)), containers_for_num_bytes>
template<typename _Tp>
using container_for_type = container_for_num_bytes<sizeof(_Tp)>
template<typename _Tp>
using make_signed_t = typename unsigned_to_signed<_Tp>::value_type
template<class _Span>
using span_element_type = decltype(get_span_element_type_helper(std::declval<_Span>()))
template<typename _Tp>
using element_type_t = typename element_type<_Tp>::value_type
template<typename _Tp>
using complex_element_type = typename complex_element_type_query<_Tp>::value_type
template<typename _Tp>
using element_storage_t = typename element_storage<_Tp>::value_type

Functions

template<saturation_integer To, saturation_integer From>
constexpr To saturating_cast (From value) noexcept
template<saturation_integer T>
constexpr T saturating_add (T lhs, T rhs) noexcept
 Add two integers, clamping an unrepresentable mathematical result.
template<saturation_integer T>
constexpr T saturating_sub (T lhs, T rhs) noexcept
 Subtract two integers, clamping an unrepresentable mathematical result.
template<saturation_integer T>
constexpr T saturating_mul (T lhs, T rhs) noexcept
 Multiply two integers, clamping an unrepresentable mathematical result.
template<saturation_integer T>
constexpr T saturating_div (T lhs, T rhs) noexcept
 Divide two integers, clamping an unrepresentable mathematical result.
template<funnel_shift_source T, std::integral S>
constexpr T funnel_shift_right (T high, T low, S s) noexcept
template<funnel_shift_source T, std::integral S>
constexpr T funnel_shift_left (T high, T low, S s) noexcept
template<class To, class From>
requires roundtrippable<From, To>
constexpr bool roundtrip_preserves_value (From x)
constexpr auto add_unchecked_flag (auto f)
constexpr auto add_convert_flag (auto f)
template<typename _F, typename... _Flags>
constexpr bool contains_flag (flags< _Flags... >)
 Query whether the given flags contains the specified type.
template<int _Np, vec_or_mask_type _Sp>
constexpr auto permute_take (generic_tag, const _Sp &in)
 A named permute which keeps the first _Np values of a simd and discards the remainder.
template<int _Np, vec_or_mask_type _Sp>
constexpr auto permute_drop (generic_tag, const _Sp &in) noexcept
 A named permute which discards the first _Np values of a vec or mask, returning the remainder.
template<int _Np, vec_or_mask_type _Sp>
constexpr auto permute_repeat_all (generic_tag, const _Sp &in) noexcept
 A named permute which creates N copies of the input concatenated together.
template<int _Np, vec_or_mask_type _Sp>
constexpr auto permute_repeat_each (generic_tag, const _Sp &in) noexcept
 A named permute which creates N copies of each element.
template<int _Np, vec_or_mask_type _Sp>
constexpr auto permute_stride (generic_tag, const _Sp &in) noexcept
 A named permute which extracts every N'th value, discarding values which do not have indexes which are multiples of N.
template<int _Np, vec_or_mask_type _Sp>
constexpr auto permute_grow (generic_tag, const _Sp &in) noexcept
 A named permute which increases the number of elements in the vec or mask, placing a copy of the given value into the new element positions.
template<int _Np, vec_type _Vp>
constexpr auto permute_grow (generic_tag, const _Vp &in, typename _Vp::value_type fill) noexcept
template<int _Np, mask_type _Mp>
constexpr auto permute_grow (generic_tag, const _Mp &in, bool fill) noexcept
template<vec_or_mask_type _Sp>
constexpr auto permute_reverse (generic_tag, const _Sp &in)
 Reverse the order in which the elements appear in the given input vec or mask.
template<int _Middle, vec_or_mask_type _Sp>
constexpr auto permute_rotate (generic_tag, const _Sp &in) noexcept
 A named permute which rotates the input so that the element at the MIDDLE index becomes the first element.
template<int ROWS, int COLS, vec_or_mask_type _Sp>
constexpr auto permute_transpose (generic_tag, const _Sp &in) noexcept
template<vec_or_mask_type... _Sps>
constexpr auto permute_zip (generic_tag, const _Sps &...simds) noexcept
template<int _Np, vec_or_mask_type _Sp>
constexpr auto permute_unzip (generic_tag, const _Sp &in) noexcept
 Unzip breaks a vec or mask down into N smaller objects, where each vec or mask is the values at the stride of N and offset by the output index. For example, unzip<2>([a 0 b 1 c 2]) will become [a b c] [0 1 2].
template<simd_size_type _Begin, simd_size_type _End, vec_or_mask_type _Vp>
constexpr auto extract (generic_tag, const _Vp &v)
template<simd_size_type _Begin, simd_size_type _End, mask_type _Mp>
constexpr auto extract (compact_mask_tag, const _Mp &m)
template<simd_size_type _Begin, vec_or_mask_type _Container, vec_or_mask_type _Child>
requires (vec_or_mask_same_element_type<_Container, _Child>)
constexpr _Container insert (generic_tag, const _Container &container, const _Child &child) noexcept
template<simd_size_type _Begin, mask_type _Container, mask_type _Child>
requires (vec_or_mask_same_element_type<_Container, _Child>)
constexpr _Container insert (compact_mask_tag, const _Container &container, const _Child &child) noexcept
template<vec_or_mask_type _Vp, typename _Op>
constexpr auto builtin_operator (generic_tag, _Vp value, _Op op)
 General purpose unary operator. Passes through to the compiler's own builtin.
template<vec_type _Vp>
constexpr auto builtin_operator (generic_tag, _Vp value, std::logical_not<>)
template<vec_or_mask_type _Vp, typename _Op>
constexpr auto builtin_operator (generic_tag, _Vp lhs, _Vp rhs, _Op op)
 General purpose binary operator.
template<vec_integral _Vp, typename _Op>
requires (any_same_v<_Op, std::divides<>, std::modulus<>>)
constexpr _Vp builtin_operator (generic_tag, _Vp lhs, _Vp rhs, _Op)
 Special treatment for integral divide and modulus. These often cause hardware exceptions if zero is used in the denominator. Such exceptions should only be raised on the active data in the vec.
template<vec_complex _Vp>
constexpr auto builtin_operator (generic_tag, const _Vp &lhs, const _Vp &rhs, std::multiplies<>)
 Generic complex multipler forwards to the complex FMA.
template<vec_type _Vp, mask_operator _Op>
constexpr auto builtin_operator (compact_mask_tag, const _Vp &x, const _Vp &y, _Op)
template<typename FN, vec_type _Vp, typename... Args>
requires (std::same_as<Args, _Vp> && ...)
constexpr auto make_mask_from_op (const _Vp &first, const Args &... args) noexcept
template<typename FN, vec_type _Vp, vec_type... _Vps>
constexpr auto do_operator (const _Vp &first, const _Vps &... rest) noexcept
template<vec_type _To, vec_type _From>
constexpr _To convert_operator (const _From &v) noexcept
 Conversion operator for basic_vec. All gate-keeping has been done, just do the convert.
template<mask_type _M, vec_type _V>
constexpr _M vec_to_mask (const _V &s)
template<vec_type _V>
constexpr auto to_container (const _V &v)
template<typename _Op, typename _Tp>
constexpr auto choose_identity_element ()
template<simd_size_type _Size, typename _Tp, typename _Abi, binary_reduction_fn< _Tp > _BinaryFn>
_Tp reduce_helper (const basic_vec< _Tp, _Abi > &v, _BinaryFn binop)
template<typename _Tuple>
constexpr auto get_array_from_tuple (_Tuple &&tuple)
template<simd_size_type _Begin, simd_size_type _Np, vec_or_mask_type _Sp>
constexpr auto splitNHelper (const _Sp &v)
template<simd_size_type _Begin, typename _Result, typename _Sp>
constexpr _Result concatHelper (const _Result &container, const _Sp &head, const vec_or_mask_type auto &... tail)
template<math_floating_point _Vp>
constexpr deduced_mask_t< _Vp > isnan (generic_tag, const _Vp &v)
template<detail::math_floating_point _Vp>
constexpr detail::deduced_mask_t< _Vp > isinf (generic_tag tag, const _Vp &v)
template<detail::math_floating_point _Vp>
constexpr detail::deduced_mask_t< _Vp > isfinite (generic_tag tag, const _Vp &v)
template<detail::math_floating_point _Vp>
constexpr detail::deduced_mask_t< _Vp > isnormal (generic_tag, const _Vp &v)
template<detail::math_floating_point _Vp>
constexpr detail::deduced_mask_t< _Vp > signbit (generic_tag, const _Vp &v)
template<typename>
consteval auto get_register_type ()
template<class... Ts>
 target_overloads (Ts...) -> target_overloads< Ts... >
template<typename _Tp>
constexpr auto get_span_static_extent (const _Tp &in)
 Query the extent of a given type.
template<typename _Span>
constexpr auto get_span_element_type_helper (const _Span &in)
template<math_floating_point _Vp>
constexpr deduced_vec_t< _Vp > maths_fn (const _Vp &v, auto op)
template<math_floating_point _Vp>
constexpr deduced_vec_t< _Vp > maths_fn (const _Vp &v0, const _Vp &v1, auto op)
template<math_floating_point _Vp, typename OP_IMPL>
constexpr deduced_vec_t< _Vp > maths_fn (const _Vp &v, OP_IMPL op_impl)
template<math_floating_point _Vp, typename OP_IMPL>
constexpr deduced_vec_t< _Vp > maths_fn (const _Vp &v0, const _Vp &v1, OP_IMPL op_impl)
template<typename _Tp, typename _AbiT, typename _Ip, typename _AbiI>
constexpr auto permute_large_elements (const basic_vec< _Tp, _AbiT > &values, const basic_vec< _Ip, _AbiI > &indexes)
template<typename _Tp, typename _AbiT, typename _Ip, typename _AbiI>
constexpr auto permute_byte_shuffle (const basic_vec< _Tp, _AbiT > &v, const basic_vec< _Ip, _AbiI > &indexes)
template<std::unsigned_integral _Tp, typename _AbiT, std::integral _Ip, typename _AbiI>
requires (sizeof(basic_vec<_Tp, _AbiT>) <= 32)
auto permute_x86_register (x86_avx2_tag, const basic_vec< _Tp, _AbiT > &v, const basic_vec< _Ip, _AbiI > &indexes)
 Permute one register of Intel AVX2 values.
template<std::unsigned_integral _Tp, typename _AbiT, std::integral _Ip, typename _AbiI>
requires (basic_vec<_Tp, _AbiT>::size <= vec<_Tp>::size)
auto permute_x86_register (x86_avx512_tag, const basic_vec< _Tp, _AbiT > &v, const basic_vec< _Ip, _AbiI > &indexes)
 Permute one register of Intel AVX-512 values.
template<std::unsigned_integral _Tp, typename _AbiT, std::integral _Ip, typename _AbiI>
requires (basic_vec<_Tp, _AbiT>::size > vec<_Tp>::size && basic_vec<_Tp, _AbiT>::size <= 2 * vec<_Tp>::size && sizeof(_Tp) == sizeof(_Ip))
auto permute_x86_register (x86_avx512_tag, const basic_vec< _Tp, _AbiT > &v, const basic_vec< _Ip, _AbiI > &indexes)
 Permute two Intel AVX-512 registers of values (including 2 Intel AVX10 registers).
template<std::unsigned_integral _Tp, typename _AbiT, vec_integral _Ip>
auto permute_recurse (const basic_vec< _Tp, _AbiT > &values, const _Ip &indexes)
template<typename _Tp, typename _AbiTp, std::integral _Ip, typename _AbiIp, std::derived_from< x86_avx2_tag > VENDOR>
constexpr basic_vec< _Tp, _AbiIp > permute (VENDOR tag, const basic_vec< _Tp, _AbiTp > &v, const basic_vec< _Ip, _AbiIp > &indexes)
template<std::size_t _BytesTp, typename _AbiTp, typename _Ip, typename _AbiIp>
constexpr basic_mask< _BytesTp, _AbiIp > permute (x86_avx512_tag, const basic_mask< _BytesTp, _AbiTp > &m, const basic_vec< _Ip, _AbiIp > &indexes)
template<simd_size_type _OutSize, std::size_t _Bytes, typename _Abi, typename _Gp>
constexpr auto generated_permute (x86_avx512_tag, const basic_mask< _Bytes, _Abi > &m, _Gp)
 Use a generator to permute a compact bit mask.
template<int _Np, mask_type _Mp>
constexpr auto permute_drop (x86_avx512_tag, const _Mp &in) noexcept
 A named permute which discards the first _Np values of a vec, returning the remainder.
template<int _Np, mask_type _Mp>
constexpr auto permute_take (x86_avx512_tag, const _Mp &in) noexcept
 Create a mask containing only the first _Np elements. The remaining elements are discarded.
template<int _Np, mask_type _Mp>
constexpr auto permute_grow (x86_avx512_tag, const _Mp &in) noexcept
 Make the given mask grow to _Np elements, filling the extra elements with false.
template<int _Np, mask_type _Mp>
constexpr auto permute_grow (x86_avx512_tag, const _Mp &in, bool fill) noexcept
 Make the given mask grow to _Np elements, filling the extra elements with the supplied value.
template<mask_type _Mp, int _Stride>
constexpr auto every_nth_bit ()
template<mask_type _Mp>
constexpr std::bitset< _Mp::size > mask_to_bitset (x86_sse_tag, const _Mp &mask) noexcept
template<mask_type _Mp>
constexpr std::bitset< _Mp::size > mask_to_bitset (x86_avx512_tag, const _Mp &mask) noexcept
template<std::floating_point _Tp, typename _Abi>
constexpr basic_vec< _Tp, _Abi > fma (x86_avx2_tag, const basic_vec< _Tp, _Abi > &x, const basic_vec< _Tp, _Abi > &y, const basic_vec< _Tp, _Abi > &acc)
template<std::floating_point _Tp, typename _Abi>
constexpr basic_vec< _Tp, _Abi > fmaddsub (x86_avx2_tag, const basic_vec< _Tp, _Abi > &x, const basic_vec< _Tp, _Abi > &y, const basic_vec< _Tp, _Abi > &acc)
template<std::floating_point _Tp, typename _Abi>
constexpr basic_vec< _Tp, _Abi > fmsubadd (x86_avx2_tag, const basic_vec< _Tp, _Abi > &x, const basic_vec< _Tp, _Abi > &y, const basic_vec< _Tp, _Abi > &acc)
template<vec_type _Vp>
constexpr _Vp set_element (generic_tag, const _Vp &v, int index, typename _Vp::value_type new_value)
template<mask_type _Mp>
constexpr _Mp set_element (generic_tag, const _Mp &m, int index, bool new_value)
template<mask_type _Mp>
constexpr _Mp set_element (compact_mask_tag, const _Mp &m, int index, bool new_value)
template<RoundOp _Op, typename _Tp, typename _Abi>
requires (detail::is_floating_point_v<_Tp>)
constexpr basic_vec< _Tp, _Abi > round_op (x86_tag, const basic_vec< _Tp, _Abi > &v)
 Rounding operations (ceil, floor, etc.).

Variables

template<typename>
constexpr bool is_vec_v = false
template<typename _Tp, typename _Abi>
constexpr bool is_vec_v< basic_vec< _Tp, _Abi > > = true
template<typename>
constexpr bool is_mask_v = false
template<std::size_t _Bytes, typename _Abi>
constexpr bool is_mask_v< basic_mask< _Bytes, _Abi > > = true
template<typename _From, typename _To>
constexpr bool value_preserving_convertible_to_v
template<typename _Tp>
constexpr bool disable_vectorization
template<typename _From, typename _To>
constexpr bool needs_explicit_conversion_v
template<class Wrapper, class To>
constexpr bool wrapped_value_is_representable_by_v
template<typename _Tp>
constexpr auto arg_native_size = _Tp::never_instantiated
template<typename _Tp, typename _Abi>
constexpr auto arg_native_size< basic_vec< _Tp, _Abi > > = detail::max_native_size<_Tp>
template<std::size_t _Bytes, typename _Abi>
constexpr auto arg_native_size< basic_mask< _Bytes, _Abi > > = detail::maxBytesInVec / _Bytes
template<simd_size_type Size, simd_size_type... Sizes>
constexpr bool are_all_sizes_equal = (... && (Size == Sizes))
 Checks that all sizes are equal.
template<simd_size_type _NewSize, simd_size_type _VecOrMaskSize>
constexpr simd_size_type new_simd_size = (_NewSize == 0) ? _VecOrMaskSize : _NewSize
 Utility to get new vec or mask size.
auto minBinaryOperator = [](auto lhs, auto rhs) { using std::min; return min(lhs, rhs); }
auto maxBinaryOperator = [](auto lhs, auto rhs) { using std::max; return max(lhs, rhs); }
constexpr int maxBytesInVec = 16
template<typename _Tp, int _Np>
constexpr int register_size = maxBytesInVec / sizeof(_Tp)
constexpr bool isLlvm = false
 Compile time flag to indicate whether the LLVM compiler is being used.
template<class T, class... Us>
constexpr bool any_same_v = (std::same_as<std::remove_cvref_t<T>, Us> || ...)
template<typename _T>
constexpr bool is_fp16_v = false
template<typename>
constexpr bool dependent_false = false
template<class T>
constexpr bool is_floating_point_v = is_floating_point<std::remove_cvref_t<T>>::value
template<class T>
constexpr bool is_arithmetic_like_v = std::is_integral_v<std::remove_cvref_t<T>> || is_floating_point_v<T>
template<typename _Tp>
constexpr simd_size_type max_native_size = detail::maxBytesInVec / sizeof(_Tp)
 The maximum native size of a register containing the given types.
template<typename _Tp>
constexpr simd_size_type max_fixed_size = 128
template<class _Span>
constexpr std::size_t span_extent_v = decltype(get_span_static_extent(std::declval<_Span>()))::value
target_overloads msb_to_bitmask_impl
enum  X86_FP_CLASSIFY {
  QUIET_NAN = 0x01 , POS_ZERO = 0x02 , NEG_ZERO = 0x04 , POS_INF = 0x08 ,
  NEG_INF = 0x10 , DENORM = 0x20 , NEG = 0x40 , SIGNAL_NAN = 0x80
}
 Constants which specify to the compiler intrinsic which FP classification operation to perform.
template<typename _Tp>
constexpr bool has_native_support_for_classify
 Detect whether native classification support is available for the given type. Emulated FP16 has no such support, but native FP16 does.
template<vec_type _Vp, typename _Up, std::size_t _Extent, typename _Flags>
constexpr void store_masked (x86_tag, const _Vp &value_original, std::span< _Up, _Extent > to, const typename _Vp::mask_type &mask_original, _Flags flags)
 Implement masked stores for Intel SSE and Intel AVX targets.
template<vec_type _Vp, typename _Up, std::size_t _Extent, typename _Flags>
constexpr void store (x86_tag, const _Vp &value_original, std::span< _Up, _Extent > to, _Flags flags)
 Special case code for handling 4 and 8 byte masked stores on Intel AVX2. This is faster than using the Intel SSE variant above.
template<typename _Range, std::integral _Idx, typename _IdxAbi, typename... _Flags>
requires std::ranges::contiguous_range<_Range> && std::ranges::sized_range<_Range> && (sizeof(std::ranges::range_value_t<_Range>) <= 8)
constexpr auto gather_from (x86_avx2_tag, const _Range &r, const typename basic_vec< _Idx, _IdxAbi >::mask_type &mask, const basic_vec< _Idx, _IdxAbi > &indexes, flags< _Flags... > flags)
 Masked gather operation.
template<detail::contiguous_sized_range _Range, vec_integral _Idx, typename... _Flags>
constexpr auto gather_from (x86_avx2_tag, const _Range &r, const _Idx &indexes, flags< _Flags... > flags)
 Constants which specify to the compiler intrinsic which FP classification operation to perform.
template<typename _Tp, typename _Abi, mask_operator _Op>
constexpr auto builtin_operator (x86_avx512_tag, basic_vec< _Tp, _Abi > x, basic_vec< _Tp, _Abi > y, _Op)
 Constants which specify to the compiler intrinsic which FP classification operation to perform.
template<typename _Tp, typename _Abi, mask_operator _Op>
requires (detail::is_floating_point_v<_Tp>)
constexpr auto builtin_operator (x86_avx512_tag, basic_vec< std::complex< _Tp >, _Abi > lhs, basic_vec< std::complex< _Tp >, _Abi > rhs, _Op cmp_op)
 Implement equality/inequality for complex values. In all cases the underlying elements are compared (e.g., float for std::complex<float>) using an appropriate operator, and then adjacent bits in the comparison are combined together using AND/OR operation. For example, in equality, the two individual elements in each complex values are first compared for equality, and then the overall bit for the single complex element is created by ANDing the two bits together (i.e., a complex number is only equal if both of its individual elements are equal).
template<int _Op, typename _Tp, typename _Abi>
auto x86_fp_classify_mask (const basic_vec< _Tp, _Abi > &value)
 Classify the floating-point vec values using the fpclassify intrinsic.
template<typename _Tp, typename _Abi>
requires (has_native_support_for_classify<_Tp>)
constexpr basic_vec< _Tp, _Abi >::mask_type isinf (x86_avx512_tag, const basic_vec< _Tp, _Abi > &v)
 x86 floating-point classification function.
template<typename _Tp, typename _Abi>
requires (has_native_support_for_classify<_Tp>)
constexpr basic_vec< _Tp, _Abi >::mask_type isnan (x86_avx512_tag, const basic_vec< _Tp, _Abi > &v)
 Constants which specify to the compiler intrinsic which FP classification operation to perform.
template<typename _Tp, typename _Abi>
requires (has_native_support_for_classify<_Tp>)
constexpr basic_vec< _Tp, _Abi >::mask_type isfinite (x86_avx512_tag, const basic_vec< _Tp, _Abi > &v)
 Constants which specify to the compiler intrinsic which FP classification operation to perform.
template<typename _Tp, typename _Abi>
requires (has_native_support_for_classify<_Tp>)
constexpr basic_vec< _Tp, _Abi >::mask_type isnormal (x86_avx512_tag, const basic_vec< _Tp, _Abi > &v)
 Constants which specify to the compiler intrinsic which FP classification operation to perform.
__m128i shuffle_epi8 (__m128i values, __m128i indexes)
__m256i shuffle_epi8 (__m256i values, __m256i indexes)
 Constants which specify to the compiler intrinsic which FP classification operation to perform.
template<typename _Gen, typename _Abi>
constexpr basic_vec< std::uint8_t, _Abi > shuffle_epi8_lut (_Gen, basic_vec< std::uint8_t, _Abi > indexes)
template<typename _Tp, typename _Abi>
constexpr basic_vec< _Tp, _Abi > popcount (x86_sse_tag, const basic_vec< _Tp, _Abi > &x) noexcept
 }@
template<typename _Tp, typename _Abi>
constexpr auto has_single_bit (x86_avxsnc_tag, const basic_vec< _Tp, _Abi > &x) noexcept
 Query whether each element has exactly one bit set.
template<std::unsigned_integral _Tp, typename _Abi>
constexpr basic_vec< _Tp, _Abi > clz (x86_sse_tag, const basic_vec< _Tp, _Abi > &x) noexcept
 Count the number of leading zero bits in each element.
template<typename _Tp, typename _Abi>
requires (sizeof(_Tp) == 1)
constexpr basic_vec< _Tp, _Abi > bitreverse (x86_sse_tag, const basic_vec< _Tp, _Abi > &x) noexcept
 Count the number of leading zero bits in each element.
template<vec_integral _Vp>
requires (sizeof(typename _Vp::value_type) == 1)
constexpr _Vp bitreverse (x86_avxsnc_tag, const _Vp &x) noexcept
 Reverse the order of the bits in each byte using the GFNI ISA.
template<typename _Tp, typename _Abi>
requires (detail::is_floating_point_v<_Tp>)
constexpr basic_vec< _Tp, _Abi > rcp (x86_sse_tag, const basic_vec< _Tp, _Abi > &v)
 Constants which specify to the compiler intrinsic which FP classification operation to perform.
template<typename _Tp, typename _Abi>
requires (detail::is_floating_point_v<_Tp>)
constexpr basic_vec< _Tp, _Abi > rsqrt (x86_sse_tag, const basic_vec< _Tp, _Abi > &v)
 Constants which specify to the compiler intrinsic which FP classification operation to perform.
template<typename _Tp, typename _Abi>
requires (detail::is_floating_point_v<_Tp>)
constexpr basic_vec< _Tp, _Abi > sqrt (x86_sse_tag, const basic_vec< _Tp, _Abi > &v)
 Constants which specify to the compiler intrinsic which FP classification operation to perform.
template<std::integral _Tp, typename _Abi>
requires (sizeof(_Tp) <= 2)
constexpr basic_vec< _Tp, _Abi > saturating_add (x86_tag, const basic_vec< _Tp, _Abi > &lhs, const basic_vec< _Tp, _Abi > &rhs) noexcept
 Compute the saturated addition of each respective pair of vector elements.
template<std::integral _Tp, typename _Abi>
requires (sizeof(_Tp) <= 2)
constexpr basic_vec< _Tp, _Abi > saturating_sub (x86_tag, const basic_vec< _Tp, _Abi > &lhs, const basic_vec< _Tp, _Abi > &rhs) noexcept
 Compute the saturated subtraction of each respective pair of vector elements.

Detailed Description

Detect a scoped enum. This will be provided in C++23 onwards.

Typedef Documentation

◆ containers_for_num_bytes

using xvec::simd::detail::containers_for_num_bytes = std::tuple<void, std::uint8_t, std::uint16_t, std::uint32_t, std::uint64_t, __uint128_t>

Return an unsigned integer container which is the same size as the supplied type. The container is a plain bucket-of-bits.

◆ dependent_type

template<typename _Parent, typename _Type>
using xvec::simd::detail::dependent_type = typename std::conditional<true, _Type, _Parent>::type

Utility to convert a concrete type into a dependent type. This defers type checking from template definition time to instantiation time, allowing use of forward-declared types in template functions. The type will be fully defined by instantiation time. Usage:

template<typename T> void func() { dependent_type<T, ForwardDeclaredType<int>> obj; }

Template Parameters
ParentThe template parameter to create dependency on
TypeThe concrete type to make dependent

◆ load_return_type_iter

template<typename _Vp, std::contiguous_iterator _It>
using xvec::simd::detail::load_return_type_iter
Initial value:
std::conditional_t<std::same_as<_Vp, std::nullptr_t>,
Vector of elements sharing an element type and ABI.
Definition simd:161

◆ load_return_type_range

template<typename _Vp, std::ranges::range _Range>
using xvec::simd::detail::load_return_type_range
Initial value:
std::conditional_t<std::same_as<_Vp, std::nullptr_t>,

Function Documentation

◆ bitreverse() [1/2]

template<vec_integral _Vp>
requires (sizeof(typename _Vp::value_type) == 1)
_Vp xvec::simd::detail::bitreverse ( x86_avxsnc_tag ,
const _Vp & x )
constexprnoexcept

Reverse the order of the bits in each byte using the GFNI ISA.

Template Parameters
_NpThe number of elements in each vec
Parameters
xThe vec value whose bits will be reversed.
Returns
The bit-reverse vec value.

◆ bitreverse() [2/2]

template<typename _Tp, typename _Abi>
requires (sizeof(_Tp) == 1)
basic_vec< _Tp, _Abi > xvec::simd::detail::bitreverse ( x86_sse_tag ,
const basic_vec< _Tp, _Abi > & x )
constexprnoexcept

Count the number of leading zero bits in each element.

Parameters
xThe input value
Returns
A vec value in which each element contains the number of 1 bits in each respective input element.

Reverse the order of the bits in each byte of the input.

Template Parameters
_NpThe number of elements in each vec
Parameters
xThe vec value whose bits will be reversed.
Returns
The bit-reversed vec value.

◆ builtin_operator() [1/3]

template<vec_type _Vp, mask_operator _Op>
auto xvec::simd::detail::builtin_operator ( compact_mask_tag ,
const _Vp & x,
const _Vp & y,
_Op  )
constexpr

Generic comparator for compact mask targets. This is almost certainly inefficient so the target should provide something better.

◆ builtin_operator() [2/3]

template<vec_type _Vp>
auto xvec::simd::detail::builtin_operator ( generic_tag ,
_Vp value,
std::logical_not<>  )
constexpr

Provide a default for !x. This removes the need for compact-mask operations to have to do anything special.

◆ builtin_operator() [3/3]

template<typename _Tp, typename _Abi, mask_operator _Op>
requires (detail::is_floating_point_v<_Tp>)
auto xvec::simd::detail::builtin_operator ( x86_avx512_tag ,
basic_vec< std::complex< _Tp >, _Abi > lhs,
basic_vec< std::complex< _Tp >, _Abi > rhs,
_Op cmp_op )
constexpr

Implement equality/inequality for complex values. In all cases the underlying elements are compared (e.g., float for std::complex<float>) using an appropriate operator, and then adjacent bits in the comparison are combined together using AND/OR operation. For example, in equality, the two individual elements in each complex values are first compared for equality, and then the overall bit for the single complex element is created by ANDing the two bits together (i.e., a complex number is only equal if both of its individual elements are equal).

Template Parameters
_TpThe type of the elements to compare.
_OpThe operation to perform. Must be equal_to or not_equal_to.
_NpThe number of complex elements in the vec value.
Parameters
lhsThe left-hand operand to compare
rhsThe right-hand operand to compare
Returns
A compact bit mask with one element for each complex element.

Given a mask of up to 32 bits, reduce it down to 16 bits by either AND'ing or OR'ing adjacent bits.

◆ clz()

template<std::unsigned_integral _Tp, typename _Abi>
basic_vec< _Tp, _Abi > xvec::simd::detail::clz ( x86_sse_tag ,
const basic_vec< _Tp, _Abi > & x )
constexprnoexcept

Count the number of leading zero bits in each element.

Parameters
xThe input value
Returns
A vec value in which each element contains the number of 1 bits in each respective input element.

◆ concatHelper()

template<simd_size_type _Begin, typename _Result, typename _Sp>
_Result xvec::simd::detail::concatHelper ( const _Result & container,
const _Sp & head,
const vec_or_mask_type auto &... tail )
constexpr

Utility function to help concatenate several masks into a single larger mask.

Template Parameters
_BeginThe position at which the first mask will be inserted into the output
_ResultThe type of the output container
_SpThe type of the head element to be inserted
Parameters
containerThe container that will hold the concatenated elements
headThe next mask to insert
tailThe remaining mask values to insert.
Returns
A new copy of the output container with all the smaller masks concatenated together.

◆ do_operator()

template<typename FN, vec_type _Vp, vec_type... _Vps>
auto xvec::simd::detail::do_operator ( const _Vp & first,
const _Vps &... rest )
constexprnoexcept

Generic operator dispatcher. This is the main entry point for all operators. It dispatches to the appropriate implementation based on the type of the operator, the input, return type, whether there is a customisation point, whether it is a user-defined type, and so on.

◆ every_nth_bit()

template<mask_type _Mp, int _Stride>
auto xvec::simd::detail::every_nth_bit ( )
constexpr

Utility function to create a bit mask containing bits are set at a distance apart of _Stride.

Template Parameters
_MpThe output mask type
_StrideThe distance between one set bit and the next
Returns
An integer containing _Mp::size bits set at a distance of _Stride apart.

◆ funnel_shift_left()

template<funnel_shift_source T, std::integral S>
T xvec::simd::detail::funnel_shift_left ( T high,
T low,
S s )
nodiscardconstexprnoexcept

funnel_shift_left(high, low, s)

Preconditions: 0 <= s < N, where N = numeric_limits<T>::digits. Returns: (high << r) | (low >> ((N - r) % N)), where r = static_cast<unsigned>(s). Remark: funnel_shift_left(high, low, 0) returns high.

◆ funnel_shift_right()

template<funnel_shift_source T, std::integral S>
T xvec::simd::detail::funnel_shift_right ( T high,
T low,
S s )
nodiscardconstexprnoexcept

funnel_shift_right(high, low, s)

Preconditions: 0 <= s < N, where N = numeric_limits<T>::digits. Returns: (low >> r) | (high << ((N - r) % N)), where r = static_cast<unsigned>(s). Remark: funnel_shift_right(high, low, 0) returns low.

◆ gather_from()

template<typename _Range, std::integral _Idx, typename _IdxAbi, typename... _Flags>
requires std::ranges::contiguous_range<_Range> && std::ranges::sized_range<_Range> && (sizeof(std::ranges::range_value_t<_Range>) <= 8)
auto xvec::simd::detail::gather_from ( x86_avx2_tag ,
const _Range & r,
const typename basic_vec< _Idx, _IdxAbi >::mask_type & mask,
const basic_vec< _Idx, _IdxAbi > & indexes,
flags< _Flags... > flags )
constexpr

Masked gather operation.

Template Parameters
_TpThe element type to gather
_Idxthe index type
_IdxAbithe ABI of the index type
Parameters
data_ptrPointer to the region of memory from which to gather.
indexesThe indexes to gather from the memory region.
Returns
A vec of the gathered indexes from the supplied region.

◆ get_array_from_tuple()

template<typename _Tuple>
auto xvec::simd::detail::get_array_from_tuple ( _Tuple && tuple)
constexpr

Given a tuple, convert it into an array of values.

Template Parameters
_TupleThe type of the tuple to convert
Parameters
tupleThe tuple value to convert
Returns
An array containing the same elements as the original tuple

◆ get_register_type()

template<typename>
auto xvec::simd::detail::get_register_type ( )
consteval

In generic targets, there is no way to know what the register type should be, so return an invalid_register type to indicate that the target does not support the requested type. This will cause a compile-time error if the user tries to use a type which is not supported by the target. Targets which support a specific register type should provide a specialization of this function which returns the appropriate register type.

◆ get_span_element_type_helper()

template<typename _Span>
auto xvec::simd::detail::get_span_element_type_helper ( const _Span & in)
constexpr

Query the element type of a range or span-like type. Returns nullptr type if the element type cannot be determined.

◆ has_single_bit()

template<typename _Tp, typename _Abi>
auto xvec::simd::detail::has_single_bit ( x86_avxsnc_tag ,
const basic_vec< _Tp, _Abi > & x )
constexprnoexcept

Query whether each element has exactly one bit set.

Parameters
xThe value to query
Returns
A simd::mask which has an element set to true if the element has exactly one set bit.

◆ isfinite()

template<detail::math_floating_point _Vp>
detail::deduced_mask_t< _Vp > xvec::simd::detail::isfinite ( generic_tag tag,
const _Vp & v )
constexpr

Generic implementation of finite-value classification.

◆ isinf()

template<detail::math_floating_point _Vp>
detail::deduced_mask_t< _Vp > xvec::simd::detail::isinf ( generic_tag tag,
const _Vp & v )
constexpr

Generic implementation of infinity classification.

◆ isnan()

template<math_floating_point _Vp>
deduced_mask_t< _Vp > xvec::simd::detail::isnan ( generic_tag ,
const _Vp & v )
constexpr

Generic implementation of NaN classification.

◆ isnormal()

template<detail::math_floating_point _Vp>
detail::deduced_mask_t< _Vp > xvec::simd::detail::isnormal ( generic_tag ,
const _Vp & v )
constexpr

Generic implementation of normal-value classification.

◆ make_mask_from_op()

template<typename FN, vec_type _Vp, typename... Args>
requires (std::same_as<Args, _Vp> && ...)
auto xvec::simd::detail::make_mask_from_op ( const _Vp & first,
const Args &... args )
constexprnoexcept

Generic complex equality for wide masks. Each `bit' of the mask result will be a container which is the same size as _Tp. Adjacent values are compared for equality or inequality. */ template<vec_complex _Vp, mask_operator _Op> constexpr typename _Vp::mask_type builtin_operator(generic_tag, _Vp lhs, _Vp rhs, _Op) { using _Tp = typename _Vp::value_type::value_type;

static_assert(sizeof(_Tp) <= 8, "Can't deal with 128-bit elements like complex<double> yet");

using binop_type = std::remove_cvref_t<_Op>; constexpr bool isEqualOp = std::is_same_v<binop_type, std::equal_to<>>; constexpr bool isNotEqualOp = std::is_same_v<binop_type, std::not_equal_to<>>; static_assert(isEqualOp || isNotEqualOp, "Complex values only allow equality comparisons");

Element-wise comparison to generate a mask for each individual value. const auto compareElements = _Op{}(simd_bit_cast<_Tp>(lhs), simd_bit_cast<_Tp>(rhs));

Treat the mask as having half as many elements which are twice as big. Adjacent elements will be 0 or -1. const auto cmplxMask = simd_bit_cast<container_for_type<typename _Vp::value_type>>(-compareElements);

Compare wider elements to all 0 or all 1. if constexpr (isEqualOp) return typename _Vp::mask_type(cmplxMask == cw<-1>); else return typename _Vp::mask_type(cmplxMask != cw<0>); }

/** Generate mask from binary operator. Converts operator result to boolean, then to mask element. Generates wide mask first, then converts to basic_mask - this two-step approach enables better compiler auto-vectorisation than direct element-wise generation of compact masks.

◆ maths_fn()

template<math_floating_point _Vp, typename OP_IMPL>
deduced_vec_t< _Vp > xvec::simd::detail::maths_fn ( const _Vp & v,
OP_IMPL op_impl )
constexpr

Invoke an overloaded intrinsic data set representing a common maths operation onto the supplied SIMD value.

Template Parameters
_TpThe type of the SIMD elements.
_AbiThe ABI of the SIMD
OP_IMPLthe overload set to invoke
Parameters
vThe SIMD value used as input.
op_implThe operation to invoke.
Returns
The result of applying the overloaded intrinsic to all of the elements of the SIMD value. Integral values will be promoted to double precision.

◆ permute()

template<typename _Tp, typename _AbiTp, std::integral _Ip, typename _AbiIp, std::derived_from< x86_avx2_tag > VENDOR>
basic_vec< _Tp, _AbiIp > xvec::simd::detail::permute ( VENDOR tag,
const basic_vec< _Tp, _AbiTp > & v,
const basic_vec< _Ip, _AbiIp > & indexes )
constexpr

Entry point for the x86 permutations. This code tries to find the best approach to permuting the supplied value, whether that is calling a dedicated instruction, recursively breaking down large permutes into combinations of smaller permutes, or transforming the permute into a permute of a different element type to fit.

◆ permute_byte_shuffle()

template<typename _Tp, typename _AbiT, typename _Ip, typename _AbiI>
auto xvec::simd::detail::permute_byte_shuffle ( const basic_vec< _Tp, _AbiT > & v,
const basic_vec< _Ip, _AbiI > & indexes )
constexpr

Permute individual bytes using the in-lane shuffle instruction. This is faster than permutex[2]var_epi8 where it exists for small use cases, and on machines which don't support permutex[2]var_epi8 extended variants of this which duplicate the source values are likely to be faster too.

◆ permute_drop() [1/2]

template<int _Np, vec_or_mask_type _Sp>
auto xvec::simd::detail::permute_drop ( generic_tag ,
const _Sp & in )
constexprnoexcept

A named permute which discards the first _Np values of a vec or mask, returning the remainder.

Template Parameters
_NpThe number of elements to discard.

◆ permute_drop() [2/2]

template<int _Np, mask_type _Mp>
auto xvec::simd::detail::permute_drop ( x86_avx512_tag ,
const _Mp & in )
constexprnoexcept

A named permute which discards the first _Np values of a vec, returning the remainder.

Custom x86 versions of some of the named permutes. Typically these optimized for Intel AVX-512 masks, since the compiler can do a good job of most vec value permutes without help.

◆ permute_large_elements()

template<typename _Tp, typename _AbiT, typename _Ip, typename _AbiI>
auto xvec::simd::detail::permute_large_elements ( const basic_vec< _Tp, _AbiT > & values,
const basic_vec< _Ip, _AbiI > & indexes )
constexpr

Special permutation code for dealing with permutions of very large elements which have no native support. The elements are handled by treating them as blocks of 64-bit element instead, and permuting each element using severla such indexes.

◆ permute_repeat_all()

template<int _Np, vec_or_mask_type _Sp>
auto xvec::simd::detail::permute_repeat_all ( generic_tag ,
const _Sp & in )
constexprnoexcept

A named permute which creates N copies of the input concatenated together.

Template Parameters
_NpThe number of repeats of the input to create.

◆ permute_repeat_each()

template<int _Np, vec_or_mask_type _Sp>
auto xvec::simd::detail::permute_repeat_each ( generic_tag ,
const _Sp & in )
constexprnoexcept

A named permute which creates N copies of each element.

Template Parameters
_NpThe number of repeats of each element.

◆ permute_rotate()

template<int _Middle, vec_or_mask_type _Sp>
auto xvec::simd::detail::permute_rotate ( generic_tag ,
const _Sp & in )
constexprnoexcept

A named permute which rotates the input so that the element at the MIDDLE index becomes the first element.

Template Parameters
_MiddleThe _Middle index, which will be moved to the first index.

◆ permute_stride()

template<int _Np, vec_or_mask_type _Sp>
auto xvec::simd::detail::permute_stride ( generic_tag ,
const _Sp & in )
constexprnoexcept

A named permute which extracts every N'th value, discarding values which do not have indexes which are multiples of N.

Template Parameters
_NpThe multiple of the element indexes to read from.

◆ permute_take()

template<int _Np, vec_or_mask_type _Sp>
auto xvec::simd::detail::permute_take ( generic_tag ,
const _Sp & in )
constexpr

A named permute which keeps the first _Np values of a simd and discards the remainder.

Template Parameters
_NpThe number of elements to keep.

◆ permute_unzip()

template<int _Np, vec_or_mask_type _Sp>
auto xvec::simd::detail::permute_unzip ( generic_tag ,
const _Sp & in )
constexprnoexcept

Unzip breaks a vec or mask down into N smaller objects, where each vec or mask is the values at the stride of N and offset by the output index. For example, unzip<2>([a 0 b 1 c 2]) will become [a b c] [0 1 2].

Template Parameters
_NpThe number of simds to create.

◆ permute_zip()

template<vec_or_mask_type... _Sps>
auto xvec::simd::detail::permute_zip ( generic_tag ,
const _Sps &... simds )
constexprnoexcept

zip takes one or more vec or mask values and produces a new vec or mask where all the i'th elements are moved into contiguous positions. For example, zip([a b c], [0 1 2]) becomes [a 0 b 1 c 2]. The output size is limited by the smallest of the inputs.

◆ popcount()

template<typename _Tp, typename _Abi>
basic_vec< _Tp, _Abi > xvec::simd::detail::popcount ( x86_sse_tag ,
const basic_vec< _Tp, _Abi > & x )
constexprnoexcept

}@

Compute the number of 1 bits in each vec element

Parameters
xThe value to query
Returns
A vec containing the number of 1 bits found in each respective element.

◆ reduce_helper()

template<simd_size_type _Size, typename _Tp, typename _Abi, binary_reduction_fn< _Tp > _BinaryFn>
_Tp xvec::simd::detail::reduce_helper ( const basic_vec< _Tp, _Abi > & v,
_BinaryFn binop )
inline

Reduction helper function. This works by splitting down into two approximately equal power-of-2 sized pairs, and then applying the binary operator, before recursively applying. Note that the size is passed in explicitly so that when the reduction has dropped below the minimum register size, the incoming argument can remain a simd register.

◆ saturating_cast()

template<saturation_integer To, saturation_integer From>
To xvec::simd::detail::saturating_cast ( From value)
nodiscardconstexprnoexcept

Convert an integer to another integer type, clamping values outside the destination type's representable range.

◆ set_element() [1/3]

template<mask_type _Mp>
_Mp xvec::simd::detail::set_element ( compact_mask_tag ,
const _Mp & m,
int index,
bool new_value )
constexpr

Return a copy of the incoming vec_or_mask_type value, with the element at the given index replaced with the new value.

◆ set_element() [2/3]

template<mask_type _Mp>
_Mp xvec::simd::detail::set_element ( generic_tag ,
const _Mp & m,
int index,
bool new_value )
constexpr

Return a copy of the incoming vec_or_mask_type value, with the element at the given index replaced with the new value.

◆ set_element() [3/3]

template<vec_type _Vp>
_Vp xvec::simd::detail::set_element ( generic_tag ,
const _Vp & v,
int index,
typename _Vp::value_type new_value )
constexpr

Return a copy of the incoming vec_or_mask_type value, with the element at the given index replaced with the new value.

◆ shuffle_epi8()

__m128i xvec::simd::detail::shuffle_epi8 ( __m128i values,
__m128i indexes )
inline

In-lane (128-bit) byte shuffles

◆ shuffle_epi8_lut()

template<typename _Gen, typename _Abi>
basic_vec< std::uint8_t, _Abi > xvec::simd::detail::shuffle_epi8_lut ( _Gen ,
basic_vec< std::uint8_t, _Abi > indexes )
constexpr

Perform a shuffle_epi8 from a table of bytes created from the given generator. This is a basic building block for many bit query operations (e.g., popcount, bit reverse). It can be implemented efficiently by using the lane-wise shuffle_epi8 instruction, where the LUT is duplicated into each lane. Ths indexing behaves exactly like a shuffle_epi8 (i.e., use the bottom 4 bits as a lane-wise index, zeroing if the index MSB is set). The name is chosen to reflect this specialist use (i.e., this is not a general 4-bit lut).

◆ signbit()

template<detail::math_floating_point _Vp>
detail::deduced_mask_t< _Vp > xvec::simd::detail::signbit ( generic_tag ,
const _Vp & v )
constexpr

Generic implementation of sign-bit classification.

◆ splitNHelper()

template<simd_size_type _Begin, simd_size_type _Np, vec_or_mask_type _Sp>
auto xvec::simd::detail::splitNHelper ( const _Sp & v)
constexpr

Split the incoming vec_or_mask_type value into smaller values no bigger than size N (i.e., multiple blocks of size N, and possibly one remainder block less than N).

Template Parameters
_BeginThe starting position in the input vector to extract from
_NpThe maximum number of elements to include in each extracted block
_SpThe type of the input vec or mask value
Parameters
vThe vec or mask value to split
Returns
A tuple of smaller vec or mask values

◆ store()

template<vec_type _Vp, typename _Up, std::size_t _Extent, typename _Flags>
void xvec::simd::detail::store ( x86_tag ,
const _Vp & value_original,
std::span< _Up, _Extent > to,
_Flags flags )
constexpr

Special case code for handling 4 and 8 byte masked stores on Intel AVX2. This is faster than using the Intel SSE variant above.

Store up to a native-sized value to memory. All x86 ISAs are handled here.

◆ store_masked()

template<vec_type _Vp, typename _Up, std::size_t _Extent, typename _Flags>
void xvec::simd::detail::store_masked ( x86_tag ,
const _Vp & value_original,
std::span< _Up, _Extent > to,
const typename _Vp::mask_type & mask_original,
_Flags flags )
constexpr

Implement masked stores for Intel SSE and Intel AVX targets.

Template Parameters
_Vpthe type of the source.
_UpThe element type for the vec being stored.
_ExtentThe extent of the output span.
_FlagsMemory flags. This can be used to enable or disable boundary checking.
Parameters
value_originalThe vec value to write to memory.
toThe output buffer as a span.
mask_originalThe mask value controlling which vec elements will be written to memory.
flagsMemory flags. This can be used to enable or disable boundary checking.

◆ to_container()

template<vec_type _V>
auto xvec::simd::detail::to_container ( const _V & v)
constexpr

Convert a vec value into a vec of container elements. This allows a permute to be written in terms of raw bits in a container without having to care about the actual element type.

◆ vec_to_mask()

template<mask_type _M, vec_type _V>
_M xvec::simd::detail::vec_to_mask ( const _V & s)
constexpr

Utility to convert a vec into a mask, such that a zero element in the input gives false, otherwise trye in the mask output. This is used to allow constexpr permutations of mask to be implemented by converting a mask into a vec, performing the required permute, and then converting the permuted vec back into a mask.

The most concise way to convert a vec into a mask is to do asSimd != 0 but that would invoke operator!= which is unimplemented (issue #538) for very large element types (e.g., complex<double>, which is represented as an int128_t). Instead we use a mask generator to built the mask elements one-by-one, which wouldn't be efficient if executed at run-time but it doesn't matter because this is consteval code. :TODO: Even better if this were a consteval function, but until C++23 we can't do that.

Note that the type of mask is supplied so that the appropriate return type is used by the caller instead of whatever the default would be for the incoming vec (e.g., the incoming vec might be a container, not the actual vec type being permuted.

◆ x86_fp_classify_mask()

template<int _Op, typename _Tp, typename _Abi>
auto xvec::simd::detail::x86_fp_classify_mask ( const basic_vec< _Tp, _Abi > & value)
inline

Classify the floating-point vec values using the fpclassify intrinsic.

Template Parameters
_TpThe type of floating-point value to classify
_MpThe type of mask element to generate for the given floating-point value
_RpThe result mask to generate
_OpThe set of immediate values for fp_classify to query.
_NpThe number of vec elements.
Parameters
valueA set of floating-point vec values
Returns
A compact mask which has a bit set if the corresponding element in the input meets the classification requirements, and false otherwise.

Variable Documentation

◆ any_same_v

template<class T, class... Us>
bool xvec::simd::detail::any_same_v = (std::same_as<std::remove_cvref_t<T>, Us> || ...)
inlineconstexpr

Small helper: is T the same (after cvref-stripping) as any of Us...? Used by mask_operator and other "T must be one of these" concepts.

◆ arg_native_size

template<typename _Tp>
auto xvec::simd::detail::arg_native_size = _Tp::never_instantiated
inlineconstexpr

Compute the native size of a vec or mask type. _Tp::never_instantiated is a trick to make sure we never instantiate primary template

◆ dependent_false

template<typename>
bool xvec::simd::detail::dependent_false = false
inlineconstexpr

Define a utility to provoke a static_assert failure in certain unreachable constexpr statements. It can be used like this:

if constexpr (someCompileTimeExpr) doSomething(); else vec_unreachable();

A plain static_assert wouldn't work there (prior to C++23) as it would always be evaluated.

◆ has_native_support_for_classify

template<typename _Tp>
bool xvec::simd::detail::has_native_support_for_classify
constexpr
Initial value:
=
detail::is_floating_point_v<_Tp> && (hasAvxFp16 || !is_fp16_v<_Tp>)
constexpr bool is_fp16_v
Definition utilities.hpp:90

Detect whether native classification support is available for the given type. Emulated FP16 has no such support, but native FP16 does.

Template Parameters
_TpThe type to query for classification support.

◆ is_fp16_v

template<typename _T>
bool xvec::simd::detail::is_fp16_v = false
inlineconstexpr

Compile time query to determine whether the given type is a half-precision float. Not every platform supports this so we can't use std::is_same directly.

◆ max_fixed_size

template<typename _Tp>
simd_size_type xvec::simd::detail::max_fixed_size = 128
inlineconstexpr

The implementation-defined upper limit on size. Currently constrainted by how big a compact mask can be (__int128_t).

◆ maxBytesInVec

int xvec::simd::detail::maxBytesInVec = 16
inlineconstexpr

Generic version must make some assumption about the maximum register size and mask type in order to provide some basic functionality. These can be overridden by targets which have different capabilities. In practice, a completely generic version would be scalar, but the default is set to 128-bit vectors and wide masks to allow the library to be used in a more efficient way on targets which support that without needing to write target-specific code.

◆ needs_explicit_conversion_v

template<typename _From, typename _To>
bool xvec::simd::detail::needs_explicit_conversion_v
inlineconstexpr
Initial value:

Determine whether a simd element conversion from _From to _To must be explicit. For builtin vectorizable types (arithmetic, __int128, complex), this uses the traditional value-preserving and rank-based rules from [simd.ctor]. For all other types (enums, UDTs, or mixed builtin/UDT conversions), P2964R2 specifies that simd defers to the type author's judgment: if the scalar conversion is implicit (is_convertible_v is true), the simd conversion is implicit; if the scalar conversion requires explicit construction, so does the simd conversion.

◆ value_preserving_convertible_to_v

template<typename _From, typename _To>
bool xvec::simd::detail::value_preserving_convertible_to_v
inlineconstexpr

Concept to determine whether a value of one scalar type can be converted to another in a way which preserves every possible value.

◆ wrapped_value_is_representable_by_v

template<class Wrapper, class To>
bool xvec::simd::detail::wrapped_value_is_representable_by_v
inlineconstexpr
Initial value:
= []{
using From = std::remove_cvref_t<decltype(Wrapper::value)>;
if constexpr (std::is_integral_v<From> && std::is_integral_v<To>) {
return std::in_range<To>(Wrapper::value);
} else if constexpr (roundtrippable<From, To>) {
return roundtrip_preserves_value<To>(Wrapper::value);
} else {
return false;
}
}()
Definition core.hpp:256