5#include "argon/argon_full.hpp"
6#include "argon/argon_half.hpp"
8#include "argon/store.hpp"
26#ifndef ARGON_PLATFORM_MVE
27namespace argon::vectorize::detail {
34template <
typename ScalarType>
36#if defined(__arm__) && !defined(__aarch64__) && defined(__GNUC__)
45template <
size_t Lane,
typename ScalarType>
47 const ScalarType*
ptr,
51 if (first +
Lane < count) {
60template <
size_t Lane,
typename ScalarType>
63 if (first +
Lane < count) {
71template <
typename ScalarType>
74 constexpr size_t half = half_type::lanes;
75 const half_type zero{ScalarType{0}};
83template <
typename ScalarType>
95template <
size_t Str
ide,
typename ScalarType>
96using half_multi_type = neon::MultiVector_t<typename ArgonHalf<ScalarType>::vector_type, Stride>;
100template <
size_t Lane,
size_t Str
ide,
typename ScalarType>
102 const ScalarType*
ptr,
106 if constexpr (
Lane + 1 < half_type::lanes) {
107 if (first +
Lane < count) {
108 auto loaded = half_type::template LoadToLaneInterleaved<Lane, Stride>(multi,
ptr +
Lane * Stride);
109 for (
size_t channel = 0; channel < Stride; ++channel)
110 multi.val[channel] = loaded.data()[channel].vec();
119template <
size_t Lane,
size_t Str
ide,
typename ScalarType>
125 if constexpr (
Lane + 1 < half_type::lanes) {
126 if (first +
Lane < count) {
136template <
size_t Str
ide,
typename ScalarType>
140 constexpr size_t half = half_type::lanes;
142 for (
size_t channel = 0; channel < Stride; ++channel)
143 zero.val[channel] = half_type{ScalarType{0}}.vec();
144 half_multi_type<Stride, ScalarType> low = zero;
145 half_multi_type<Stride, ScalarType> high = zero;
147 auto whole = half_type::template LoadInterleaved<Stride>(ptr);
148 for (
size_t channel = 0; channel < Stride; ++channel)
149 low.val[channel] = whole.data()[channel].vec();
150 high = load_frames<0, Stride>(zero, ptr + half * Stride, half, count);
152 low = load_frames<0, Stride>(zero, ptr, 0, count);
154 std::array<Argon<ScalarType>, Stride> out;
155 for (
size_t channel = 0; channel < Stride; ++channel) {
156 out.data()[channel] =
Argon<ScalarType>{half_type{low.val[channel]}, half_type{high.val[channel]}};
163template <
size_t Str
ide,
typename ScalarType>
168 constexpr size_t half = half_type::lanes;
171 for (
size_t channel = 0; channel < Stride; ++channel) {
172 low.val[channel] = value.data()[channel].GetLow().vec();
173 high.val[channel] = value.data()[channel].GetHigh().vec();
185template <
typename N,
typename S>
187 constexpr size_t lanes = Argon<S>::lanes;
188 if constexpr (
sizeof(S) == 2 *
sizeof(N)) {
191 const auto wide = neon::move_long(narrow.vec());
195 std::array<S, lanes> out{};
196 for (
size_t i = 0; i < lanes; ++i) {
198 out.data()[i] =
static_cast<S
>(
ptr[i]);
206template <
typename N,
typename S>
208 constexpr size_t lanes = Argon<S>::lanes;
209 if constexpr (
sizeof(S) == 2 *
sizeof(N)) {
211 using SameSign = std::conditional_t<std::is_signed_v<N>, std::make_signed_t<S>, std::make_unsigned_t<S>>;
215 for (
size_t i = 0; i < lanes; ++i) {
217 ptr[i] =
static_cast<N
>(values.data()[i]);
Definition argon_half.hpp:11
Definition argon_full.hpp:44
ace ArgonHalf< ScalarType > GetLow() const
Return the lower 64 bits as an ArgonHalf.
Definition argon_full.hpp:268
ace ArgonHalf< ScalarType > GetHigh() const
Return the upper 64 bits as an ArgonHalf.
Definition argon_full.hpp:266
Represents a single lane of a SIMD vector with a runtime-determined index.
Definition lane.hpp:107
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 void StoreTo(scalar_type *ptr) const
Store the vector to a pointer.
Definition vector.hpp:1356
ace std::array< scalar_type, lanes > to_array() const
Convert the vector to an array of scalar values.
Definition vector.hpp:319
Header file for SIMD features and platform detection.
ArgonHalf< ScalarType > load_lanes(ArgonHalf< ScalarType > v, const ScalarType *ptr, size_t first, size_t count)
Load lanes [Lane, half - 1) of the doubleword v from ptr + lane, while first + lane < count.
Definition first_n.hpp:46
Argon< S > load_first_n_widen(const N *ptr, size_t count)
Load the first count (0 < count < lanes) elements of the narrower integer type N at ptr,...
Definition first_n.hpp:186
half_multi_type< Stride, ScalarType > load_frames(half_multi_type< Stride, ScalarType > multi, const ScalarType *ptr, size_t first, size_t count)
Load frames [Lane, half - 1) of multi from ptr + lane * Stride, one vld2-vld4 to a lane each,...
Definition first_n.hpp:101
void store_frames(half_multi_type< Stride, ScalarType > multi, ScalarType *ptr, size_t first, size_t count)
Store frames [Lane, half - 1) of multi to ptr + lane * Stride, one vst2-vst4 from a lane each,...
Definition first_n.hpp:120
neon::MultiVector_t< typename ArgonHalf< ScalarType >::vector_type, Stride > half_multi_type
The channels of interleaved data as doublewords, the operand of the structured loads and stores.
Definition first_n.hpp:96
void store_lanes(ArgonHalf< ScalarType > v, ScalarType *ptr, size_t first, size_t count)
Store lanes [Lane, half - 1) of the doubleword v to ptr + lane, while first + lane < count (see load_...
Definition first_n.hpp:61
ScalarType * opaque_address(ScalarType *ptr)
ptr, as an address the compiler can't relate to its neighbours.
Definition first_n.hpp:35
void store_first_n_interleaved(ScalarType *ptr, std::array< Argon< ScalarType >, Stride > value, size_t count)
Store the first count frames (0 < count < lanes) of value, one vector per channel,...
Definition first_n.hpp:164
std::array< Argon< ScalarType >, Stride > load_first_n_interleaved(const ScalarType *ptr, size_t count)
Load the first count frames (0 < count < lanes) of Stride interleaved elements at ptr,...
Definition first_n.hpp:137
Argon< ScalarType > load_first_n(const ScalarType *ptr, size_t count)
Load the first count lanes at ptr (0 < count < lanes); the rest are zero and not read.
Definition first_n.hpp:72
void store_first_n_narrow(N *ptr, Argon< S > value, size_t count)
Store the low bits of the first count (0 < count < lanes) lanes of value as the narrower integer type...
Definition first_n.hpp:207
void store_first_n(ScalarType *ptr, Argon< ScalarType > value, size_t count)
Store the first count lanes of value to ptr (0 < count < lanes); the rest are not written.
Definition first_n.hpp:84
ace void store_lane_interleaved(scalar_type *ptr, std::array< argon_type, stride > multi_vec)
Store a lane of an array of vectors to a location in memory with interleaving.
Definition store.hpp:203
ace void store_interleaved(scalar_type *ptr, simd::MultiVector_t< intrinsic_type, stride > multi_vec)
Store a multi-vector to a location in memory with interleaving.
Definition store.hpp:32