Argon 0.1.0
Loading...
Searching...
No Matches
argon::PointerVector< T > Class Template Reference

One pointer per lane, gathered from and scattered to together, and advanced together: walking several buffers (channels, matrix columns, filter states) at once. More...

#include <pointer_vector.hpp>

Public Types

using argon_type = Argon<value_type>
 The vector type loaded and stored.

Public Member Functions

 PointerVector (const std::array< T *, lanes > &pointers)
 Point lane i at pointers[i].
std::array< T *, lanes > pointers () const
 The current pointers.
template<int offset = 0>
argon_type Load () const
 Load lane i from offset bytes past pointer i.
template<int offset = 0>
void Store (argon_type value) const
 Store lane i of value to offset bytes past pointer i.
template<int step>
void Advance ()
 Advance every pointer by step bytes.
template<int step>
argon_type AdvanceAndLoad ()
 Advance every pointer by step bytes, then load through them: one step of a lockstep walk.
template<int step>
void AdvanceAndStore (argon_type value)
 Advance every pointer by step bytes, then store value through them.

Static Public Attributes

static constexpr size_t lanes = argon_type::lanes
 The number of pointers.
template<int offset>
static constexpr bool valid_offset
 Whether a byte offset or step is encodable: a multiple of the element size, within range.

Detailed Description

template<typename T>
requires (lane_scalar<std::remove_const_t<T>> && (sizeof(T) == 4 || sizeof(T) == 8))
class argon::PointerVector< T >

One pointer per lane, gathered from and scattered to together, and advanced together: walking several buffers (channels, matrix columns, filter states) at once.

Template Parameters
TThe element type: 32-bit (4 lanes) or 64-bit (2 lanes). A const type allows loads only.

On MVE the pointers live in a vector register and each access is one gather or scatter (vldrw / vldrd / vstrw / vstrd with a vector of base addresses). Elsewhere they are ordinary pointers, accessed lane by lane. Offsets and steps are in bytes; as the instructions require, they are multiples of sizeof(T), within ±508 bytes for 32-bit elements and ±1016 for 64-bit ones. The limits apply on every platform, so code stays portable.

Member Function Documentation

◆ AdvanceAndLoad()

template<typename T>
template<int step>
argon_type argon::PointerVector< T >::AdvanceAndLoad ( )
inline

Advance every pointer by step bytes, then load through them: one step of a lockstep walk.

MVE with clang: the pre-incrementing write-back gather (vldrw.32 ... [q]!). GCC 16.2 crashes on the 32-bit write-back intrinsics given anything but the address of a local, so with GCC this is a gather and an add, with the same result.

◆ AdvanceAndStore()

template<typename T>
template<int step>
void argon::PointerVector< T >::AdvanceAndStore ( argon_type value)
inline

Advance every pointer by step bytes, then store value through them.

MVE with clang: the write-back scatter (vstrw.32 ... [q]!); with GCC a scatter and an add, as for AdvanceAndLoad.

Member Data Documentation

◆ valid_offset

template<typename T>
template<int offset>
bool argon::PointerVector< T >::valid_offset
staticconstexpr
Initial value:
= offset % int{sizeof(T)} == 0 && offset >= -127 * int{sizeof(T)} &&
offset <= 127 * int{sizeof(T)}

Whether a byte offset or step is encodable: a multiple of the element size, within range.


The documentation for this class was generated from the following file: