Argon 0.1.0
Loading...
Searching...
No Matches
concepts.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
13#define simd neon
14#endif
15
16namespace simd {
17// clang-format off
18
21template <typename T>
22constexpr bool is_quadword_v =
23 std::is_same_v<std::remove_cv_t<T>, uint8x16_t>
24 || std::is_same_v<std::remove_cv_t<T>, uint16x8_t>
25 || std::is_same_v<std::remove_cv_t<T>, uint32x4_t>
26 || std::is_same_v<std::remove_cv_t<T>, uint64x2_t>
27 || std::is_same_v<std::remove_cv_t<T>, int8x16_t>
28 || std::is_same_v<std::remove_cv_t<T>, int16x8_t>
29 || std::is_same_v<std::remove_cv_t<T>, int32x4_t>
30 || std::is_same_v<std::remove_cv_t<T>, int64x2_t>
31#if ARGON_HAS_SINGLE_FLOAT
32 || std::is_same_v<std::remove_cv_t<T>, float32x4_t>
33#endif
34#if ARGON_HAS_DOUBLE_FLOAT
35 || std::is_same_v<std::remove_cv_t<T>, float64x2_t>
36#endif
37#if ARGON_HAS_HALF_FLOAT
38 || std::is_same_v<std::remove_cv_t<T>, float16x8_t>
39#endif
40#if ARGON_HAS_BRAIN_FLOAT
41 || std::is_same_v<std::remove_cv_t<T>, bfloat16x8_t>
42#endif
43#if ARGON_HAS_POLY
44 || std::is_same_v<std::remove_cv_t<T>, poly8x16_t>
45 || std::is_same_v<std::remove_cv_t<T>, poly16x8_t>
46 || std::is_same_v<std::remove_cv_t<T>, poly32x4_t>
47 || std::is_same_v<std::remove_cv_t<T>, poly64x2_t>
48#endif
49 ;
50// clang-format on
51
55template <typename T>
56concept is_quadword = is_quadword_v<T>;
57
58#ifndef ARGON_PLATFORM_MVE
59// clang-format off
60
63template <typename T>
64constexpr bool is_doubleword_v =
65 std::is_same_v<std::remove_cv_t<T>, uint8x8_t>
66 || std::is_same_v<std::remove_cv_t<T>, uint16x4_t>
67 || std::is_same_v<std::remove_cv_t<T>, uint32x2_t>
68 || std::is_same_v<std::remove_cv_t<T>, uint64x1_t>
69 || std::is_same_v<std::remove_cv_t<T>, int8x8_t>
70 || std::is_same_v<std::remove_cv_t<T>, int16x4_t>
71 || std::is_same_v<std::remove_cv_t<T>, int32x2_t>
72 || std::is_same_v<std::remove_cv_t<T>, int64x1_t>
73#if ARGON_HAS_SINGLE_FLOAT
74 || std::is_same_v<std::remove_cv_t<T>, float32x2_t>
75#endif
76#if ARGON_HAS_DOUBLE_FLOAT
77 || std::is_same_v<std::remove_cv_t<T>, float64x1_t>
78#endif
79#if ARGON_HAS_HALF_FLOAT
80 || std::is_same_v<std::remove_cv_t<T>, float16x4_t>
81#endif
82#if ARGON_HAS_BRAIN_FLOAT
83 || std::is_same_v<std::remove_cv_t<T>, bfloat16x4_t>
84#endif
85#if ARGON_HAS_POLY
86 || std::is_same_v<std::remove_cv_t<T>, poly8x8_t>
87 || std::is_same_v<std::remove_cv_t<T>, poly16x4_t>
88 || std::is_same_v<std::remove_cv_t<T>, poly32x2_t>
89 || std::is_same_v<std::remove_cv_t<T>, poly64x1_t>
90#endif
91 ;
92// clang-format on
93
94#else
95template <typename T>
96constexpr bool is_doubleword_v = false;
97#endif
98
101template <typename T>
102concept is_doubleword = is_doubleword_v<T>;
103
107#ifndef ARGON_PLATFORM_MVE
108template <typename T>
110#else
111template <typename T>
113#endif
114
115} // namespace simd
116#undef simd
Concept to check if a type is a double-word SIMD vector type.
Definition concepts.hpp:102
Concept to check if a type is a quad-word SIMD vector type.
Definition concepts.hpp:56
Concept to check if a type is a vector type (either double-word or quad-word).
Definition concepts.hpp:109
Header file for SIMD features and platform detection.
SIMDe's NEON implementation (x86 and other non-Arm hosts) under the NEON intrinsic names.