Skip to content

Commit

Permalink
broadcast & deinterleave fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jfalcou committed Dec 4, 2022
1 parent d5ca61c commit 858b0e9
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 37 deletions.
20 changes: 13 additions & 7 deletions test/unit/api/regular/deinterleave_groups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,19 @@ TTS_CASE_TPL( "Check behavior of deinterleave on arithmetic data", less_test_typ
<typename T>(tts::type<T>)
{
constexpr std::ptrdiff_t max_fields_count = 5;
// maybe unsused for gcc bug
[[maybe_unused]] static constexpr unsigned max_group_size = (T::size() >= 64) ? 4 : T::size();

eve::detail::for_<1, 1, max_fields_count + 1>([](auto fields) {
eve::detail::for_<0, 1, std::countr_zero(max_group_size) + 1>([&](auto group_size_log) {
deinterleave_groups_test<1 << group_size_log(), fields(), T>();

});
eve::detail::for_<1, 1, max_fields_count + 1>([](auto fields)
{
// maybe unsused for gcc bug
static constexpr std::size_t max_group_size = (T::size() >= 64) ? 4 : T::size();
constexpr auto nn = std::countr_zero(max_group_size) + 1;
eve::detail::for_<0, 1, nn>
(
[&](auto group_size_log)
{
constexpr auto gs = 1 << group_size_log();
deinterleave_groups_test<gs, fields(), T>();
}
);
});
};
32 changes: 16 additions & 16 deletions test/unit/api/regular/swizzle/broadcast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@
template<int I, int N>
inline constexpr auto broadcast = eve::fix_pattern<N>( [](int, int){ return I; } );

template<std::size_t... V, typename S>
auto bcast_test(S d, std::index_sequence<V...>)
{
auto check = [&]<typename I>(S simd, I idx)
{
constexpr auto i = I::value
typename S::template rescale<typename S::cardinal_type> ref(simd.get(i));
TTS_EQUAL(eve::shuffle(simd,broadcast<i,S::size()>) , ref);
TTS_EQUAL((eve::broadcast(simd, idx)) , ref);
};

(check(d,eve::index<V>), ...);
};

//==================================================================================================
// Broadcast test
//==================================================================================================
Expand All @@ -25,20 +39,6 @@ TTS_CASE_WITH( "Check behavior of broadcast swizzle"
)
<typename T, typename L> (T data, L logicals)
{
auto f = [&]<std::size_t N, typename S>(S simd, std::integral_constant<std::size_t,N>)
{
[&]<std::size_t... V>(std::index_sequence<V...>)
{
([&]()
{
typename S::template rescale<typename S::cardinal_type> ref(simd.get(V));
TTS_EQUAL(eve::shuffle(simd,broadcast<V,S::size()>) , ref);
TTS_EQUAL((eve::broadcast(simd, eve::index<V>)) , ref);
}(), ...);

}( std::make_index_sequence<S::size()>{} );
};

f(data , std::integral_constant<std::size_t,T::size()>{});
f(logicals, std::integral_constant<std::size_t,L::size()>{});
bcast_test( data , std::make_index_sequence<T::size()>{} );
bcast_test( logicals, std::make_index_sequence<L::size()>{} );
};
29 changes: 15 additions & 14 deletions test/unit/api/tuple/swizzle/broadcast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@
template<int I, int N>
inline constexpr auto broadcast = eve::fix_pattern<N>( [](int, int){ return I; } );

template<std::size_t... V, typename S>
auto bcast_test(S d, std::index_sequence<V...>)
{
auto check = [&]<typename I>(S simd, I idx)
{
constexpr auto i = I::value
typename S::template rescale<typename S::cardinal_type> ref(simd.get(i));
TTS_EQUAL(eve::shuffle(simd,broadcast<i,S::size()>) , ref);
TTS_EQUAL((eve::broadcast(simd, idx)) , ref);
};

(check(d,eve::index<V>), ...);
};

//==================================================================================================
// Identity test
//==================================================================================================
Expand All @@ -28,18 +42,5 @@ TTS_CASE_TPL( "Check behavior of broadcast swizzle", eve::test::scalar::all_type
};
};

auto f = [&]<std::size_t N, typename S>(S simd, std::integral_constant<std::size_t,N>)
{
[&]<std::size_t... V>(std::index_sequence<V...>)
{
([&]()
{
typename S::template rescale<typename S::cardinal_type> ref(simd.get(V));
TTS_EQUAL(eve::shuffle(simd,broadcast<V,S::size()>) , ref);
TTS_EQUAL((eve::broadcast(simd, eve::index<V>)) , ref);
}(), ...);

}( std::make_index_sequence<S::size()>{} );
};
f(data , std::integral_constant<std::size_t,eve::wide<s_t>::size()>{});
bcast_test(data, std::make_index_sequence<eve::wide<s_t>::size()>{} );
};

0 comments on commit 858b0e9

Please sign in to comment.