diff options
author | Alexander Smirnov <alex@ydb.tech> | 2024-11-20 11:14:58 +0000 |
---|---|---|
committer | Alexander Smirnov <alex@ydb.tech> | 2024-11-20 11:14:58 +0000 |
commit | 31773f157bf8164364649b5f470f52dece0a4317 (patch) | |
tree | 33d0f7eef45303ab68cf08ab381ce5e5e36c5240 /contrib/libs/cxxsupp/libcxx/include/experimental/__simd | |
parent | 2c7938962d8689e175574fc1e817c05049f27905 (diff) | |
parent | eff600952d5dfe17942f38f510a8ac2b203bb3a5 (diff) | |
download | ydb-31773f157bf8164364649b5f470f52dece0a4317.tar.gz |
Merge branch 'rightlib' into mergelibs-241120-1113
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/experimental/__simd')
4 files changed, 40 insertions, 0 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/scalar.h b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/scalar.h index 341292612e..479809392f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/scalar.h +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/scalar.h @@ -46,6 +46,11 @@ struct __simd_operations<_Tp, simd_abi::__scalar> { using _MaskStorage = __mask_storage<_Tp, simd_abi::__scalar>; static _LIBCPP_HIDE_FROM_ABI _SimdStorage __broadcast(_Tp __v) noexcept { return {__v}; } + + template <class _Generator> + static _LIBCPP_HIDE_FROM_ABI _SimdStorage __generate(_Generator&& __g) noexcept { + return {__g(std::integral_constant<size_t, 0>())}; + } }; template <class _Tp> diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/simd.h b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/simd.h index 30856f4b03..954f94c907 100644 --- a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/simd.h +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/simd.h @@ -44,6 +44,10 @@ public: template <class _Up, enable_if_t<__can_broadcast_v<value_type, __remove_cvref_t<_Up>>, int> = 0> _LIBCPP_HIDE_FROM_ABI simd(_Up&& __v) noexcept : __s_(_Impl::__broadcast(static_cast<value_type>(__v))) {} + // generator constructor + template <class _Generator, enable_if_t<__can_generate_v<value_type, _Generator, size()>, int> = 0> + explicit _LIBCPP_HIDE_FROM_ABI simd(_Generator&& __g) : __s_(_Impl::__generate(std::forward<_Generator>(__g))) {} + // scalar access [simd.subscr] // Add operator[] temporarily to test braodcast. Add test for it in later patch. _LIBCPP_HIDE_FROM_ABI value_type operator[](size_t __i) const { return __s_.__get(__i); } diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/utility.h b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/utility.h index 0dba345e05..847d006629 100644 --- a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/utility.h +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/utility.h @@ -19,6 +19,7 @@ #include <__type_traits/is_volatile.h> #include <__type_traits/void_t.h> #include <__utility/declval.h> +#include <__utility/integer_sequence.h> #include <cstdint> #include <limits> @@ -71,6 +72,25 @@ inline constexpr bool __can_broadcast_v = (!__is_vectorizable_v<_Up> && is_convertible_v<_Up, _Tp>) || is_same_v<_Up, int> || (is_same_v<_Up, unsigned int> && is_unsigned_v<_Tp>); +template <class _Tp, class _Generator, std::size_t _Idx, class = void> +inline constexpr bool __is_well_formed = false; + +template <class _Tp, class _Generator, std::size_t _Idx> +inline constexpr bool + __is_well_formed<_Tp, + _Generator, + _Idx, + std::void_t<decltype(std::declval<_Generator>()(integral_constant<size_t, _Idx>()))>> = + __can_broadcast_v<_Tp, decltype(std::declval<_Generator>()(integral_constant<size_t, _Idx>()))>; + +template <class _Tp, class _Generator, std::size_t... _Idxes> +_LIBCPP_HIDE_FROM_ABI constexpr bool __can_generate(index_sequence<_Idxes...>) { + return (true && ... && __is_well_formed<_Tp, _Generator, _Idxes>); +} + +template <class _Tp, class _Generator, std::size_t _Size> +inline constexpr bool __can_generate_v = experimental::__can_generate<_Tp, _Generator>(make_index_sequence<_Size>()); + } // namespace parallelism_v2 _LIBCPP_END_NAMESPACE_EXPERIMENTAL diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/vec_ext.h b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/vec_ext.h index 44a1f481ab..4b23bfe384 100644 --- a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/vec_ext.h +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/vec_ext.h @@ -11,6 +11,7 @@ #define _LIBCPP_EXPERIMENTAL___SIMD_VEC_EXT_H #include <__bit/bit_ceil.h> +#include <__utility/forward.h> #include <cstddef> #include <experimental/__simd/internal_declaration.h> #include <experimental/__simd/utility.h> @@ -56,6 +57,16 @@ struct __simd_operations<_Tp, simd_abi::__vec_ext<_Np>> { } return __result; } + + template <class _Generator, size_t... _Is> + static _LIBCPP_HIDE_FROM_ABI _SimdStorage __generate_init(_Generator&& __g, std::index_sequence<_Is...>) { + return _SimdStorage{{__g(std::integral_constant<size_t, _Is>())...}}; + } + + template <class _Generator> + static _LIBCPP_HIDE_FROM_ABI _SimdStorage __generate(_Generator&& __g) noexcept { + return __generate_init(std::forward<_Generator>(__g), std::make_index_sequence<_Np>()); + } }; template <class _Tp, int _Np> |