32#if (defined(__GNUC__) || defined(__clang__)) && !defined(PULP_SIMD_DISABLE_VECTOR_LANES)
33#define PULP_SIMD_HAS_VECTOR_LANES 1
37template <
typename T, std::
size_t N>
struct vector_lanes {
38 static_assert(std::is_arithmetic_v<T> && N > 1 && (N & (N - 1)) == 0,
39 "Lanes needs an arithmetic element type and a power-of-two width above 1");
40 typedef T type __attribute__((vector_size(N *
sizeof(T))));
45template <
typename T, std::
size_t N>
using Lanes =
typename detail::vector_lanes<T, N>::type;
47#define PULP_SIMD_HAS_VECTOR_LANES 0
54 if constexpr (std::is_arithmetic_v<V>)
55 return std::size_t{1};
57 return sizeof(V) /
sizeof(V{}[0]);
61template <
typename V>
inline auto get_lane(
const V& v, std::size_t i)
noexcept {
62 if constexpr (std::is_arithmetic_v<V>) {
71template <
typename V,
typename T>
inline void set_lane(V& v, std::size_t i, T x)
noexcept {
72 if constexpr (std::is_arithmetic_v<V>) {
74 v =
static_cast<V
>(x);
Definition scalar_kernels.hpp:20
void set_lane(V &v, std::size_t i, T x) noexcept
Set lane i of v to x; a scalar is its own lane 0.
Definition lanes.hpp:71
constexpr bool kHasVectorLanes
Definition lanes.hpp:48
constexpr std::size_t lane_count
Number of lanes in V: 1 for a scalar, N for Lanes<T, N>.
Definition lanes.hpp:53
auto get_lane(const V &v, std::size_t i) noexcept
Lane i of v; a scalar is its own lane 0.
Definition lanes.hpp:61