10#include "arm_simd/helpers.hpp"
11#include "arm_simd/helpers/multivector.hpp"
12#include "arm_simd/helpers/scalar.hpp"
13#include "arm_simd/helpers/vec64.hpp"
16#include "helpers/bool.hpp"
17#include "helpers/float_fixups.hpp"
18#include "helpers/mve_compare.hpp"
23#ifdef __ARM_FEATURE_MVE
29#ifdef ARGON_PLATFORM_SIMDE
30#define ace [[gnu::always_inline]] inline
32#define ace [[gnu::always_inline]] constexpr
34#define ace [[gnu::always_inline]] inline
45template <
typename T,
typename... Ts>
46inline constexpr bool is_one_of = std::disjunction_v<std::is_same<T, Ts>...>;
52template <
typename VectorType>
55 template <
size_t LaneIndex>
63#ifdef ARGON_PLATFORM_MVE
83 [[deprecated(
"predicate_type is the mask vector type; use mask_type, or argon_bool_type for "
84 "the Predicate comparisons return")]] =
mask_type;
90 static constexpr size_t lanes = (simd::is_quadword_v<VectorType> ? 16 : 8) /
sizeof(
scalar_type);
102 ace
Vector(VectorType vector) : vec_{
std::move(vector)} {};
110 requires(!std::is_same_v<scalar_type, VectorType>)
122 template <
size_t LaneIndex>
128 template <
typename... ArgTypes>
129 requires(
sizeof...(ArgTypes) > 1)
144#ifdef ARGON_PLATFORM_MVE
145 return simd::duplicate(scalar);
147 return simd::duplicate<VectorType>(scalar);
155 template <simd::is_vector_type IntrinsicType>
157#ifdef ARGON_PLATFORM_MVE
158 return simd::duplicate(lane.
Get());
160 return simd::duplicate_lane<vector_type>(lane.
vec(), lane.
lane());
168 template <
size_t LaneIndex>
170#ifdef ARGON_PLATFORM_MVE
171 return simd::duplicate(lane.
Get());
173 if constexpr (simd::is_quadword_v<VectorType>) {
175 return simd::duplicate_lane_quad<LaneIndex>(lane.
vec());
179 constexpr size_t local_lane = LaneIndex >= (
lanes / 2) ? LaneIndex - (
lanes / 2) : LaneIndex;
180 return simd::duplicate_lane_quad<local_lane>(lane.
vec());
183 return simd::duplicate_lane<LaneIndex>(lane.
vec());
196#if __cpp_if_consteval >= 202106L
197 return IotaHelper(start, std::make_index_sequence<lanes>{});
199 return Argon{start}.
Add(VectorType{0, 1, 2, 3});
207 template <
typename FuncType>
208 requires std::convertible_to<FuncType, std::function<
scalar_type()>>
212 std::array<scalar_type, lanes> out;
213 utility::constexpr_for<0, lanes, 1>([&]<
size_t i>() {
216 return Load(out.data());
224 template <
typename FuncType>
229 std::array<scalar_type, lanes> out;
230 utility::constexpr_for<0, lanes, 1>([&]<
size_t i>() {
233 return Load(out.data());
295#if ARGON_USE_COMPILER_EXTENSIONS
304#if ARGON_USE_COMPILER_EXTENSIONS
312 [[gnu::always_inline]]
constexpr VectorType
vec()
const {
return vec_; }
315 [[gnu::always_inline]]
constexpr operator VectorType()
const {
return vec_; }
319 ace std::array<scalar_type, lanes>
to_array()
const {
320 std::array<scalar_type, lanes> out;
321 simd::store1(out.data(), vec_);
330 ace
lane_type GetLane(
const size_t i) {
return {vec_,
static_cast<int>(i)}; }
342 template <
size_t LaneIndex>
347 template <
size_t LaneIndex>
359 if constexpr (ARGON_USE_COMPILER_EXTENSIONS) {
368 if constexpr (ARGON_USE_COMPILER_EXTENSIONS) {
377 if constexpr (ARGON_USE_COMPILER_EXTENSIONS) {
379 }
else if constexpr (std::is_unsigned_v<scalar_type>) {
382 return simd::negate(vec_);
389 return vec_ + b.vec_;
391 return simd::add(vec_, b);
411 return vec_ - b.vec_;
413 return simd::subtract(vec_, b);
431#ifdef ARGON_PLATFORM_MVE
432 return mve::add(vec_, mve::subtract_absolute(b, c));
434 return neon::subtract_absolute_add(vec_, b, c);
441 return vec_ * b.vec_;
442 }
else if constexpr (std::is_integral_v<scalar_type> &&
sizeof(
scalar_type) == 8) {
445 const auto y = b.to_array();
446 for (
size_t i = 0; i < x.size(); ++i)
448 return argon_type::Load(x.data());
450 return simd::multiply(vec_, b);
459 return simd::multiply(vec_, b);
463#ifndef ARGON_PLATFORM_MVE
468 template <
size_t LaneIndex>
470 return neon::multiply_lane(vec_, b.
vec(), b.
lane());
478#ifdef ARGON_PLATFORM_MVE
480 return simd::multiply_add_fused(vec_, b.vec_, c.vec_);
484 return vec_ + b.vec_ * c.vec_;
486 return simd::multiply_add(vec_, b, c);
493#ifdef ARGON_PLATFORM_MVE
495 return simd::multiply_add_fused(vec_, b.vec_, c);
502 return vec_ + b.vec_ * c;
505 return simd::multiply_add(vec_, b, c);
513#ifndef ARGON_PLATFORM_MVE
517 return simd::multiply_add_lane(vec_, b.vec(), c.
vec(), c.
lane());
526 template <
size_t LaneIndex>
528 return simd::multiply_add_lane(vec_, b.vec(), c.
vec(), c.
lane());
532 template <
size_t LaneIndex>
541#ifdef ARGON_PLATFORM_MVE
543 return simd::multiply_subtract_fused(vec_, b.vec_, c.vec_);
545 return vec_ - b.vec_ * c.vec_;
549 return vec_ - b.vec_ * c.vec_;
551 return simd::multiply_subtract(vec_, b, c);
559#ifdef ARGON_PLATFORM_MVE
561 return simd::multiply_subtract_fused(vec_, b.vec_, simd::duplicate(c));
563 return vec_ - b.vec_ * c;
570 return vec_ - b.vec_ * c;
573 return simd::multiply_subtract(vec_, b, c);
582#if ARGON_HAS_FUSED_MULTIPLY_ADD
588 requires std::same_as<scalar_type, float>
590 return simd::multiply_add_fused(vec_, b.vec_, c.vec_);
596 requires std::same_as<scalar_type, float>
598 return simd::multiply_add_fused(vec_, b.vec_, c);
604 requires std::same_as<scalar_type, float>
606 return simd::multiply_subtract_fused(vec_, b.vec_, c.vec_);
612 requires std::same_as<scalar_type, float>
614#ifdef ARGON_PLATFORM_MVE
615 return simd::multiply_subtract_fused(vec_, b.vec_, simd::duplicate(c));
617 return simd::multiply_subtract_fused(vec_, b.vec_, c);
622#ifndef ARGON_PLATFORM_MVE
626 return simd::multiply_subtract_lane(vec_, b.vec(), c.
vec(), c.
lane());
638#ifndef ARGON_PLATFORM_MVE
642 return simd::multiply_double_saturate_high_lane(vec_, l.
vec(), l.
lane());
649 return simd::multiply_double_round_saturate_high(vec_, v);
655 return simd::multiply_double_round_saturate_high(vec_, s);
658#ifndef ARGON_PLATFORM_MVE
662 return simd::multiply_double_round_saturate_high_lane(vec_, l.
vec(), l.
lane());
677#ifdef ARGON_PLATFORM_MVE
680 return simd::reciprocal_estimate(vec_);
690#ifdef ARGON_PLATFORM_MVE
693 const auto bits = std::bit_cast<Bool_t<VectorType>>(vec_);
694 const VectorType guess = std::bit_cast<VectorType>(0x5f3759dfu - (bits >> 1));
695 return guess * (1.5f - 0.5f * vec_ * guess * guess);
697 return simd::reciprocal_sqrt_estimate(vec_);
707#ifdef ARGON_PLATFORM_MVE
708 return 2.f - vec_ * b.vec_;
710 return simd::reciprocal_step(vec_, b.vec_);
720#ifdef ARGON_PLATFORM_MVE
721 return (3.f - vec_ * b.vec_) * 0.5f;
723 return simd::reciprocal_sqrt_step(vec_, b.vec_);
734 for (
int i = 0; i < n_iters; ++i) {
747 for (
int i = 0; i < n_iters; ++i) {
755 template <
typename arg_type>
757 std::is_convertible_v<arg_type, scalar_type>)
759 return Add(b.MultiplyFixedQMax(c));
764 template <
typename arg_type>
766 std::is_convertible_v<arg_type, scalar_type>)
768 return Add(b.MultiplyRoundFixedQMax(c));
774 if constexpr (ARGON_USE_COMPILER_EXTENSIONS) {
775 return vec_ / b.vec_;
777 return simd::divide(vec_, b);
783 if constexpr (ARGON_USE_COMPILER_EXTENSIONS) {
784 return vec_ / b.vec_;
794 if constexpr (ARGON_USE_COMPILER_EXTENSIONS) {
795 return vec_ % b.vec_;
806 if constexpr (ARGON_USE_COMPILER_EXTENSIONS) {
809 return this->map([b](
scalar_type lane1) {
return std::fmod(lane1, b); });
822#ifdef ARGON_PLATFORM_MVE
825 return simd::predicate_select(vec_, b.vec_,
826 helpers::mve_compare<helpers::MveComparison::GreaterThan>(vec_, b.vec_));
829 if constexpr (ARGON_USE_COMPILER_EXTENSIONS) {
830 return vec_ > b.vec_ ? vec_ : b.vec_;
835 return simd::max(vec_, b);
843#ifdef ARGON_PLATFORM_MVE
845 return simd::predicate_select(vec_, b.vec_,
846 helpers::mve_compare<helpers::MveComparison::GreaterThan>(b.vec_, vec_));
849 if constexpr (ARGON_USE_COMPILER_EXTENSIONS) {
850 return vec_ < b.vec_ ? vec_ : b.vec_;
855 return simd::min(vec_, b);
873 return simd::max_strict(vec_, b.vec_);
890 return simd::min_strict(vec_, b.vec_);
901 using bits_type = std::conditional_t<
sizeof(
scalar_type) == 2, uint16_t,
902 std::conditional_t<
sizeof(
scalar_type) == 4, uint32_t, uint64_t>>;
905 const auto a_bits = a.template As<bits_type>(), b_bits = b.template As<bits_type>();
906 const argon_type zeros = (max ? (a_bits & b_bits) : (a_bits | b_bits)).
template As<scalar_type>();
907 r = (a == b).
Select(zeros, r);
908 return (b == b).Select(r, a);
913#ifdef ARGON_PLATFORM_MVE
914 return argon_bool_type{helpers::mve_compare<helpers::MveComparison::Equal>(vec_, b.vec_)};
922#ifdef ARGON_PLATFORM_MVE
923 return argon_bool_type{helpers::mve_compare<helpers::MveComparison::GreaterThanOrEqual>(vec_, b.vec_)};
925#if ARGON_GCC_AARCH32_FLOAT
935#ifdef ARGON_PLATFORM_MVE
936 return argon_bool_type{helpers::mve_compare<helpers::MveComparison::GreaterThanOrEqual>(b.vec_, vec_)};
938#if ARGON_GCC_AARCH32_FLOAT
948#ifdef ARGON_PLATFORM_MVE
949 return argon_bool_type{helpers::mve_compare<helpers::MveComparison::GreaterThan>(vec_, b.vec_)};
951#if ARGON_GCC_AARCH32_FLOAT
961#ifdef ARGON_PLATFORM_MVE
962 return argon_bool_type{helpers::mve_compare<helpers::MveComparison::GreaterThan>(b.vec_, vec_)};
964#if ARGON_GCC_AARCH32_FLOAT
975 requires std::is_integral_v<scalar_type>
977 if constexpr (ARGON_USE_COMPILER_EXTENSIONS) {
978 return vec_ << b.vec_;
980 return simd::shift_left(vec_, b.vec_);
987 requires std::is_integral_v<scalar_type>
989 if constexpr (ARGON_USE_COMPILER_EXTENSIONS) {
993 return simd::shift_left(vec_, b.vec_);
999 requires std::is_integral_v<scalar_type>
1001 using signed_scalar = std::make_signed_t<scalar_type>;
1003 return simd::shift_left(vec_, b.vec());
1010 if constexpr (ARGON_USE_COMPILER_EXTENSIONS) {
1013 return simd::shift_left<n>(vec_);
1019 requires(std::is_integral_v<scalar_type>)
1021 return simd::shift_left_saturate(vec_, b);
1033 return simd::shift_left_saturate<n>(vec_);
1043 return simd::shift_left_insert<n>(vec_, b);
1049 if constexpr (ARGON_USE_COMPILER_EXTENSIONS) {
1052 return simd::shift_right<n>(vec_);
1059 return simd::shift_right_round<n>(vec_);
1067#ifdef ARGON_PLATFORM_MVE
1068 return vec_ + (b >> n).
vec();
1070 return simd::shift_right_accumulate<n>(vec_, b);
1079#ifdef ARGON_PLATFORM_MVE
1080 return vec_ + mve::shift_right_round<n>(b.vec());
1082 return simd::shift_right_accumulate_round<n>(vec_, b);
1091 return simd::shift_right_insert<n>(vec_, b);
1096#ifdef ARGON_PLATFORM_MVE
1097 return mve::load1(ptr);
1099 return neon::load1<VectorType>(ptr);
1105#ifdef ARGON_PLATFORM_MVE
1106 return simd::duplicate(*ptr);
1108 return simd::load1_duplicate<VectorType>(ptr);
1117#ifdef ARGON_PLATFORM_MVE
1118 return mve::load1(ptr, active.
native());
1121 utility::constexpr_for<0, lanes, 1>([&]<
int i>() {
1167 template <
size_t lane>
1178 template <
size_t str
ide>
1180#ifdef ARGON_PLATFORM_MVE
1181 static_assert(stride > 1 && stride < 5,
"De-interleaving Loads can only be performed with a stride of 2, 3, or 4");
1182 if constexpr (stride == 2) {
1184 }
else if constexpr (stride == 3) {
1186 const offset_type offsets = offset_type::Iota(0) * 3;
1189 }
else if constexpr (stride == 4) {
1193 static_assert(stride > 1 && stride < 5,
"De-interleaving Loads can only be performed with a stride of 2, 3, or 4");
1194 using multivec_type = simd::MultiVector_t<VectorType, stride>;
1195 if constexpr (stride == 2) {
1197 }
else if constexpr (stride == 3) {
1199 }
else if constexpr (stride == 4) {
1210 template <
size_t str
ide>
1212#ifdef ARGON_PLATFORM_MVE
1213 static_assert(stride == 2 || stride == 4,
1214 "De-interleaving LoadCopy can only be performed with a stride of 2, 3, or 4");
1215 if constexpr (stride == 2) {
1216 return {mve::duplicate(*ptr++), mve::duplicate(*ptr++)};
1217 }
else if constexpr (stride == 4) {
1218 return {mve::duplicate(*ptr++), mve::duplicate(*ptr++), mve::duplicate(*ptr++), mve::duplicate(*ptr)};
1221 static_assert(stride > 1 && stride < 5,
1222 "De-interleaving LoadCopy can only be performed with a stride of 2, 3, or 4");
1223 using multivec_type = simd::MultiVector<VectorType, stride>::type;
1224 if constexpr (stride == 2) {
1225 return argon::to_array(simd::load2_duplicate<multivec_type>(ptr).val);
1226 }
else if constexpr (stride == 3) {
1227 return argon::to_array(simd::load3_duplicate<multivec_type>(ptr).val);
1228 }
else if constexpr (stride == 4) {
1229 return argon::to_array(simd::load4_duplicate<multivec_type>(ptr).val);
1240 template <
size_t LaneIndex,
size_t Str
ide>
1243 static_assert(Stride > 1 && Stride < 5,
"De-interleaving Loads can only be performed with a stride of 2, 3, or 4");
1244#ifdef ARGON_PLATFORM_MVE
1246 utility::constexpr_for<0, Stride, 1>([&]<
int i>() {
1247 out.val[i][LaneIndex] = ptr[i];
1251 if constexpr (Stride == 2) {
1252 if constexpr (simd::is_quadword_v<VectorType>) {
1253 return argon::to_array(simd::load2_lane_quad<LaneIndex>(ptr, multi).val);
1257 }
else if constexpr (Stride == 3) {
1258 if constexpr (simd::is_quadword_v<VectorType>) {
1259 return argon::to_array(simd::load3_lane_quad<LaneIndex>(ptr, multi).val);
1263 }
else if constexpr (Stride == 4) {
1264 if constexpr (simd::is_quadword_v<VectorType>) {
1265 return argon::to_array(simd::load4_lane_quad<LaneIndex>(ptr, multi).val);
1274 template <
size_t lane,
size_t str
ide>
1277 using multivec_type = simd::MultiVector_t<VectorType, stride>;
1291 template <
size_t str
ide>
1295 static_assert(stride > 1 && stride < 5,
"De-interleaving Loads can only be performed with a stride of 2, 3, or 4");
1296 std::array<argon_type, stride> multi{};
1297 utility::constexpr_for<0, lanes, 1>([&]<
int i>() {
1298 auto lane_val = simd::get_lane<i>(offset_vector);
1313 static_assert(n > 1 && n < 5,
"LoadMulti can only be performed with a size of 2, 3, or 4");
1314#ifdef ARGON_PLATFORM_MVE
1315 std::array<argon_type, n> multi{};
1316 utility::constexpr_for<0, n, 1>([&]<
int i>() {
1317 multi[i] =
Load(ptr);
1322#if defined(__clang__) || (__GNUC__ > 13)
1323 using multi_type = simd::MultiVector_t<VectorType, n>;
1324 if constexpr (n == 2) {
1326 }
else if constexpr (n == 3) {
1328 }
else if constexpr (n == 4) {
1334 if constexpr (n == 2) {
1335 auto a = simd::load1<VectorType>(ptr);
1336 auto b = simd::load1<VectorType>(ptr +
lanes);
1338 }
else if constexpr (n == 3) {
1339 auto a = simd::load1<VectorType>(ptr);
1340 auto b = simd::load1<VectorType>(ptr +
lanes);
1341 auto c = simd::load1<VectorType>(ptr + 2 *
lanes);
1343 }
else if constexpr (n == 4) {
1344 auto a = simd::load1<VectorType>(ptr);
1345 auto b = simd::load1<VectorType>(ptr +
lanes);
1346 auto c = simd::load1<VectorType>(ptr + 2 *
lanes);
1347 auto d = simd::load1<VectorType>(ptr + 3 *
lanes);
1348 return {a, b, c, d};
1363#ifdef ARGON_PLATFORM_MVE
1364 mve::store1(ptr, vec_, active.
native());
1366 utility::constexpr_for<0, lanes, 1>([&]<
int i>() {
1368 ptr[i] = simd::get_lane<i>(vec_);
1405 template <
int LaneIndex>
1407#ifdef ARGON_PLATFORM_MVE
1408 *ptr = vec_[LaneIndex];
1410 simd::store1_lane<LaneIndex>(ptr, vec_);
1414#ifndef ARGON_PLATFORM_MVE
1437 if constexpr (ARGON_USE_COMPILER_EXTENSIONS) {
1440 return simd::bitwise_not(vec_);
1446 if constexpr (ARGON_USE_COMPILER_EXTENSIONS) {
1447 return vec_ & b.vec_;
1449 return simd::bitwise_and(vec_, b);
1455 if constexpr (ARGON_USE_COMPILER_EXTENSIONS) {
1456 return vec_ | b.vec_;
1458 return simd::bitwise_or(vec_, b);
1464 if constexpr (ARGON_USE_COMPILER_EXTENSIONS) {
1465 return vec_ ^ b.vec_;
1467 return simd::bitwise_xor(vec_, b);
1474 if constexpr (ARGON_USE_COMPILER_EXTENSIONS) {
1475 return vec_ | ~b.vec_;
1477 return simd::bitwise_or_not(vec_, b);
1484 if constexpr (ARGON_USE_COMPILER_EXTENSIONS) {
1485 return vec_ & ~b.vec_;
1487 return simd::bitwise_clear(vec_, b);
1497 template <
typename ArgType>
1498 requires std::is_unsigned_v<scalar_type>
1500#ifdef ARGON_PLATFORM_MVE
1502 const auto t = std::bit_cast<VectorType>(true_value.vec());
1503 const auto f = std::bit_cast<VectorType>(false_value.vec());
1504 return ArgType{std::bit_cast<typename ArgType::vector_type>((vec_ & t) | (f & ~vec_))};
1506 return ArgType{simd::bitwise_select(vec_, true_value, false_value)};
1511 template <
typename ArgType>
1512 requires std::is_unsigned_v<scalar_type>
1513 ace ArgType
Select(ArgType true_value, ArgType false_value)
const {
1520 requires std::is_integral_v<scalar_type>
1522#ifdef ARGON_PLATFORM_MVE
1543#ifdef ARGON_PLATFORM_MVE
1544#define ARGON_PREDICATED_BINARY(Name, mve_name, mve_has_it) \
1545 ace argon_type Name(argon_type b, argon_bool_type active) const { \
1546 if constexpr (mve_has_it) { \
1547 return mve::mve_name(vec_, b.vec_, active.native()); \
1552 ace argon_type Name(argon_type b, argon_bool_type active, argon_type inactive) const { \
1553 if constexpr (mve_has_it) { \
1554 return mve::mve_name(inactive.vec_, vec_, b.vec_, active.native()); \
1556 return active.Select(Name(b), inactive); \
1559#define ARGON_PREDICATED_UNARY(Name, mve_name, mve_has_it) \
1560 ace argon_type Name(argon_bool_type active) const { \
1561 if constexpr (mve_has_it) { \
1562 return mve::mve_name(vec_, active.native()); \
1567 ace argon_type Name(argon_bool_type active, argon_type inactive) const { \
1568 if constexpr (mve_has_it) { \
1569 return mve::mve_name(inactive.vec_, vec_, active.native()); \
1571 return active.Select(Name(), inactive); \
1575#define ARGON_PREDICATED_BINARY(Name, mve_name, mve_has_it) \
1576 ace argon_type Name(argon_type b, argon_bool_type ) const { return Name(b); } \
1577 ace argon_type Name(argon_type b, argon_bool_type active, argon_type inactive) const { \
1578 return active.Select(Name(b), inactive); \
1580#define ARGON_PREDICATED_UNARY(Name, mve_name, mve_has_it) \
1581 ace argon_type Name(argon_bool_type ) const { return Name(); } \
1582 ace argon_type Name(argon_bool_type active, argon_type inactive) const { return active.Select(Name(), inactive); }
1585 ARGON_PREDICATED_BINARY(
Add, add,
true)
1586 ARGON_PREDICATED_BINARY(
Subtract, subtract, true)
1587 ARGON_PREDICATED_BINARY(
Multiply, multiply, true)
1591 ARGON_PREDICATED_BINARY(
SubtractAbs, subtract_absolute, true)
1592 ARGON_PREDICATED_BINARY(
BitwiseAnd, bitwise_and, true)
1593 ARGON_PREDICATED_BINARY(
BitwiseOr, bitwise_or, true)
1594 ARGON_PREDICATED_BINARY(
BitwiseXor, bitwise_xor, true)
1600#undef ARGON_PREDICATED_BINARY
1601#undef ARGON_PREDICATED_UNARY
1607#ifdef ARGON_PLATFORM_MVE
1609 return simd::multiply_add_fused(vec_, b.vec_, c.vec_, active.
native());
1619#ifdef ARGON_PLATFORM_MVE
1621 return simd::multiply_add_fused(vec_, b.vec_, c, active.
native());
1631#ifdef ARGON_PLATFORM_MVE
1633 return simd::multiply_subtract_fused(vec_, b.vec_, c.vec_, active.
native());
1644#ifdef ARGON_PLATFORM_MVE
1645 return argon_bool_type{helpers::mve_compare<helpers::MveComparison::Equal>(vec_, b.vec_, active.
native())};
1647 return active &
Equal(b);
1654#ifdef ARGON_PLATFORM_MVE
1655 return argon_bool_type{helpers::mve_compare<helpers::MveComparison::GreaterThan>(vec_, b.vec_, active.
native())};
1664#ifdef ARGON_PLATFORM_MVE
1666 helpers::mve_compare<helpers::MveComparison::GreaterThanOrEqual>(vec_, b.vec_, active.
native())};
1679 return b.GreaterThanOrEqual(*
this, active);
1687 return simd::count_leading_sign_bits(vec_);
1697#ifdef ARGON_PLATFORM_MVE
1698 auto new_vec = vec_;
1699 utility::constexpr_for<0, lanes, 1>([&]<
int i>() {
1700 new_vec[i] = std::popcount(vec_[i]);
1704 return neon::count_active_bits(vec_);
1716#ifdef ARGON_PLATFORM_MVE
1717 return ShuffleConcat<[](
size_t i) {
return i + n; }>(vec_, b.vec_);
1719 return simd::extract<n>(vec_, b);
1723 ace
argon_type Reverse64bit()
const {
return simd::reverse_64bit(vec_); }
1724 ace
argon_type Reverse32bit()
const {
return simd::reverse_32bit(vec_); }
1725 ace
argon_type Reverse16bit()
const {
return simd::reverse_16bit(vec_); }
1731#ifdef ARGON_PLATFORM_MVE
1733 return {ShuffleConcat<[](
size_t i) {
return i / 2 + (i % 2) *
lanes; }>(vec_, b.vec_),
1734 ShuffleConcat<[](
size_t i) {
return (i +
lanes) / 2 + (i % 2) *
lanes; }>(vec_, b.vec_)};
1744#ifdef ARGON_PLATFORM_MVE
1745 return {ShuffleConcat<[](
size_t i) {
return i * 2; }>(vec_, b.vec_),
1746 ShuffleConcat<[](
size_t i) {
return i * 2 + 1; }>(vec_, b.vec_)};
1758#ifdef ARGON_PLATFORM_MVE
1759 return {ShuffleConcat<[](
size_t i) {
return i % 2 ?
lanes + i - 1 : i; }>(vec_, b.vec_),
1760 ShuffleConcat<[](
size_t i) {
return i % 2 ?
lanes + i : i + 1; }>(vec_, b.vec_)};
1769 template <
typename FuncType>
1773 utility::constexpr_for<0, lanes, 1>([&]<
int i>() {
1774 out[i] = body(vec_[i]);
1779 template <
typename FuncType>
1781 ace
argon_type map_with_index(FuncType body)
const {
1783 utility::constexpr_for<0, lanes, 1>([&]<
int i>() {
1784 out[i] = body(vec_[i], i);
1789 template <
typename FuncType>
1793 utility::constexpr_for<0, lanes, 1>([&]<
int i>() {
1794 out[i] = body(vec_[i], other.vec_[i]);
1799 template <
typename FuncType>
1800 requires std::convertible_to<FuncType, std::function<void(
scalar_type&)>>
1802 VectorType out = vec_;
1803 utility::constexpr_for<0, lanes, 1>([&]<
int i>() {
1814 template <
typename FuncType>
1815 requires std::convertible_to<FuncType, std::function<void(
scalar_type&,
int)>>
1816 ace
argon_type each_lane_with_index(FuncType body) {
1817 VectorType out = vec_;
1818 utility::constexpr_for<0, lanes, 1>([&]<
int i>() {
1827 template <
typename FuncType>
1828 requires std::convertible_to<FuncType, std::function<void()>>
1829 ace
void if_lane(FuncType true_branch) {
1830 utility::constexpr_for<0, lanes, 1>([&]<
int i>() {
1837 template <
typename FuncType>
1838 requires std::convertible_to<FuncType, std::function<void()>>
1839 ace
void if_else_lane(FuncType true_branch, FuncType false_branch) {
1840 utility::constexpr_for<0, lanes, 1>([&]<
int i>() {
1849 template <
typename FuncType>
1850 requires std::convertible_to<FuncType, std::function<void(
int)>>
1851 ace
void if_lane_with_index(FuncType true_branch) {
1852 utility::constexpr_for<0, lanes, 1>([&]<
int i>() {
1859 template <
typename FuncType1,
typename FuncType2>
1860 requires std::convertible_to<FuncType1, std::function<void(
int)>> &&
1861 std::convertible_to<FuncType2, std::function<void(
int)>>
1862 ace
void if_else_lane_with_index(FuncType1 true_branch, FuncType2 false_branch) {
1863 utility::constexpr_for<0, lanes, 1>([&]<
int i>() {
1878 template <std::
size_t Index>
1879 std::tuple_element_t<Index, argon_type> get() {
1880#ifdef ARGON_PLATFORM_MVE
1890 template <
bool byte_offsets,
typename Po
interType,
typename OffsetType>
1891 ace
static PointerType*
LaneAddress(PointerType* base, OffsetType offset) {
1892 if constexpr (byte_offsets) {
1893 using byte_type = std::conditional_t<std::is_const_v<PointerType>,
const char,
char>;
1894 return reinterpret_cast<PointerType*
>(
reinterpret_cast<byte_type*
>(base) + offset);
1896 return base + offset;
1901 template <
bool byte_offsets,
typename... PredicateType>
1903 static_assert(
sizeof...(PredicateType) <= 1);
1904#ifdef ARGON_PLATFORM_MVE
1905 const auto off = offsets.vec();
1907 return mve::load_byte_gather_offset(base, off, active.native()...);
1909 if constexpr (byte_offsets) {
1910 return mve::load_halfword_gather_offset(base, off, active.native()...);
1912 return mve::load_halfword_gather_shifted_offset(base, off, active.native()...);
1915 if constexpr (byte_offsets) {
1916 return mve::load_word_gather_offset(base, off, active.native()...);
1918 return mve::load_word_gather_shifted_offset(base, off, active.native()...);
1921 if constexpr (byte_offsets) {
1922 return mve::load_doubleword_gather_offset(base, off, active.native()...);
1924 return mve::load_doubleword_gather_shifted_offset(base, off, active.native()...);
1929 utility::constexpr_for<0, lanes, 1>([&]<
int i>() {
1930 if ((active.Active(i) && ...)) {
1931 const auto offset = simd::get_lane<i>(offsets.vec());
1940 template <
bool byte_offsets,
typename... PredicateType>
1942 static_assert(
sizeof...(PredicateType) <= 1);
1943#ifdef ARGON_PLATFORM_MVE
1944 const auto off = offsets.vec();
1946 mve::store_byte_scatter_offset(base, off, vec_, active.native()...);
1948 if constexpr (byte_offsets) {
1949 mve::store_halfword_scatter_offset(base, off, vec_, active.native()...);
1951 mve::store_halfword_scatter_shifted_offset(base, off, vec_, active.native()...);
1954 if constexpr (byte_offsets) {
1955 mve::store_word_scatter_offset(base, off, vec_, active.native()...);
1957 mve::store_word_scatter_shifted_offset(base, off, vec_, active.native()...);
1960 if constexpr (byte_offsets) {
1961 mve::store_doubleword_scatter_offset(base, off, vec_, active.native()...);
1963 mve::store_doubleword_scatter_shifted_offset(base, off, vec_, active.native()...);
1967 utility::constexpr_for<0, lanes, 1>([&]<
int i>() {
1968 if ((active.Active(i) && ...)) {
1976 template <
typename ArgType>
1981 return std::forward<ArgType>(arg);
1985#ifdef ARGON_PLATFORM_MVE
1988 template <auto index>
1989 ace
static VectorType ShuffleConcat(VectorType a, VectorType b) {
1990 return [&]<std::size_t... Is>(std::index_sequence<Is...>) {
1991 return VectorType(__builtin_shufflevector(a, b, index(Is)...));
1992 }(std::make_index_sequence<lanes>{});
1996 template <std::size_t... Ints>
1998 return VectorType{
static_cast<scalar_type>(start + Ints)...};
2010template <
typename T>
2015template <
size_t Index,
typename T>
2016struct tuple_element<Index,
argon::Vector<T>> {
2017 static_assert(Index < argon::Vector<T>::lanes);
Provides utility templates and concepts for type traits and compile-time iteration.
Definition argon_full.hpp:44
Represents a single lane of a SIMD vector with the lane index known at compile time.
Definition lane.hpp:35
ace int lane()
On ARM32, return the local lane index within the 64-bit half-register returned by vec().
Definition lane.hpp:85
ace neon::Vec64_t< scalar_type > vec()
On ARM32, return the 64-bit half-register that contains this lane.
Definition lane.hpp:73
ace scalar_type Get() const
Get the scalar value of this lane.
Definition lane.hpp:64
ace argon_type Load(const scalar_type *ptr)
Load a scalar from ptr into this lane and return the updated vector.
Definition lane.hpp:50
Represents a single lane of a SIMD vector with a runtime-determined index.
Definition lane.hpp:107
ace int lane()
On ARM32, return the local lane index within the 64-bit half-register returned by vec().
Definition lane.hpp:153
ace neon::Vec64_t< scalar_type > vec()
On ARM32, return the 64-bit half-register that contains this lane.
Definition lane.hpp:141
ace scalar_type Get() const
Get the scalar value of this lane.
Definition lane.hpp:130
A per-lane boolean for vectors of type VectorType, as returned by comparisons.
Definition predicate.hpp:39
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
ace void StoreScatterOffsetBytes(scalar_type *base, offset_type offsets) const
Scatter the lanes to base plus a byte offset per lane.
Definition vector.hpp:1378
ace argon_type PairwiseMin(argon_type b) const
Select the maximum of each pair of lanes in the two vectors.
Definition vector.hpp:1430
Lane< simd::Vec128_t< ScalarType > > lane_type
Definition vector.hpp:57
ace argon_type MultiplySubtract(argon_type b, lane_type c) const
Multiply a vector by a lane value and subtract from a third vector.
Definition vector.hpp:625
ace Vector(VectorType vector)
Constructs a Vector from a SIMD vector type.
Definition vector.hpp:102
simd::Vec128_t< ScalarType > vector_type
Definition vector.hpp:78
ace void StoreScatterOffsetBytes(scalar_type *base, offset_type offsets, argon_bool_type active) const
Scatter the active lanes to base plus a byte offset per lane; inactive lanes are not written.
Definition vector.hpp:1384
ace argon_type Modulo(argon_type b) const
Get the modulo of two vectors.
Definition vector.hpp:793
ace argon_bool_type operator<(argon_type b) const
Compare two vectors, checking if this vector is less than the other.
Definition vector.hpp:258
ace argon_type ShiftLeftRound(argon_type b) const
Shift the elements of the vector to the left by a specified number of bits, rounding the result.
Definition vector.hpp:1025
ace Lane< const VectorType > GetLane(const int i) const
Get a single lane of the vector by index.
Definition vector.hpp:335
std::array< argon_type, 2 > TransposeWith(argon_type b) const
Perform a 2x2 matrix transpose on two vectors, returning two vectors of pairs.
Definition vector.hpp:1757
ace argon_type MaxNumber(argon_type b) const
The larger of each lane by IEEE 754 maxNum, as Arm's vmaxnm: a quiet NaN in one operand gives the oth...
Definition vector.hpp:868
constexpr Vector(const Vector &other)=default
Copy constructor for the Vector class.
static ace std::array< argon_type, stride > LoadInterleaved(const scalar_type *ptr)
Load multiple vectors from a pointer, de-interleaving.
Definition vector.hpp:1179
static ace argon_type Iota(scalar_type start)
Constructs a Vector from an incrementing sequence.
Definition vector.hpp:194
static ace argon_type FromScalar(scalar_type scalar)
Definition vector.hpp:143
ace argon_type Multiply(scalar_type b) const
Multiply a vector by a scalar value.
Definition vector.hpp:455
static ace argon_type Load(const scalar_type *ptr, argon_bool_type active)
Load the active lanes of a vector from a pointer; inactive lanes are zero and their memory is not rea...
Definition vector.hpp:1116
ace argon_type MultiplySubtract(argon_type b, argon_type c) const
Multiply two vectors and subtract from a third vector.
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
ace argon_bool_type LessThan(argon_type b, argon_bool_type active) const
Compare only the lanes of active: a predicate active where active holds and a < b.
Definition vector.hpp:1674
constexpr VectorType vec() const
Get the underlying SIMD vector.
Definition vector.hpp:312
ace void Scatter(scalar_type *base, offset_type offsets, PredicateType... active) const
Scatter by byte or element offsets, optionally only the lanes of one predicate.
Definition vector.hpp:1941
ace argon_type Multiply(argon_type b) const
Multiply two vectors.
Definition vector.hpp:439
ace argon_bool_type LessThanOrEqual(argon_type b) const
Compare the lanes of two vectors, returning a predicate active where a is less than or equal to b.
Definition vector.hpp:934
static constexpr bool mve_float
Definition vector.hpp:69
ace argon_type operator--() const
Decrement the vector by 1 and return the result.
Definition vector.hpp:273
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)
Load a vector from a pointer.
Definition vector.hpp:1095
ace argon_type operator+(argon_type b) const
Add a vector and return the result.
Definition vector.hpp:240
ace void StoreTo(scalar_type *ptr, argon_bool_type active) const
Store the active lanes of the vector to a pointer; memory for inactive lanes is not written.
Definition vector.hpp:1362
ace argon_type ShiftLeft(helpers::ArgonFor_t< simd::make_signed_t< Bool_t< VectorType > > > b) const
Shift the elemnets of the vector to the left by a specified number of bits.
Definition vector.hpp:974
ace argon_type Multiply(const_lane_type< LaneIndex > b) const
Multiply a vector by a lane value.
Definition vector.hpp:469
ace argon_type PairwiseAdd(argon_type b) const
Pairwise ops.
Definition vector.hpp:1420
ace argon_type MultiplyAdd(scalar_type b, argon_type c) const
Multiply a vector by a scalar value and add a third vector.
Definition vector.hpp:511
ace void StoreScatterOffsetIndex(scalar_type *base, offset_type offsets, argon_bool_type active) const
Scatter the active lanes to base[offsets[i]]; inactive lanes are not written.
Definition vector.hpp:1398
ace argon_bool_type operator>=(argon_type b) const
Compare two vectors, checking if this vector is greater than or equal to the other.
Definition vector.hpp:267
ace argon_type MultiplyAdd(argon_type b, lane_type c) const
Multiply a vector by a lane value and add a third vector.
Definition vector.hpp:516
static ace argon_type LoadGatherOffsetBytes(const scalar_type *base, offset_type offsets, argon_bool_type active)
Gather the active lanes from base plus a byte offset per lane; inactive lanes are zero and not read.
Definition vector.hpp:1143
ace argon_bool_type operator==(argon_type b) const
Compare two vectors for equality.
Definition vector.hpp:252
ace argon_type MultiplyAdd(argon_type b, argon_type c) const
Multiply two vectors and add a third vector.
Definition vector.hpp:477
ace argon_type ShiftLeft(std::make_signed_t< simd::Scalar_t< Bool_t< VectorType > > > n) const
Shift the elements of the vector to the left by a specified number of bits.
Definition vector.hpp:986
ace argon_type BitwiseOrNot(argon_type b) const
Bitwise OR of the vector with the NOT of another vector.
Definition vector.hpp:1473
ace helpers::ArgonFor_t< simd::make_signed_t< Bool_t< VectorType > > > CountLeadingSignBits() const
Count the number of consecutive bits following the sign bit that are set to the same value as the sig...
Definition vector.hpp:1684
static ace argon_type FromLane(argon::ConstLane< LaneIndex, VectorType > lane)
Constructs a Vector from a ConstLane object.
Definition vector.hpp:169
ace argon_type AddSaturate(argon_type b) const
Adds two vectors, saturating the result.
Definition vector.hpp:406
ace argon_type ReciprocalSqrtEstimateRefine(int n_iters=1) const
Compute a refined reciprocal-sqrt estimate using Newton-Raphson iterations.
Definition vector.hpp:743
std::array< argon_type, 2 > UnzipWith(argon_type b)
Unzip two vectors, returning two vectors of pairs.
Definition vector.hpp:1743
ace argon_type operator++() const
Increment the vector by 1 and return the result.
Definition vector.hpp:270
ace argon_type MultiplyAddFixedQMax(argon_type b, arg_type c) const
Multiply-add three fixed-point vectors, returning a fixed-point sum.
Definition vector.hpp:758
ace argon_type operator^(argon_type b) const
Bitwise XOR two vectors and return the result.
Definition vector.hpp:282
ace argon_bool_type GreaterThanOrEqual(argon_type b, argon_bool_type active) const
Compare only the lanes of active: a predicate active where active holds and a >= b.
Definition vector.hpp:1663
ace argon_bool_type Equal(argon_type b) const
Compare the lanes of two vectors, returning a predicate active where a == b.
Definition vector.hpp:912
ace void StoreTo(scalar_type *ptr) const
Store the vector to a pointer.
Definition vector.hpp:1356
ConstLane< LaneIndex, simd::Vec128_t< ScalarType > > const_lane_type
Definition vector.hpp:56
ace argon_type MultiplyRoundFixedQMax(lane_type l) const
Multiply a fixed-point vector by a lane value, returning a fixed-point product.
Definition vector.hpp:661
ace Vector(scalar_type scalar)
Constructs a Vector from a scalar value.
Definition vector.hpp:109
static constexpr bool extension_arithmetic
Definition vector.hpp:61
ace argon_type MultiplyAdd(argon_type b, scalar_type c, argon_bool_type active) const
MultiplyAdd under a predicate: lanes outside active keep this vector's value, the accumulator (as ACL...
Definition vector.hpp:1618
ace argon_type CountActiveBits() const
Count the number of bits that are set to one in the vector.
Definition vector.hpp:1696
ace argon_type MultiplyFixedQMax(scalar_type s) const
Multiply a QMax fixed-point vector by a scalar value, returning a fixed-point product.
Definition vector.hpp:636
static ace std::array< argon_type, stride > LoadToLaneInterleaved(std::array< argon_type, stride > multi, const scalar_type *ptr)
Load a value from a pointer into a vector at the lane index lane, de-interleaving.
Definition vector.hpp:1275
ace argon_type PairwiseMax(argon_type b) const
Select the maximum of each pair of lanes in the two vectors.
Definition vector.hpp:1425
ace argon_type operator/(argon_type b) const
Divide a vector and return the result.
Definition vector.hpp:249
ace argon_type BitwiseNot() const
Bitwise ops.
Definition vector.hpp:1436
ace ConstLane< LaneIndex, const VectorType > GetLane() const
Get a single lane of the vector by index.
Definition vector.hpp:343
ace argon_type Max(argon_type b) const
Compare the lanes of two vectors, copying the larger of each lane to the result.
Definition vector.hpp:821
ace argon_bool_type Equal(argon_type b, argon_bool_type active) const
Compare only the lanes of active: a predicate active where active holds and a == b.
Definition vector.hpp:1643
static ace argon_type FromLane(argon::Lane< IntrinsicType > lane)
Definition vector.hpp:156
constexpr Vector & operator=(Vector &&other)=default
Move assignment operator for the Vector class.
ace argon_type ShiftLeftInsert(argon_type b) const
Shift the elements of the vector to the left by a specified number of bits, and then OR the result wi...
Definition vector.hpp:1042
ace ArgType BitwiseSelect(ArgType true_value, ArgType false_value) const
Bitwise select between two vectors, using the current vector as a mask.
Definition vector.hpp:1499
ace argon_type BitwiseAnd(argon_type b) const
Bitwise AND of the vector with another vector.
Definition vector.hpp:1445
static ace PointerType * LaneAddress(PointerType *base, OffsetType offset)
The address of one gathered / scattered lane: base plus a byte offset, or base indexed by an element ...
Definition vector.hpp:1891
ace argon_type MultiplyAdd(argon_type b, const_lane_type< LaneIndex > c) const
Multiply a vector by a lane value and add a third vector.
Definition vector.hpp:527
ace argon_type Modulo(scalar_type b) const
Get the modulo of a vector and a scalar value.
Definition vector.hpp:805
ace argon_type Popcount() const
Count the number of bits that are set to one in the vector.
Definition vector.hpp:1709
ace argon_bool_type LessThan(argon_type b) const
Compare the lanes of two vectors, returning a predicate active where a is less than b.
Definition vector.hpp:960
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 ShiftLeftRoundSaturate(argon_type b) const
Shift the elements of the vector to the left by a specified number of bits, rounding and saturating t...
Definition vector.hpp:1028
ace argon_type ShiftRight() const
Shift the elements of the vector to the right by a specified number of bits.
Definition vector.hpp:1048
ace argon_type Negate() const
Bitwise negate the vector and return the result.
Definition vector.hpp:376
static ace argon_type LoadGatherOffsetIndex(const scalar_type *base, offset_type offsets)
Gather a vector from base[offsets[i]].
Definition vector.hpp:1152
static constexpr bool mve_platform
Definition vector.hpp:66
ace void StoreLaneTo(scalar_type *ptr)
Store a lane of the vector to a pointer.
Definition vector.hpp:1406
ace argon_type Multiply(lane_type b) const
Multiply a vector by a lane value.
Definition vector.hpp:465
ace argon_type MultiplySubtract(argon_type b, scalar_type c) const
Multiply a vector by a scalar value and subtract from a third vector.
Definition vector.hpp:558
ace argon_type MultiplyAdd(const_lane_type< LaneIndex > b, argon_type c) const
Multiply a vector by a lane value and add a third vector.
Definition vector.hpp:533
ace argon_bool_type CompareTestNonzero(argon_type b) const
Compare the lanes of (a & b) with zero, returning a predicate active where they share a set bit.
Definition vector.hpp:1519
ace argon_type MultiplyRoundFixedQMax(scalar_type s) const
Multiply a fixed-point vector by a scalar value, returning a fixed-point product.
Definition vector.hpp:654
ace argon_bool_type GreaterThanOrEqual(argon_type b) const
Compare the lanes of two vectors, returning a predicate active where a is greater than or equal to b.
Definition vector.hpp:921
ace argon_bool_type operator>(argon_type b) const
Compare two vectors, checking if this vector is greater than the other.
Definition vector.hpp:261
ace argon_type operator<<(const int i) const
Shift the elements of the vector to the left by a specified number of bits.
Definition vector.hpp:303
ace argon_type AddHalve(argon_type b) const
Adds two vectors, halving the result.
Definition vector.hpp:397
helpers::ArgonFor_t< simd::make_unsigned_t< Bool_t< simd::Vec128_t< ScalarType > > > > offset_type
Definition vector.hpp:86
static ace std::array< argon_type, stride > LoadGatherOffsetIndexInterleaved(const scalar_type *base_ptr, helpers::ArgonFor_t< simd::make_unsigned_t< Bool_t< VectorType > > > offset_vector)
Perform a Load-Gather of interleaved elements.
Definition vector.hpp:1292
static ace decltype(auto) LaneValue(ArgType &&arg)
Definition vector.hpp:1977
ace argon_type MinNumber(argon_type b) const
The smaller of each lane by IEEE 754 minNum, as Arm's vminnm: a quiet NaN in one operand gives the ot...
Definition vector.hpp:885
ace argon_type Divide(argon_type b) const
Divide two vectors.
Definition vector.hpp:782
ace argon_type ShiftRightRound() const
Shift the elements of the vector to the right by a specified number of bits, rounding the result.
Definition vector.hpp:1058
static ace std::array< argon_type, stride > LoadCopyInterleaved(const scalar_type *ptr)
Load multiple vectors from a pointer, duplicating the value across all lanes.
Definition vector.hpp:1211
static ace int size()
Get the number of elements.
Definition vector.hpp:1767
ace argon_bool_type GreaterThan(argon_type b) const
Compare the lanes of two vectors, returning a predicate active where a is greater than b.
Definition vector.hpp:947
ace std::array< argon_type, 2 > ZipWith(argon_type b) const
Zip two vectors together, returning two vectors of pairs.
Definition vector.hpp:1730
ace argon_type operator-(argon_type b) const
Subtract a vector and return the result.
Definition vector.hpp:243
ace argon_type MultiplyRoundAddFixedQMax(argon_type b, arg_type c) const
Multiply-round-add three fixed-point vectors, returning a fixed-point sum.
Definition vector.hpp:767
helpers::ArgonFor_t< simd::Vec128_t< ScalarType > > argon_type
Definition vector.hpp:79
static ace argon_type LoadScalar(const scalar_type *ptr)
Constructs a Vector from a scalar pointer.
Definition vector.hpp:137
ace argon_type ShiftRightAccumulateRound(argon_type b) const
Shift the elements of the b vector to the right by a specified number of bits, and then add the resul...
Definition vector.hpp:1078
ace bool all() const
Whether every lane is nonzero.
Definition vector.hpp:1876
ace argon_type operator*(argon_type b) const
Multiply a vector and return the result.
Definition vector.hpp:246
static ace argon_type LoadCopy(const scalar_type *ptr)
Load a vector from a pointer, duplicating the value across all lanes.
Definition vector.hpp:1104
Bool_t< simd::Vec128_t< ScalarType > > mask_type
Definition vector.hpp:80
ace argon_type ReciprocalStep(argon_type b) const
Newton-Raphson step for reciprocal refinement: (2 - a * b) / 2.
Definition vector.hpp:704
ace argon_type LoadToLane(const scalar_type *ptr)
Load a lane from a pointer.
Definition vector.hpp:1168
ace argon_type SubtractAbs(argon_type b) const
Subtract two vectors, taking the absolute value of the result.
Definition vector.hpp:426
ace argon_type ShiftLeft() const
Shift the elements of the vector to the left by a specified number of bits.
Definition vector.hpp:1009
static ace argon_type Gather(const scalar_type *base, offset_type offsets, PredicateType... active)
Gather by byte or element offsets, optionally only the lanes of one predicate (inactive lanes are zer...
Definition vector.hpp:1902
ace const_lane_type< lanes - 1 > LastLane()
Get the last lane of the vector.
Definition vector.hpp:353
ace Lane< const VectorType > GetLane(const size_t i) const
Get a single lane of the vector by index.
Definition vector.hpp:329
ace bool any() const
Whether any lane is nonzero.
Definition vector.hpp:1873
ace argon_bool_type LessThanOrEqual(argon_type b, argon_bool_type active) const
Compare only the lanes of active: a predicate active where active holds and a <= b.
Definition vector.hpp:1678
ace argon_type ShiftLeftSaturate(helpers::ArgonFor_t< simd::make_signed_t< Bool_t< VectorType > > > b) const
Shift the elements of the vector to the left by a specified number of bits, saturating the result.
Definition vector.hpp:1018
ace argon_type MultiplyFixedQMax(lane_type l) const
Multiply a QMax fixed-point vector by a lane value, returning a fixed-point product.
Definition vector.hpp:641
ace argon_type MultiplySubtract(scalar_type b, argon_type c) const
Multiply a vector by a scalar value and subtract from a third vector.
Definition vector.hpp:580
ace argon_bool_type operator<=(argon_type b) const
Compare two vectors, checking if this vector is less than or equal to the other.
Definition vector.hpp:264
ace argon_type MultiplySubtract(argon_type b, argon_type c, argon_bool_type active) const
MultiplySubtract under a predicate: lanes outside active keep this vector's value (as ACLE's vfmsq_m)...
Definition vector.hpp:1630
ace argon_type ShiftLeftSaturate() const
Shift the elements of the vector to the left by a specified number of bits, saturating the result.
Definition vector.hpp:1032
ace argon_type operator&(argon_type b) const
Bitwise AND two vectors and return the result.
Definition vector.hpp:276
ace argon_type MultiplyRoundFixedQMax(argon_type v) const
Multiply two fixed-point vectors, returning a fixed-point product.
Definition vector.hpp:648
ace argon_type ReciprocalSqrtStep(argon_type b) const
Newton-Raphson step for reciprocal-sqrt refinement: (3 - a * b) / 2.
Definition vector.hpp:717
ace argon_bool_type TestNonzero() const
Return a predicate active where the lane is nonzero.
Definition vector.hpp:1530
ace argon_type SubtractSaturate(argon_type b) const
Subtract two vectors, saturating the result.
Definition vector.hpp:422
static ace std::array< argon_type, Stride > LoadToLaneInterleaved(simd::MultiVector_t< VectorType, Stride > multi, const scalar_type *ptr)
Load a value from a pointer into a vector at the lane index lane, de-interleaving.
Definition vector.hpp:1241
static ace std::array< argon_type, n > LoadMulti(const scalar_type *ptr)
Load n vectors from a single contiguous set of memory.
Definition vector.hpp:1312
ace Vector(ArgTypes... args)
Constructs a Vector from one value per lane.
Definition vector.hpp:130
ace argon_type MultiplyAdd(argon_type b, argon_type c, argon_bool_type active) const
MultiplyAdd under a predicate: lanes outside active keep this vector's value, the accumulator (as ACL...
Definition vector.hpp:1606
ace argon_type ReciprocalSqrtEstimate() const
1 / sqrt(value), using an estimate for speed
Definition vector.hpp:687
ace argon_type operator|(argon_type b) const
Bitwise OR two vectors and return the result.
Definition vector.hpp:279
ace argon_type MultiplyFixedQMax(argon_type v) const
Multiply two QMax fixed-point vectors, returning a fixed-point product.
Definition vector.hpp:632
ace argon_type ReciprocalEstimateRefine(int n_iters=1) const
Compute a refined reciprocal estimate using Newton-Raphson iterations.
Definition vector.hpp:730
ace argon_type MultiplyAdd(argon_type b, scalar_type c) const
Multiply a vector by a scalar value and add a third vector.
Definition vector.hpp:492
ace void StoreScatterOffsetIndex(scalar_type *base, offset_type offsets) const
Scatter the lanes to base[offsets[i]].
Definition vector.hpp:1392
simd::Scalar_t< simd::Vec128_t< ScalarType > > scalar_type
Definition vector.hpp:58
static constexpr bool fixup_float_compare
Definition vector.hpp:77
ace std::array< scalar_type, lanes > to_array() const
Convert the vector to an array of scalar values.
Definition vector.hpp:319
ace argon_type NumberMinMax(argon_type b) const
MaxNumber/MinNumber from compares and selects, where there is no vmaxnm/vminnm.
Definition vector.hpp:900
ace argon_type operator~() const
Bitwise NOT the vector and return the result.
Definition vector.hpp:285
ace Vector(argon::ConstLane< LaneIndex, VectorType > lane)
Constructs a Vector from a ConstLane object.
Definition vector.hpp:123
static ace argon_type LoadGatherOffsetBytes(const scalar_type *base, offset_type offsets)
Gather a vector from base plus a byte offset per lane.
Definition vector.hpp:1135
ace argon_bool_type GreaterThan(argon_type b, argon_bool_type active) const
Compare only the lanes of active: a predicate active where active holds and a > b.
Definition vector.hpp:1653
ace argon_type Absolute() const
Get the absolute value of the vector.
Definition vector.hpp:669
static constexpr size_t lanes
Definition vector.hpp:90
ace lane_type operator[](const size_t i)
Access a lane of the vector by index.
Definition vector.hpp:291
static constexpr bool native_maxnm
Definition vector.hpp:74
ace argon_type BitwiseClear(argon_type b) const
Bitwise AND of the vector with the NOT of another vector.
Definition vector.hpp:1492
ace argon_type BitwiseAndNot(argon_type b) const
Bitwise AND of the vector with the NOT of another vector.
Definition vector.hpp:1483
ace argon_type ShiftRightAccumulate(argon_type b) const
Shift the elements of the b vector to the right by a specified number of bits, and then add the resul...
Definition vector.hpp:1066
ace argon_type operator>>(const int i) const
Shift the elements of the vector to the right by a specified number of bits.
Definition vector.hpp:294
ace argon_type Add(argon_type b) const
Add two vectors.
Definition vector.hpp:387
ace argon_type BitwiseOr(argon_type b) const
Bitwise OR of the vector with another vector.
Definition vector.hpp:1454
constexpr Vector()=default
The default constructor for the Vector class.
constexpr Vector & operator=(const Vector &other)=default
Copy assignment operator for the Vector class.
static ace argon_type GenerateWithIndex(FuncType body)
Constructs a Vector from a function that generates values with an index.
Definition vector.hpp:226
ace argon_bool_type operator!=(argon_type b) const
Compare two vectors for inequality.
Definition vector.hpp:255
static ace argon_type LoadGatherOffsetIndex(const scalar_type *base, offset_type offsets, argon_bool_type active)
Gather the active lanes from base[offsets[i]]; inactive lanes are zero and not read.
Definition vector.hpp:1160
ace ArgType Select(ArgType true_value, ArgType false_value) const
Bitwise select between two vectors, using the current vector as a mask.
Definition vector.hpp:1513
ace argon_type ShiftByVector(int count) const
vshl by count in every lane: left for positive counts, right (arithmetic or logical) for negative one...
Definition vector.hpp:998
ace argon_type CountLeadingZeroBits() const
Count the number of consecutive top bits that are set to zero.
Definition vector.hpp:1692
ace argon_type Min(argon_type b) const
Compare the lanes of two vectors, copying the smaller of each lane to the result.
Definition vector.hpp:842
ace argon_type operator-() const
Negate the SIMD vector and return the result.
Definition vector.hpp:237
ace argon_type SubtractHalve(argon_type b) const
Subtract two vectors, halving the result.
Definition vector.hpp:419
ace argon_type MultiplyAdd(lane_type b, argon_type c) const
Multiply a vector by a lane value and add a third vector.
Definition vector.hpp:522
ace argon_type ShiftRightInsert(argon_type b) const
Shift the elements of the vector to the right by a specified number of bits, ORing the result with th...
Definition vector.hpp:1090
ace argon_type SubtractAbsAdd(argon_type b, argon_type c) const
Subtract two vectors, taking the absolute value of the result and adding a third vector.
Definition vector.hpp:430
ace argon_type ReciprocalEstimate() const
1 / value, using an estimate for speed
Definition vector.hpp:674
constexpr Vector(Vector &&other)=default
Move constructor for the Vector class.
ace argon_type Subtract(argon_type b) const
Subtract two vectors.
Definition vector.hpp:409
ace argon_type BitwiseXor(argon_type b) const
Bitwise XOR of the vector with another vector.
Definition vector.hpp:1463
ace Vector(argon::Lane< VectorType > lane)
Constructs a Vector from a Lane object.
Definition vector.hpp:116
static ace argon_type Generate(FuncType body)
Constructs a Vector from a function that generates values.
Definition vector.hpp:209
ace argon_type AddHalveRound(argon_type b) const
Adds two vectors, halving and rounding the result.
Definition vector.hpp:401
Predicate< simd::Vec128_t< ScalarType > > argon_bool_type
Definition vector.hpp:85
ace Lane< const VectorType > operator[](const size_t i) const
Access a lane of the vector by index.
Definition vector.hpp:288
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
Header file for SIMD features and platform detection.
#define ARGON_NEON_FP16_VECTOR
True where NEON has half-precision vector arithmetic (FEAT_FP16), so the f16 forms of vmaxnm/vminnm e...
Definition features.h:93
#define ARGON_HAS_MAXNM
True where vmaxnm/vminnm exist (simd::max_strict / min_strict): Helium with floating point,...
Definition features.h:77
#define ARGON_GCC_AARCH32_FLOAT
True where GCC compiles AArch32 NEON code without -ffast-math: it then scalarises generic vector-exte...
Definition features.h:111
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
A 128-bit SIMD vector wrapping a scalar type, providing arithmetic, logical, and data-movement operat...
Definition argon.hpp:30
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
Bool< T >::type Bool_t
Helper alias to get the boolean type of a SIMD operation.
Definition bool.hpp:49
constexpr bool is_one_of
Helper template to check if a type is one of the specified types.
Definition vector.hpp:46
constexpr std::array< helpers::ArgonFor_t< T >, N > to_array(T(&a)[N])
Convert a C-style array of vector types to a std::array of Argon types.
Definition to_array.hpp:31
Lane deconstruction feature.
Definition argon_full.hpp:1547
A per-lane boolean for a SIMD vector type, as returned by comparisons.
Helper functions to convert C-style arrays to std::array of Argon types, mimicking std::to_array.