10#include "helpers/argon_for.hpp"
13#ifdef __ARM_FEATURE_MVE
20#define ace [[nodiscard]] [[gnu::always_inline]] constexpr
22#define ace [[nodiscard]] [[gnu::always_inline]] inline
33template <
typename N,
typename W>
34concept widenable_from = std::is_integral_v<N> && std::is_integral_v<W> &&
sizeof(N) <
sizeof(W) &&
sizeof(W) <= 4;
39enum class DotForm { Plain, Exchange, Subtract, SubtractExchange };
42template <
typename ScalarType>
48 using vector_type = simd::Vec128_t<ScalarType>;
51 static_assert(simd::is_quadword_v<vector_type>);
53 static constexpr size_t bytes = 16;
54 static constexpr size_t lanes = bytes /
sizeof(ScalarType);
63 [[gnu::always_inline]]
constexpr Argon(vector_type vector) : T{vector} {}
67 template <
size_t LaneIndex>
70 template <
typename... ArgTypes>
71 requires(
sizeof...(ArgTypes) > 1)
72 [[gnu::always_inline]]
constexpr Argon(ArgTypes... args) : T{args...} {}
79 ace
Argon(std::array<ScalarType, 4> value_list) : T{FromFour(value_list)} {};
83 template <
typename S = ScalarType>
84 requires std::is_same_v<S, ScalarType>
88 ace
Argon(argon::ConstLane<0, vector_type> b) : T{b} {};
90 template <simd::is_vector_type
intrinsic_type>
91 ace
Argon(argon::Lane<intrinsic_type> b) : T{b} {};
96 template <
typename new_scalar_type>
98 return simd::reinterpret<simd::Vec128_t<new_scalar_type>>(this->vec_);
101#ifndef ARGON_PLATFORM_MVE
106 return simd::combine(low, high);
112 auto rev_half = this->Reverse64bit();
113 return Combine(rev_half.GetHigh(), rev_half.GetLow());
118 template <
typename U>
120 std::is_same_v<U, typename argon::helpers::NextSmaller<ScalarType>::type>
122 return simd::multiply_add_long(this->vec_, b, c);
125 template <
typename U,
typename C>
127 std::is_same_v<C, simd::Vec64_t<argon::helpers::NextSmaller_t<ScalarType>>>
129 return simd::multiply_add_long(this->vec_, b, c);
133 template <
typename U>
135 std::is_same_v<U, typename argon::helpers::NextSmaller<ScalarType>::type>
137 return simd::multiply_add_long(this->vec_, b, c);
141 template <
typename U>
143 std::is_same_v<U, typename argon::helpers::NextSmaller<ScalarType>::type>
145 return simd::multiply_add_long(this->vec_, b, c.vec(), c.lane());
149 template <
typename U>
151 std::is_same_v<U, typename argon::helpers::NextSmaller<ScalarType>::type>
153 return simd::multiply_subtract_long(this->vec_, b, c);
157 template <
typename U>
159 std::is_same_v<U, typename argon::helpers::NextSmaller<ScalarType>::type>
161 return simd::multiply_subtract_long(this->vec_, b, c);
165 template <
typename U>
167 std::is_same_v<U, typename argon::helpers::NextSmaller<ScalarType>::type>
169 return simd::multiply_subtract_long(this->vec_, b, c.vec(), c.lane());
177 auto result = simd::add_narrow(this->vec_, b);
185 auto result = simd::add_round_narrow(this->vec_, b);
193 auto result = simd::subtract_narrow(this->vec_, b);
201 auto result = simd::subtract_round_narrow(this->vec_, b);
210 auto result = simd::shift_right_narrow<n>(this->vec_);
219 auto result = simd::shift_right_saturate_narrow<n>(this->vec_);
228 auto result = simd::shift_right_round_saturate_narrow<n>(this->vec_);
237 auto result = simd::shift_right_round_narrow<n>(this->vec_);
243 requires
argon::helpers::has_smaller_v<ScalarType>
245 auto result = simd::move_narrow(this->vec_);
251 requires
argon::helpers::has_smaller_v<ScalarType>
253 auto result = simd::move_saturate_narrow(this->vec_);
258 template <
typename NextSmallerType>
260 std::is_same_v<NextSmallerType, argon::helpers::NextSmaller_t<ScalarType>>
262 return neon::multiply_double_add_saturate_long(this->vec_, b, c);
280 template <
typename S = ScalarType>
281 requires(std::is_integral_v<S> &&
sizeof(S) <= 2)
283#ifdef ARGON_PLATFORM_MVE
284 return mve::move_long_bottom(this->vec_);
286 constexpr int half = 8 *
sizeof(S);
292 template <
typename S = ScalarType>
293 requires(std::is_integral_v<S> &&
sizeof(S) <= 2)
295#ifdef ARGON_PLATFORM_MVE
296 return mve::move_long_top(this->vec_);
298 constexpr int half = 8 *
sizeof(S);
304 template <
int n,
typename S = ScalarType>
305 requires(std::is_integral_v<S> &&
sizeof(S) <= 2 && n >= 1 && n <= 8 *
int{
sizeof(S)})
307#ifdef ARGON_PLATFORM_MVE
308 return mve::shift_left_long_bottom<n>(this->vec_);
315 template <
int n,
typename S = ScalarType>
316 requires(std::is_integral_v<S> &&
sizeof(S) <= 2 && n >= 1 && n <= 8 *
int{
sizeof(S)})
318#ifdef ARGON_PLATFORM_MVE
319 return mve::shift_left_long_top<n>(this->vec_);
326 template <
typename S = ScalarType>
327 requires(std::is_integral_v<S> &&
sizeof(S) <= 4)
329#ifdef ARGON_PLATFORM_MVE
330 return mve::multiply_long_bottom(this->vec_, b.
vec());
332 return BottomLanes(*
this) * BottomLanes(b);
337 template <
typename S = ScalarType>
338 requires(std::is_integral_v<S> &&
sizeof(S) <= 4)
340#ifdef ARGON_PLATFORM_MVE
341 return mve::multiply_long_top(this->vec_, b.
vec());
343 return TopLanes(*
this) * TopLanes(b);
349 template <
typename S = ScalarType>
350 requires(std::is_integral_v<S> && (
sizeof(S) == 2 ||
sizeof(S) == 4))
352#ifdef ARGON_PLATFORM_MVE
353 return mve::move_narrow_bottom(dest.vec(), this->vec_);
355 return InsertBottom(dest, *
this);
361 template <
typename S = ScalarType>
362 requires(std::is_integral_v<S> && (
sizeof(S) == 2 ||
sizeof(S) == 4))
364#ifdef ARGON_PLATFORM_MVE
365 return mve::move_narrow_top(dest.vec(), this->vec_);
367 return InsertTop(dest, *
this);
372 template <
typename S = ScalarType>
373 requires(std::is_integral_v<S> && (
sizeof(S) == 2 ||
sizeof(S) == 4))
375#ifdef ARGON_PLATFORM_MVE
376 return mve::move_narrow_saturate_bottom(dest.vec(), this->vec_);
383 template <
typename S = ScalarType>
384 requires(std::is_integral_v<S> && (
sizeof(S) == 2 ||
sizeof(S) == 4))
386#ifdef ARGON_PLATFORM_MVE
387 return mve::move_narrow_saturate_top(dest.vec(), this->vec_);
393#ifdef ARGON_PLATFORM_MVE
394#define ARGON_SHIFT_NARROW_BODY(mve_name, Insert, neon_value) return mve::mve_name<n>(dest.vec(), this->vec_);
396#define ARGON_SHIFT_NARROW_BODY(mve_name, Insert, neon_value) return Insert(dest, neon_value);
399#define ARGON_SHIFT_NARROW(Name, mve_name, Insert, neon_value) \
400 template <int n, typename S = ScalarType> \
401 requires(std::is_integral_v<S> && (sizeof(S) == 2 || sizeof(S) == 4) && n >= 1 && n <= 4 * int{sizeof(S)}) \
402 ace Argon<argon::helpers::NextSmaller_t<S>> Name(Argon<argon::helpers::NextSmaller_t<S>> dest) \
403 const {ARGON_SHIFT_NARROW_BODY(mve_name, Insert, neon_value)}
408 ARGON_SHIFT_NARROW(ShiftRightNarrowTop, shift_right_narrow_top, InsertTop, this->template
ShiftRight<n>())
411 shift_right_narrow_round_bottom,
416 shift_right_narrow_round_top,
422 shift_right_narrow_saturate_bottom,
427 shift_right_narrow_saturate_top,
433 shift_right_narrow_round_saturate_bottom,
439 shift_right_narrow_round_saturate_top,
442#undef ARGON_SHIFT_NARROW
443#undef ARGON_SHIFT_NARROW_BODY
452 using dot_type = std::conditional_t<std::is_signed_v<ScalarType>, int32_t, uint32_t>;
454 using dot_long_type = std::conditional_t<std::is_signed_v<ScalarType>, int64_t, uint64_t>;
460 template <DotForm form = DotForm::Plain,
typename S = ScalarType>
461 requires(std::is_integral_v<S> &&
sizeof(S) <= 4 && (form == DotForm::Plain || std::is_signed_v<S>))
463#ifdef ARGON_PLATFORM_MVE
464 if constexpr (form == DotForm::Plain) {
465 return mve::multiply_add_dual_reduce_add_accumulate(acc, this->vec_, b.
vec());
466 }
else if constexpr (form == DotForm::Exchange) {
467 return mve::multiply_add_dual_reduce_add_accumulate_exchange_pairs(acc, this->vec_, b.
vec());
468 }
else if constexpr (form == DotForm::Subtract) {
469 return mve::multiply_subtract_dual_reduce_add_accumulate(acc, this->vec_, b.
vec());
471 return mve::multiply_subtract_dual_reduce_add_accumulate_exchange_pairs(acc, this->vec_, b.
vec());
474 using U = std::make_unsigned_t<dot_type>;
475 if constexpr (form == DotForm::Plain) {
479 if constexpr (
sizeof(S) == 1) {
484 }
else if constexpr (
sizeof(S) == 2) {
489 return static_cast<dot_type>(
static_cast<U
>(acc) +
static_cast<U
>(lanes_sum));
491 U sum =
static_cast<U
>(acc);
492 for (
auto p : DotProducts<form>(b))
493 sum +=
static_cast<U
>(p);
501 template <DotForm form = DotForm::Plain,
typename S = ScalarType>
502 requires(std::is_integral_v<S> && (
sizeof(S) == 2 ||
sizeof(S) == 4) &&
503 (form == DotForm::Plain || std::is_signed_v<S>))
505#ifdef ARGON_PLATFORM_MVE
506 if constexpr (form == DotForm::Plain) {
507 return mve::multiply_add_long_dual_reduce_add_accumulate(acc, this->vec_, b.
vec());
508 }
else if constexpr (form == DotForm::Exchange) {
509 return mve::multiply_add_long_dual_reduce_add_accumulate_exchange_pairs(acc, this->vec_, b.
vec());
510 }
else if constexpr (form == DotForm::Subtract) {
511 return mve::multiply_subtract_long_dual_reduce_add_accumulate(acc, this->vec_, b.
vec());
513 return mve::multiply_subtract_long_dual_reduce_add_accumulate_exchange_pairs(acc, this->vec_, b.
vec());
516 if constexpr (form == DotForm::Plain &&
sizeof(S) == 2) {
522 return static_cast<dot_long_type>(
static_cast<uint64_t
>(acc) +
static_cast<uint64_t
>(lanes_sum));
524 uint64_t sum =
static_cast<uint64_t
>(acc);
525 for (
auto p : DotProducts<form>(b))
536 template <DotForm form = DotForm::Plain,
typename S = ScalarType>
537 requires(std::is_integral_v<S> &&
sizeof(S) == 4 && (form == DotForm::Plain || std::is_signed_v<S>))
539#ifdef ARGON_PLATFORM_MVE
540 if constexpr (form == DotForm::Plain) {
541 return mve::multiply_add_long_round_dual_reduce_add_high_accumulate(acc, this->vec_, b.
vec());
542 }
else if constexpr (form == DotForm::Exchange) {
543 return mve::multiply_add_long_round_dual_reduce_add_high_accumulate_exchange_pairs(acc, this->vec_, b.
vec());
544 }
else if constexpr (form == DotForm::Subtract) {
545 return mve::multiply_subtract_long_round_dual_reduce_add_high_accumulate(acc, this->vec_, b.
vec());
547 return mve::multiply_subtract_long_round_dual_reduce_add_high_accumulate_exchange_pairs(acc, this->vec_, b.
vec());
550 uint64_t sum =
static_cast<uint64_t
>(acc);
551 for (
auto p : DotProducts<form>(b)) {
552 sum +=
static_cast<uint64_t
>((p + 128) >> 8);
561 template <
typename S = ScalarType>
562 requires(std::is_integral_v<S> && std::is_signed_v<S> &&
sizeof(S) <= 4)
577 template <
int step = 1,
typename S = ScalarType>
578 requires(std::is_unsigned_v<S> &&
sizeof(S) <= 4 && (step == 1 || step == 2 || step == 4 || step == 8))
580#ifdef ARGON_PLATFORM_MVE
583 uint32_t next = offset;
584 typename Argon<S>::vector_type indices;
585 if constexpr (
sizeof(S) == 1) {
586 indices = viwdupq_wb_u8(&next,
size, step);
587 }
else if constexpr (
sizeof(S) == 2) {
588 indices = viwdupq_wb_u16(&next,
size, step);
590 indices = viwdupq_wb_u32(&next,
size, step);
595 std::array<S, lanes> out{};
596 for (
auto& lane : out) {
597 lane =
static_cast<S
>(offset);
611 template <
int step = 1,
typename S = ScalarType>
612 requires(std::is_unsigned_v<S> &&
sizeof(S) <= 4 && (step == 1 || step == 2 || step == 4 || step == 8))
614#ifdef ARGON_PLATFORM_MVE
615 uint32_t next = offset;
616 typename Argon<S>::vector_type indices;
617 if constexpr (
sizeof(S) == 1) {
618 indices = vdwdupq_wb_u8(&next,
size, step);
619 }
else if constexpr (
sizeof(S) == 2) {
620 indices = vdwdupq_wb_u16(&next,
size, step);
622 indices = vdwdupq_wb_u32(&next,
size, step);
627 std::array<S, lanes> out{};
628 for (
auto& lane : out) {
629 lane =
static_cast<S
>(offset);
646 template <
typename N,
typename S = ScalarType>
649#ifdef ARGON_PLATFORM_MVE
650 return Argon<S>{WidenMve<N, S>(ptr)};
652 if constexpr (
sizeof(S) == 2 *
sizeof(N)) {
654 const auto wide = neon::move_long(neon::load1<neon::Vec64_t<N>>(ptr));
658 std::array<S, lanes> out{};
659 for (
size_t i = 0; i < lanes; ++i)
660 out.data()[i] =
static_cast<S
>(ptr[i]);
668 template <
typename N,
typename S = ScalarType>
671#ifdef ARGON_PLATFORM_MVE
674 std::array<S, lanes> out{};
675 for (
size_t i = 0; i < lanes; ++i) {
677 out.data()[i] =
static_cast<S
>(ptr[i]);
684 template <
typename N,
typename S = ScalarType>
687#ifdef ARGON_PLATFORM_MVE
690 if constexpr (
sizeof(S) == 2 *
sizeof(N)) {
692 using SameSign = std::conditional_t<std::is_signed_v<N>, std::make_signed_t<S>, std::make_unsigned_t<S>>;
693 neon::store1(ptr, neon::move_narrow(this->
template As<SameSign>().
vec()));
696 for (
size_t i = 0; i < lanes; ++i)
697 ptr[i] =
static_cast<N
>(values.data()[i]);
703 template <
typename N,
typename S = ScalarType>
706#ifdef ARGON_PLATFORM_MVE
707 NarrowMve<N>(ptr, active.
native());
710 for (
size_t i = 0; i < lanes; ++i) {
712 ptr[i] =
static_cast<N
>(values.data()[i]);
718 template <
typename N,
typename S = ScalarType,
typename... PredicateType>
722 PredicateType... active) {
723 return GatherWiden<false, N, S>(base, offsets, active...);
727 template <
typename N,
typename S = ScalarType,
typename... PredicateType>
731 PredicateType... active) {
732 return GatherWiden<true, N, S>(base, offsets, active...);
736 template <
typename N,
typename S = ScalarType,
typename... PredicateType>
740 PredicateType... active)
const {
741 ScatterNarrow<false>(base, offsets, active...);
745 template <
typename N,
typename S = ScalarType,
typename... PredicateType>
749 PredicateType... active)
const {
750 ScatterNarrow<true>(base, offsets, active...);
759 template <
typename S = ScalarType>
760 requires(
sizeof(S) <= 4)
762#ifdef ARGON_PLATFORM_MVE
764 if constexpr (
sizeof(S) == 2) {
765 return vcaddq_rot90_f16(this->vec_, b.
vec());
767 return vcaddq_rot90_f32(this->vec_, b.
vec());
770 return mve::complex_add_rotate_90(this->vec_, b.
vec());
773#ifdef __ARM_FEATURE_COMPLEX
775 return neon::complex_add_rotate_90(this->vec_, b.
vec());
777 const auto swapped = SwapPairs(b);
778 return EvenLanes().Select(*
this - swapped, *
this + swapped);
783 template <
typename S = ScalarType>
784 requires(
sizeof(S) <= 4)
786#ifdef ARGON_PLATFORM_MVE
788 if constexpr (
sizeof(S) == 2) {
789 return vcaddq_rot270_f16(this->vec_, b.
vec());
791 return vcaddq_rot270_f32(this->vec_, b.
vec());
794 return mve::complex_add_rotate_270(this->vec_, b.
vec());
797#ifdef __ARM_FEATURE_COMPLEX
799 return neon::complex_add_rotate_270(this->vec_, b.
vec());
801 const auto swapped = SwapPairs(b);
802 return EvenLanes().Select(*
this + swapped, *
this - swapped);
807 template <
typename S = ScalarType>
808 requires(std::is_integral_v<S> && std::is_signed_v<S> &&
sizeof(S) <= 4)
810#ifdef ARGON_PLATFORM_MVE
811 return mve::complex_add_rotate_90_halve(this->vec_, b.
vec());
813 const auto swapped = SwapPairs(b);
819 template <
typename S = ScalarType>
820 requires(std::is_integral_v<S> && std::is_signed_v<S> &&
sizeof(S) <= 4)
822#ifdef ARGON_PLATFORM_MVE
823 return mve::complex_add_rotate_270_halve(this->vec_, b.
vec());
825 const auto swapped = SwapPairs(b);
834 template <
int rotation,
typename S = ScalarType>
836 (rotation == 0 || rotation == 90 || rotation == 180 || rotation == 270))
838#if defined(ARGON_PLATFORM_MVE) || defined(__ARM_FEATURE_COMPLEX)
839 if constexpr (rotation == 0) {
840 return simd::complex_multiply_add(this->vec_, b.
vec(), c.
vec());
841 }
else if constexpr (rotation == 90) {
842 return simd::complex_multiply_add_rotate_90(this->vec_, b.
vec(), c.
vec());
843 }
else if constexpr (rotation == 180) {
844 return simd::complex_multiply_add_rotate_180(this->vec_, b.
vec(), c.
vec());
846 return simd::complex_multiply_add_rotate_270(this->vec_, b.
vec(), c.
vec());
849 const auto even = EvenLanes();
850 if constexpr (rotation == 0 || rotation == 180) {
851 const auto real = even.Select(b, SwapPairs(b));
854 const auto imag = even.Select(SwapPairs(b), b);
855 const auto swapped = SwapPairs(c);
857 return rotation == 90 ? even.Select(minus, plus) : even.Select(plus, minus);
863 template <
typename S = ScalarType>
871 template <
typename S = ScalarType>
883 template <
typename S = ScalarType>
884 requires(std::is_integral_v<S> &&
sizeof(S) <= 4)
886#ifdef ARGON_PLATFORM_MVE
887 return mve::bit_reverse_shift_right(this->vec_,
static_cast<int32_t
>(bits));
889 using U = std::make_unsigned_t<S>;
890 constexpr int width = 8 *
sizeof(S);
896 bytes = neon::reverse_bits(bytes.vec());
900 bytes = (bytes >> 4) | (bytes << 4);
902 if constexpr (
sizeof(S) == 2) {
903 bytes = bytes.Reverse16bit();
904 }
else if constexpr (
sizeof(S) == 4) {
905 bytes = bytes.Reverse32bit();
907 const auto reversed = bytes.template
As<U>();
908 return (bits >= width ? reversed : reversed >> (width - bits)).template
As<S>();
918 template <
typename S = ScalarType>
919 requires(std::is_integral_v<S> &&
sizeof(S) == 4)
921#ifdef ARGON_PLATFORM_MVE
922 unsigned c = carry & 1;
924 if constexpr (std::is_signed_v<S>) {
925 out = vadcq_s32(this->vec_, b.
vec(), &c);
927 out = vadcq_u32(this->vec_, b.
vec(), &c);
933 std::array<uint32_t, 4> sum{};
934 uint64_t c = carry & 1;
935 for (
size_t i = 0; i < 4; ++i) {
936 c += uint64_t{x[i]} + y[i];
937 sum[i] =
static_cast<uint32_t
>(c);
940 carry =
static_cast<uint32_t
>(c);
947 template <
typename S = ScalarType>
948 requires(std::is_integral_v<S> &&
sizeof(S) == 4)
950#ifdef ARGON_PLATFORM_MVE
951 unsigned c = 1 - (borrow & 1);
953 if constexpr (std::is_signed_v<S>) {
954 out = vsbcq_s32(this->vec_, b.
vec(), &c);
956 out = vsbcq_u32(this->vec_, b.
vec(), &c);
962 std::array<uint32_t, 4> difference{};
963 uint64_t owed = borrow & 1;
964 for (
size_t i = 0; i < 4; ++i) {
965 const uint64_t subtrahend = uint64_t{y[i]} + owed;
966 difference[i] =
static_cast<uint32_t
>(uint64_t{x[i]} - subtrahend);
967 owed = subtrahend > x[i];
969 borrow =
static_cast<uint32_t
>(owed);
977 template <
int n,
typename S = ScalarType>
978 requires(std::is_integral_v<S> &&
sizeof(S) <= 4 && n >= 1 && n <= 32)
980#ifdef ARGON_PLATFORM_MVE
985 return out.template
As<S>();
987 const auto x = this->
template As<uint32_t>().to_array();
988 std::array<uint32_t, 4> shifted{};
989 const uint64_t in_mask = n == 32 ? ~uint32_t{0} : ((uint32_t{1} << n) - 1);
990 uint64_t incoming = carry & in_mask;
991 for (
size_t i = 0; i < 4; ++i) {
992 const uint64_t wide = (uint64_t{x[i]} << n) | incoming;
993 shifted[i] =
static_cast<uint32_t
>(wide);
994 incoming = wide >> 32;
996 carry =
static_cast<uint32_t
>(incoming);
1003 template <
typename U>
1005#ifndef __ARM_FEATURE_MVE
1007 if constexpr (std::is_same_v<ScalarType, float> && std::is_same_v<U, int32_t>) {
1008 return argon::helpers::convert_to_int32(this->vec_);
1009 }
else if constexpr (std::is_same_v<ScalarType, float> && std::is_same_v<U, uint32_t>) {
1010 return argon::helpers::convert_to_uint32(this->vec_);
1013 return simd::convert<typename simd::Vec128<U>::type>(this->vec_);
1019 template <
typename U,
int fracbits>
1020 requires(std::is_same_v<U, uint32_t> || std::is_same_v<U, int32_t> || std::is_same_v<U, float>)
1022 if constexpr (std::is_same_v<U, float>) {
1023 return simd::convert_n<fracbits>(this->vec_);
1024 }
else if constexpr (std::is_unsigned_v<U>) {
1025#ifndef __ARM_FEATURE_MVE
1026 return argon::helpers::convert_n_to_uint32<fracbits>(this->vec_);
1028 return simd::convert_n_unsigned<fracbits>(this->vec_);
1030 }
else if constexpr (std::is_signed_v<U>) {
1031#ifndef __ARM_FEATURE_MVE
1032 return argon::helpers::convert_n_to_int32<fracbits>(this->vec_);
1034 return simd::convert_n_signed<fracbits>(this->vec_);
1045#ifdef ARGON_PLATFORM_MVE
1047 static constexpr bool mve_across_add = std::is_integral_v<ScalarType> &&
sizeof(ScalarType) < 8;
1050#ifdef ARGON_PLATFORM_MVE
1054 template <
typename OpType>
1055 ScalarType FoldFloatPairs(OpType op)
const {
1056 if constexpr (
lanes == 4) {
1057 Argon pairs = op(*
this, this->Reverse64bit());
1058 return static_cast<ScalarType
>(op(pairs[0], pairs[2]));
1060 Argon pairs = op(*
this, this->Reverse32bit());
1061 Argon quads = op(pairs, pairs.Reverse64bit());
1062 return static_cast<ScalarType
>(op(quads[0], quads[4]));
1067#ifdef ARGON_PLATFORM_NEON
1069 static constexpr bool neon_pairwise_lanes =
1070 (std::is_integral_v<ScalarType> &&
sizeof(ScalarType) <= 4) || std::is_same_v<ScalarType, float>;
1078 template <
typename HalfOp,
typename PairwiseOp>
1079 ace ScalarType FoldHalves(HalfOp op, PairwiseOp pairwise)
const {
1081 if constexpr (lanes >= 4) {
1082 half = pairwise(half);
1084 if constexpr (lanes >= 8) {
1085 half = pairwise(half);
1087 if constexpr (lanes >= 16) {
1088 half = pairwise(half);
1098 template <
typename CommutableOpType>
1099 ScalarType
Reduce(CommutableOpType op)
const {
1101 auto sum = op(*
this, rev);
1102 if constexpr (lanes == 16) {
1103 sum = op(sum, sum.Reverse16bit());
1105 if constexpr (lanes == 8 || lanes == 16) {
1106 sum = op(sum, sum.Reverse32bit());
1108 if constexpr (lanes == 4 || lanes == 8 || lanes == 16) {
1109 sum = op(sum, sum.Reverse64bit());
1116#if defined(__aarch64__)
1118 return simd::reduce_add(this->vec_);
1120#elifdef ARGON_PLATFORM_MVE
1121 if constexpr (mve_across_add) {
1122 return static_cast<ScalarType
>(mve::reduce_add(this->vec_));
1125 return FoldFloatPairs([](
auto a,
auto b) {
return a + b; });
1127#elifdef ARGON_PLATFORM_NEON
1128 if constexpr (neon_pairwise_lanes) {
1129 return FoldHalves([](
auto a,
auto b) {
return a.Add(b); }, [](
auto h) {
return h.PairwiseAdd(h); });
1132 return this->
Reduce([](
auto a,
auto b) {
return a + b; });
1140#ifdef ARGON_PLATFORM_MVE
1141 if constexpr (mve_across_add) {
1142 return static_cast<ScalarType
>(mve::reduce_add(this->vec_, active.
native()));
1151 if constexpr (
requires { simd::reduce_max(this->vec_); }) {
1152 return simd::reduce_max(this->vec_);
1155 return std::reduce(arr.begin(), arr.end(), arr[0], [](
auto a,
auto b) { return std::max(a, b); });
1158#ifdef ARGON_PLATFORM_MVE
1159 if constexpr (std::is_integral_v<ScalarType> &&
sizeof(ScalarType) <= 4) {
1160 return mve::maximum_across_vector(std::numeric_limits<ScalarType>::lowest(), this->vec_);
1163 return FoldFloatPairs([](
auto a,
auto b) {
1164 if constexpr (
requires { a.Max(b); }) {
1167 return a > b ? a : b;
1172#ifdef ARGON_PLATFORM_NEON
1173 if constexpr (neon_pairwise_lanes) {
1174 return FoldHalves([](
auto a,
auto b) {
return a.Max(b); }, [](
auto h) {
return h.PairwiseMax(h); });
1177 return this->
Reduce([](
auto a,
auto b) {
return a.Max(b); });
1184 if constexpr (
requires { simd::reduce_min(this->vec_); }) {
1185 return simd::reduce_min(this->vec_);
1188 return std::reduce(arr.begin(), arr.end(), arr[0], [](
auto a,
auto b) { return std::min(a, b); });
1191#ifdef ARGON_PLATFORM_MVE
1192 if constexpr (std::is_integral_v<ScalarType> &&
sizeof(ScalarType) <= 4) {
1193 return mve::minimum_across_vector(std::numeric_limits<ScalarType>::max(), this->vec_);
1196 return FoldFloatPairs([](
auto a,
auto b) {
1197 if constexpr (
requires { a.Min(b); }) {
1200 return a < b ? a : b;
1205#ifdef ARGON_PLATFORM_NEON
1206 if constexpr (neon_pairwise_lanes) {
1207 return FoldHalves([](
auto a,
auto b) {
return a.Min(b); }, [](
auto h) {
return h.PairwiseMin(h); });
1211 return std::reduce(arr.begin(), arr.end(), arr[0], [](
auto a,
auto b) { return std::min(a, b); });
1217 template <
typename S = ScalarType>
1218 requires(std::is_integral_v<S> && std::is_signed_v<S> &&
sizeof(S) <= 4)
1219 ace std::make_unsigned_t<S>
ReduceMaxAbs(std::make_unsigned_t<S> init = 0)
const {
1220#ifdef ARGON_PLATFORM_MVE
1221 return mve::maximum_absolute_across_vector(init, this->vec_);
1223 using U = std::make_unsigned_t<S>;
1230 template <
typename S = ScalarType>
1231 requires(std::is_integral_v<S> && std::is_signed_v<S> &&
sizeof(S) <= 4)
1233 std::make_unsigned_t<S> init = std::numeric_limits<std::make_unsigned_t<S>>::max())
const {
1234#ifdef ARGON_PLATFORM_MVE
1235 return mve::minimum_absolute_across_vector(init, this->vec_);
1237 using U = std::make_unsigned_t<S>;
1244 template <
typename S = ScalarType>
1245 requires(std::is_integral_v<S> && std::is_unsigned_v<S> &&
sizeof(S) <= 4)
1247#ifdef ARGON_PLATFORM_MVE
1248 return mve::maximum_absolute(this->vec_, b.
vec());
1255 template <
typename S = ScalarType>
1256 requires(std::is_integral_v<S> && std::is_unsigned_v<S> &&
sizeof(S) <= 4)
1258#ifdef ARGON_PLATFORM_MVE
1259 return mve::minimum_absolute(this->vec_, b.
vec());
1267#ifdef ARGON_PLATFORM_MVE
1269 uint64x2_t dwords = simd::reinterpret<uint64x2_t>(this->vec_);
1270 return simd::reinterpret<vector_type>(uint64x2_t{dwords[1], dwords[0]});
1273 return this->
template Extract<lanes / 2>(*this);
1277#if ARGON_HAS_CRYPTO && !defined(ARGON_PLATFORM_MVE)
1283 requires std::is_same_v<ScalarType, uint8_t>
1285 return neon::aes_encrypt(this->vec_, key.vec_);
1293 requires std::is_same_v<ScalarType, uint8_t>
1295 return neon::aes_decrypt(this->vec_, key.vec_);
1302 requires std::is_same_v<ScalarType, uint8_t>
1304 return neon::aes_mix_columns(this->vec_);
1311 requires std::is_same_v<ScalarType, uint8_t>
1313 return neon::aes_inverse_mix_columns(this->vec_);
1318#ifndef ARGON_PLATFORM_MVE
1323 template <
typename S>
1325 constexpr int half = 8 *
sizeof(S);
1330 template <
typename S>
1336 template <
typename W>
1338 using U = std::make_unsigned_t<W>;
1339 return Argon<U>{
static_cast<U
>((U{1} << (4 *
sizeof(W))) - 1)};
1343 template <
typename W>
1347 return LowHalfMask<W>().Select(wide, dest.template
As<W>()).template
As<N>();
1351 template <
typename W>
1355 return LowHalfMask<W>().Select(dest.template
As<W>(), wide.template
ShiftLeft<4 *
sizeof(W)>()).template
As<N>();
1359 template <
typename S>
1361 if constexpr (
sizeof(S) == 1) {
1362 return v.Reverse16bit();
1363 }
else if constexpr (
sizeof(S) == 2) {
1364 return v.Reverse32bit();
1366 return v.Reverse64bit();
1372 using U = std::conditional_t<
sizeof(ScalarType) == 1, uint8_t,
1373 std::conditional_t<
sizeof(ScalarType) == 2, uint16_t, uint32_t>>;
1378 template <DotForm form,
typename S>
1379 ace std::array<std::conditional_t<std::is_signed_v<S>, int64_t, uint64_t>,
Argon<S>::lanes> DotProducts(
1381 using T = std::conditional_t<std::is_signed_v<S>, int64_t, uint64_t>;
1382 constexpr bool exchange = form == DotForm::Exchange || form == DotForm::SubtractExchange;
1385 std::array<T, Argon<S>::lanes> out{};
1386 for (
size_t i = 0; i < out.size(); ++i) {
1387 const size_t j = exchange ? (i ^ 1) : i;
1388 T p =
static_cast<T
>(x[i]) *
static_cast<T
>(y[j]);
1390 const bool negate = form == DotForm::Subtract ? (i & 1) : (form ==
DotForm::SubtractExchange && !(i & 1));
1392 p =
static_cast<T
>(T{0} - p);
1399 template <
typename W>
1402 const Argon<W> high{
static_cast<W
>(std::numeric_limits<N>::max())};
1403 if constexpr (std::is_signed_v<W>) {
1404 return wide.
Min(high).Max(
Argon<W>{
static_cast<W
>(std::numeric_limits<N>::min())});
1406 return wide.
Min(high);
1414 template <
typename N,
typename S>
1415 using ExtendedFrom = std::conditional_t<std::is_signed_v<N>, std::make_signed_t<S>, std::make_unsigned_t<S>>;
1417#ifdef ARGON_PLATFORM_MVE
1418 template <
typename N,
typename S,
typename... P>
1419 ace
static Argon<S> WidenMve(
const N* ptr, P... p) {
1422 if constexpr (
sizeof(N) == 1) {
1423 v = mve::load_byte<native>(ptr, p...);
1425 v = mve::load_halfword<native>(ptr, p...);
1430 template <
typename N,
typename... P>
1431 [[gnu::always_inline]]
inline void NarrowMve(N* ptr, P... p)
const {
1433 if constexpr (
sizeof(N) == 1) {
1434 mve::store_byte(ptr, v, p...);
1436 mve::store_halfword(ptr, v, p...);
1441 template <
bool byte_offsets,
typename N,
typename S,
typename... PredicateType>
1443#ifdef ARGON_PLATFORM_MVE
1444 using native = ExtendedFrom<N, S>;
1446 if constexpr (
sizeof(N) == 1) {
1447 v = mve::load_byte_gather_offset(base, offsets.
vec(), active.native()...);
1448 }
else if constexpr (byte_offsets) {
1449 v = mve::load_halfword_gather_offset(base, offsets.
vec(), active.native()...);
1451 v = mve::load_halfword_gather_shifted_offset(base, offsets.
vec(), active.native()...);
1453 return v.template
As<S>();
1455 const auto off = offsets.
to_array();
1456 std::array<S, lanes> out{};
1457 for (
size_t i = 0; i < lanes; ++i) {
1458 if ((active.Active(i) && ...)) {
1460 byte_offsets ?
reinterpret_cast<const N*
>(
reinterpret_cast<const char*
>(base) + off[i]) : base + off[i];
1461 out[i] =
static_cast<S
>(*p);
1468 template <
bool byte_offsets,
typename N,
typename... PredicateType>
1469 [[gnu::always_inline]]
inline void ScatterNarrow(N* base,
1471 PredicateType... active)
const {
1472#ifdef ARGON_PLATFORM_MVE
1474 if constexpr (
sizeof(N) == 1) {
1475 mve::store_byte_scatter_offset(base, offsets.
vec(), v, active.native()...);
1476 }
else if constexpr (byte_offsets) {
1477 mve::store_halfword_scatter_offset(base, offsets.
vec(), v, active.native()...);
1479 mve::store_halfword_scatter_shifted_offset(base, offsets.
vec(), v, active.native()...);
1482 const auto off = offsets.
to_array();
1483 const auto values = this->
to_array();
1484 for (
size_t i = 0; i < lanes; ++i) {
1485 if ((active.Active(i) && ...)) {
1486 N* p = byte_offsets ?
reinterpret_cast<N*
>(
reinterpret_cast<char*
>(base) + off[i]) : base + off[i];
1487 *p =
static_cast<N
>(values[i]);
1495 ace
static vector_type FromFour(std::array<ScalarType, 4> values) {
1496 if constexpr (lanes <= 4) {
1497 return T::Load(values.data());
1499 std::array<ScalarType, lanes> padded{};
1500 std::copy(values.begin(), values.end(), padded.begin());
1501 return T::Load(padded.data());
1506template <
typename... arg_types>
1507 requires(
sizeof...(arg_types) > 1)
1509Argon(arg_types...) ->
Argon<std::tuple_element_t<0, std::tuple<arg_types...>>>;
1511#ifndef ARGON_PLATFORM_MVE
1512template <
typename VectorType>
1515template <
typename VectorType>
1519template <
typename ScalarType>
1520 requires std::is_scalar_v<ScalarType>
1523template <
typename V>
1524 requires std::is_scalar_v<V>
1529template <
typename V>
1530 requires std::is_scalar_v<V>
1535template <
typename V>
1536 requires std::is_scalar_v<V>
1541template <
typename V>
1542 requires std::is_scalar_v<V>
1549template <
typename T>
1551 static constexpr size_t value = Argon<T>::lanes;
1554template <
size_t Index,
typename T>
1556 static_assert(Index < Argon<T>::lanes);
Provides utility templates and concepts for type traits and compile-time iteration.
ace argon_next_larger MultiplyLong(ArgonHalf< ScalarType > b) const
Multiply this and b, widening each product to the next-larger element type (vector × vector).
Definition argon_half.hpp:201
Definition argon_half.hpp:11
Definition argon_full.hpp:44
void StoreNarrow(N *ptr, typename Argon< S >::argon_bool_type active) const
Store the low bits of the active lanes as N; memory for inactive lanes is not written.
Definition argon_full.hpp:705
ace auto ShiftRightRoundNarrow() const
Shift right, round, and narrow.
Definition argon_full.hpp:236
ScalarType Reduce(CommutableOpType op) const
Fold all lanes into a single scalar using a commutative binary operation.
Definition argon_full.hpp:1099
ace Argon< ScalarType > MultiplyAddLong(ArgonHalf< U > b, typename ArgonHalf< U >::lane_type c)
Multiply a half-vector by a lane and add the widened result (vector × lane).
Definition argon_full.hpp:144
ace Argon< ScalarType > MultiplyAddLong(ArgonHalf< U > b, U c)
Multiply a half-vector by a scalar and add the widened result (vector × scalar).
Definition argon_full.hpp:136
this template ShiftRightRound()) ARGON_SHIFT_NARROW(ShiftRightSaturateNarrowBottom
static ace Argon< S > CircularIndices(uint32_t &offset, uint32_t size)
The next lanes indices of a forward walk through a circular buffer of size elements.
Definition argon_full.hpp:579
constexpr Argon(ArgTypes... args)
Construct from one value per lane, each converted to the lane type.
Definition argon_full.hpp:72
void StoreScatterOffsetBytesNarrow(N *base, typename Argon< S >::offset_type offsets, PredicateType... active) const
Scatter the low bits of each lane as N to base plus a byte offset per lane.
Definition argon_full.hpp:747
ace Argon< ScalarType > MultiplySubtractLong(ArgonHalf< U > b, typename ArgonHalf< U >::lane_type c)
Multiply a half-vector by a lane and subtract the widened result (vector × lane).
Definition argon_full.hpp:168
ace Argon< ScalarType > Reverse() const
Reverse the order of all elements in the 128-bit vector.
Definition argon_full.hpp:1041
ace Argon< S > ComplexAddRotate90(Argon< S > b) const
a + i·b for each complex pair: re = a.re − b.im, im = a.im + b.re. MVE / FCMA: vcadd #90.
Definition argon_full.hpp:761
ace Argon< ScalarType > MultiplySubtractLong(ArgonHalf< U > b, ArgonHalf< U > c)
Multiply two narrower half-vectors and subtract the widened result from this vector (vector × vector)...
Definition argon_full.hpp:152
ace Argon< argon::helpers::NextLarger_t< S > > MultiplyLongBottom(Argon< S > b) const
Multiply the even (bottom) lanes, producing full-width products. MVE: vmullb.
Definition argon_full.hpp:328
ace Argon< S > ShiftLeftWithCarry(uint32_t &carry) const
Shift the whole vector, as a 128-bit number, left by n bits: the low n bits of carry shift in at the ...
Definition argon_full.hpp:979
ace auto Narrow() const
Truncate each lane to the next-smaller element type (no saturation).
Definition argon_full.hpp:242
ace Argon< argon::helpers::NextSmaller_t< S > > SaturateNarrowBottom(Argon< argon::helpers::NextSmaller_t< S > > dest) const
Narrow each lane with saturation into the even (bottom) lanes of dest. MVE: vqmovnb.
Definition argon_full.hpp:374
ARGON_SHIFT_NARROW(ShiftRightRoundNarrowBottom, shift_right_narrow_round_bottom, InsertBottom, this->template ShiftRightRound< n >()) ARGON_SHIFT_NARROW(ShiftRightRoundNarrowTop
Shift each lane right by n and narrow it into the even (bottom) lanes of dest. MVE: vshrnb.
ace Argon< S > ComplexMultiply(Argon< S > b) const
The complex product a·b of each pair. Float lanes. MVE / FCMA: two vcmla.
Definition argon_full.hpp:865
constexpr Argon(vector_type vector)
Construct from the underlying intrinsic vector.
Definition argon_full.hpp:63
ace auto AddRoundNarrow(Argon< ScalarType > b) const
Add, round, and narrow: add b, round the result, and truncate to the next-smaller type.
Definition argon_full.hpp:182
ace auto ShiftRightSaturateNarrow() const
Shift right, saturate, and narrow: shift each lane right by n bits with unsigned saturation.
Definition argon_full.hpp:218
ace std::make_unsigned_t< S > ReduceMaxAbs(std::make_unsigned_t< S > init=0) const
The largest magnitude across the lanes, or init if that is larger: a peak meter.
Definition argon_full.hpp:1219
ace Argon(argon::Vector< vector_type > vec)
Construct from an underlying argon::Vector.
Definition argon_full.hpp:75
void StoreScatterOffsetIndexNarrow(N *base, typename Argon< S >::offset_type offsets, PredicateType... active) const
Scatter the low bits of each lane as N to base[offsets[i]]. MVE: vstrb / vstrh scatter.
Definition argon_full.hpp:738
ace Argon< U > ConvertTo() const
Convert each lane to a different element type.
Definition argon_full.hpp:1004
ScalarType ReduceMin() const
Return the minimum value across all lanes.
Definition argon_full.hpp:1182
constexpr Argon()=default
Leave the lanes uninitialised; value-initialisation (Argon<T>{}) zeroes them.
ace Argon< S > ComplexAddRotate270Halve(Argon< S > b) const
(a − i·b) / 2 without overflow. Signed integer lanes. MVE: vhcadd #270.
Definition argon_full.hpp:821
constexpr Argon(argon::ConstLane< LaneIndex, vector_type > lane)
Duplicate lane LaneIndex of lane's vector across every lane.
Definition argon_full.hpp:68
ScalarType ReduceAdd(typename T::argon_bool_type active) const
Sum the active lanes and return the scalar result.
Definition argon_full.hpp:1139
ace Argon< ScalarType > SwapDoublewords() const
Swap the upper and lower 64-bit halves of the vector.
Definition argon_full.hpp:1266
static ace Argon< next_larger > Combine(ArgonHalf< next_larger > low, ArgonHalf< next_larger > high)
Definition argon_full.hpp:105
ace Argon< S > ComplexMultiplyConjugate(Argon< S > b) const
The complex product a·conj(b) of each pair. Float lanes. MVE / FCMA: two vcmla.
Definition argon_full.hpp:873
ace Argon< argon::helpers::NextLarger_t< S > > MultiplyLongTop(Argon< S > b) const
Multiply the odd (top) lanes, producing full-width products. MVE: vmullt.
Definition argon_full.hpp:339
static ace Argon< S > LoadWiden(const N *ptr)
Load lanes elements of the narrower integer type N and extend each to a lane. MVE: vldrb / vldrh.
Definition argon_full.hpp:648
ace auto SaturateNarrow() const
Saturate and narrow each lane to the next-smaller element type.
Definition argon_full.hpp:250
ace Argon< new_scalar_type > As() const
Reinterpret the vector bits as a vector of a different element type.
Definition argon_full.hpp:97
ace ArgonHalf< ScalarType > GetLow() const
Return the lower 64 bits as an ArgonHalf.
Definition argon_full.hpp:268
ace dot_type DotProduct(Argon< S > b, dot_type acc=0) const
Sum acc and the products of every lane of this vector with the matching lane of b.
Definition argon_full.hpp:462
ace std::make_unsigned_t< S > ReduceMinAbs(std::make_unsigned_t< S > init=std::numeric_limits< std::make_unsigned_t< S > >::max()) const
The smallest magnitude across the lanes, or init if that is smaller.
Definition argon_full.hpp:1232
ace Argon< ScalarType > Reverse()
Reverse the order of all elements across the full 128-bit vector.
Definition argon_full.hpp:111
std::conditional_t< std::is_signed_v< ScalarType >, int64_t, uint64_t > dot_long_type
The 64-bit accumulator of DotProductLong and DotProductRoundHigh.
Definition argon_full.hpp:454
ace Argon< ScalarType > MultiplyAddLong(ArgonHalf< U > b, C c)
Multiply two narrower vectors and add the widened result (vector × raw intrinsic).
Definition argon_full.hpp:128
ace dot_long_type DotProductLong(Argon< S > b, dot_long_type acc=0) const
As DotProduct, with products and sum in 64 bits.
Definition argon_full.hpp:504
ace Argon< argon::helpers::NextLarger_t< S > > ShiftLeftLongBottom() const
Widen the even (bottom) lanes and shift them left by n. MVE: vshllb.
Definition argon_full.hpp:306
std::conditional_t< std::is_signed_v< ScalarType >, int32_t, uint32_t > dot_type
The 32-bit accumulator of DotProduct: int32_t for signed lanes, uint32_t for unsigned.
Definition argon_full.hpp:452
ace ArgonHalf< ScalarType > GetHigh() const
Return the upper 64 bits as an ArgonHalf.
Definition argon_full.hpp:266
ace Argon< S > ComplexMultiplyAdd(Argon< S > b, Argon< S > c) const
Accumulate one rotation of the complex product of b and c into this vector, exactly as vcmla.
Definition argon_full.hpp:837
ace Argon< argon::helpers::NextLarger_t< S > > WidenTop() const
Widen the odd (top) lanes to the next larger type. MVE: vmovlt.
Definition argon_full.hpp:294
this template SaturateToNarrow(this->template ShiftRight< n >())) ARGON_SHIFT_NARROW(ShiftRightSaturateNarrowTop
Shift each lane right by n and narrow it with saturation into the top lanes of dest....
ace Argon< S > AddWithCarry(Argon< S > b, uint32_t &carry) const
Add b and carry (0 or 1) to the vector as 128-bit numbers; carry becomes the carry out.
Definition argon_full.hpp:920
ace Argon< S > ComplexAddRotate270(Argon< S > b) const
a − i·b for each complex pair: re = a.re + b.im, im = a.im − b.re. MVE / FCMA: vcadd #270.
Definition argon_full.hpp:785
ace Argon< argon::helpers::NextLarger_t< S > > ShiftLeftLongTop() const
Widen the odd (top) lanes and shift them left by n. MVE: vshllt.
Definition argon_full.hpp:317
ace Argon< argon::helpers::NextSmaller_t< S > > NarrowBottom(Argon< argon::helpers::NextSmaller_t< S > > dest) const
Narrow each lane (keeping its low half) into the even (bottom) lanes of dest.
Definition argon_full.hpp:351
ace Argon< ScalarType > MultiplyDoubleAddSaturateLong(ArgonHalf< NextSmallerType > b, ArgonHalf< NextSmallerType > c)
Multiply, double, add, and saturate long: this + saturate(2 * b * c) widening to ScalarType.
Definition argon_full.hpp:261
static ace Argon< S > LoadGatherOffsetBytesWiden(const N *base, typename Argon< S >::offset_type offsets, PredicateType... active)
Gather N from base plus a byte offset per lane, extending each to a lane.
Definition argon_full.hpp:729
ace Argon< S > MinAbs(Argon< std::make_signed_t< S > > b) const
Each lane's minimum of this (unsigned) vector and the magnitude of b. MVE: vmina.
Definition argon_full.hpp:1257
constexpr Argon(typename T::scalar_type scalar)
Duplicate a scalar across every lane.
Definition argon_full.hpp:65
ace dot_long_type DotProductRoundHigh(Argon< S > b, dot_long_type acc=0) const
As DotProductLong, but with each product divided by 256 and rounded: acc + Σ ⌊(pᵢ + 128) / 256⌋.
Definition argon_full.hpp:538
ace auto ShiftRightNarrow() const
Shift each lane right by n bits and narrow the result to the next-smaller type.
Definition argon_full.hpp:209
ace Argon< argon::helpers::NextSmaller_t< S > > SaturateNarrowTop(Argon< argon::helpers::NextSmaller_t< S > > dest) const
Narrow each lane with saturation into the odd (top) lanes of dest. MVE: vqmovnt.
Definition argon_full.hpp:385
ace Argon< argon::helpers::NextSmaller_t< S > > NarrowTop(Argon< argon::helpers::NextSmaller_t< S > > dest) const
Narrow each lane (keeping its low half) into the odd (top) lanes of dest.
Definition argon_full.hpp:363
ScalarType ReduceAdd() const
Sum all lanes and return the scalar result.
Definition argon_full.hpp:1115
ace Argon(std::array< ScalarType, 4 > value_list)
Construct from four values: lane i takes value_list[i].
Definition argon_full.hpp:79
ace Argon(ArgonHalf< S > low, ArgonHalf< S > high)
Construct by combining a low and high 64-bit half-vector.
Definition argon_full.hpp:85
ace Argon< S > BitReverse(int bits) const
The low bits bits of each lane, reversed; the other bits are zero.
Definition argon_full.hpp:885
ace Argon< ScalarType > MultiplySubtractLong(ArgonHalf< U > b, U c)
Multiply a half-vector by a scalar and subtract the widened result (vector × scalar).
Definition argon_full.hpp:160
static ace Argon< S > CircularIndicesDown(uint32_t &offset, uint32_t size)
The next lanes indices of a backward walk through a circular buffer of size elements.
Definition argon_full.hpp:613
static ace Argon< S > LoadGatherOffsetIndexWiden(const N *base, typename Argon< S >::offset_type offsets, PredicateType... active)
Gather base[offsets[i]] of the narrower type N, extending each to a lane. MVE: vldrb / vldrh gather.
Definition argon_full.hpp:720
ScalarType ReduceMax() const
Return the maximum value across all lanes.
Definition argon_full.hpp:1149
void StoreNarrow(N *ptr) const
Store the low bits of each lane as the narrower integer type N. MVE: vstrb / vstrh.
Definition argon_full.hpp:686
ace auto SubtractRoundNarrow(Argon< ScalarType > b) const
Subtract, round, and narrow: subtract b, round the result, and truncate to the next-smaller type.
Definition argon_full.hpp:198
ace Argon< S > SubtractWithBorrow(Argon< S > b, uint32_t &borrow) const
Subtract b and borrow (0 or 1) from the vector as 128-bit numbers; borrow becomes the borrow out.
Definition argon_full.hpp:949
ace Argon< argon::helpers::NextLarger_t< S > > WidenBottom() const
Widen the even (bottom) lanes to the next larger type. MVE: vmovlb.
Definition argon_full.hpp:282
ace Argon< S > ComplexAddRotate90Halve(Argon< S > b) const
(a + i·b) / 2 without overflow. Signed integer lanes. MVE: vhcadd #90.
Definition argon_full.hpp:809
ace Argon< ScalarType > MultiplyAddLong(ArgonHalf< U > b, ArgonHalf< U > c)
Multiply two narrower half-vectors and add the widened result to this vector (vector × vector).
Definition argon_full.hpp:121
ace auto AddNarrow(Argon< ScalarType > b) const
Add and narrow: add b to this vector and truncate each lane to the next-smaller type.
Definition argon_full.hpp:174
ace auto SubtractNarrow(Argon< ScalarType > b) const
Subtract and narrow: subtract b and truncate each lane to the next-smaller type.
Definition argon_full.hpp:190
ace Argon< U > ConvertTo() const
Convert each lane to a different type using a fixed-point fractional bit count.
Definition argon_full.hpp:1021
ace std::pair< dot_type, dot_type > ComplexDotProduct(Argon< S > b) const
The complex dot product Σ a·b of vectors of interleaved (real, imaginary) pairs, as {real,...
Definition argon_full.hpp:563
static ace Argon< S > LoadWiden(const N *ptr, typename Argon< S >::argon_bool_type active)
Load and extend the active lanes; inactive lanes are zero and their memory is not read.
Definition argon_full.hpp:670
ace Argon< S > MaxAbs(Argon< std::make_signed_t< S > > b) const
Each lane's maximum of this (unsigned) vector and the magnitude of b: running peak tracking,...
Definition argon_full.hpp:1246
ace auto ShiftRightRoundSaturateNarrow() const
Shift right, round, saturate, and narrow.
Definition argon_full.hpp:227
Represents a single lane of a SIMD vector with the lane index known at compile time.
Definition lane.hpp:35
Represents a single lane of a SIMD vector with a runtime-determined index.
Definition lane.hpp:107
ace storage_type native() const
The native predicate representation: a mask vector on NEON, an mve_pred16_t on MVE.
Definition predicate.hpp:133
ace ArgType Select(ArgType true_value, ArgType false_value) const
Choose each lane from true_value where the predicate is active, and from false_value otherwise.
Definition predicate.hpp:189
ace bool Active(size_t i) const
Whether a single lane is active.
Definition predicate.hpp:246
Represents a SIMD vector with various operations.
Definition vector.hpp:53
simd::Vec128_t< ScalarType > vector_type
Definition vector.hpp:78
ace argon_type MultiplySubtract(argon_type b, argon_type c) const
Definition vector.hpp:540
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 ...
Definition vector.hpp:1715
constexpr VectorType vec() const
Get the underlying SIMD vector.
Definition vector.hpp:312
ace argon_type Multiply(argon_type b) const
Multiply two vectors.
Definition vector.hpp:439
ace argon_type ShiftLeft(const int i) const
Shift the elements of the vector to the left by a specified number of bits.
Definition vector.hpp:367
static ace argon_type Load(const scalar_type *ptr)
Definition vector.hpp:1095
ace argon_type MultiplyAdd(argon_type b, argon_type c) const
Definition vector.hpp:477
ace argon_type Max(argon_type b) const
Definition vector.hpp:821
ace argon_type ShiftRight(const int i) const
Shift the elements of the vector to the right by a specified number of bits.
Definition vector.hpp:358
ace argon_type ShiftRight() const
Definition vector.hpp:1048
ace argon_type AddHalve(argon_type b) const
Definition vector.hpp:397
helpers::ArgonFor_t< simd::make_unsigned_t< Bool_t< simd::Vec128_t< ScalarType > > > > offset_type
Definition vector.hpp:86
ace argon_type Divide(argon_type b) const
Divide two vectors.
Definition vector.hpp:782
static ace int size()
Get the number of elements.
Definition vector.hpp:1767
ace argon_type ShiftLeft() const
Definition vector.hpp:1009
simd::Scalar_t< VectorType > scalar_type
The scalar type of the SIMD vector.
Definition vector.hpp:58
ace std::array< scalar_type, lanes > to_array() const
Definition vector.hpp:319
ace argon_type Absolute() const
Definition vector.hpp:669
static constexpr size_t lanes
Definition vector.hpp:90
ace argon_type Add(argon_type b) const
Add two vectors.
Definition vector.hpp:387
ace argon_type Min(argon_type b) const
Definition vector.hpp:842
ace argon_type SubtractHalve(argon_type b) const
Definition vector.hpp:419
ace argon_type Subtract(argon_type b) const
Subtract two vectors.
Definition vector.hpp:409
Predicate< simd::Vec128_t< ScalarType > > argon_bool_type
Definition vector.hpp:85
A floating-point lane type: float, double, or float16_t where half-float vectors exist.
Definition lane_scalar.hpp:35
A scalar type a vector lane can hold: an arithmetic type, or float16_t where half-float vectors exist...
Definition lane_scalar.hpp:31
Whether lanes of integer type W can be loaded from (and stored as) the narrower integer type N,...
Definition argon_full.hpp:34
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
NextSmaller< T >::type NextSmaller_t
Helper alias to get the next smaller type for a given type.
Definition helpers.hpp:97
constexpr bool has_smaller_v
Helper template to determine if a type has a smaller corresponding type.
Definition helpers.hpp:18
NextLarger< T >::type NextLarger_t
Helper alias to get the next larger type for a given type.
Definition helpers.hpp:75
A 128-bit SIMD vector wrapping a scalar type, providing arithmetic, logical, and data-movement operat...
Definition argon.hpp:30
DotForm
The forms of Argon::DotProduct and friends. See Argon::DotProduct.
Definition argon_full.hpp:39
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
Lane deconstruction feature.
Definition argon_full.hpp:1547