9#include "argon/argon_full.hpp"
10#include "argon/helpers/argon_for.hpp"
11#include "argon/helpers/size.hpp"
12#include "arm_simd/helpers/vec128.hpp"
15#ifdef __ARM_FEATURE_MVE
21namespace argon::vectorize {
26template <
typename ScalarType>
27struct load_store :
public std::ranges::view_interface<load_store<ScalarType>> {
80 loaded_ = dirty_ =
false;
93 friend bool operator==(
const Iterator& a,
const Iterator& b) {
return a.ptr == b.ptr; }
96 friend bool operator==(
const Iterator& a,
const ScalarType* ptr) {
return a.ptr == ptr; }
100 friend bool operator!=(
const Iterator& a,
const Iterator& b) {
return a.ptr != b.ptr; }
103 friend bool operator!=(
const Iterator& a,
const ScalarType* ptr) {
return a.ptr != ptr; }
107 vec = value_type::Load(ptr);
115 vec = value_type::Load(
ptr);
121 mutable bool loaded_ =
false;
122 ScalarType* ptr =
nullptr;
125 static_assert(std::input_or_output_iterator<Iterator>);
128 struct ConstIterator {
133 ConstIterator() =
default;
153 ConstIterator tmp = *
this;
160 friend bool operator==(
const ConstIterator& a,
const ConstIterator& b) {
return a.ptr == b.ptr; }
164 friend bool operator!=(
const ConstIterator& a,
const ConstIterator& b) {
return a.ptr != b.ptr; }
167 friend bool operator==(
const ConstIterator& a,
const ScalarType* ptr) {
return a.ptr == ptr; }
170 const ScalarType*
ptr =
nullptr;
172 static_assert(std::input_iterator<ConstIterator>);
181 : start_{start}, size_{
helpers::vectorizeable_size<ScalarType>(
end - start) /
lanes}, count_{static_cast<size_t>(
end - start)} {};
192 : start_{span.data()}, size_{
helpers::vectorizeable_size<ScalarType>(span.
size()) /
lanes}, count_{span.
size()} {};
197 template <std::ranges::contiguous_range R>
207 ScalarType*
end()
const {
return start_ + (size_ *
lanes); }
215 const ScalarType*
cend()
const {
return start_ + (size_ *
lanes); }
220 size_t size()
const {
return size_; }
235template <std::ranges::contiguous_range R>
236load_store(R&& r) -> load_store<std::ranges::range_value_t<R>>;
238static_assert(std::ranges::range<load_store<int32_t>>);
239static_assert(std::ranges::view<load_store<int32_t>>);
240static_assert(std::movable<load_store<int32_t>>);
241static_assert(std::ranges::viewable_range<load_store<int32_t>>);
In-place read/write view of a range as vectors, including a final partial vector.
Definition tail.hpp:275
Contains helper templates and concepts for type manipulation and compile-time utilities.
Definition argon.hpp:156
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
Lane deconstruction feature.
Definition argon_full.hpp:1547
A const iterator for the vectorized view.
Definition load_store.hpp:128
const value_type operator*() const
Dereference the const iterator to get the current value.
Definition load_store.hpp:141
friend bool operator==(const ConstIterator &a, const ScalarType *ptr)
Compare against the end of the range (cend()).
Definition load_store.hpp:167
ConstIterator(const ScalarType *ptr)
Constructs a const iterator from a pointer to the start of the range.
Definition load_store.hpp:137
ConstIterator operator++(int)
Postfix increment operator for the const iterator.
Definition load_store.hpp:152
helpers::ArgonFor_t< intrinsic_type > value_type
The value type of the iterator.
Definition load_store.hpp:130
friend bool operator==(const ConstIterator &a, const ConstIterator &b)
Equivalence operator.
Definition load_store.hpp:160
friend bool operator!=(const ConstIterator &a, const ConstIterator &b)
Non-equivalence operator.
Definition load_store.hpp:164
std::ptrdiff_t difference_type
The difference type of the iterator.
Definition load_store.hpp:131
std::forward_iterator_tag iterator_category
The iterator category.
Definition load_store.hpp:129
ConstIterator & operator++()
Increment operator for the const iterator.
Definition load_store.hpp:145
An iterator for the vectorized view.
Definition load_store.hpp:36
friend bool operator==(const Iterator &a, const ScalarType *ptr)
Comparison operators for the iterator.
Definition load_store.hpp:96
helpers::ArgonFor_t< intrinsic_type > value_type
The value type of the iterator.
Definition load_store.hpp:38
friend bool operator!=(const Iterator &a, const Iterator &b)
Comparison operators for the iterator.
Definition load_store.hpp:100
Iterator(ScalarType *ptr)
Constructs an iterator from a pointer to the start of the range.
Definition load_store.hpp:45
Iterator & operator++()
Increment the iterator to the next value.
Definition load_store.hpp:75
void reload()
Reload the iterator with the current value.
Definition load_store.hpp:106
Iterator operator++(int)
Postfix increment operator for the iterator.
Definition load_store.hpp:85
std::forward_iterator_tag iterator_category
The iterator category.
Definition load_store.hpp:37
value_type & operator*()
Dereference the iterator to get the current value.
Definition load_store.hpp:54
value_type * operator->()
Dereference the iterator to get the current value.
Definition load_store.hpp:67
friend bool operator==(const Iterator &a, const Iterator &b)
Comparison operators for the iterator.
Definition load_store.hpp:93
std::ptrdiff_t difference_type
The difference type of the iterator.
Definition load_store.hpp:39
friend bool operator!=(const Iterator &a, const ScalarType *ptr)
Comparison operators for the iterator.
Definition load_store.hpp:103
load_store(ScalarType *start, ScalarType *end)
Constructs a vectorized view from a pointer to the start of the range and the end of the range.
Definition load_store.hpp:180
load_store(std::span< ScalarType > span)
Constructs a vectorized view from a span.
Definition load_store.hpp:191
iterator begin() const
Returns an iterator to the beginning.
Definition load_store.hpp:203
ConstIterator const_iterator
The const iterator type for the vectorized view.
Definition load_store.hpp:175
size_t size() const
Get the size of the view.
Definition load_store.hpp:220
Iterator iterator
The iterator type for the vectorized view.
Definition load_store.hpp:174
simd::Vec128_t< ScalarType > intrinsic_type
The SIMD vector type used for vectorization.
Definition load_store.hpp:29
static constexpr size_t lanes
The number of lanes in the SIMD vector.
Definition load_store.hpp:32
load_store(R &&r)
Constructs a vectorized view from a range.
Definition load_store.hpp:198
const ScalarType * cend() const
Returns a const iterator to the end of the range.
Definition load_store.hpp:215
load_store_tail< ScalarType > with_tail() const
A view of the same range that also visits the final, partial vector.
Definition load_store.hpp:225
load_store(ScalarType *start, const size_t size)
Constructs a vectorized view from a pointer to the start of the range and the size of the range.
Definition load_store.hpp:186
const_iterator cbegin() const
Returns a const iterator to the beginning of the range.
Definition load_store.hpp:211
ScalarType * end() const
Returns an iterator to the end.
Definition load_store.hpp:207
A view that loads data from a contiguous range into SIMD vectors.
Definition load.hpp:37
Vectorized views that also visit the final, partial vector of a range (see with_tail() on the views).