6#include "argon/argon_full.hpp"
23 using value_type = std::remove_const_t<T>;
27 static constexpr size_t lanes = argon_type::lanes;
31 static constexpr bool valid_offset = offset %
int{
sizeof(T)} == 0 && offset >= -127 *
int{
sizeof(T)} &&
32 offset <= 127 *
int{
sizeof(T)};
36#ifdef ARGON_PLATFORM_MVE
37 std::array<address_scalar, lanes> addresses{};
38 for (
size_t i = 0; i < lanes; ++i) addresses[i] = static_cast<address_scalar>(
reinterpret_cast<uintptr_t
>(
pointers[i]));
47#ifdef ARGON_PLATFORM_MVE
49 std::array<T*, lanes> out{};
50 for (
size_t i = 0; i < lanes; ++i) out[i] = reinterpret_cast<T*>(
static_cast<uintptr_t
>(addresses[i]));
58 template <
int offset = 0>
59 requires valid_offset<offset>
61#ifdef ARGON_PLATFORM_MVE
62 if constexpr (std::is_same_v<value_type, int32_t>) {
63 return vldrwq_gather_base_s32(addresses_, offset);
64 }
else if constexpr (std::is_same_v<value_type, uint32_t>) {
65 return vldrwq_gather_base_u32(addresses_, offset);
66 }
else if constexpr (std::is_same_v<value_type, float>) {
67 return vldrwq_gather_base_f32(addresses_, offset);
68 }
else if constexpr (std::is_same_v<value_type, int64_t>) {
69 return vldrdq_gather_base_s64(addresses_, offset);
71 return vldrdq_gather_base_u64(addresses_, offset);
74 std::array<value_type, lanes> out{};
75 for (
size_t i = 0; i < lanes; ++i) out[i] = *At<offset>(i);
81 template <
int offset = 0>
82 requires(valid_offset<offset> && !std::is_const_v<T>)
84#ifdef ARGON_PLATFORM_MVE
85 if constexpr (std::is_same_v<value_type, int32_t>) {
86 vstrwq_scatter_base_s32(addresses_, offset, value.
vec());
87 }
else if constexpr (std::is_same_v<value_type, uint32_t>) {
88 vstrwq_scatter_base_u32(addresses_, offset, value.
vec());
89 }
else if constexpr (std::is_same_v<value_type, float>) {
90 vstrwq_scatter_base_f32(addresses_, offset, value.
vec());
91 }
else if constexpr (std::is_same_v<value_type, int64_t>) {
92 vstrdq_scatter_base_s64(addresses_, offset, value.
vec());
94 vstrdq_scatter_base_u64(addresses_, offset, value.
vec());
97 const auto values = value.
to_array();
98 for (
size_t i = 0; i < lanes; ++i) *At<offset>(i) = values[i];
104 requires valid_offset<step>
106#ifdef ARGON_PLATFORM_MVE
109 for (
auto& p : pointers_) p =
reinterpret_cast<T*
>(
reinterpret_cast<std::conditional_t<std::is_const_v<T>,
const char,
char>*>(p) + step);
118 requires valid_offset<step>
120#if defined(ARGON_PLATFORM_MVE) && defined(__clang__)
121 if constexpr (std::is_same_v<value_type, int32_t>) {
122 return vldrwq_gather_base_wb_s32(&addresses_, step);
123 }
else if constexpr (std::is_same_v<value_type, uint32_t>) {
124 return vldrwq_gather_base_wb_u32(&addresses_, step);
125 }
else if constexpr (std::is_same_v<value_type, float>) {
126 return vldrwq_gather_base_wb_f32(&addresses_, step);
127 }
else if constexpr (std::is_same_v<value_type, int64_t>) {
128 return vldrdq_gather_base_wb_s64(&addresses_, step);
130 return vldrdq_gather_base_wb_u64(&addresses_, step);
143 requires(valid_offset<step> && !std::is_const_v<T>)
145#if defined(ARGON_PLATFORM_MVE) && defined(__clang__)
146 if constexpr (std::is_same_v<value_type, int32_t>) {
147 vstrwq_scatter_base_wb_s32(&addresses_, step, value.
vec());
148 }
else if constexpr (std::is_same_v<value_type, uint32_t>) {
149 vstrwq_scatter_base_wb_u32(&addresses_, step, value.
vec());
150 }
else if constexpr (std::is_same_v<value_type, float>) {
151 vstrwq_scatter_base_wb_f32(&addresses_, step, value.
vec());
152 }
else if constexpr (std::is_same_v<value_type, int64_t>) {
153 vstrdq_scatter_base_wb_s64(&addresses_, step, value.
vec());
155 vstrdq_scatter_base_wb_u64(&addresses_, step, value.
vec());
164#ifdef ARGON_PLATFORM_MVE
166 using address_scalar = std::conditional_t<
sizeof(T) == 4, uint32_t, uint64_t>;
167 typename Argon<address_scalar>::vector_type addresses_;
169 template <
int offset>
170 T* At(
size_t lane)
const {
171 using byte = std::conditional_t<std::is_const_v<T>,
const char,
char>;
172 return reinterpret_cast<T*
>(
reinterpret_cast<byte*
>(pointers_[lane]) + offset);
175 std::array<T*, lanes> pointers_{};
Definition argon_full.hpp:44
void AdvanceAndStore(argon_type value)
Advance every pointer by step bytes, then store value through them.
Definition pointer_vector.hpp:144
Argon< value_type > argon_type
The vector type loaded and stored.
Definition pointer_vector.hpp:26
static constexpr size_t lanes
The number of pointers.
Definition pointer_vector.hpp:27
void Store(argon_type value) const
Store lane i of value to offset bytes past pointer i.
Definition pointer_vector.hpp:83
void Advance()
Advance every pointer by step bytes.
Definition pointer_vector.hpp:105
argon_type Load() const
Load lane i from offset bytes past pointer i.
Definition pointer_vector.hpp:60
std::array< T *, lanes > pointers() const
The current pointers.
Definition pointer_vector.hpp:46
PointerVector(const std::array< T *, lanes > &pointers)
Point lane i at pointers[i].
Definition pointer_vector.hpp:35
static constexpr bool valid_offset
Whether a byte offset or step is encodable: a multiple of the element size, within range.
Definition pointer_vector.hpp:31
argon_type AdvanceAndLoad()
Advance every pointer by step bytes, then load through them: one step of a lockstep walk.
Definition pointer_vector.hpp:119
constexpr VectorType vec() const
Get the underlying SIMD vector.
Definition vector.hpp:312
static ace argon_type Load(const scalar_type *ptr)
Definition vector.hpp:1095
ace std::array< scalar_type, lanes > to_array() const
Convert the vector to an array of scalar values.
Definition vector.hpp:319
A scalar type a vector lane can hold: an arithmetic type, or float16_t where half-float vectors exist...
Definition lane_scalar.hpp:31
A 128-bit SIMD vector wrapping a scalar type, providing arithmetic, logical, and data-movement operat...
Definition argon.hpp:30