Index: libcxx/include/experimental/simd =================================================================== --- libcxx/include/experimental/simd +++ libcxx/include/experimental/simd @@ -1131,10 +1131,6 @@ return simd_cast::value>>(__v); } -template -fixed_size_simd_mask<_Tp, simd_size<_Tp, _Abi>::value> -to_fixed_size(const simd_mask<_Tp, _Abi>&) noexcept; - // NOTE: As an extension, allow transforming to a native type with a size // that's not native_simd::size(). template @@ -1143,9 +1139,6 @@ return simd_cast>>(__v); } -template -native_simd_mask<_Tp> to_native(const fixed_size_simd_mask<_Tp, _Np>&) noexcept; - // NOTE: As an extension, allow transforming to a compatible type with a size // that's not simd::size(). template @@ -1154,14 +1147,11 @@ return simd_cast>>(__v); } -template -simd_mask<_Tp> to_compatible(const fixed_size_simd_mask<_Tp, _Np>&) noexcept; - -template +template _TupleType __split_tuple_impl(_Tp** __buffers, - std::index_sequence<__indicies...>) { - return _TupleType(typename std::tuple_element<__indicies, _TupleType>::type( - __buffers[__indicies], element_aligned_tag())...); + std::index_sequence<__indices...>) { + return _TupleType(typename std::tuple_element<__indices, _TupleType>::type( + __buffers[__indices], element_aligned_tag())...); } template @@ -1187,10 +1177,6 @@ __buffers, std::make_index_sequence()); } -template -tuple>...> -split(const simd_mask<_Tp, _Abi>&); - // NOTE: P0820 extension template typename std::enable_if< @@ -1223,23 +1209,11 @@ _SimdType::size()>(__v); } -template -array< - simd_mask<_Tp, rebind_abi_t<_Tp, simd_size<_Tp, _Abi>::value / __array_size, - _Abi>>, - __array_size> -split_by(const simd_mask<_Tp, _Abi>& x); - -template -array<_SimdType, simd_size::value / - _SimdType::size()> -split(const simd_mask&); - -template +template void __concat_tuple_impl(_TupleType __vs, _Tp** __buffers, - std::index_sequence<__indicies...>) { - int __unused[] = {(std::get<__indicies>(__vs).copy_to(__buffers[__indicies], - element_aligned_tag()), + std::index_sequence<__indices...>) { + int __unused[] = {(std::get<__indices>(__vs).copy_to(__buffers[__indices], + element_aligned_tag()), 0)...}; (void)__unused; } @@ -1278,15 +1252,157 @@ return __v; } +struct __simd_mask_friend { + template + static fixed_size_simd_mask<_Tp, simd_size<_Tp, _Abi>::value> + __to_fixed_size(const simd_mask<_Tp, _Abi>& __m) noexcept { + return to_fixed_size(__m.__s_); + } + + template + static simd_mask<_Tp, simd_abi::__native<_Tp, _Np>> + __to_native(const fixed_size_simd_mask<_Tp, _Np>& __m) noexcept { + return to_native(__m.__s_); + } + + template + static simd_mask<_Tp, simd_abi::__compatible<_Tp, _Np>> + __to_compatible(const fixed_size_simd_mask<_Tp, _Np>& __m) noexcept { + return to_compatible(__m.__s_); + } + + template + static _ResType __split_impl(const _TupleType& __t, + std::index_sequence<__indices...>) { + return _ResType(std::get<__indices>(__t)...); + } + + template + static typename std::enable_if< + __variadic_sum(__sizes...) == simd<_Tp, _Abi>::size(), + tuple>...>>::type + __split(const simd_mask<_Tp, _Abi>& __m) { + return __split_impl< + tuple>...>>( + split<__sizes...>(__m.__s_), + std::make_index_sequence()); + } + + template + static typename std::enable_if< + simd_size<_Tp, _Abi>::value % __array_size == 0, + array::value / __array_size, + _Abi>>, + __array_size>>::type + __split_by(const simd_mask<_Tp, _Abi>& __m) { + auto __arr = split_by<__array_size>(__m.__s_); + array::value / __array_size, + _Abi>>, + __array_size> + __ret; + for (size_t __i = 0; __i < __ret.size(); __i++) { + __ret[__i] = __arr[__i]; + } + return __ret; + } + + template + static typename std::enable_if< + is_simd_mask<_MaskType>::value && + simd_size::value % + _MaskType::size() == + 0, + array<_MaskType, simd_size::value / + _MaskType::size()>>::type + __split(const simd_mask& __m) { + return split(__m.__s_); + } + + template + static simd_mask< + _Tp, + rebind_abi_t<_Tp, __variadic_sum(simd_size<_Tp, _Abis>::value...), + _Abis...>> + __concat(const simd_mask<_Tp, _Abis>&... __ms) { + return concat(__ms.__s_...); + } + + template + static simd_mask<_Tp, + rebind_abi_t<_Tp, _Np * simd_size<_Tp, _Abi>::value, _Abi>> + __concat(const std::array, _Np>& __ms) { + std::array __arr; + for (size_t __i = 0; __i < __ms.size(); __i++) { + __arr[__i] = __ms[__i].__s_; + } + return concat(__arr); + } +}; + +template +fixed_size_simd_mask<_Tp, simd_size<_Tp, _Abi>::value> +to_fixed_size(const simd_mask<_Tp, _Abi>& __m) noexcept { + return __simd_mask_friend::__to_fixed_size(__m); +} + +template +simd_mask<_Tp, simd_abi::__native<_Tp, _Np>> +to_native(const fixed_size_simd_mask<_Tp, _Np>& __m) noexcept { + return __simd_mask_friend::__to_native(__m); +} + +template +simd_mask<_Tp, simd_abi::__compatible<_Tp, _Np>> +to_compatible(const fixed_size_simd_mask<_Tp, _Np>& __m) noexcept { + return __simd_mask_friend::__to_compatible(__m); +} + +template +typename std::enable_if< + __variadic_sum(__sizes...) == simd<_Tp, _Abi>::size(), + tuple>...>>::type +split(const simd_mask<_Tp, _Abi>& __m) { + return __simd_mask_friend::__split<__sizes...>(__m); +} + +template +static typename std::enable_if< + simd_size<_Tp, _Abi>::value % __array_size == 0, + array::value / __array_size, + _Abi>>, + __array_size>>::type +split_by(const simd_mask<_Tp, _Abi>& __m) { + return __simd_mask_friend::__split_by<__array_size>(__m); +} + +template +static typename std::enable_if< + is_simd_mask<_MaskType>::value && + simd_size::value % + _MaskType::size() == + 0, + array<_MaskType, simd_size::value / + _MaskType::size()>>::type +split(const simd_mask& __m) { + return __simd_mask_friend::__split<_MaskType>(__m); +} + template simd_mask<_Tp, rebind_abi_t< _Tp, __variadic_sum(simd_size<_Tp, _Abis>::value...), _Abis...>> -concat(const simd_mask<_Tp, _Abis>&...); +concat(const simd_mask<_Tp, _Abis>&... __ms) { + return __simd_mask_friend::__concat(__ms...); +} template -simd_mask<_Tp, rebind_abi_t<_Tp, _Np, _Abi>> -concat(const std::array, _Np>&); +simd_mask<_Tp, rebind_abi_t<_Tp, _Np * simd_size<_Tp, _Abi>::value, _Abi>> +concat(const std::array, _Np>& __ms) { + return __simd_mask_friend::__concat(__ms); +} // reductions [simd.mask.reductions] template @@ -1297,25 +1413,62 @@ } return __ret; } + template -bool any_of(const simd_mask<_Tp, _Abi>&) noexcept; +bool any_of(const simd_mask<_Tp, _Abi>& __m) noexcept { + bool __ret = false; + for (size_t __i = 0; __i < __m.size(); __i++) { + __ret |= __m[__i]; + } + return __ret; +} + template -bool none_of(const simd_mask<_Tp, _Abi>&) noexcept; +bool none_of(const simd_mask<_Tp, _Abi>& __m) noexcept { + return !any_of(__m); +} + template -bool some_of(const simd_mask<_Tp, _Abi>&) noexcept; +bool some_of(const simd_mask<_Tp, _Abi>& __m) noexcept { + return !all_of(__m) && !none_of(__m); +} + template -int popcount(const simd_mask<_Tp, _Abi>&) noexcept; +int popcount(const simd_mask<_Tp, _Abi>& __m) noexcept { + int __ret = 0; + for (size_t __i = 0; __i < __m.size(); __i++) { + __ret += __m[__i]; + } + return __ret; +} + template -int find_first_set(const simd_mask<_Tp, _Abi>&); +int find_first_set(const simd_mask<_Tp, _Abi>& __m) { + for (size_t __i = 0; __i < __m.size(); __i++) { + if (__m[__i]) { + return __i; + } + } + return __m.size(); +} + template -int find_last_set(const simd_mask<_Tp, _Abi>&); -bool all_of(bool) noexcept; -bool any_of(bool) noexcept; -bool none_of(bool) noexcept; -bool some_of(bool) noexcept; -int popcount(bool) noexcept; -int find_first_set(bool) noexcept; -int find_last_set(bool) noexcept; +int find_last_set(const simd_mask<_Tp, _Abi>& __m) { + for (int __i = __m.size() - 1; __i >= 0; __i--) { + if (__m[__i]) { + return __i; + } + } + return __m.size(); +} + +bool all_of(bool __v) noexcept { return __v; } +bool any_of(bool __v) noexcept { return __v; } +bool none_of(bool __v) noexcept { return !__v; } +bool some_of(bool) noexcept { return false; } +int popcount(bool __v) noexcept { return __v; } +int find_first_set(bool) noexcept { return 0; } +int find_last_set(bool) noexcept { return 0; } // masked assignment [simd.whereexpr] template @@ -1530,15 +1683,15 @@ std::is_unsigned<_Tp>::value); } - template + template static constexpr decltype( std::forward_as_tuple(std::declval<_Generator>()( - std::integral_constant())...), + std::integral_constant())...), bool()) - __can_generate(std::index_sequence<__indicies...>) { + __can_generate(std::index_sequence<__indices...>) { return !__variadic_sum( !__can_broadcast()( - std::integral_constant()))>()...); + std::integral_constant()))>()...); } template @@ -1546,11 +1699,11 @@ return false; } - template - void __generator_init(_Generator&& __g, std::index_sequence<__indicies...>) { - int __unused[] = {((*this)[__indicies] = - __g(std::integral_constant()), - 0)...}; + template + void __generator_init(_Generator&& __g, std::index_sequence<__indices...>) { + int __unused[] = { + ((*this)[__indices] = __g(std::integral_constant()), + 0)...}; (void)__unused; } @@ -1859,7 +2012,9 @@ simd<__element_type, _Abi> __s_; - explicit simd_mask(const simd<__element_type, _Abi>& __mask) : __s_(__mask) {} + simd_mask(const simd<__element_type, _Abi>& __mask) : __s_(__mask) {} + + friend struct __simd_mask_friend; public: using value_type = bool; Index: libcxx/test/std/experimental/simd/simd.horizontal/concat.pass.cpp =================================================================== --- libcxx/test/std/experimental/simd/simd.horizontal/concat.pass.cpp +++ libcxx/test/std/experimental/simd/simd.horizontal/concat.pass.cpp @@ -33,7 +33,7 @@ using namespace std::experimental::parallelism_v2; -void test_concat() { +void test_concat_simd() { auto v = concat(fixed_size_simd([](int i) { return i; }), fixed_size_simd([](int i) { return i + 1; }), fixed_size_simd([](int i) { return i + 3; })); @@ -46,7 +46,20 @@ assert(v[5] == 5); } -void test_concat_array() { +void test_concat_mask() { + auto v = concat(fixed_size_simd_mask(true), + fixed_size_simd_mask(true), + fixed_size_simd_mask(true)); + static_assert(v.size() == 6, ""); + assert(v[0]); + assert(v[1]); + assert(v[2]); + assert(v[3]); + assert(v[4]); + assert(v[5]); +} + +void test_concat_array_simd() { std::array, 2> arr; arr[0] = fixed_size_simd([](int) { return 0; }); arr[1] = fixed_size_simd([](int) { return 1; }); @@ -59,6 +72,19 @@ assert(v[3] == 1); } +void test_concat_array_mask() { + std::array, 2> arr; + arr[0] = fixed_size_simd_mask(true); + arr[1] = fixed_size_simd_mask(true); + + auto v = concat(arr); + static_assert(v.size() == 4, ""); + assert(v[0]); + assert(v[1]); + assert(v[2]); + assert(v[3]); +} + void compile_split_propagate_abi() { static_assert(std::is_same(), simd()))::abi_type, @@ -75,6 +101,8 @@ } int main() { - test_concat(); - test_concat_array(); + test_concat_simd(); + test_concat_mask(); + test_concat_array_simd(); + test_concat_array_mask(); } Index: libcxx/test/std/experimental/simd/simd.horizontal/mask.pass.cpp =================================================================== --- /dev/null +++ libcxx/test/std/experimental/simd/simd.horizontal/mask.pass.cpp @@ -0,0 +1,189 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// +// +// // reductions [simd.mask.reductions] +// template bool all_of(const simd_mask&) noexcept; +// template bool any_of(const simd_mask&) noexcept; +// template bool none_of(const simd_mask&) noexcept; +// template bool some_of(const simd_mask&) noexcept; +// template int popcount(const simd_mask&) noexcept; +// template int find_first_set(const simd_mask&); +// template int find_last_set(const simd_mask&); +// +// bool all_of(see below ) noexcept; +// bool any_of(see below ) noexcept; +// bool none_of(see below ) noexcept; +// bool some_of(see below ) noexcept; +// int popcount(see below ) noexcept; +// int find_first_set(see below ) noexcept; +// int find_last_set(see below ) noexcept; + +#include +#include +#include + +using namespace std::experimental::parallelism_v2; + +void test_all_of() { + { + bool expected[] = {false, false}; + assert( + !all_of(fixed_size_simd_mask(expected, element_aligned_tag()))); + } + { + bool expected[] = {true, false}; + assert( + !all_of(fixed_size_simd_mask(expected, element_aligned_tag()))); + } + { + bool expected[] = {true, true}; + assert( + all_of(fixed_size_simd_mask(expected, element_aligned_tag()))); + } +} + +void test_any_of() { + { + bool expected[] = {false, false}; + assert( + !any_of(fixed_size_simd_mask(expected, element_aligned_tag()))); + } + { + bool expected[] = {true, false}; + assert( + any_of(fixed_size_simd_mask(expected, element_aligned_tag()))); + } + { + bool expected[] = {true, true}; + assert( + any_of(fixed_size_simd_mask(expected, element_aligned_tag()))); + } +} + +void test_none_of() { + { + bool expected[] = {false, false}; + assert( + none_of(fixed_size_simd_mask(expected, element_aligned_tag()))); + } + { + bool expected[] = {true, false}; + assert(!none_of( + fixed_size_simd_mask(expected, element_aligned_tag()))); + } + { + bool expected[] = {true, true}; + assert(!none_of( + fixed_size_simd_mask(expected, element_aligned_tag()))); + } +} + +void test_some_of() { + { + bool expected[] = {false, false}; + assert(!some_of( + fixed_size_simd_mask(expected, element_aligned_tag()))); + } + { + bool expected[] = {true, false}; + assert( + some_of(fixed_size_simd_mask(expected, element_aligned_tag()))); + } + { + bool expected[] = {true, true}; + assert(!some_of( + fixed_size_simd_mask(expected, element_aligned_tag()))); + } +} + +void test_popcount() { + { + bool expected[] = {false, false}; + assert(popcount(fixed_size_simd_mask(expected, + element_aligned_tag())) == 0); + } + { + bool expected[] = {true, false}; + assert(popcount(fixed_size_simd_mask(expected, + element_aligned_tag())) == 1); + } + { + bool expected[] = {true, true}; + assert(popcount(fixed_size_simd_mask(expected, + element_aligned_tag())) == 2); + } +} + +void test_find_first_set() { + { + bool expected[] = {false, true, true}; + assert(find_first_set(fixed_size_simd_mask( + expected, element_aligned_tag())) == 1); + } + { + bool expected[] = {true, false, true}; + assert(find_first_set(fixed_size_simd_mask( + expected, element_aligned_tag())) == 0); + } + { + bool expected[] = {true, true, false}; + assert(find_first_set(fixed_size_simd_mask( + expected, element_aligned_tag())) == 0); + } +} + +void test_find_last_set() { + { + bool expected[] = {false, true, true}; + assert(find_last_set(fixed_size_simd_mask( + expected, element_aligned_tag())) == 2); + } + { + bool expected[] = {true, false, true}; + assert(find_last_set(fixed_size_simd_mask( + expected, element_aligned_tag())) == 2); + } + { + bool expected[] = {true, true, false}; + assert(find_last_set(fixed_size_simd_mask( + expected, element_aligned_tag())) == 1); + } +} + +void test_bool_functions() { + assert(all_of(true)); + assert(!all_of(false)); + assert(any_of(true)); + assert(!any_of(false)); + assert(!none_of(true)); + assert(none_of(false)); + assert(!some_of(true)); + assert(!some_of(false)); + assert(popcount(true) == 1); + assert(popcount(false) == 0); + assert(find_first_set(true) == 0); + assert(find_first_set(false) == 0); + assert(find_last_set(true) == 0); + assert(find_last_set(false) == 0); +} + +int main() { + test_all_of(); + test_any_of(); + test_none_of(); + test_some_of(); + test_popcount(); + test_find_first_set(); + test_find_last_set(); + test_bool_functions(); +} Index: libcxx/test/std/experimental/simd/simd.horizontal/split.pass.cpp =================================================================== --- libcxx/test/std/experimental/simd/simd.horizontal/split.pass.cpp +++ libcxx/test/std/experimental/simd/simd.horizontal/split.pass.cpp @@ -39,7 +39,7 @@ using namespace std::experimental::parallelism_v2; -void test_split() { +void test_split_simd() { auto t = split<1, 2, 3>(fixed_size_simd([](int i) { return i; })); static_assert(std::tuple_size::value == 3, ""); @@ -56,7 +56,24 @@ assert(std::get<2>(t)[2] == 5); } -void test_split_array() { +void test_split_mask() { + auto t = split<1, 2, 3>(fixed_size_simd_mask(true)); + static_assert(std::tuple_size::value == 3, ""); + + assert(std::get<0>(t).size() == 1); + assert(std::get<0>(t)[0]); + + assert(std::get<1>(t).size() == 2); + assert(std::get<1>(t)[0]); + assert(std::get<1>(t)[1]); + + assert(std::get<2>(t).size() == 3); + assert(std::get<2>(t)[0]); + assert(std::get<2>(t)[1]); + assert(std::get<2>(t)[2]); +} + +void test_split_array_simd() { { auto arr = split_by<2>(fixed_size_simd([](int i) { return i; })); static_assert(arr.size() == 2, ""); @@ -88,7 +105,38 @@ } } -void compile_split_propagate_abi() { +void test_split_array_mask() { + { + auto arr = split_by<2>(fixed_size_simd_mask(true)); + static_assert(arr.size() == 2, ""); + + assert(arr[0].size() == 3); + assert(arr[0][0]); + assert(arr[0][1]); + assert(arr[0][2]); + + assert(arr[1].size() == 3); + assert(arr[1][0]); + assert(arr[1][1]); + assert(arr[1][2]); + } + { + auto arr = split>(fixed_size_simd(true)); + static_assert(arr.size() == 2, ""); + + assert(arr[0].size() == 3); + assert(arr[0][0]); + assert(arr[0][1]); + assert(arr[0][2]); + + assert(arr[1].size() == 3); + assert(arr[1][0]); + assert(arr[1][1]); + assert(arr[1][2]); + } +} + +void compile_split_simd_propagate_abi() { using compatible_simd_half = simd::size() / 2, simd_abi::compatible>>; @@ -119,7 +167,41 @@ ""); } +void compile_split_simd_mask_propagate_abi() { + using compatible_simd_mask_half = + simd_mask::size() / 2, + simd_abi::compatible>>; + using native_simd_mask_half = + simd_mask::size() / 2, + simd_abi::native>>; + + static_assert(std::is_same::size() / 2, + simd_mask::size() / 2>( + simd_mask())), + std::tuple>::value, + ""); + + static_assert( + std::is_same< + decltype(split::size() / 2, + native_simd_mask::size() / 2>( + native_simd_mask())), + std::tuple>::value, + ""); + + static_assert(std::is_same(simd_mask())), + std::array>::value, + ""); + + static_assert(std::is_same(native_simd_mask())), + std::array>::value, + ""); +} + int main() { - test_split(); - test_split_array(); + test_split_simd(); + test_split_mask(); + test_split_array_simd(); + test_split_array_mask(); } Index: libcxx/test/std/experimental/simd/simd.casts/to_compatible.pass.cpp =================================================================== --- libcxx/test/std/experimental/simd/simd.casts/to_compatible.pass.cpp +++ libcxx/test/std/experimental/simd/simd.casts/to_compatible.pass.cpp @@ -25,26 +25,47 @@ using namespace std::experimental::parallelism_v2; void test_to_compatible() { - auto v = to_compatible( - fixed_size_simd::size()>([](int i) { return i; })); - simd w([](int i) { return i; }); + { + auto v = to_compatible( + fixed_size_simd::size()>([](int i) { return i; })); + simd w([](int i) { return i; }); - static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); - for (size_t i = 0; i < v.size(); i++) { - assert(v[i] == w[i]); + for (size_t i = 0; i < v.size(); i++) { + assert(v[i] == w[i]); + } + } + + { + auto v = + to_compatible(fixed_size_simd_mask::size()>(true)); + static_assert(std::is_same, decltype(v)>::value, ""); + assert(all_of(v)); } } void test_to_compatible_extension() { - auto arr = split_by<32 / simd::size()>( - to_compatible(fixed_size_simd([](int i) { return i; }))); - static_assert(std::is_same>::value, ""); - int v = 0; - for (size_t i = 0; i < arr.size(); i++) { - for (size_t j = 0; j < arr[0].size(); j++) { - assert(arr[i][j] == v); - v++; + { + std::array, 2> arr = split_by<2>(to_compatible( + fixed_size_simd::size() * 2>([](int i) { return i; }))); + static_assert(std::is_same>::value, + ""); + int v = 0; + for (size_t i = 0; i < arr.size(); i++) { + for (size_t j = 0; j < arr[0].size(); j++) { + assert(arr[i][j] == v); + v++; + } + } + } + { + std::array, 2> arr = split_by<2>(to_compatible( + fixed_size_simd_mask::size() * 2>(true))); + for (size_t i = 0; i < arr.size(); i++) { + for (size_t j = 0; j < arr[0].size(); j++) { + assert(arr[i][j]); + } } } } Index: libcxx/test/std/experimental/simd/simd.casts/to_fixed_size.pass.cpp =================================================================== --- libcxx/test/std/experimental/simd/simd.casts/to_fixed_size.pass.cpp +++ libcxx/test/std/experimental/simd/simd.casts/to_fixed_size.pass.cpp @@ -27,13 +27,23 @@ using namespace std::experimental::parallelism_v2; void test_to_fixed_size() { - auto v = to_fixed_size(native_simd([](int i) { return i; })); - static_assert(std::is_same::size()>, - decltype(v)>::value, - ""); + { + auto v = to_fixed_size(native_simd([](int i) { return i; })); + static_assert(std::is_same::size()>, + decltype(v)>::value, + ""); - for (size_t i = 0; i < v.size(); i++) { - assert(v[i] == (int)i); + for (size_t i = 0; i < v.size(); i++) { + assert(v[i] == (int)i); + } + } + { + auto v = to_fixed_size(native_simd_mask(true)); + static_assert( + std::is_same::size()>, + decltype(v)>::value, + ""); + assert(all_of(v)); } } Index: libcxx/test/std/experimental/simd/simd.casts/to_native.pass.cpp =================================================================== --- libcxx/test/std/experimental/simd/simd.casts/to_native.pass.cpp +++ libcxx/test/std/experimental/simd/simd.casts/to_native.pass.cpp @@ -25,27 +25,47 @@ using namespace std::experimental::parallelism_v2; void test_to_native() { - auto v = to_native( - fixed_size_simd::size()>([](int i) { return i; })); - native_simd w([](int i) { return i; }); + { + auto v = to_native(fixed_size_simd::size()>( + [](int i) { return i; })); + native_simd w([](int i) { return i; }); - static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); - for (size_t i = 0; i < v.size(); i++) { - assert(v[i] == w[i]); + for (size_t i = 0; i < v.size(); i++) { + assert(v[i] == w[i]); + } + } + { + auto v = to_native( + fixed_size_simd_mask::size()>(true)); + static_assert(std::is_same, decltype(v)>::value, ""); + assert(all_of(v)); } } void test_to_native_extension() { - auto arr = split_by<32 / native_simd::size()>( - to_native(fixed_size_simd([](int i) { return i; }))); - static_assert( - std::is_same>::value, ""); - int v = 0; - for (size_t i = 0; i < arr.size(); i++) { - for (size_t j = 0; j < arr[0].size(); j++) { - assert(arr[i][j] == v); - v++; + { + std::array, 2> arr = split_by<2>( + to_native(fixed_size_simd::size() * 2>( + [](int i) { return i; }))); + static_assert( + std::is_same>::value, ""); + int v = 0; + for (size_t i = 0; i < arr.size(); i++) { + for (size_t j = 0; j < arr[0].size(); j++) { + assert(arr[i][j] == v); + v++; + } + } + } + { + std::array, 2> arr = split_by<2>(to_native( + fixed_size_simd_mask::size() * 2>(true))); + for (size_t i = 0; i < arr.size(); i++) { + for (size_t j = 0; j < arr[0].size(); j++) { + assert(arr[i][j]); + } } } }