28 #ifndef VC_COMMON_ALGORITHMS_H_ 29 #define VC_COMMON_ALGORITHMS_H_ 33 namespace Vc_VERSIONED_NAMESPACE
48 constexpr
bool all_of(
bool b) {
return b; }
57 constexpr
bool any_of(
bool b) {
return b; }
66 constexpr
bool none_of(
bool b) {
return !b; }
76 constexpr
bool some_of(
bool) {
return false; }
107 template <
class InputIt,
class UnaryFunction>
108 UnaryFunction
simd_for_each(InputIt first, InputIt last, UnaryFunction f);
110 template <
class InputIt,
class UnaryFunction,
111 class ValueType =
typename std::iterator_traits<InputIt>::value_type>
113 std::is_arithmetic<ValueType>::value &&
114 Traits::is_functor_argument_immutable<UnaryFunction, Vector<ValueType>>::value,
119 typedef Scalar::Vector<ValueType> V1;
120 for (;
reinterpret_cast<std::uintptr_t
>(std::addressof(*first)) &
126 const auto lastV = last - V::Size + 1;
127 for (; first < lastV; first += V::Size) {
130 for (; first != last; ++first) {
136 template <
typename InputIt,
typename UnaryFunction>
138 std::is_arithmetic<typename std::iterator_traits<InputIt>::value_type>::value &&
139 !Traits::is_functor_argument_immutable<
146 typedef Scalar::Vector<typename std::iterator_traits<InputIt>::value_type> V1;
147 for (;
reinterpret_cast<std::uintptr_t
>(std::addressof(*first)) &
155 const auto lastV = last - V::Size + 1;
156 for (; first < lastV; first += V::Size) {
161 for (; first != last; ++first) {
170 template <
typename InputIt,
typename UnaryFunction>
172 !std::is_arithmetic<typename std::iterator_traits<InputIt>::value_type>::value,
176 return std::for_each(first, last, std::move(f));
180 template <
typename InputIt,
typename UnaryFunction>
182 std::is_arithmetic<typename std::iterator_traits<InputIt>::value_type>::value &&
183 Traits::is_functor_argument_immutable<
187 simd_for_each_n(InputIt first, std::size_t count, UnaryFunction f)
189 typename std::make_signed<size_t>::type len = count;
191 typedef Scalar::Vector<typename std::iterator_traits<InputIt>::value_type> V1;
192 for (;
reinterpret_cast<std::uintptr_t
>(std::addressof(*first)) &
198 for (; len >= int(V::Size); len -= V::Size, first += V::Size) {
201 for (; len != 0; --len, ++first) {
207 template <
typename InputIt,
typename UnaryFunction>
209 std::is_arithmetic<typename std::iterator_traits<InputIt>::value_type>::value &&
210 !Traits::is_functor_argument_immutable<
214 simd_for_each_n(InputIt first, std::size_t count, UnaryFunction f)
216 typename std::make_signed<size_t>::type len = count;
218 typedef Scalar::Vector<typename std::iterator_traits<InputIt>::value_type> V1;
219 for (;
reinterpret_cast<std::uintptr_t
>(std::addressof(*first)) &
227 for (; len >= int(V::Size); len -= V::Size, first += V::Size) {
232 for (; len != 0; --len, ++first) {
244 template <
typename InputIt,
typename UnaryFunction>
245 inline enable_if<!std::is_arithmetic<typename InputIt::value_type>::value, UnaryFunction>
246 simd_for_each_n(InputIt first, std::size_t count, UnaryFunction f)
248 for (std::size_t i = 0; i < count; ++i, static_cast<void>(++first))
249 std::apply(f, *first);
253 template <
typename InputIt,
typename UnaryFunction>
255 !std::is_arithmetic<typename std::iterator_traits<InputIt>::value_type>::value,
257 simd_for_each_n(InputIt first, std::size_t count, UnaryFunction f)
259 return std::for_each_n(first, count, std::move(f));
266 #endif // VC_COMMON_ALGORITHMS_H_ The main vector class for expressing data parallelism.
constexpr bool any_of(bool b)
Returns b.
enable_if< !std::is_arithmetic< typename std::iterator_traits< InputIt >::value_type >::value, UnaryFunction > simd_for_each(InputIt first, InputIt last, UnaryFunction f)
Vc variant of the std::for_each algorithm.
bool isFull() const
Returns a logical AND of all components.
constexpr bool none_of(bool b)
Returns !b.
constexpr bool all_of(bool b)
Returns b.
constexpr AlignedTag Aligned
Use this object for a flags parameter to request aligned loads and stores.
constexpr bool some_of(bool)
Returns false.
The main SIMD mask class.
bool isNotEmpty() const
Returns a logical OR of all components.
constexpr std::size_t MemoryAlignment
Specifies the most conservative memory alignment necessary for aligned loads and stores of Vector typ...
bool isEmpty() const
Returns true if components are false, false otherwise.
bool isMix() const
Returns !isFull() && !isEmpty().