Argon 0.1.0
Loading...
Searching...
No Matches
scalar.hpp
1#pragma once
2#include <type_traits>
3#include "argon/features.h"
4
5#ifdef __ARM_NEON
6#include <arm_neon.h>
7#define simd neon
8#elifdef __ARM_FEATURE_MVE
9#include <arm_mve.h>
10#define simd mve
11#else
12#define SIMDE_ENABLE_NATIVE_ALIASES
13#include <arm/neon.h>
14#define simd neon
15#endif
16
17namespace simd {
18// clang-format off
19
22template <typename T> struct Scalar;
23
25template <> struct Scalar<int8x16_t> { using type = int8_t; };
26template <> struct Scalar<uint8x16_t> { using type = uint8_t; };
27template <> struct Scalar<int16x8_t> { using type = int16_t; };
28template <> struct Scalar<uint16x8_t> { using type = uint16_t; };
29template <> struct Scalar<int32x4_t> { using type = int32_t; };
30template <> struct Scalar<uint32x4_t> { using type = uint32_t; };
31template <> struct Scalar<int64x2_t> { using type = int64_t; };
32template <> struct Scalar<uint64x2_t> { using type = uint64_t; };
33
34#if ARGON_HAS_SINGLE_FLOAT
35template <> struct Scalar<float32x4_t> { using type = float; };
36#endif
37
38#if ARGON_HAS_HALF_FLOAT
39template <> struct Scalar<float16x8_t> { using type = float16_t; };
40#endif
41
42#if ARGON_HAS_DOUBLE_FLOAT
43template <> struct Scalar<float64x2_t> { using type = double; };
44#endif
45
46#ifndef ARGON_PLATFORM_MVE
47template <> struct Scalar<int8x8_t> { using type = int8_t; };
48template <> struct Scalar<uint8x8_t> { using type = uint8_t; };
49template <> struct Scalar<int16x4_t> { using type = int16_t; };
50template <> struct Scalar<uint16x4_t> { using type = uint16_t; };
51template <> struct Scalar<int32x2_t> { using type = int32_t; };
52template <> struct Scalar<uint32x2_t> { using type = uint32_t; };
53template <> struct Scalar<int64x1_t> { using type = int64_t; };
54template <> struct Scalar<uint64x1_t> { using type = uint64_t; };
55#if ARGON_HAS_SINGLE_FLOAT
56template <> struct Scalar<float32x2_t> { using type = float; };
57#endif
58
59#if ARGON_HAS_HALF_FLOAT
60template <> struct Scalar<float16x4_t> { using type = float16_t; };
61#endif
62
63#if ARGON_HAS_DOUBLE_FLOAT
64template <> struct Scalar<float64x1_t> { using type = double; };
65#endif
66#endif
68
71template <typename T>
72using Scalar_t = typename Scalar<std::remove_cv_t<T>>::type;
73
74// clang-format on
75} // namespace simd
76#undef simd
Header file for SIMD features and platform detection.
Helper template to get the scalar type of a SIMD vector type.
Definition scalar.hpp:22