aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/include/experimental/__simd
diff options
context:
space:
mode:
authorMaxim Yurchuk <maxim-yurchuk@ydb.tech>2024-11-20 17:37:57 +0000
committerGitHub <noreply@github.com>2024-11-20 17:37:57 +0000
commitf76323e9b295c15751e51e3443aa47a36bee8023 (patch)
tree4113c8cad473a33e0f746966e0cf087252fa1d7a /contrib/libs/cxxsupp/libcxx/include/experimental/__simd
parent753ecb8d410a4cb459c26f3a0082fb2d1724fe63 (diff)
parenta7b9a6afea2a9d7a7bfac4c5eb4c1a8e60adb9e6 (diff)
downloadydb-f76323e9b295c15751e51e3443aa47a36bee8023.tar.gz
Merge pull request #11788 from ydb-platform/mergelibs-241120-1113
Library import 241120-1113
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/experimental/__simd')
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/experimental/__simd/scalar.h5
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/experimental/__simd/simd.h4
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/experimental/__simd/utility.h20
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/experimental/__simd/vec_ext.h11
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>