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