File indexing completed on 2026-05-03 08:14:08
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef _LIBCPP_EXPERIMENTAL___SIMD_TRAITS_H
0011 #define _LIBCPP_EXPERIMENTAL___SIMD_TRAITS_H
0012
0013 #include <__bit/bit_ceil.h>
0014 #include <__config>
0015 #include <__cstddef/size_t.h>
0016 #include <__type_traits/integral_constant.h>
0017 #include <__type_traits/is_same.h>
0018 #include <experimental/__simd/declaration.h>
0019 #include <experimental/__simd/utility.h>
0020
0021 #if _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_ENABLE_EXPERIMENTAL)
0022
0023 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
0024 inline namespace parallelism_v2 {
0025
0026
0027 template <class _Tp>
0028 inline constexpr bool is_abi_tag_v = false;
0029
0030 template <class _Tp>
0031 struct is_abi_tag : bool_constant<is_abi_tag_v<_Tp>> {};
0032
0033 template <class _Tp>
0034 inline constexpr bool is_simd_v = false;
0035
0036 template <class _Tp>
0037 struct is_simd : bool_constant<is_simd_v<_Tp>> {};
0038
0039 template <class _Tp>
0040 inline constexpr bool is_simd_mask_v = false;
0041
0042 template <class _Tp>
0043 struct is_simd_mask : bool_constant<is_simd_mask_v<_Tp>> {};
0044
0045 template <class _Tp>
0046 inline constexpr bool is_simd_flag_type_v = false;
0047
0048 template <class _Tp>
0049 struct is_simd_flag_type : bool_constant<is_simd_flag_type_v<_Tp>> {};
0050
0051 template <class _Tp, class _Abi = simd_abi::compatible<_Tp>, bool = (__is_vectorizable_v<_Tp> && is_abi_tag_v<_Abi>)>
0052 struct simd_size : integral_constant<size_t, _Abi::__simd_size> {};
0053
0054 template <class _Tp, class _Abi>
0055 struct simd_size<_Tp, _Abi, false> {};
0056
0057 template <class _Tp, class _Abi = simd_abi::compatible<_Tp>>
0058 inline constexpr size_t simd_size_v = simd_size<_Tp, _Abi>::value;
0059
0060 template <class _Tp,
0061 class _Up = typename _Tp::value_type,
0062 bool = (is_simd_v<_Tp> && __is_vectorizable_v<_Up>) || (is_simd_mask_v<_Tp> && is_same_v<_Up, bool>)>
0063 struct memory_alignment : integral_constant<size_t, std::__bit_ceil(sizeof(_Up) * _Tp::size())> {};
0064
0065 template <class _Tp, class _Up>
0066 struct memory_alignment<_Tp, _Up, false> {};
0067
0068 template <class _Tp, class _Up = typename _Tp::value_type>
0069 inline constexpr size_t memory_alignment_v = memory_alignment<_Tp, _Up>::value;
0070
0071 }
0072 _LIBCPP_END_NAMESPACE_EXPERIMENTAL
0073
0074 #endif
0075 #endif