Argon 0.1.0
Loading...
Searching...
No Matches
vector.hpp
1#pragma once
2#include "argon/features.h"
3
4#ifdef __ARM_NEON
5#include <arm_neon.h>
6#define simd neon
7#elifdef __ARM_FEATURE_MVE
8#include <arm_mve.h>
9#define simd mve
10#else
12#define simd neon
13#endif
14
15namespace simd {
16// clang-format off
19template <typename T, size_t Lanes> struct Vector;
20
21
23template <> struct Vector<int8_t, 16> { using type = int8x16_t; };
24template <> struct Vector<uint8_t, 16> { using type = uint8x16_t; };
25template <> struct Vector<int16_t, 8> { using type = int16x8_t; };
26template <> struct Vector<uint16_t, 8> { using type = uint16x8_t; };
27template <> struct Vector<int32_t, 4> { using type = int32x4_t; };
28template <> struct Vector<uint32_t, 4> { using type = uint32x4_t; };
29template <> struct Vector<int64_t, 2> { using type = int64x2_t; };
30template <> struct Vector<uint64_t, 2> { using type = uint64x2_t; };
31
32#if ARGON_HAS_SINGLE_FLOAT
33template <> struct Vector<float, 4> {using type = float32x4_t; };
34#endif
35
36#if ARGON_HAS_HALF_FLOAT
37template <> struct Vector<float16_t, 8> {using type = float16x8_t; };
38#endif
39
40#if ARGON_HAS_DOUBLE_FLOAT
41template <> struct Vector<float64_t, 2> {using type = float64x2_t; };
42#endif
43
44#ifndef ARGON_PLATFORM_MVE
45template <> struct Vector<int8_t, 8> { using type = int8x8_t; };
46template <> struct Vector<uint8_t, 8> { using type = uint8x8_t; };
47template <> struct Vector<int16_t, 4> { using type = int16x4_t; };
48template <> struct Vector<uint16_t, 4> { using type = uint16x4_t; };
49template <> struct Vector<int32_t, 2> { using type = int32x2_t; };
50template <> struct Vector<uint32_t, 2> { using type = uint32x2_t; };
51template <> struct Vector<int64_t, 1> { using type = int64x1_t; };
52template <> struct Vector<uint64_t, 1> { using type = uint64x1_t; };
53
54#if ARGON_HAS_SINGLE_FLOAT
55template <> struct Vector<float, 2> {using type = float32x2_t; };
56#endif
57
58#if ARGON_HAS_HALF_FLOAT
59template <> struct Vector<float16_t, 4> {using type = float16x4_t; };
60#endif
61
62#if ARGON_HAS_DOUBLE_FLOAT
63template <> struct Vector<float64_t, 1> {using type = float64x1_t; };
64#endif
65#endif
67
70template <typename T, size_t Lanes>
71using Vector_t = typename Vector<T, Lanes>::type;
72
73// clang-format on
74} // namespace simd
75#undef simd
Header file for SIMD features and platform detection.
SIMDe's NEON implementation (x86 and other non-Arm hosts) under the NEON intrinsic names.
Helper template to get the SIMD double-word vector type for a given scalar type.
Definition vector.hpp:19