13#include <xvec/detail/config.hpp>
17namespace _XVEC_NAMESPACE::simd
29#if defined(__SSE__) and !defined(_XVEC_FORCE_SCALAR)
39struct x86_sse_tag :
public x86_tag {};
40struct x86_avx_tag :
public x86_sse_tag {};
41struct x86_avx2_tag :
public x86_avx_tag {};
42struct compact_mask_tag :
public x86_avx2_tag {};
43struct x86_avx512_tag :
public compact_mask_tag {};
44struct x86_avxsnc_tag :
public x86_avx512_tag {};
45struct x86_avxspr_tag :
public x86_avxsnc_tag {};
46struct x86_avx10_tag :
public x86_avxspr_tag {};
48#if defined(__AVX10_2__)
49 using target_tag = x86_avx10_tag;
50#elif defined(__AVX512FP16__)
51 using target_tag = x86_avxspr_tag;
52#elif defined(__AVX512VPOPCNTDQ__)
53 using target_tag = x86_avxsnc_tag;
54#elif defined(__AVX512F__)
55 using target_tag = x86_avx512_tag;
56#elif defined (__AVX2__)
57 using target_tag = x86_avx2_tag;
58#elif defined (__AVX__)
59 using target_tag = x86_avx_tag;
61 using target_tag = x86_sse_tag;
68inline constexpr bool hasSse = std::derived_from<target_tag, x86_sse_tag>;
69inline constexpr bool hasAvx = std::derived_from<target_tag, x86_avx_tag>;
70inline constexpr bool hasAvx2 = std::derived_from<target_tag, x86_avx2_tag>;
71inline constexpr bool hasAvx512 = std::derived_from<target_tag, x86_avx512_tag>;
72inline constexpr bool hasAvxFp16 = std::derived_from<target_tag, x86_avxspr_tag>;
75inline constexpr int maxBytesInVec = hasAvx512 ? 64 : hasAvx ? 32 : hasSse ? 16 : 0;
81template<
typename _Tp,
int _Np>
82inline constexpr int register_size =
83 (hasAvx512 && (
sizeof(_Tp) * _Np) > 32) ? (64 /
sizeof(_Tp)) :
84 (hasAvx && (
sizeof(_Tp) * _Np) > 16) ? (32 /
sizeof(_Tp)) :
94 constexpr auto bytes =
sizeof(T);
96 using _Tp = std::remove_cvref_t<decltype(std::declval<T&>()[0])>;
98 constexpr bool isFloat = std::same_as<float, _Tp>;
99 constexpr bool isDouble = std::same_as<double, _Tp>;
102 return invalid_register{};
104#if defined(__AVX512FP16__)
105 if constexpr (std::same_as<_Tp, _Float16>)
107 if constexpr (bytes > 32)
return __m512h();
108 else if constexpr (bytes > 16)
return __m256h();
109 else return __m128h();
112#if defined(__AVX512F__)
113 if constexpr (bytes > 32)
115 if constexpr (isFloat)
return __m512();
116 else if constexpr (isDouble)
return __m512d();
117 else return __m512i();
121 if constexpr (bytes > 16)
123 if constexpr (isFloat)
return __m256();
124 else if constexpr (isDouble)
return __m256d();
125 else return __m256i();
129 if constexpr (isFloat)
return __m128();
130 else if constexpr (isDouble)
return __m128d();
131 else return __m128i();
149template<
typename _Tp,
int _Np>
inline constexpr int register_size =
maxBytesInVec /
sizeof(_Tp);
163#if defined(_XVEC_GENERIC_COMPACT)
177inline constexpr auto target = target_tag{};
Definition target_config.hpp:175
consteval auto get_register_type()
Definition target_config.hpp:157
constexpr int maxBytesInVec
Definition target_config.hpp:148
Definition target_config.hpp:161
Definition target_config.hpp:23
Definition target_config.hpp:27